From 0c65601cd0c1cb66cbeca7ee18b469dd0b1e103c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 25 Sep 2003 19:19:15 +0200 Subject: [PATCH] ALSA CVS update D:2003/09/10 17:26:26 C:ICE1724 driver A:Takashi Iwai F:pci/ice1712/ice1724.c:1.16->1.17 L:use SIZE register to get the current DMA position. L:this register seems more reliable than BASE register. --- sound/pci/ice1712/ice1724.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 0fc548dff5f0a..82c798438ef36 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -482,8 +482,6 @@ static int snd_vt1724_playback_pro_prepare(snd_pcm_substream_t * substream) return 0; } -#define CHECK_INVALID_PTR - static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(snd_pcm_substream_t * substream) { ice1712_t *ice = snd_pcm_substream_chip(substream); @@ -491,20 +489,28 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(snd_pcm_substream_t * s if (!(inl(ICEMT1724(ice, DMA_CONTROL)) & VT1724_PDMA0_START)) return 0; +#if 0 /* read PLAYBACK_ADDR */ ptr = inl(ICEMT1724(ice, PLAYBACK_ADDR)); -#ifdef CHECK_INVALID_PTR if (ptr < substream->runtime->dma_addr) { snd_printd("ice1724: invalid negative ptr\n"); return 0; } -#endif ptr -= substream->runtime->dma_addr; ptr = bytes_to_frames(substream->runtime, ptr); -#ifdef CHECK_INVALID_PTR if (ptr >= substream->runtime->buffer_size) { snd_printd("ice1724: invalid ptr %d (size=%d)\n", (int)ptr, (int)substream->runtime->period_size); return 0; } +#else /* read PLAYBACK_SIZE */ + ptr = inl(ICEMT1724(ice, PLAYBACK_SIZE)) & 0xffffff; + ptr = (ptr + 1) << 2; + ptr = bytes_to_frames(substream->runtime, ptr); + if (ptr <= substream->runtime->buffer_size) + ptr = substream->runtime->buffer_size - ptr; + else { + snd_printd("ice1724: invalid ptr %d (size=%d)\n", (int)ptr, (int)substream->runtime->buffer_size); + ptr = 0; + } #endif return ptr; } @@ -536,9 +542,22 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(snd_pcm_substream_t *substream, if (!(inl(ICEMT1724(ice, DMA_CONTROL)) & reg->start)) return 0; +#if 0 /* use ADDR register */ ptr = inl(ice->profi_port + reg->addr); ptr -= substream->runtime->dma_addr; return bytes_to_frames(substream->runtime, ptr); +#else /* use SIZE register */ + ptr = inw(ice->profi_port + reg->size); + ptr = (ptr + 1) << 2; + ptr = bytes_to_frames(substream->runtime, ptr); + if (ptr <= substream->runtime->buffer_size) + ptr = substream->runtime->buffer_size - ptr; + else { + snd_printd("ice1724: invalid ptr %d (size=%d)\n", (int)ptr, (int)substream->runtime->buffer_size); + ptr = 0; + } + return ptr; +#endif } const static struct vt1724_pcm_reg vt1724_capture_pro_reg = { -- 2.53.0