Commit add7c0a6 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: ca0106 - clean up playback pointer callback

Clean up the playback pointer callback function a bit, and make the
pointer check more strictly to avoid bogus pointers.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9fe856e4
...@@ -1002,29 +1002,27 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream) ...@@ -1002,29 +1002,27 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream)
struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); struct snd_ca0106 *emu = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_ca0106_pcm *epcm = runtime->private_data; struct snd_ca0106_pcm *epcm = runtime->private_data;
snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; unsigned int ptr, prev_ptr;
int channel = epcm->channel_id; int channel = epcm->channel_id;
int timeout = 10;
if (!epcm->running) if (!epcm->running)
return 0; return 0;
ptr3 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); prev_ptr = -1;
ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); do {
ptr4 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); ptr = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel);
if (ptr3 != ptr4) ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); ptr = (ptr >> 3) * runtime->period_size;
ptr2 = bytes_to_frames(runtime, ptr1); ptr += bytes_to_frames(runtime,
ptr2+= (ptr4 >> 3) * runtime->period_size; snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel));
ptr=ptr2; if (ptr >= runtime->buffer_size)
if (ptr >= runtime->buffer_size) ptr -= runtime->buffer_size;
ptr -= runtime->buffer_size; if (prev_ptr == ptr)
/* return ptr;
printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " prev_ptr = ptr;
"buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", } while (--timeout);
ptr1, ptr2, ptr, (int)runtime->buffer_size, snd_printk(KERN_WARNING "ca0106: unstable DMA pointer!\n");
(int)runtime->period_size, (int)runtime->frame_bits, return 0;
(int)runtime->rate);
*/
return ptr;
} }
/* pointer_capture callback */ /* pointer_capture callback */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment