* Re: [Alsa-user] Upgrade problems -addendum [not found] ` <200301221647.05780.tais.hansen@osd.dk> @ 2003-01-22 16:23 ` Takashi Iwai 2003-01-23 0:35 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-22 16:23 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1237 bytes --] (moved to alsa-devel) At Wed, 22 Jan 2003 16:47:00 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Wednesday 22 January 2003 15:50, Takashi Iwai wrote: > > > I'm getting a bunch of errors in syslog though. I imagine it's just debug > > > output and nothing serious. > > could you enable POINTER_DEBUG at the beginning of via82xx.c? > > this will print more debug lines. > > which application cause these messages? every application? > > do you notice any drop outs during playback? > > I've enabled POINTER_DEBUG and logged ALSA & fail output from syslog. The > output is attached in two files. (gzipped) > > ogg123: > I heard a short pop in the sound with each log entry pair; fail & ALSA. > > artsd: > Log entries only occured when starting/resuming or suspending/killing artsd. > Tried playing for a while with noatun and I didn't notice any pops or other > anomalies. could you test the following two patches? with the first one, the driver will calculate the current pointer like VIA686 does. if this is ok, no messages will appear. the second one is to force to increase the index. you'll see debug messages, anyway, if POINTER_DEBUG is defined. Takashi [-- Attachment #2: via-pointer-test.dif --] [-- Type: application/octet-stream, Size: 620 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 22 Jan 2003 16:15:33 -0000 @@ -1037,7 +1037,8 @@ .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_multi_prepare, .trigger = snd_via82xx_pcm_trigger, - .pointer = snd_via8233_pcm_pointer, + // .pointer = snd_via8233_pcm_pointer, + .pointer = snd_via686_pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; [-- Attachment #3: via-pointer-test2.dif --] [-- Type: application/octet-stream, Size: 1196 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 22 Jan 2003 16:20:04 -0000 @@ -589,8 +589,16 @@ #endif /* count register returns full size when end of buffer is reached */ if (size != count) { +#if 0 snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); res = viadev->lastpos; +#else + idx++; + if (idx >= viadev->tbl_entries) + idx = 0; + size = viadev->idx_table[idx].size; + res = viadev->idx_table[idx].offset + size - count; +#endif } else { res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { @@ -648,7 +656,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Alsa-user] Upgrade problems -addendum 2003-01-22 16:23 ` [Alsa-user] Upgrade problems -addendum Takashi Iwai @ 2003-01-23 0:35 ` Tais M. Hansen 2003-01-23 10:03 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-23 0:35 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 2427 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 22 January 2003 17:23, Takashi Iwai wrote: > could you test the following two patches? > with the first one, the driver will calculate the current pointer like > VIA686 does. if this is ok, no messages will appear. The first patch makes artsd freeze the computer for about 10-20 seconds and then aborts with a "cpu overload" message. ogg123 sometimes plays noise when starting while speeding through the ogg-file, sometimes it plays normally. Only ogg123 generated output in syslog which I've attached in alsa-ogg123-syslog-p1.txt.gz. > the second one is to force to increase the index. you'll see debug > messages, anyway, if POINTER_DEBUG is defined. First, removing first patch and applying the second patch. Ogg123 freezes when started with no sound and a lot of errors. Ctrl-C is caught after about 10 secs. Syslog output is attached in alsa-ogg123-syslog-p2.txt.gz. Artsd starts but keep looping a short random piece of noise. No sound can be played/heard when played. Killing artsd produces the output attached in alsa-artsd-syslog-p2.txt.gz. Applying both patches. Ogg123 and artsd behaves like when only the first patch was applied. I let ogg123 run a little longer and noticed that sometimes about half a second noise where played. Syslog errors from using ogg123 this time is attached in alsa-ogg123-syslog-p1+p2.txt.gz. Note: POINTER_DEBUG was defined and the initial patch you sent was applied throughout the test. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPi8464IvLOJqwYc4AQK1Rg//d/KK5N09con1WpRHybusmLzQgCyAJes7 ZacJuyVjC3ZufbvaXWFrDtfP/H5FJp4CnZ0f2wOLj16vrgL5huszWLLUYdUrIGIg J+HmUlEUydACBO55csHIX9L6LbIPJtlrUHI5JDGTkQ2Tkq3fLnmsgrhjt4FuikDa mP+sX82Fqduiz5yaOmK9I5f5T8R+hkX/F0TkT/nBUDnZODKPGDwfe2NXvECXLS8i p0cWyx4GZWZ3CrOghDz1+sqFNg3x3Emf+iX9VcF4a56RLUcDRoTkoLLyOyG2oXHs HeyPjJValZRZ5K/O9R9XVRFqAqS7haI0lPykIb3QVekTa31D7cU/sWgyrG6/g2RB Z7EViUL1hVa8hIgOQsSzfMHneu3CDQxaayXsYr6waNiu/jx2+ieRemQDq6nCJuSd v+30YvOO5hJ4f3f5ix/PtG3Wq6B5mpPhtNWVzW/10V4jkB/3rjBiY4WSuDi4QX/8 WZz4J5tm9sxlwTu/es353FVxstvP9r5I8aB+82ontsEiSljrLrgWeiTiiY6Ucf30 lo3mUDmIz8Puif0d/3zOw9M2fu/szzSsyJimaJ61s/+slS2olUH+jE7FnKOoRmBt tI4MvSxdW0W+j0U5VrlRP7YbsGN+ebRn3DzQ4Q7pyd6Fkk0+sagHEFsrRuMyifKg pxf42L/p8YA= =s6sT -----END PGP SIGNATURE----- [-- Attachment #2: alsa-ogg123-syslog-p1.txt.gz --] [-- Type: application/x-gzip, Size: 237 bytes --] [-- Attachment #3: alsa-artsd-syslog-p2.txt.gz --] [-- Type: application/x-gzip, Size: 157 bytes --] [-- Attachment #4: alsa-ogg123-syslog-p2.txt.gz --] [-- Type: application/x-gzip, Size: 213 bytes --] [-- Attachment #5: alsa-ogg123-syslog-p1+p2.txt.gz --] [-- Type: application/x-gzip, Size: 270 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 0:35 ` Tais M. Hansen @ 2003-01-23 10:03 ` Takashi Iwai 2003-01-23 11:15 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-23 10:03 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1802 bytes --] At Thu, 23 Jan 2003 01:35:53 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > On Wednesday 22 January 2003 17:23, Takashi Iwai wrote: > > could you test the following two patches? > > with the first one, the driver will calculate the current pointer like > > VIA686 does. if this is ok, no messages will appear. > > The first patch makes artsd freeze the computer for about 10-20 seconds and > then aborts with a "cpu overload" message. ogg123 sometimes plays noise when > starting while speeding through the ogg-file, sometimes it plays normally. > Only ogg123 generated output in syslog which I've attached in > alsa-ogg123-syslog-p1.txt.gz. ok, that's not good... > > > the second one is to force to increase the index. you'll see debug > > messages, anyway, if POINTER_DEBUG is defined. > > First, removing first patch and applying the second patch. Ogg123 freezes when > started with no sound and a lot of errors. Ctrl-C is caught after about 10 > secs. Syslog output is attached in alsa-ogg123-syslog-p2.txt.gz. Artsd starts > but keep looping a short random piece of noise. No sound can be played/heard > when played. Killing artsd produces the output attached in > alsa-artsd-syslog-p2.txt.gz. hmm... > Applying both patches. Ogg123 and artsd behaves like when only the first patch > was applied. I let ogg123 run a little longer and noticed that sometimes > about half a second noise where played. Syslog errors from using ogg123 this > time is attached in alsa-ogg123-syslog-p1+p2.txt.gz. ah, applying both has no effect.. > Note: POINTER_DEBUG was defined and the initial patch you sent was applied > throughout the test. ok, the attached is the third trial. please appply it solely without the preivous patches. hope this works better... ciao, Takashi [-- Attachment #2: via-pointer-test3.dif --] [-- Type: application/octet-stream, Size: 2138 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 23 Jan 2003 09:40:01 -0000 @@ -232,6 +232,7 @@ struct snd_via_sg_table *idx_table; /* for recovery from the unexpected pointer */ unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; unsigned int bufsize2; }; @@ -485,6 +486,7 @@ outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; } @@ -589,17 +591,26 @@ #endif /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + /* assume the next index */ + idx = viadev->lastidx + 1; + if (idx >= viadev->tbl_entries) + idx = 0; + size = viadev->idx_table[idx].size; + res = viadev->idx_table[idx].offset + size - count; + if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { + snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; + } } else { res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + return viadev->lastpos; } } } viadev->lastpos = res; /* remember the last positiion */ + viadev->lastidx = idx; if (res >= viadev->bufsize) res -= viadev->bufsize; return res; @@ -648,7 +659,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 10:03 ` Takashi Iwai @ 2003-01-23 11:15 ` Tais M. Hansen 2003-01-23 11:46 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-23 11:15 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 23 January 2003 11:03, Takashi Iwai wrote: > ok, the attached is the third trial. > please appply it solely without the preivous patches. I'm assuming the very first via8233a-fix.dif is still supposed to be applied. (won't work without it anyway) > hope this works better... Well... Ogg123 freezes the same way as with test1. Artsd no longer fails with "cpu overload", but it's constantly busy and can't play sound. There's nothing to see in syslog but there's suddenly a bunch of output in the debug log. This is ogg123: Jan 23 12:05:25 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:123: Unexpected hw_pointer value (stream = 0, delta: -1024, max jitter = 4096): wrong interrupt acknowledge? Jan 23 12:05:35 proficio last message repeated 429 times Jan 23 12:05:35 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:2117: playback write error (DMA or IRQ trouble?) And this is artsd: Jan 23 12:06:31 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:123: Unexpected hw_pointer value (stream = 0, delta: -1024, max jitter = 8192): wrong interrupt acknowledge? Jan 23 12:06:41 proficio last message repeated 206 times Aplay is able to play a wav-file though but it also generates errors in the debug log: Jan 23 12:08:16 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:123: Unexpected hw_pointer value (stream = 0, delta: -3386, max jitter = 11025): wrong interrupt acknowledge? Aplay also threw the usual in syslog once: Jan 23 12:08:18 proficio kernel: ALSA ../alsa-kernel/pci/via82xx.c:601: invalid via82xx_cur_ptr, using last valid pointer - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPi/O0IIvLOJqwYc4AQIpHQ//SToDIhB49e/UlJYOqTkTrya/25Vuvqju dYIhobeCn1bm8Lbun3Eb75rBt6pWqf/6g3YhfxdYwVYi5HD9YrX9SaqkOFdEFxiZ KUR0Vop7Nyu7Y379w7BKNZILE6ApvgKoSSsYXiR4EMI3mu5Rst+fAbhvyKuL1+u0 eggkgbZgffmMjZFtm0yyPywBmQxUz1INknIhs+/AXpTpbfHFxIEtaZGwSuEpK2DO is33gNvMIrAGmaXWoC3xNLLcDAOffcWVY3Cjx7KJAi8+UOAiJ15LCORaO41uv3r9 MvycX3KpDvMb5u+/RH00fLutTY8fQKiSwjRCRJWz3QBLOPJw18mIUz55T4i7VSoO x00fy+73xx2IePd9tT8mGZRr+leH19tnXP44+5QeVEj3GuOd85fw4nFkf+01z+9X m0DSS44/+UUG/XDQjl3SBeD0ad3alqOm748Ef0mHnmy058VF+Vh65s6B7bUzq/bf p59x0Ea1Tk9fph8+vyhJfvTLBMzywGhhNrOUuijUwjAkvojsMyB879ay838xkL0c lRW7WmvmB8HSoFCvJmjXHuHCoxP9GrRw0L3V4zj/OmuD8qM+SYUBhkdmLjEjzgsh e9RfEftSNDZSR+bdXE3nChiGWqeDCJXvYdZVcM/kpUfnZbRTZOdKdN2mqZLBvm6D dXEZcr9VgfA= =hpJK -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 11:15 ` Tais M. Hansen @ 2003-01-23 11:46 ` Takashi Iwai 2003-01-23 12:36 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-23 11:46 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1763 bytes --] At Thu, 23 Jan 2003 12:15:26 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > On Thursday 23 January 2003 11:03, Takashi Iwai wrote: > > ok, the attached is the third trial. > > please appply it solely without the preivous patches. > > I'm assuming the very first via8233a-fix.dif is still supposed to be applied. > (won't work without it anyway) yes. the patch had been already applied to cvs. > > hope this works better... > > Well... Ogg123 freezes the same way as with test1. Artsd no longer fails with > "cpu overload", but it's constantly busy and can't play sound. There's > nothing to see in syslog but there's suddenly a bunch of output in the debug > log. > > This is ogg123: > > Jan 23 12:05:25 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:123: > Unexpected hw_pointer value (stream = 0, delta: -1024, max jitter = 4096): > wrong interrupt acknowledge? > Jan 23 12:05:35 proficio last message repeated 429 times > Jan 23 12:05:35 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:2117: > playback write error (DMA or IRQ trouble?) > > And this is artsd: > > Jan 23 12:06:31 proficio kernel: ALSA ../alsa-kernel/core/pcm_lib.c:123: > Unexpected hw_pointer value (stream = 0, delta: -1024, max jitter = 8192): > wrong interrupt acknowledge? > Jan 23 12:06:41 proficio last message repeated 206 times hmm, it'd better to start from the beginning. please try the attached patch (solely). this will generate bunch of debug messages at each interrupt but won't improve any behavior. so, it would be enough to run only once or twice if you got bad playback. from the obtained log, we'll be able to know whether the interrupt is properly generated, or at which condition, the read of register value fails. ciao, Takashi [-- Attachment #2: via-pointer-debug.dif --] [-- Type: application/octet-stream, Size: 3497 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 23 Jan 2003 11:41:45 -0000 @@ -232,6 +232,7 @@ struct snd_via_sg_table *idx_table; /* for recovery from the unexpected pointer */ unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; unsigned int bufsize2; }; @@ -485,6 +486,7 @@ outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; } @@ -512,10 +514,13 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; + unsigned char status = inb(port) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG); + if (status) { + outb(status, port); /* ack */ if (viadev->substream && viadev->running) { spin_unlock(&chip->reg_lock); + printk("via: period_elapsed [%d]\n", i); snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -582,24 +587,25 @@ size = viadev->idx_table[idx].size; res = viadev->idx_table[idx].offset + size - count; - /* check the validity of the calculated position */ - if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + printk("via: idx = %i/%i, lastpos = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif + /* check the validity of the calculated position */ + if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + printk("invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; } else { res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + printk("invalid via82xx_cur_ptr (2), using last valid pointer\n"); + return viadev->lastpos; } } } viadev->lastpos = res; /* remember the last positiion */ + viadev->lastidx = idx; if (res >= viadev->bufsize) res -= viadev->bufsize; return res; @@ -648,7 +654,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 11:46 ` Takashi Iwai @ 2003-01-23 12:36 ` Tais M. Hansen 2003-01-23 15:08 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-23 12:36 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 2228 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 23 January 2003 12:46, Takashi Iwai wrote: > > I'm assuming the very first via8233a-fix.dif is still supposed to be > > applied. (won't work without it anyway) > yes. the patch had been already applied to cvs. Ok, I'll just do a cvs update then. > > Well... Ogg123 freezes the same way as with test1. Artsd no longer fails > > with "cpu overload", but it's constantly busy and can't play sound. > > ... > hmm, it'd better to start from the beginning. > please try the attached patch (solely). > this will generate bunch of debug messages at each interrupt but won't > improve any behavior. > so, it would be enough to run only once or twice if you got bad > playback. > from the obtained log, we'll be able to know whether the interrupt is > properly generated, or at which condition, the read of register value > fails. Okay, fresh cvs checkout. Enabled POINTER_DEBUG and applied the via-pointer-debug.dif. Ogg123 freezes/stalls without ever making a sound, like with the previous test and test3 patches. Log output is attached. Aplay plays a wav-file fine. No problems noticed. Log output is attached. When artsd is started a short piece of noise is looped, as described earlier. Can't play any sound through arts. Log output attached. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPi/h6IIvLOJqwYc4AQI/CBAAoZjVwgiDiERJiN2klyM/eriOO9fezFs6 ZOE1q3fugqhplVXr+CSiOA4P/KG49FUkGFoZYuuaK0xwJcEtneY6zvHcK+29E2zf iiLPaUU19zrnN/Bd11pVqeKKa6zixYuNgG3WLVcXs+dhtCYIGIi930Pdk/5AjXq8 ChB5oTzBXfLZs3pm7wte3mELJSZ1sZQ9q3BUzkjEBUot7AkRW4LEx540MCTvQ6+r d2fYjXswuEeOo/BySuJofCd3Uiv/1tx2jwkDPckjbFZNh0YVZtdp0as1phb/PVOt 05oUj+9nDVFRStqdMaBODSBOiKceewkXR7RwtHa9+OaprjRchGvpyo3x3gJjtfZU HcJqhPQQnt1/xa9JHht2FanHMuY/GJgBJXiNo6bWMkhVWe3d30wcFJpxTL7vzu8h hbbEsH5cAEAP5+KG+lPz07ZF2CZezJovevsE33aAk29Xm7bugDd56yWgLloarulE Ihjk3RLRM3gx6/fdx4JQHt4HTg2cDjKQV2fWkl8XKGhEqDLTIF1D8yGSfVhUbdmh J+F9Ntyhw2GXbaD9JXqDpSFx1QWURvj1BVtwbLZ8aTn7XGzNZiSGK+8UY02jXQ3+ cb5TzUganC9vYrLUfd3lSDiWZobXXs76epyWAAoyh6F00MeGBP3lbAXEdx3eph5D M7RC9gOpl8c= =HyhA -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay.txt.gz --] [-- Type: application/x-gzip, Size: 1035 bytes --] [-- Attachment #3: alsa-artsd.txt.gz --] [-- Type: application/x-gzip, Size: 692 bytes --] [-- Attachment #4: alsa-ogg123.txt.gz --] [-- Type: application/x-gzip, Size: 856 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 12:36 ` Tais M. Hansen @ 2003-01-23 15:08 ` Takashi Iwai 2003-01-23 17:50 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-23 15:08 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1258 bytes --] At Thu, 23 Jan 2003 13:36:53 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > > > Well... Ogg123 freezes the same way as with test1. Artsd no longer fails > > > with "cpu overload", but it's constantly busy and can't play sound. > > > ... > > hmm, it'd better to start from the beginning. > > please try the attached patch (solely). > > this will generate bunch of debug messages at each interrupt but won't > > improve any behavior. > > so, it would be enough to run only once or twice if you got bad > > playback. > > from the obtained log, we'll be able to know whether the interrupt is > > properly generated, or at which condition, the read of register value > > fails. > > Okay, fresh cvs checkout. Enabled POINTER_DEBUG and applied the > via-pointer-debug.dif. > > Ogg123 freezes/stalls without ever making a sound, like with the previous test > and test3 patches. Log output is attached. > > Aplay plays a wav-file fine. No problems noticed. Log output is attached. > > When artsd is started a short piece of noise is looped, as described earlier. > Can't play any sound through arts. Log output attached. thanks. it seems really the index value was not updated correctly by the chip. ok, take 4: please try the new one... Takashi [-- Attachment #2: via-pointer-test4.dif --] [-- Type: application/octet-stream, Size: 4271 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 23 Jan 2003 15:05:35 -0000 @@ -230,7 +230,10 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; unsigned int bufsize; unsigned int bufsize2; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -303,6 +312,7 @@ dev->tbl_entries = idx; dev->bufsize = periods * fragsize; dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,6 +328,10 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } @@ -481,10 +495,12 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->intr_cnt = 0; } @@ -512,9 +528,16 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); @@ -587,15 +610,21 @@ #ifdef POINTER_DEBUG printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif - /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + /* recover from the interrupt position */ + idx = viadev->period_idx[viadev->intr_cnt]; + size = viadev->idx_table[idx].size; + res = viadev->idx_table[idx].offset + size - count; + if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { + snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; + } } else { + /* count register returns full size when end of buffer is reached */ res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + return viadev->lastpos; } } } @@ -648,7 +677,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 15:08 ` Takashi Iwai @ 2003-01-23 17:50 ` Tais M. Hansen 2003-01-23 18:07 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-23 17:50 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1475 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 23 January 2003 16:08, Takashi Iwai wrote: > > Okay, fresh cvs checkout. Enabled POINTER_DEBUG and applied the > > via-pointer-debug.dif. > > Ogg123 freezes/stalls without ever making a sound, like with the previous > > test and test3 patches. Log output is attached. > > Aplay plays a wav-file fine. No problems noticed. Log output is attached. > thanks. > it seems really the index value was not updated correctly by the > chip. > ok, take 4: please try the new one... Same as before, log output attached. :) - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjArcYIvLOJqwYc4AQJQyBAAjSgAESxt/dy8dhIaK1XFUAW4fwdnwgFB 8Ydg+Fac5vlsGLpZ2+VnF/wjo4391ZkgdSQIyViCt996csGv1IuVilkd4Nx77dJU /+dbnrHfbP/bATFY3zBMiGahgfDyQQnXb6zrrmQPLRLqN9jYkAoOJRKVJRxme6QT Yc1+S09pxYp9s+wwrf1MQ9k/j5P4KST2jNOfNQsu1nrvpbeHJLxPLps8UJlbz/2O /ZMhyPRUCJJ+8vqTbReaw5fPt4z+vZUzWmiSQkRaH/zmu0mFjEGn0shLwduokKP7 dykv2VOQJT/rzx9bhmj1fXNLf6Fm7JK36VrckOGlmJ/zgXAvI4hmgE210fiIE+Hl 5eX+XQczas7AmdNpwIsfQBnoEidw+14L3mMweMNS4En3mVzaRixzucddlKZP71rN EyV30nlmUhUqDRk5QJnwVZwSXKvILLrYMKSmJ1hmfC6MsD0NNZE97mTVn6L4gPDd SyjElY8q3Ry2OdzaWzIem+fgNK031fzJxVFBNH+zxgNnKocO84wH47vOlweArEkd 4IISZlSMUM78xeCu1DbzFS0BDZkU5vDET0+wQ4sz82Yc1T6nieLOWMMuHrWoztE9 aCj/Hn6KreGdR9jRy+Nt7D+YIQ+NUzFIIohq8nuqvaEOZ3sn5IUV5nSpyUSZsh9F 0nccZ6azGDE= =qJIw -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-test4.txt.gz --] [-- Type: application/x-gzip, Size: 947 bytes --] [-- Attachment #3: alsa-ogg123-test4.txt.gz --] [-- Type: application/x-gzip, Size: 383 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 17:50 ` Tais M. Hansen @ 2003-01-23 18:07 ` Takashi Iwai 2003-01-23 18:43 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-23 18:07 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 721 bytes --] At Thu, 23 Jan 2003 18:50:38 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > On Thursday 23 January 2003 16:08, Takashi Iwai wrote: > > > Okay, fresh cvs checkout. Enabled POINTER_DEBUG and applied the > > > via-pointer-debug.dif. > > > Ogg123 freezes/stalls without ever making a sound, like with the previous > > > test and test3 patches. Log output is attached. > > > Aplay plays a wav-file fine. No problems noticed. Log output is attached. > > thanks. > > it seems really the index value was not updated correctly by the > > chip. > > ok, take 4: please try the new one... > > Same as before, log output attached. :) the next one is to put all logs to /var/log/debug. and will show more verbose. Takashi [-- Attachment #2: via-pointer-test5.dif --] [-- Type: application/octet-stream, Size: 4939 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 23 Jan 2003 18:05:17 -0000 @@ -230,7 +230,10 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; unsigned int bufsize; unsigned int bufsize2; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -303,6 +312,7 @@ dev->tbl_entries = idx; dev->bufsize = periods * fragsize; dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,6 +328,10 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } @@ -481,10 +495,12 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->intr_cnt = 0; } @@ -512,10 +528,20 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -585,17 +611,26 @@ /* check the validity of the calculated position */ if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif - /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + /* recover from the interrupt position */ + idx = viadev->period_idx[viadev->intr_cnt]; + size = viadev->idx_table[idx].size; + res = viadev->idx_table[idx].offset + size - count; +#ifdef POINTER_DEBUG + snd_printd("intr_cnt = %d, idx = %d, size = %d\n", viadev->intr_cnt, idx, size); +#endif + if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { + snd_printd("invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; + } } else { + /* count register returns full size when end of buffer is reached */ res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + snd_printd("invalid via82xx_cur_ptr (2), using last valid pointer\n"); + return viadev->lastpos; } } } @@ -648,7 +683,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 18:07 ` Takashi Iwai @ 2003-01-23 18:43 ` Tais M. Hansen 2003-01-24 9:12 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-23 18:43 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1353 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 23 January 2003 19:07, Takashi Iwai wrote: > > > thanks. > > > it seems really the index value was not updated correctly by the > > > chip. > > > ok, take 4: please try the new one... > > Same as before, log output attached. :) > the next one is to put all logs to /var/log/debug. > and will show more verbose. Ok, log output attached, 3 files with loads of gibberish ;). Same behavior btw. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjA36oIvLOJqwYc4AQKg9w/9E46Tbs7SEdaRFx8OjYLJwDk1QoSQcu7r jE/4B6+1PmqMPIfvmr5C0MjGM5Q+rDiGa1ZRHGfKAvshOcR7RJhCvtTqrJ2G9f36 O1B0+a1lkp/SCWSVkW29eQq37tn1wumn+FrIGNGm99QKlHfkcxXCMRmZMC8LyXmj Rf9ZNKjhz365yZcmnJoX3x3j/O+3q1AmlCCoz0BPhx5GVUPBoic38gj6nS36rWaE wnp+B/BjQ2WQ4lfpSW7KXvYzPpDxxz9XyTHan78O6+6kiaNPiNyTN2haYCL/RJAN 1EVZMqsRwdz3UCWx73A5LyA/SsDQ1bhtJwfcBr194rGM4uDc4BGuSWMg/BYt3KPg O2QkQu0EA0n+i/fTLG67wLCJldslOqTd5nnz6NEa1aaaJT3dSekq4pc7iKBKXKu/ ZJ1K/Mj7w90hGZyyFsXPI53nTrVAkIcwOyaUE88WZ1WEnGEpCoomRJY5+C1gJcnp IQPaaAJVSeqPKJ/ypHUgu4KS5L/QyNlD01hwFbom1C6lz58iyMJdS12Lo1J+64ja exv+OPncxT3vGj/SCotClLS28YAUIStiLhMRcQjQR6AiV0XgTk4XfyqgUa6Qy6IE fAWk7TVekdm+AgKUa+xBWBa+Rs5yykHBGB8foaGJUsZVqOxN2PfQ6lE/8csXOjNB IMrfuUeyraU= =R+NV -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-test5.txt.gz --] [-- Type: application/x-gzip, Size: 2433 bytes --] [-- Attachment #3: alsa-artsd-test5.txt.gz --] [-- Type: application/x-gzip, Size: 747 bytes --] [-- Attachment #4: alsa-ogg123-test5.txt.gz --] [-- Type: application/x-gzip, Size: 1162 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-23 18:43 ` Tais M. Hansen @ 2003-01-24 9:12 ` Takashi Iwai 2003-01-24 12:41 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-24 9:12 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1019 bytes --] At Thu, 23 Jan 2003 19:43:52 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > [1 <text/plain; iso-8859-1 (quoted-printable)>] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Thursday 23 January 2003 19:07, Takashi Iwai wrote: > > > > thanks. > > > > it seems really the index value was not updated correctly by the > > > > chip. > > > > ok, take 4: please try the new one... > > > Same as before, log output attached. :) > > the next one is to put all logs to /var/log/debug. > > and will show more verbose. > > Ok, log output attached, 3 files with loads of gibberish ;). Same behavior > btw. thanks. sigh, this chip is really weird. perhaps in the last patch, the recoverd pointer overtook the actual pointer and got the driver confused. take 6: the calculation of recovered pointer is changed. and the register value of CURRPTR is shown as reference. if it's more acculate, we can refer to it instead... as usual, debug messages appear by enabling DEBUG_POITNER. Takashi [-- Attachment #2: via-pointer-test6.dif --] [-- Type: application/octet-stream, Size: 5010 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 24 Jan 2003 09:05:27 -0000 @@ -230,7 +230,10 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; unsigned int bufsize; unsigned int bufsize2; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -303,6 +312,7 @@ dev->tbl_entries = idx; dev->bufsize = periods * fragsize; dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,6 +328,10 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } @@ -481,10 +495,12 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->intr_cnt = 0; } @@ -512,10 +528,20 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -585,17 +611,22 @@ /* check the validity of the calculated position */ if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + // snd_printd("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif - /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + /* recover from the interrupt position */ + idx = viadev->period_idx[viadev->intr_cnt]; + res = viadev->idx_table[idx].offset; + if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { + snd_printd("invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; + } } else { + /* count register returns full size when end of buffer is reached */ res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + snd_printd("invalid via82xx_cur_ptr (2), using last valid pointer\n"); + return viadev->lastpos; } } } @@ -648,8 +679,15 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; +#ifdef POINTER_DEBUG + { unsigned int ptr; + ptr = inl(VIAREG(chip, OFFSET_CURR_PTR) + viadev->reg_offset); + ptr -= (unsigned int)viadev->table_addr; + snd_printd("idx = %d, count = 0x%x, ptr = 0x%x\n", idx, count, ptr); + } +#endif res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 9:12 ` Takashi Iwai @ 2003-01-24 12:41 ` Tais M. Hansen 2003-01-24 13:30 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-24 12:41 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1573 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 24 January 2003 10:12, Takashi Iwai wrote: > > Ok, log output attached, 3 files with loads of gibberish ;). Same > > behavior btw. > thanks. sigh, this chip is really weird. > perhaps in the last patch, the recoverd pointer overtook the actual > pointer and got the driver confused. > take 6: the calculation of recovered pointer is changed. > and the register value of CURRPTR is shown as reference. > if it's more acculate, we can refer to it instead... > as usual, debug messages appear by enabling DEBUG_POITNER. Same deal as before, another 3 files filled with debug output. Good luck. :) - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjE0ZIIvLOJqwYc4AQLLFg/+NmqJA1HIeSmt6ukM/aw9v8n3fwLpK61k eGdakXrtZpao+T5EJG9aDsRoCJ6I5qRzw7s8KPFxx0AHLbDNMohLegTTxTB/KltT IFxRTW6JiAxwcRoR/nX/rFTZGEogXx8lTLIFALx8KD7jv/nudC0jWwFYeYKG9ky1 Q7zkbmdfcsivp2j7PUJVFGVQvYRYbrXvbaGD3BIfa7zPHWAaBK2tHWUZZ2TJFXT3 ZKoKtPnlzgxFXF9YP//OqE/Y5Qjjvs1SCk9hR4jL1yKmr9VeSCOySh+c8gAFOFaj hLICqz4fbtFkLurRk4B/puu8q/R4ftvC+z2cSUtvdLrVONzgYBwhsPibqKiI1hv5 wd6auUmMTxwar95iuiRNKdHPTId9FOZY0jEEJi4njOjZmUKSaZqa5g53OQ8rf63W GeupoL9DoGtewOpf4uvR6hvq5QjO2MGO0VyY5752LFyk7hIX1ryEvsuOsChMhOvl Akh+JVYXNSU+lgcnQCnrB45a9bH2MIIc0WnT8dlBi2o1oiyZTbp99n2GIt6y0ey4 L/ECWRoK0Wrd4yesPwNnl6S3AmmWKmZc8WurdDQcc5clOwTyZwXR67BSjXFTxTb8 oP6Q6zLMfFxcFReR1HCXWLbQGaw4oJbLuUh6zkGLnTxmizCc7uGZGnDpA/O6gWSq fsT3lXLYi60= =eiiU -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-test6.txt.gz --] [-- Type: application/x-gzip, Size: 3065 bytes --] [-- Attachment #3: alsa-artsd-test6.txt.gz --] [-- Type: application/x-gzip, Size: 1590 bytes --] [-- Attachment #4: alsa-ogg123-test6.txt.gz --] [-- Type: application/x-gzip, Size: 3292 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 12:41 ` Tais M. Hansen @ 2003-01-24 13:30 ` Takashi Iwai 2003-01-24 14:12 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-24 13:30 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1081 bytes --] At Fri, 24 Jan 2003 13:41:06 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > [1 <text/plain; iso-8859-1 (quoted-printable)>] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Friday 24 January 2003 10:12, Takashi Iwai wrote: > > > Ok, log output attached, 3 files with loads of gibberish ;). Same > > > behavior btw. > > thanks. sigh, this chip is really weird. > > perhaps in the last patch, the recoverd pointer overtook the actual > > pointer and got the driver confused. > > take 6: the calculation of recovered pointer is changed. > > and the register value of CURRPTR is shown as reference. > > if it's more acculate, we can refer to it instead... > > as usual, debug messages appear by enabling DEBUG_POITNER. > > Same deal as before, another 3 files filled with debug output. Good luck. :) it seems that we need to use CURRPTR always on your chip. i guess this depends on the board, how reliable IDX register is. if the attached new patch works, i'll add a module option to enable this behavior. good luck for you, too :) Takashi [-- Attachment #2: via-pointer-test7.dif --] [-- Type: application/octet-stream, Size: 3926 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 24 Jan 2003 13:27:39 -0000 @@ -88,7 +88,7 @@ MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(mpu_port, "MPU-401 port."); MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000"); @@ -481,8 +481,9 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; } @@ -512,10 +513,17 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -585,17 +593,17 @@ /* check the validity of the calculated position */ if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + snd_printd("invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; } else { res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + snd_printd("invalid via82xx_cur_ptr (2), using last valid pointer\n"); + return viadev->lastpos; } } } @@ -648,8 +656,18 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; +#if 1 /* FIXME */ + { + unsigned int ptr; + ptr = inl(VIAREG(chip, OFFSET_CURR_PTR) + viadev->reg_offset); + if (ptr <= (unsigned int)viadev->table_addr) + idx = 0; + else + idx = (ptr - (unsigned int)viadev->table_addr - 4) / 8; + } +#endif res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 13:30 ` Takashi Iwai @ 2003-01-24 14:12 ` Tais M. Hansen 2003-01-24 15:45 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-24 14:12 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 2013 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 24 January 2003 14:30, Takashi Iwai wrote: > > Same deal as before, another 3 files filled with debug output. Good luck. > > :) > it seems that we need to use CURRPTR always on your chip. > i guess this depends on the board, how reliable IDX register is. Need any specific info about the board? Chip? I saw some talks about the ALC650 chip in another thread on this list and alsamixer claims I've got such a chip. > if the attached new patch works, i'll add a module option to enable > this behavior. > good luck for you, too :) Thanks. Maybe we should exchange good luck more often. Seems like you worked some magic here. :) Ogg123 now plays but there's a lot of pops, clicks and stuttering. Log output were produced in both syslog and debug. Attached as allways. Aplay played as always. I think I heard pops here and there but it wasn't much. Log output from debug attached. Artsd started as supposed to with a single pop. Noatun seemed to play without any noticeable weirdness. No pops etc. Log output from debug attached. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjFJwIIvLOJqwYc4AQJUkRAAjIJ66U1Fb2HDWHQcqRh0BnAIJKZaIki3 ky+IkXkJ32YqznaiO88Cv6GlRJjJAfES8IyRrUZB8WT0LA79mKGSQyoS5xoMK6MW KsqPPHf/h1o3QCKa/rY8OH0oPUzD5PvfGqU1Iyk3uUTjtaQYm+4B/V7wpQjfnRbb 5sumdqo8oWchgzoKqeY17bdPE7lAMxYoWeRglIPMI6N1I/iyJNAONnfHNMFVH1FE uZQ3EKipd7qMw8RZHA2+C29xTU3rK4aMqRMqsBHHNBXMzNsNIRuGenSYQAynHeCY U0UzPBirqZKCOWEJuBWjhEWhAk1CCnBb1vsM1MVEJ0e47RfIF9HL3kHK4Eiwk301 fHOIGR+x9iAO/21en8oVzEj6sNdWGMMPXV1U+byJbe/C6I7nRBQCBMZDdbw2/haU uvhzMoBihW7EwLoWlMFCXbseX3vcHf8lmSLyh39M+aK2FcMnYiFGE7gp0L84NS2Q mnh6b9CFDPlffGET9+DULqZqv/clYsqHLOtT7ECjLyb3zcm6rGw+pU3wKNPcRtpW GL0saHyIy1fhU6Z+LDSPYlcBDl0+AtjeGhNTG44UmrfW92SM1jJb0f52rRe0zelq hih9SE6meCIHYjBk9/LcCYYAdBW9sybBPqjr+ywskbNrLH87TrfYftpUWXAq1sar einpLW5cIcw= =K4LD -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-test7.txt.gz --] [-- Type: application/x-gzip, Size: 166 bytes --] [-- Attachment #3: alsa-artsd-test7.txt.gz --] [-- Type: application/x-gzip, Size: 1441 bytes --] [-- Attachment #4: alsa-ogg123-test7.txt.gz --] [-- Type: application/x-gzip, Size: 1006 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 14:12 ` Tais M. Hansen @ 2003-01-24 15:45 ` Takashi Iwai 2003-01-24 16:40 ` Tais M. Hansen 2003-01-24 16:42 ` Re: [Alsa-user] Upgrade problems -addendum Tais M. Hansen 0 siblings, 2 replies; 29+ messages in thread From: Takashi Iwai @ 2003-01-24 15:45 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1490 bytes --] At Fri, 24 Jan 2003 15:12:13 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > On Friday 24 January 2003 14:30, Takashi Iwai wrote: > > > Same deal as before, another 3 files filled with debug output. Good luck. > > > :) > > it seems that we need to use CURRPTR always on your chip. > > i guess this depends on the board, how reliable IDX register is. > > Need any specific info about the board? Chip? I saw some talks about the > ALC650 chip in another thread on this list and alsamixer claims I've got such > a chip. most likely it has nothing to do with ALC650. but lspci -v and lspci -n (for the chip) might be helpful for the later development. > > > if the attached new patch works, i'll add a module option to enable > > this behavior. > > good luck for you, too :) > > Thanks. Maybe we should exchange good luck more often. Seems like you worked > some magic here. :) now comes the patch of the week: now you'll have possibility to change the behavior of the driver via a module option idx_detect. idx_detect=0 : the default, won't work for you. idx_detect=1 : like test7. perhaps not perfect. idx_detect=2 : use the interrupt pointer only. the resolution will be in the size of periods. this should work. idx_detect=3 : like test7 but don't evaluate the counter. might be be finer than idx_detect=2 but might be inaccurate in some cases. if the debug output is only 'elapsed only', it's ok. have fun :) Takashi [-- Attachment #2: via-pointer-test8.dif --] [-- Type: application/octet-stream, Size: 10846 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 24 Jan 2003 15:36:52 -0000 @@ -75,6 +75,7 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; +static int idx_detect[SNDRV_CARDS]; MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); @@ -88,9 +89,12 @@ MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(mpu_port, "MPU-401 port."); MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000"); +MODULE_PARM(idx_detect, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +MODULE_PARM_DESC(idx_detect, "Index update method for VIA823x chips (0 = default)."); +MODULE_PARM_SYNTAX(idx_detect, SNDRV_ENABLED); /* pci ids */ @@ -203,6 +207,14 @@ #define VIA_TBL_BIT_FLAG 0x40000000 #define VIA_TBL_BIT_EOL 0x80000000 +/* idx_detection */ +enum { + VIA_IDX_USE_IDX_REG, + VIA_IDX_USE_CURRPTR, + VIA_IDX_USE_PERIODS, + VIA_IDX_USE_CPTR_IDX +}; + /* */ @@ -230,7 +242,10 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; unsigned int bufsize; unsigned int bufsize2; @@ -262,11 +277,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -303,6 +324,7 @@ dev->tbl_entries = idx; dev->bufsize = periods * fragsize; dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,13 +340,18 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } /* */ -enum { TYPE_VIA686 = 1, TYPE_VIA8233 }; +enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; +enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ @@ -344,6 +371,7 @@ unsigned char old_legacy; unsigned char old_legacy_cfg; + int idx_detection; struct pci_dev *pci; snd_card_t *card; @@ -365,8 +393,8 @@ }; static struct pci_device_id snd_via82xx_ids[] __devinitdata = { - { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA686, }, /* 686A */ - { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA8233, }, /* VT8233 */ + { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ + { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ { 0, } }; @@ -481,10 +509,12 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->intr_cnt = 0; } @@ -512,10 +542,20 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -538,7 +578,7 @@ unsigned char val; unsigned long port = chip->port + viadev->reg_offset; - if (chip->chip_type == TYPE_VIA8233) + if (chip->chip_type != TYPE_VIA686) val = VIA_REG_CTRL_INT; else val = 0; @@ -585,17 +625,17 @@ /* check the validity of the calculated position */ if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); #endif /* count register returns full size when end of buffer is reached */ if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; + snd_printd("invalid via82xx_cur_ptr, using last valid pointer\n"); + return viadev->lastpos; } else { res = viadev->idx_table[idx].offset + size; if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + snd_printd("invalid via82xx_cur_ptr (2), using last valid pointer\n"); + return viadev->lastpos; } } } @@ -646,11 +686,35 @@ snd_assert(viadev->tbl_entries, return 0); if (!(inb(VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset) & VIA_REG_STAT_ACTIVE)) return 0; + + if (chip->idx_detection == VIA_IDX_USE_PERIODS) { + idx = viadev->period_idx[viadev->intr_cnt]; + res = viadev->idx_table[idx].offset; + return bytes_to_frames(substream->runtime, res); + } + spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; - count &= 0xffffff; - res = calc_linear_pos(viadev, idx, count); + switch (chip->idx_detection) { + case VIA_IDX_USE_CURRPTR: + case VIA_IDX_USE_CPTR_IDX: + /* detect the index from CURRPTR register */ + idx = inl(VIAREG(chip, OFFSET_CURR_PTR) + viadev->reg_offset); + if (idx <= (unsigned int)viadev->table_addr) + idx = 0; + else + idx = (idx - (unsigned int)viadev->table_addr - 4) / 8; + break; + default: + idx = (count >> 24) & viadev->tbl_entries; + break; + } + if (chip->idx_detection != VIA_IDX_USE_CPTR_IDX) { + count &= 0xffffff; + res = calc_linear_pos(viadev, idx, count); + } else { + res = viadev->idx_table[idx].offset; + } spin_unlock(&chip->reg_lock); return bytes_to_frames(substream->runtime, res); @@ -950,7 +1014,7 @@ if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; substream->runtime->hw.channels_max = 6; - if (chip->revision == VIA_REV_8233A) + if (chip->chip_type == TYPE_VIA8233A) snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); return 0; } @@ -1365,7 +1429,7 @@ int i, err, caps; unsigned char val; - caps = chip->revision == VIA_REV_8233A ? 1 : 2; + caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; for (i = 0; i < caps; i++) { snd_via8233_capture_source.index = i; err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); @@ -1651,6 +1715,19 @@ return 0; } +struct via823x_info { + int revision; + char *name; + int type; +}; +static struct via823x_info via823x_cards[] = { + { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, + { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, + { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, + { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A }, + { VIA_REV_8233, "VIA 8235", TYPE_VIA8233 }, +}; + static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -1658,7 +1735,7 @@ snd_card_t *card; via82xx_t *chip; unsigned char revision; - int chip_type; + int chip_type = 0, card_type; int i, err; if (dev >= SNDRV_CARDS) @@ -1672,24 +1749,30 @@ if (card == NULL) return -ENOMEM; - chip_type = pci_id->driver_data; + card_type = pci_id->driver_data; pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - switch (chip_type) { - case TYPE_VIA686: + switch (card_type) { + case TYPE_CARD_VIA686: strcpy(card->driver, "VIA686A"); strcpy(card->shortname, "VIA 82C686A/B"); + chip_type = TYPE_VIA686; break; - case TYPE_VIA8233: - if (revision == VIA_REV_8233A) { + case TYPE_CARD_VIA8233: + chip_type = TYPE_VIA8233; + sprintf(card->shortname, "VIA 823x rev%d", revision); + for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { + if (revision == via823x_cards[i].revision) { + chip_type = via823x_cards[i].type; + strcpy(card->shortname, via823x_cards[i].name); + } + } + if (chip_type == VIA_REV_8233A) strcpy(card->driver, "VIA8233A"); - strcpy(card->shortname, "VIA 8233A"); - } else { + else strcpy(card->driver, "VIA8233"); - strcpy(card->shortname, "VIA 8233/C"); - } break; default: - snd_printk(KERN_ERR "invalid chip type %d\n", chip_type); + snd_printk(KERN_ERR "invalid card type %d\n", card_type); err = -EINVAL; goto __error; } @@ -1697,6 +1780,8 @@ if ((err = snd_via82xx_create(card, pci, chip_type, ac97_clock[dev], &chip)) < 0) goto __error; + chip->idx_detection = idx_detect[dev]; + if ((err = snd_via82xx_mixer_new(chip)) < 0) goto __error; @@ -1705,7 +1790,7 @@ (err = snd_via686_init_misc(chip, dev)) < 0) goto __error; } else { - if (revision == VIA_REV_8233A) { + if (chip_type == VIA_REV_8233A) { if ((err = snd_via8233a_pcm_new(chip)) < 0) goto __error; } else { @@ -1792,4 +1877,3 @@ __setup("snd-via82xx=", alsa_card_via82xx_setup); #endif /* ifndef MODULE */ - ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 15:45 ` Takashi Iwai @ 2003-01-24 16:40 ` Tais M. Hansen 2003-01-24 17:08 ` Takashi Iwai 2003-01-24 16:42 ` Re: [Alsa-user] Upgrade problems -addendum Tais M. Hansen 1 sibling, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-24 16:40 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 24 January 2003 16:45, Takashi Iwai wrote: > > Need any specific info about the board? Chip? I saw some talks about the > > ALC650 chip in another thread on this list and alsamixer claims I've got > > such a chip. > most likely it has nothing to do with ALC650. > but lspci -v and lspci -n (for the chip) might be helpful for the > later development. $ lspci -s 00:11.5 -v 00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233 AC97 Audio Controller (rev 40) Subsystem: Micro-star International Co Ltd: Unknown device 4720 Flags: medium devsel, IRQ 9 I/O ports at e800 [size=256] Capabilities: [c0] Power Management version 2 $ lspci -s 00:11.5 -n 00:11.5 Class 0401: 1106:3059 (rev 40) > now comes the patch of the week: > now you'll have possibility to change the behavior of the driver via a > module option idx_detect. > idx_detect=0 : the default, won't work for you. And it didn't. > idx_detect=1 : like test7. perhaps not perfect. No sound, so you're right. > idx_detect=2 : use the interrupt pointer only. the resolution will be > in the size of periods. this should work. Maybe. But it didn't. Seems to go a little too fast playing. No sound at all. > idx_detect=3 : like test7 but don't evaluate the counter. > might be be finer than idx_detect=2 but might be > inaccurate in some cases. This one killed my system the first time. Nice blinking keyboard leds. :) Second run it runs speeds through the file. No sound at all. I've attached log output from all idx'es, though only tested with ogg123. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjFsa4IvLOJqwYc4AQL4Mw//ZCPhB71mnpTZmYxBGa0yym0j2FAfGPSy 4H2gAry+jpe9wDEOddijFaSdx/mYj04ST/4Vl+cNbPaV1kldMdrqWrU3Fx0vfIqE FRC5SapuNiykdI1kMVIDotiEWU5MEhZG2UB5TwhDkSwwI3lPKfJDUsax79KCfIz/ m/8m7j0j9K0gtmDZhmD8v2TEpiiT1mk927BpqcZVI8lI3F0Ya0ggD3rI+rB+TJXQ CMgZqO74TDVA2LoWPRGHVK/VPvvVEJmr2/5+TW9Y7E5zCJx1O1PsKGcXsv1P8Pw4 gRtLwJHxFhtgn59o8L2pJI+giy27ZpX8EJ+kj917r3S/XbXE62Hr/zWQBZN5HqMF 4YfWHukX3/+5yOkzfB257VXXYk6giHDiXyxXspw0nFbTZLwKuBNCRPxQZvrO1UQ/ TmFfLW6qvq8bMreO6q7xC7N+AWIpCXf1LkqEPZsjVozSBMKahWBSTIIpBGQalUGS pBPo3gVDIKXVJT9NCUufBcmYuyImehscO2aICL1ojEsNO7zqWtkmKyGNEt3m/yA1 yhWbHABwsY029UU7SnOQpcaps0xEtF5Nl/XjljTT7dMJwV4Nep26DNW1c+Dmt+si D1q7oWgmke6tqFXpXG3T/7vrWQMP50vag+Nf1whl3Zz31qkyqHFA1qlvcEyxFXuS zU5qKaolsfk= =lsXG -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 16:40 ` Tais M. Hansen @ 2003-01-24 17:08 ` Takashi Iwai 2003-01-24 21:24 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-24 17:08 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel At Fri, 24 Jan 2003 17:40:09 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Friday 24 January 2003 16:45, Takashi Iwai wrote: > > > Need any specific info about the board? Chip? I saw some talks about the > > > ALC650 chip in another thread on this list and alsamixer claims I've got > > > such a chip. > > most likely it has nothing to do with ALC650. > > but lspci -v and lspci -n (for the chip) might be helpful for the > > later development. > > $ lspci -s 00:11.5 -v > 00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233 AC97 Audio > Controller (rev 40) > Subsystem: Micro-star International Co Ltd: Unknown device 4720 > Flags: medium devsel, IRQ 9 > I/O ports at e800 [size=256] > Capabilities: [c0] Power Management version 2 > > $ lspci -s 00:11.5 -n > 00:11.5 Class 0401: 1106:3059 (rev 40) sorry, i need the output of "lspci -nv". > > > now comes the patch of the week: > > now you'll have possibility to change the behavior of the driver via a > > module option idx_detect. > > idx_detect=0 : the default, won't work for you. > > And it didn't. > > > > idx_detect=1 : like test7. perhaps not perfect. > > No sound, so you're right. hmm, it should produce some sounds. > > idx_detect=2 : use the interrupt pointer only. the resolution will be > > in the size of periods. this should work. > > Maybe. But it didn't. Seems to go a little too fast playing. No sound at all. no sound? on all applications? then it can be another bug in the different place, which was got in during the last rewrite... Takashi ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 17:08 ` Takashi Iwai @ 2003-01-24 21:24 ` Tais M. Hansen 2003-01-27 10:42 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-24 21:24 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 24 January 2003 18:08, Takashi Iwai wrote: > sorry, i need the output of "lspci -nv". $ lspci -s 00:11.5 -nv 00:11.5 Class 0401: 1106:3059 (rev 40) Subsystem: 1462:4720 Flags: medium devsel, IRQ 9 I/O ports at e800 [size=256] Capabilities: [c0] Power Management version 2 > > > now comes the patch of the week: > > > idx_detect=1 : like test7. perhaps not perfect. > > No sound, so you're right. > hmm, it should produce some sounds. I just gave it another try with aplay. Bad idea; froze the system. Something's really wrong with the test8-patch. > > > idx_detect=2 : use the interrupt pointer only. the resolution will be > > > in the size of periods. this should work. > > Maybe. But it didn't. Seems to go a little too fast playing. No sound at > > all. > no sound? > on all applications? Well, I'd like to try, but now that my system froze on 1 and 3, I wouldn't dare. :) > then it can be another bug in the different place, which was got in > during the last rewrite... Sounds possible. If only I had more insight on audio hardware programming I'd might be able to be more helpful. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjGvHoIvLOJqwYc4AQLkeBAAmC5cKCyCd7D3HoCfNSvd7DbtmppUtHV2 /6axRVxaJG+BTJ4fRiyZGzDJYywhvmgIpy6AlM81hNMwSWTXtx9AbyB7GKtBepTW qRUl/dB2E7oKmWvWNCL4h+wdyFeQqIqs5NG7QaOXtUaeQAJaacqmLrY22kmyx9ek 37hUBuWoJcX/VpGfvojhbOvoIspnMszgBiFOINHXE3cKi2y7YNyJp2LhDbeDVjhu Oy/oL4OIAAgB7OTFGFvlT2/w3zSiYs2ctuz5Rt9yHeMSZ4tb4nInI3epSlpWxZQr fCkTmcjD3bea30OMkjlK7B6AkNudPIG/qXIhl1gZrhYFBctCISDdJLxtR/P21U3C J7J6JiPhdTfBSgiglQBcngtWHL873ZiWHnmdrD5b+9n0ocylzKO92kEXIhUB1q52 aXtl5KRojnsPx7jnB6x7EYIc5A7DJMKkVdxXQT2cUxGhvSwkV3C1kGnwVm4V0s6S to22WbFpah3b8Ywfk+CInZGOc/zPDc61gLpf/Oo7Hv3zsCry4rd6JFM366I/jDlW 8s52bA4JKM1ch0kOB5IhC7iwVUOXYutwqDDJH5eq5WISWviU1WEuJefcxSmu7Hpt RqUEwEq+WQKHSWSpN9h/68EBpqkIiRXoFTfzSedKh34XYpYkr4IXtosorrIPh5VP RNsVE8j6cDI= =BSFL -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 21:24 ` Tais M. Hansen @ 2003-01-27 10:42 ` Takashi Iwai 2003-01-27 14:42 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-27 10:42 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 487 bytes --] At Fri, 24 Jan 2003 22:24:43 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > > > > now comes the patch of the week: > > > > idx_detect=1 : like test7. perhaps not perfect. > > > No sound, so you're right. > > hmm, it should produce some sounds. > > I just gave it another try with aplay. Bad idea; froze the system. Something's > really wrong with the test8-patch. ok. now, i rewrote the patch completely again. the module options was removed again. here we go... Takashi [-- Attachment #2: via-pointer-test9.dif --] [-- Type: application/octet-stream, Size: 10668 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 27 Jan 2003 10:38:59 -0000 @@ -88,7 +88,7 @@ MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(mpu_port, "MPU-401 port."); MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000"); @@ -230,10 +230,13 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; - unsigned int bufsize2; }; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -302,7 +311,7 @@ } dev->tbl_entries = idx; dev->bufsize = periods * fragsize; - dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,13 +327,18 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } /* */ -enum { TYPE_VIA686 = 1, TYPE_VIA8233 }; +enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; +enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ @@ -365,8 +379,8 @@ }; static struct pci_device_id snd_via82xx_ids[] __devinitdata = { - { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA686, }, /* 686A */ - { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA8233, }, /* VT8233 */ + { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ + { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ { 0, } }; @@ -481,10 +495,13 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; + viadev->intr_cnt = 0; } @@ -512,10 +529,20 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -538,7 +565,7 @@ unsigned char val; unsigned long port = chip->port + viadev->reg_offset; - if (chip->chip_type == TYPE_VIA8233) + if (chip->chip_type != TYPE_VIA686) val = VIA_REG_CTRL_INT; else val = 0; @@ -572,36 +599,70 @@ * pointer callbacks */ +static inline int out_of_intr_idx(viadev_t *viadev, unsigned int idx) +{ + unsigned int cnt; + + if (idx < viadev->period_idx[viadev->period_idx[viadev->intr_cnt]]) + return 1; + cnt = viadev->intr_cnt + 1; + if (cnt != viadev->periods && + idx >= viadev->period_idx[viadev->period_idx[cnt]]) + return 1; + return 0; +} + /* * calculate the linear position at the given sg-buffer index and the rest count */ -static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) +static unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) { unsigned int size, res; size = viadev->idx_table[idx].size; res = viadev->idx_table[idx].offset + size - count; + if (count == 0) { + if (++idx >= viadev->tbl_entries) + idx = 0; + } - /* check the validity of the calculated position */ - if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { + if (out_of_intr_idx(viadev, idx)) { + if (size == count) { + /* count register returns full size when end of buffer is reached */ + if (++idx >= viadev->tbl_entries) + idx = 0; + if (! out_of_intr_idx(viadev, idx)) { + res = viadev->idx_table[idx].offset; + goto _ok; + } + } + if (! out_of_intr_idx(viadev, viadev->lastidx)) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("recover from last: idx = %i/%i, lastpos = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, size, count); #endif - /* count register returns full size when end of buffer is reached */ - if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; - } else { - res = viadev->idx_table[idx].offset + size; - if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + return viadev->lastpos; + } +#ifdef POINTER_DEBUG + snd_printd("recover from intr: idx = %i/%i, lastpos = 0x%x, intr_idx = %i\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->period_idx[viadev->intr_cnt]); +#endif + /* recover from the interrupt pointer */ + idx = viadev->period_idx[viadev->intr_cnt]; + res = viadev->idx_table[idx].offset; + } else { + if (res < viadev->lastpos) { + if (! out_of_intr_idx(viadev, viadev->lastidx)) { +#ifdef POINTER_DEBUG + snd_printd("recover from last #2: idx = %i/%i, curpos = 0x%x, lastpos = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, res, viadev->lastpos, size, count); +#endif + return viadev->lastpos; } } } - viadev->lastpos = res; /* remember the last positiion */ + _ok: if (res >= viadev->bufsize) res -= viadev->bufsize; + viadev->lastidx = idx; + viadev->lastpos = res; return res; } @@ -646,9 +707,10 @@ snd_assert(viadev->tbl_entries, return 0); if (!(inb(VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset) & VIA_REG_STAT_ACTIVE)) return 0; + spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); @@ -950,7 +1012,7 @@ if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; substream->runtime->hw.channels_max = 6; - if (chip->revision == VIA_REV_8233A) + if (chip->chip_type == TYPE_VIA8233A) snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); return 0; } @@ -1365,7 +1427,7 @@ int i, err, caps; unsigned char val; - caps = chip->revision == VIA_REV_8233A ? 1 : 2; + caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; for (i = 0; i < caps; i++) { snd_via8233_capture_source.index = i; err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); @@ -1651,6 +1713,19 @@ return 0; } +struct via823x_info { + int revision; + char *name; + int type; +}; +static struct via823x_info via823x_cards[] __devinitdata = { + { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, + { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, + { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, + { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A }, + { VIA_REV_8233, "VIA 8235", TYPE_VIA8233 }, +}; + static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -1658,7 +1733,7 @@ snd_card_t *card; via82xx_t *chip; unsigned char revision; - int chip_type; + int chip_type = 0, card_type; int i, err; if (dev >= SNDRV_CARDS) @@ -1672,24 +1747,31 @@ if (card == NULL) return -ENOMEM; - chip_type = pci_id->driver_data; + card_type = pci_id->driver_data; pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - switch (chip_type) { - case TYPE_VIA686: + switch (card_type) { + case TYPE_CARD_VIA686: strcpy(card->driver, "VIA686A"); strcpy(card->shortname, "VIA 82C686A/B"); + chip_type = TYPE_VIA686; break; - case TYPE_VIA8233: - if (revision == VIA_REV_8233A) { + case TYPE_CARD_VIA8233: + chip_type = TYPE_VIA8233; + sprintf(card->shortname, "VIA 823x rev%d", revision); + for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { + if (revision == via823x_cards[i].revision) { + chip_type = via823x_cards[i].type; + strcpy(card->shortname, via823x_cards[i].name); + break; + } + } + if (chip_type == VIA_REV_8233A) strcpy(card->driver, "VIA8233A"); - strcpy(card->shortname, "VIA 8233A"); - } else { + else strcpy(card->driver, "VIA8233"); - strcpy(card->shortname, "VIA 8233/C"); - } break; default: - snd_printk(KERN_ERR "invalid chip type %d\n", chip_type); + snd_printk(KERN_ERR "invalid card type %d\n", card_type); err = -EINVAL; goto __error; } @@ -1705,7 +1787,7 @@ (err = snd_via686_init_misc(chip, dev)) < 0) goto __error; } else { - if (revision == VIA_REV_8233A) { + if (chip_type == VIA_REV_8233A) { if ((err = snd_via8233a_pcm_new(chip)) < 0) goto __error; } else { @@ -1792,4 +1874,3 @@ __setup("snd-via82xx=", alsa_card_via82xx_setup); #endif /* ifndef MODULE */ - ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-27 10:42 ` Takashi Iwai @ 2003-01-27 14:42 ` Tais M. Hansen 2003-01-27 15:15 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-27 14:42 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1445 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 27 January 2003 11:42, Takashi Iwai wrote: > > I just gave it another try with aplay. Bad idea; froze the system. > > Something's really wrong with the test8-patch. > ok. now, i rewrote the patch completely again. > the module options was removed again. > here we go... Ok. Hope you had a great weekend. :) - - Fresh cvs update. Recompiled & installed alsa-lib and alsa-util. - - POINTER_DEBUG enabled. No sound from aplay but it had a lot of complaints for me. Two files attached. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjVFZoIvLOJqwYc4AQKPzQ/8DJDYSkSdi70eIaQ/4seWEiN3eC6gOhuZ 5gXmWoLFDvOTaYf4EI/TlXrrWUYqIjDYn3m6PtS4Enn0zXe5FBztguQu8vOMYGcS OSLaC1Po6gjOgI/klEgawn/G0W4ffn8YVXSYxNJGuYXYmZa2QOcYfbN/MpqH/bnj NPBc8DFyKDnMTspsz0Fr+bL8mfrJnFQzSagV5mKIGDZVExFzqzQWyU2tWpOdoOft i6OB4CnuGZWhQOmnK8fAyijfWn8m+g7UJ7UfcjhagcQnvf7xoUov5kjzZ5Js4ZaY 5jKEow9UF2vij7GfpLidHIi+LyvTybOr1YzXEFCMpb/2qt93xavCdBh1P76xRSTo By7oN6u5wV3rYBP+V3twxKff3g5Q5EVoJhCj4RKjqFIOzQdGsqlF2JZ5P+ODI37I AxL4BBKzIklKKQh0W+PBQoxlJWv+OYVFUUclDjSDYRo672IwvdrIUO4TBllawWhK 5A4LYWHeoIebzA3PFKUhdlRLa/3kpGZPWeOEbsDuJnB/9FTMiCxo6AUd/9MJ3PUC GUV8z40FkIei589mB866PKdhWx567/dJaRgcezKWtY5JWNjDJpDjP34Y/sGwodku Y1YKgqKRScrls+G/jzhzT4XXNkYE81BVF8/o6ClwQUXNUfuM0T6DcCKeHRjWYAHP yqqN7mvVJj0= =D2I5 -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-log-test9.txt.gz --] [-- Type: application/x-gzip, Size: 750 bytes --] [-- Attachment #3: alsa-aplay-stdout-test9.txt.gz --] [-- Type: application/x-gzip, Size: 514 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-27 14:42 ` Tais M. Hansen @ 2003-01-27 15:15 ` Takashi Iwai 2003-01-27 17:01 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-27 15:15 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 891 bytes --] At Mon, 27 Jan 2003 15:42:43 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > [1 <text/plain; iso-8859-1 (quoted-printable)>] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Monday 27 January 2003 11:42, Takashi Iwai wrote: > > > I just gave it another try with aplay. Bad idea; froze the system. > > > Something's really wrong with the test8-patch. > > ok. now, i rewrote the patch completely again. > > the module options was removed again. > > here we go... > > Ok. Hope you had a great weekend. :) > > - - Fresh cvs update. Recompiled & installed alsa-lib and alsa-util. > - - POINTER_DEBUG enabled. > > No sound from aplay but it had a lot of complaints for me. Two files attached. ok, the patch was buggy. but any sounds must come out. please check your mixer configuration. the fixed patch below: same as test9 but more verbose with POINTER_DEBUG. Takashi [-- Attachment #2: via-pointer-test10.dif --] [-- Type: application/octet-stream, Size: 10515 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 27 Jan 2003 15:12:46 -0000 @@ -88,7 +88,7 @@ MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(mpu_port, "MPU-401 port."); MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000"); @@ -230,10 +230,13 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; - unsigned int bufsize2; }; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -302,7 +311,7 @@ } dev->tbl_entries = idx; dev->bufsize = periods * fragsize; - dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,13 +327,18 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } /* */ -enum { TYPE_VIA686 = 1, TYPE_VIA8233 }; +enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; +enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ @@ -365,8 +379,8 @@ }; static struct pci_device_id snd_via82xx_ids[] __devinitdata = { - { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA686, }, /* 686A */ - { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA8233, }, /* VT8233 */ + { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ + { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ { 0, } }; @@ -481,10 +495,13 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; + viadev->intr_cnt = 0; } @@ -512,10 +529,20 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -538,7 +565,7 @@ unsigned char val; unsigned long port = chip->port + viadev->reg_offset; - if (chip->chip_type == TYPE_VIA8233) + if (chip->chip_type != TYPE_VIA686) val = VIA_REG_CTRL_INT; else val = 0; @@ -573,35 +600,76 @@ */ /* + * check whether the given index is within the current area + */ +static inline int out_of_intr_idx(viadev_t *viadev, unsigned int idx) +{ + unsigned int cnt; + + if (idx < viadev->period_idx[viadev->intr_cnt]) + return 1; + cnt = viadev->intr_cnt + 1; + if (cnt != viadev->periods && idx >= viadev->period_idx[cnt]) + return 1; + return 0; +} + +/* * calculate the linear position at the given sg-buffer index and the rest count */ -static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) +static unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) { unsigned int size, res; size = viadev->idx_table[idx].size; res = viadev->idx_table[idx].offset + size - count; - - /* check the validity of the calculated position */ - if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("calc_linear_pos: idx = %i/%i, ptr = 0x%x, lastpos = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, res, viadev->lastpos, size, count); #endif - /* count register returns full size when end of buffer is reached */ - if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; - } else { - res = viadev->idx_table[idx].offset + size; - if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + if (count == 0) { + /* fully processed, increase the index */ + if (++idx >= viadev->tbl_entries) + idx = 0; + } + + if (out_of_intr_idx(viadev, idx)) { + if (size == count) { + /* count register returns full size when end of buffer is reached */ + if (++idx >= viadev->tbl_entries) + idx = 0; + if (! out_of_intr_idx(viadev, idx)) { + res = viadev->idx_table[idx].offset; + goto _ok; } } + if (! out_of_intr_idx(viadev, viadev->lastidx)) { +#ifdef POINTER_DEBUG + snd_printd("recover from last\n"); +#endif + return viadev->lastpos; + } + /* recover from the interrupt pointer */ + idx = viadev->period_idx[viadev->intr_cnt]; + res = viadev->idx_table[idx].offset; +#ifdef POINTER_DEBUG + snd_printd("recover from intr: idx = %i, ptr = 0x%x\n", idx, res); +#endif + } else if (res < viadev->lastpos) { + if (! out_of_intr_idx(viadev, viadev->lastidx)) { +#ifdef POINTER_DEBUG + snd_printd("recover from last #2\n"); +#endif + return viadev->lastpos; + } } - viadev->lastpos = res; /* remember the last positiion */ + _ok: if (res >= viadev->bufsize) res -= viadev->bufsize; + viadev->lastidx = idx; + viadev->lastpos = res; +#ifdef POINTER_DEBUG + snd_printd("get position: 0x%x, idx = %d\n", res, idx); +#endif return res; } @@ -648,7 +716,7 @@ return 0; spin_lock(&chip->reg_lock); count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); @@ -950,7 +1018,7 @@ if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; substream->runtime->hw.channels_max = 6; - if (chip->revision == VIA_REV_8233A) + if (chip->chip_type == TYPE_VIA8233A) snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); return 0; } @@ -1365,7 +1433,7 @@ int i, err, caps; unsigned char val; - caps = chip->revision == VIA_REV_8233A ? 1 : 2; + caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; for (i = 0; i < caps; i++) { snd_via8233_capture_source.index = i; err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); @@ -1651,6 +1719,19 @@ return 0; } +struct via823x_info { + int revision; + char *name; + int type; +}; +static struct via823x_info via823x_cards[] __devinitdata = { + { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, + { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, + { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, + { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A }, + { VIA_REV_8233, "VIA 8235", TYPE_VIA8233 }, +}; + static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -1658,7 +1739,7 @@ snd_card_t *card; via82xx_t *chip; unsigned char revision; - int chip_type; + int chip_type = 0, card_type; int i, err; if (dev >= SNDRV_CARDS) @@ -1672,24 +1753,31 @@ if (card == NULL) return -ENOMEM; - chip_type = pci_id->driver_data; + card_type = pci_id->driver_data; pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - switch (chip_type) { - case TYPE_VIA686: + switch (card_type) { + case TYPE_CARD_VIA686: strcpy(card->driver, "VIA686A"); strcpy(card->shortname, "VIA 82C686A/B"); + chip_type = TYPE_VIA686; break; - case TYPE_VIA8233: - if (revision == VIA_REV_8233A) { + case TYPE_CARD_VIA8233: + chip_type = TYPE_VIA8233; + sprintf(card->shortname, "VIA 823x rev%d", revision); + for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { + if (revision == via823x_cards[i].revision) { + chip_type = via823x_cards[i].type; + strcpy(card->shortname, via823x_cards[i].name); + break; + } + } + if (chip_type == VIA_REV_8233A) strcpy(card->driver, "VIA8233A"); - strcpy(card->shortname, "VIA 8233A"); - } else { + else strcpy(card->driver, "VIA8233"); - strcpy(card->shortname, "VIA 8233/C"); - } break; default: - snd_printk(KERN_ERR "invalid chip type %d\n", chip_type); + snd_printk(KERN_ERR "invalid card type %d\n", card_type); err = -EINVAL; goto __error; } @@ -1705,7 +1793,7 @@ (err = snd_via686_init_misc(chip, dev)) < 0) goto __error; } else { - if (revision == VIA_REV_8233A) { + if (chip_type == VIA_REV_8233A) { if ((err = snd_via8233a_pcm_new(chip)) < 0) goto __error; } else { @@ -1792,4 +1880,3 @@ __setup("snd-via82xx=", alsa_card_via82xx_setup); #endif /* ifndef MODULE */ - ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-27 15:15 ` Takashi Iwai @ 2003-01-27 17:01 ` Tais M. Hansen 2003-01-27 17:27 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-27 17:01 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1663 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 27 January 2003 16:15, Takashi Iwai wrote: > > No sound from aplay but it had a lot of complaints for me. Two files > > attached. > ok, the patch was buggy. > but any sounds must come out. please check your mixer configuration. It seems okay. Just to make sure I reverted the patch and recompiled. Aplay played several minutes without any errors at all. I also let ogg123 play for about 10 minutes. Had a few pops and an equal amount of fails in syslog. Pretty much the same as what I started out with after your initial via-fix. I've attached the ogg123 logoutput anyway. > the fixed patch below: same as test9 but more verbose with POINTER_DEBUG. Attached 2 files from testing with aplay. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjVl+YIvLOJqwYc4AQIvqw/+Kvsr+jz1JxEKkynD4R5wDFeh5suycJ3r yCTsEliaaTw35w5+6wpGqHcIGcCHcugqIMOaWrkfseNV3Sghm3rhVAoisMHZDCq/ lhifJ1uj2i1v2gwtkrBABv4QXHZ4mk1iRSRk4rYuqho2tHlp9qYs6g8OAXclk6Ih gYDt3/Q4ceqWPhT9r0s31/nB4yr7rQpkCxO40fY9Ux4aFQFkiHb9Yi4gb2DJ53Zg Ox0GUPUnoMyx61eYJMIDUwdweSMuxopYUnNrU1vCRXwv7Txt7JCAu/afRkK+41gn IrF+Fcof1cBAxfyZrgi4RgrCONKSWSWnhainr2pymVnDbmKFZd7IT9G5I9E5xyPJ tBWsVGkUU8/fbSgA566jd592oM3qP0/uf3tkjnI5+s5rUSWMcAGiQzmBaB08ENMv hfiU2DjQ5Ls8uTpBIy5Qhqv6w3yXeAJZVzav3GNcVQZSikUBcwaS4g4Tf19X0PRr ygKLRB5aoW4O/vZIqbRrBx5rJjITFDYzPGtbp6RMoOf4omqgZHRB+oANHYLGoVfu 2f8sjIGC5isdY4FkXIdehI0g4LPqbxpQczxpreODm4Xfd0IBztUzLs8IpuddsEuy ExkL+1+NHUbqOF1MfxytBWATb+FBucCEACKlm4oVGmqHA90WVNtvCt0Wne0H4oou cn3N3N15LRU= =tiID -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-log-test10.txt.gz --] [-- Type: application/x-gzip, Size: 16816 bytes --] [-- Attachment #3: alsa-aplay-stdout-test10.txt.gz --] [-- Type: application/x-gzip, Size: 1536 bytes --] [-- Attachment #4: alsa-ogg123-log-orig.txt.gz --] [-- Type: application/x-gzip, Size: 323 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-27 17:01 ` Tais M. Hansen @ 2003-01-27 17:27 ` Takashi Iwai 2003-01-28 0:43 ` VIA823x testing Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-27 17:27 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 960 bytes --] At Mon, 27 Jan 2003 18:01:42 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > [1 <text/plain; iso-8859-1 (quoted-printable)>] > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Monday 27 January 2003 16:15, Takashi Iwai wrote: > > > No sound from aplay but it had a lot of complaints for me. Two files > > > attached. > > ok, the patch was buggy. > > but any sounds must come out. please check your mixer configuration. > > It seems okay. Just to make sure I reverted the patch and recompiled. Aplay > played several minutes without any errors at all. I also let ogg123 play for > about 10 minutes. Had a few pops and an equal amount of fails in syslog. > Pretty much the same as what I started out with after your initial via-fix. > I've attached the ogg123 logoutput anyway. > > > > the fixed patch below: same as test9 but more verbose with POINTER_DEBUG. > > Attached 2 files from testing with aplay. how about this one? Takashi [-- Attachment #2: via-pointer-test11.dif --] [-- Type: application/octet-stream, Size: 11281 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 27 Jan 2003 17:24:08 -0000 @@ -88,7 +88,7 @@ MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(mpu_port, "MPU-401 port."); MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000"); @@ -230,10 +230,13 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; - unsigned int bufsize2; }; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -302,7 +311,7 @@ } dev->tbl_entries = idx; dev->bufsize = periods * fragsize; - dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,13 +327,18 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } /* */ -enum { TYPE_VIA686 = 1, TYPE_VIA8233 }; +enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; +enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ @@ -365,8 +379,8 @@ }; static struct pci_device_id snd_via82xx_ids[] __devinitdata = { - { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA686, }, /* 686A */ - { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA8233, }, /* VT8233 */ + { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ + { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ { 0, } }; @@ -481,10 +495,13 @@ /* disable interrupts */ outb(0x00, port + VIA_REG_OFFSET_CONTROL); /* clear interrupts */ - outb(0x03, port + VIA_REG_OFFSET_STATUS); - outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ + outb(0x07, port + VIA_REG_OFFSET_STATUS); + if (chip->chip_type == TYPE_VIA686) + outb(0x00, port + VIA_REG_OFFSET_TYPE); outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; + viadev->intr_cnt = 0; } @@ -512,10 +529,20 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port) & 0x07; + if (! status) + continue; + outb(status, port); /* ack */ + if (status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + snd_printd("period elapsed\n"); +#endif snd_pcm_period_elapsed(viadev->substream); spin_lock(&chip->reg_lock); } @@ -538,7 +565,7 @@ unsigned char val; unsigned long port = chip->port + viadev->reg_offset; - if (chip->chip_type == TYPE_VIA8233) + if (chip->chip_type != TYPE_VIA686) val = VIA_REG_CTRL_INT; else val = 0; @@ -573,35 +600,85 @@ */ /* + * check whether the given index is within the current area + */ +static inline int out_of_intr_idx(viadev_t *viadev, unsigned int idx) +{ + unsigned int cnt; + + if (idx < viadev->period_idx[viadev->intr_cnt]) + return 1; + cnt = viadev->intr_cnt + 1; + if (cnt != viadev->periods && idx >= viadev->period_idx[cnt]) + return 1; + return 0; +} + +/* * calculate the linear position at the given sg-buffer index and the rest count */ -static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) +static unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) { unsigned int size, res; + int recover = 0; size = viadev->idx_table[idx].size; - res = viadev->idx_table[idx].offset + size - count; - - /* check the validity of the calculated position */ - if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("calc_linear_pos: idx = %i/%i, lastpos = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, size, count); #endif - /* count register returns full size when end of buffer is reached */ - if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; - } else { - res = viadev->idx_table[idx].offset + size; - if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + if (count == 0) { + /* fully processed, increase the index */ + if (++idx >= viadev->tbl_entries) + idx = 0; + res = viadev->idx_table[idx].offset; + } else if (count > size) { + /* totally corrupted? get the position from interrupt ptr */ + recover = 2; + res = 0; /* shut up warning */ + goto _check; + } else { + res = viadev->idx_table[idx].offset + size - count; + } + + if (out_of_intr_idx(viadev, idx)) { + if (size == count) { + /* count register returns full size when end of buffer is reached */ + if (++idx >= viadev->tbl_entries) + idx = 0; + if (! out_of_intr_idx(viadev, idx)) { + res = viadev->idx_table[idx].offset; + goto _check; } } + recover = 2; + } else if (res < viadev->lastpos) + recover = 1; + + _check: + if (recover > 0) { + if (! out_of_intr_idx(viadev, viadev->lastidx)) { +#ifdef POINTER_DEBUG + snd_printd("recover from last\n"); +#endif + return viadev->lastpos; + } + if (recover > 1) { + /* recover from the interrupt pointer */ + idx = viadev->period_idx[viadev->intr_cnt]; + res = viadev->idx_table[idx].offset; +#ifdef POINTER_DEBUG + snd_printd("recover from intr: idx = %i, ptr = 0x%x\n", idx, res); +#endif + } } - viadev->lastpos = res; /* remember the last positiion */ + if (res >= viadev->bufsize) res -= viadev->bufsize; + viadev->lastidx = idx; + viadev->lastpos = res; +#ifdef POINTER_DEBUG + snd_printd("get position: 0x%x, idx = %d\n", res, idx); +#endif return res; } @@ -642,13 +719,23 @@ via82xx_t *chip = snd_pcm_substream_chip(substream); viadev_t *viadev = (viadev_t *)substream->runtime->private_data; unsigned int idx, count, res; + int timeout = 50; snd_assert(viadev->tbl_entries, return 0); if (!(inb(VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset) & VIA_REG_STAT_ACTIVE)) return 0; + while (timeout-- > 0) { + count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); + if (count != (unsigned int)-1) + goto _got_count; + } +#ifdef POINTER_DEBUG + snd_printd("invalid CURR_COUNT reg\n"); +#endif + count = 0; + _got_count: spin_lock(&chip->reg_lock); - count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); @@ -950,7 +1037,7 @@ if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; substream->runtime->hw.channels_max = 6; - if (chip->revision == VIA_REV_8233A) + if (chip->chip_type == TYPE_VIA8233A) snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); return 0; } @@ -1365,7 +1452,7 @@ int i, err, caps; unsigned char val; - caps = chip->revision == VIA_REV_8233A ? 1 : 2; + caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; for (i = 0; i < caps; i++) { snd_via8233_capture_source.index = i; err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); @@ -1651,6 +1738,19 @@ return 0; } +struct via823x_info { + int revision; + char *name; + int type; +}; +static struct via823x_info via823x_cards[] __devinitdata = { + { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, + { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, + { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, + { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A }, + { VIA_REV_8233, "VIA 8235", TYPE_VIA8233 }, +}; + static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -1658,7 +1758,7 @@ snd_card_t *card; via82xx_t *chip; unsigned char revision; - int chip_type; + int chip_type = 0, card_type; int i, err; if (dev >= SNDRV_CARDS) @@ -1672,24 +1772,31 @@ if (card == NULL) return -ENOMEM; - chip_type = pci_id->driver_data; + card_type = pci_id->driver_data; pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - switch (chip_type) { - case TYPE_VIA686: + switch (card_type) { + case TYPE_CARD_VIA686: strcpy(card->driver, "VIA686A"); strcpy(card->shortname, "VIA 82C686A/B"); + chip_type = TYPE_VIA686; break; - case TYPE_VIA8233: - if (revision == VIA_REV_8233A) { + case TYPE_CARD_VIA8233: + chip_type = TYPE_VIA8233; + sprintf(card->shortname, "VIA 823x rev%d", revision); + for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { + if (revision == via823x_cards[i].revision) { + chip_type = via823x_cards[i].type; + strcpy(card->shortname, via823x_cards[i].name); + break; + } + } + if (chip_type == VIA_REV_8233A) strcpy(card->driver, "VIA8233A"); - strcpy(card->shortname, "VIA 8233A"); - } else { + else strcpy(card->driver, "VIA8233"); - strcpy(card->shortname, "VIA 8233/C"); - } break; default: - snd_printk(KERN_ERR "invalid chip type %d\n", chip_type); + snd_printk(KERN_ERR "invalid card type %d\n", card_type); err = -EINVAL; goto __error; } @@ -1705,7 +1812,7 @@ (err = snd_via686_init_misc(chip, dev)) < 0) goto __error; } else { - if (revision == VIA_REV_8233A) { + if (chip_type == VIA_REV_8233A) { if ((err = snd_via8233a_pcm_new(chip)) < 0) goto __error; } else { @@ -1792,4 +1899,3 @@ __setup("snd-via82xx=", alsa_card_via82xx_setup); #endif /* ifndef MODULE */ - ^ permalink raw reply [flat|nested] 29+ messages in thread
* VIA823x testing 2003-01-27 17:27 ` Takashi Iwai @ 2003-01-28 0:43 ` Tais M. Hansen 2003-01-28 9:31 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-28 0:43 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1061 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 27 January 2003 18:27, Takashi Iwai wrote: > how about this one? Still no sound. More logs for you to digest. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjXSOYIvLOJqwYc4AQIsHw/9EsI3OH8H4oQhUWjzBQwOxCqd0grsigMC AkY640gaBzw2nlPRoxSOuiofxzyryxFlCLj1KUMh7h4IjUsp5oSU1k2aMESIB5PI GSbT75aIFbEQjLD1db+lKD6Xpi/pxYvqqd5sYvyNqSQjLf3iUdWb+F1sC7W3dYW8 03SLt6M+xgH9lTFWLCkzpIxUufDR4rvIl069Sw+yvJ7fJcTbSTAfodsJksZBJdyD Ef8zMgaHs06ySeR91hr9TWVZAqhtoRNQ6sYO+d7piZoraM4IjAXsdSTKIb9DRLP7 zgo020Z/cVoIHIg+a+Y40pAAGg56WB5O1GMOF3ifQG9DFVRi4isezMS+ZdXHH2a0 mPAEagVhAPEaGfmua0bOMSlU+VVYLc7rDcRGYRHXE4J4t2CdCW8flcbUYmbWpOmr rnR1GkhFXyc0pulOvAACYFoie4bAh8sD4PXBx/GMA6lIohUoiNYkhYEpSqcP1Wku bfSIppVDKzoeoESATJfnsdYivScNx7kuBwU2GfcpqHZV84tNBcoSExoqUMDQLJ2O uD3q7tw7VTMNOq4iHlNb2/TCeCYL8mCzs0ocg+6v1H2y10t8X6QURc8TwE7recqH p//YgBDJcUtKtIWOegwdjb7Ca8KXhm48lv1IBbeowr3ps+G3T6F9o+3vJaTh6eLm qo9xbSE6esM= =p5vV -----END PGP SIGNATURE----- [-- Attachment #2: alsa-aplay-log-test11.txt.gz --] [-- Type: application/x-gzip, Size: 17225 bytes --] [-- Attachment #3: alsa-aplay-stdout-test11.txt.gz --] [-- Type: application/x-gzip, Size: 352 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: VIA823x testing 2003-01-28 0:43 ` VIA823x testing Tais M. Hansen @ 2003-01-28 9:31 ` Takashi Iwai 2003-01-28 13:25 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-28 9:31 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel At Tue, 28 Jan 2003 01:43:34 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > On Monday 27 January 2003 18:27, Takashi Iwai wrote: > > how about this one? > > Still no sound. More logs for you to digest. please check the mixer configuration. there must be any sounds, even though pops/clicks and error messages might come. Takashi ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: VIA823x testing 2003-01-28 9:31 ` Takashi Iwai @ 2003-01-28 13:25 ` Tais M. Hansen 2003-01-28 16:21 ` Takashi Iwai 0 siblings, 1 reply; 29+ messages in thread From: Tais M. Hansen @ 2003-01-28 13:25 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 28 January 2003 10:31, Takashi Iwai wrote: > > > how about this one? > > Still no sound. More logs for you to digest. > please check the mixer configuration. > there must be any sounds, even though pops/clicks and error messages > might come. No sound at all. I've tried turning everything up to full volume, unmuting everything, tried all three onboard minijacks. Not a peep. - From what I can see when playing with ogg123, it's speeding through the ogg-file. It took 4.8s to play 10s ogg-file. Btw while testing I got 23MB logoutput, want it? ;) - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjaE0IIvLOJqwYc4AQKG8w/8DkyS7f4wKKrQESHS6cOuDhbQ3i7O8m3w 320MpPr2Mk/XAxEPVeHKPHY4bQ5ffO1KferYoyBjO7rnPlJztLuYsRECXEv1bj2s Xm6kW/9R4Zn6eGuJIEaNpouBLQv2atBQa1KyiP3z9VPWqGMesGK2vpSmmwljb6Jz cdgjwHA3b3FeVvD5S/FRrnMJUfT+bgNEgl6Iz33AQiC6oGsCFRdp1LjtW3GuYRLb EqeauASb484mgT/JKVZnzitPMhHWbR3aEUO2wQhBIBflpLZT+ETjYEkGZvGLnFxw MGa+Dax2wW5ximjCBtGmRrbOhqf24Pe2hjXZHCu7MKUHFUP+1Wt/tId43jXx6Dze 3pYC+TcKIzYYCBIa7iEdBcL5IOFYj6VNpEGcSWZ/CKi49Sn1SdMqtID46EhDu6M/ nMr4uUKtFm/DfGGmoDzQkqiBZJBBpIUAtHHFuVZ6OJw3VaB73rNLQQQXh+a2aB8I q0CUY0xBIToN8LNe67m3+IPF/gOUp0tdFQD82puDvwVjMohF1XJfUVzqQ60fdOKb 6vRYoa9lVFPWiEeVsnQOuycAzTxIKd94WEXGqFX/eMHZSqqzEiOpb3Q3QSmkq1ZZ xsDwTxt0T5TFLxdurn781lsJbuyaVNVPkMWyClQwEyJEhbWgoUeL6HRW5h1EwfyD hlmy/E7u5kA= =0/V7 -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: VIA823x testing 2003-01-28 13:25 ` Tais M. Hansen @ 2003-01-28 16:21 ` Takashi Iwai 2003-01-28 23:19 ` Tais M. Hansen 0 siblings, 1 reply; 29+ messages in thread From: Takashi Iwai @ 2003-01-28 16:21 UTC (permalink / raw) To: Tais M. Hansen; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1121 bytes --] At Tue, 28 Jan 2003 14:25:31 +0100, Tais M. Hansen <tais.hansen@osd.dk> wrote: > > On Tuesday 28 January 2003 10:31, Takashi Iwai wrote: > > > > how about this one? > > > Still no sound. More logs for you to digest. > > please check the mixer configuration. > > there must be any sounds, even though pops/clicks and error messages > > might come. > > No sound at all. I've tried turning everything up to full volume, unmuting > everything, tried all three onboard minijacks. Not a peep. hmm, then it seems something goes wrong completely. at least, i see the "invalid CURR_PTR" error at each call. it's weird. did you see this in the log of ogg123? > - From what I can see when playing with ogg123, it's speeding through the > ogg-file. It took 4.8s to play 10s ogg-file. interesting. the new patch will put the timestamp at each interrupt, so you can measure the period time between interrupts. this shoud be (period-size-in-frames * 4 / sample-rate) please compare the measured values. > Btw while testing I got 23MB logoutput, want it? ;) no, it would be filtered as a spam, anyway :) ciao, Takashi [-- Attachment #2: via-pointer-test12.dif --] [-- Type: application/octet-stream, Size: 14835 bytes --] Index: alsa-kernel/pci/via82xx.c =================================================================== RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v retrieving revision 1.21 diff -u -r1.21 via82xx.c --- alsa-kernel/pci/via82xx.c 22 Jan 2003 14:21:05 -0000 1.21 +++ alsa-kernel/pci/via82xx.c 28 Jan 2003 16:15:07 -0000 @@ -88,7 +88,7 @@ MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(mpu_port, "MPU-401 port."); MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000"); @@ -230,10 +230,13 @@ u32 *table; /* physical address + flag */ dma_addr_t table_addr; struct snd_via_sg_table *idx_table; + int *period_idx; + unsigned int periods; /* for recovery from the unexpected pointer */ + unsigned int intr_cnt; unsigned int lastpos; + unsigned int lastidx; unsigned int bufsize; - unsigned int bufsize2; }; @@ -262,11 +265,17 @@ if (! dev->idx_table) return -ENOMEM; } + if (! dev->period_idx) { + dev->period_idx = kmalloc(sizeof(int) * VIA_TABLE_SIZE, GFP_KERNEL); + if (! dev->period_idx) + return -ENOMEM; + } /* fill the entries */ idx = 0; ofs = 0; for (i = 0; i < periods; i++) { + dev->period_idx[i] = idx; rest = fragsize; /* fill descriptors for a period. * a period can be split to several descriptors if it's @@ -302,7 +311,7 @@ } dev->tbl_entries = idx; dev->bufsize = periods * fragsize; - dev->bufsize2 = dev->bufsize / 2; + dev->periods = periods; return 0; } @@ -318,13 +327,18 @@ kfree(dev->idx_table); dev->idx_table = NULL; } + if (dev->period_idx) { + kfree(dev->period_idx); + dev->period_idx = NULL; + } } /* */ -enum { TYPE_VIA686 = 1, TYPE_VIA8233 }; +enum { TYPE_CARD_VIA686 = 1, TYPE_CARD_VIA8233 }; +enum { TYPE_VIA686, TYPE_VIA8233, TYPE_VIA8233A }; #define VIA_MAX_DEVS 7 /* 4 playback, 1 multi, 2 capture */ @@ -365,8 +379,8 @@ }; static struct pci_device_id snd_via82xx_ids[] __devinitdata = { - { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA686, }, /* 686A */ - { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_VIA8233, }, /* VT8233 */ + { 0x1106, 0x3058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ + { 0x1106, 0x3059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ { 0, } }; @@ -485,6 +499,8 @@ outb(0x00, port + VIA_REG_OFFSET_TYPE); /* for via686 */ outl(0, port + VIA_REG_OFFSET_CURR_PTR); viadev->lastpos = 0; + viadev->lastidx = 0; + viadev->intr_cnt = 0; } @@ -512,13 +528,26 @@ /* check status for each stream */ for (i = 0; i < chip->num_devs; i++) { viadev_t *viadev = &chip->devs[i]; - if (inb(chip->port + viadev->reg_offset) & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG)) { - outb(VIA_REG_STAT_FLAG | VIA_REG_STAT_EOL, VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset); - if (viadev->substream && viadev->running) { - spin_unlock(&chip->reg_lock); - snd_pcm_period_elapsed(viadev->substream); - spin_lock(&chip->reg_lock); + unsigned long port = chip->port + viadev->reg_offset; /* STATUS */ + unsigned char status = inb(port); + status &= (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG); + if (! status) + continue; + outb(status, port); /* ack */ + if (viadev->substream && viadev->running) { + viadev->intr_cnt++; + if (viadev->intr_cnt >= viadev->periods) + viadev->intr_cnt = 0; + spin_unlock(&chip->reg_lock); +#ifdef POINTER_DEBUG + { + struct timeval tval; + do_gettimeofday(&tval); + snd_printd("period elapsed: %d.%06d\n", tv->sec, tv->usec); } +#endif + snd_pcm_period_elapsed(viadev->substream); + spin_lock(&chip->reg_lock); } } spin_unlock(&chip->reg_lock); @@ -538,7 +567,7 @@ unsigned char val; unsigned long port = chip->port + viadev->reg_offset; - if (chip->chip_type == TYPE_VIA8233) + if (chip->chip_type != TYPE_VIA686) val = VIA_REG_CTRL_INT; else val = 0; @@ -573,35 +602,87 @@ */ /* + * check whether the given index is within the current area + */ +static inline int out_of_intr_idx(viadev_t *viadev, unsigned int idx) +{ + unsigned int cnt; + + if (idx < viadev->period_idx[viadev->intr_cnt]) + return 1; + cnt = viadev->intr_cnt + 1; + if (cnt != viadev->periods && idx >= viadev->period_idx[cnt]) + return 1; + return 0; +} + +/* * calculate the linear position at the given sg-buffer index and the rest count */ -static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) +static unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count, int recover) { - unsigned int size, res; + unsigned int size, res = 0; - size = viadev->idx_table[idx].size; - res = viadev->idx_table[idx].offset + size - count; + if (recover > 0) + goto _check; - /* check the validity of the calculated position */ - if (size < count || (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2))) { + size = viadev->idx_table[idx].size; #ifdef POINTER_DEBUG - printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + snd_printd("calc_linear_pos: idx = %i/%i, lastpos = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, size, count); #endif - /* count register returns full size when end of buffer is reached */ - if (size != count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); - res = viadev->lastpos; - } else { - res = viadev->idx_table[idx].offset + size; - if (res < viadev->lastpos && (res >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); - res = viadev->lastpos; + if (count == 0) { + /* fully processed, increase the index */ + if (++idx >= viadev->tbl_entries) + idx = 0; + res = viadev->idx_table[idx].offset; + } else if (count > size) { + /* totally corrupted? get the position from interrupt ptr */ + recover = 2; + goto _check; + } else { + res = viadev->idx_table[idx].offset + size - count; + } + + if (out_of_intr_idx(viadev, idx)) { + if (size == count) { + /* count register returns full size when end of buffer is reached */ + if (++idx >= viadev->tbl_entries) + idx = 0; + if (! out_of_intr_idx(viadev, idx)) { + res = viadev->idx_table[idx].offset; + goto _ok; } } + recover = 2; + } else if (res < viadev->lastpos) + recover = 1; + + _check: + if (recover > 0) { + if (! out_of_intr_idx(viadev, viadev->lastidx)) { +#ifdef POINTER_DEBUG + snd_printd("recover from last\n"); +#endif + return viadev->lastpos; + } + if (recover > 1) { + /* recover from the interrupt pointer */ + idx = viadev->period_idx[viadev->intr_cnt]; + res = viadev->idx_table[idx].offset; +#ifdef POINTER_DEBUG + snd_printd("recover from intr: idx = %i, ptr = 0x%x\n", idx, res); +#endif + } } - viadev->lastpos = res; /* remember the last positiion */ + + _ok: if (res >= viadev->bufsize) res -= viadev->bufsize; + viadev->lastidx = idx; + viadev->lastpos = res; +#ifdef POINTER_DEBUG + snd_printd("get position: 0x%x, idx = %d\n", res, idx); +#endif return res; } @@ -628,7 +709,7 @@ idx = 0; else /* CURR_PTR holds the address + 8 */ idx = ((ptr - (unsigned int)viadev->table_addr) / 8 - 1) % viadev->tbl_entries; - res = calc_linear_pos(viadev, idx, count); + res = calc_linear_pos(viadev, idx, count, 0); spin_unlock(&chip->reg_lock); return bytes_to_frames(substream->runtime, res); @@ -642,15 +723,27 @@ via82xx_t *chip = snd_pcm_substream_chip(substream); viadev_t *viadev = (viadev_t *)substream->runtime->private_data; unsigned int idx, count, res; + int timeout, recover; snd_assert(viadev->tbl_entries, return 0); if (!(inb(VIAREG(chip, OFFSET_STATUS) + viadev->reg_offset) & VIA_REG_STAT_ACTIVE)) return 0; + recover = 0; + timeout = 50; + do { + count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); + if (count != (unsigned int)-1) + goto _got_count; + } while (timeout-- > 0); +#ifdef POINTER_DEBUG + snd_printd("invalid CURR_COUNT reg\n"); +#endif + recover = 2; + _got_count: spin_lock(&chip->reg_lock); - count = inl(VIAREG(chip, OFFSET_CURR_COUNT) + viadev->reg_offset); - idx = count >> 24; + idx = (count >> 24) & viadev->tbl_entries; count &= 0xffffff; - res = calc_linear_pos(viadev, idx, count); + res = calc_linear_pos(viadev, idx, count, recover); spin_unlock(&chip->reg_lock); return bytes_to_frames(substream->runtime, res); @@ -696,6 +789,17 @@ /* + * set up the table pointer + */ +static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) +{ + snd_via82xx_codec_ready(chip, 0); + outl((u32)viadev->table_addr, VIAREG(chip, OFFSET_TABLE_PTR) + viadev->reg_offset); + udelay(20); + snd_via82xx_codec_ready(chip, 0); +} + +/* * prepare callback for playback and capture on via686 */ static void via686_setup_format(via82xx_t *chip, viadev_t *viadev, snd_pcm_runtime_t *runtime) @@ -704,7 +808,7 @@ snd_via82xx_channel_reset(chip, viadev); /* this must be set after channel_reset */ - outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR); + snd_via82xx_set_table_ptr(chip, viadev); outb(VIA_REG_TYPE_AUTOSTART | (runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA_REG_TYPE_16BIT : 0) | (runtime->channels > 1 ? VIA_REG_TYPE_STEREO : 0) | @@ -777,7 +881,7 @@ rbits = (0xfffff / 48000) * runtime->rate + ((0xfffff % 48000) * runtime->rate) / 48000; snd_assert((rbits & ~0xfffff) == 0, return -EINVAL); snd_via82xx_channel_reset(chip, viadev); - outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR); + snd_via82xx_set_table_ptr(chip, viadev); outb(0 , VIAREG(chip, PLAYBACK_VOLUME_L)); outb(0 , VIAREG(chip, PLAYBACK_VOLUME_R)); outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */ @@ -785,6 +889,8 @@ rbits | /* rate */ 0xff000000, /* STOP index is never reached */ port + VIA_REG_OFFSET_STOP_IDX); + udelay(20); + snd_via82xx_codec_ready(chip, 0); return 0; } @@ -807,7 +913,7 @@ snd_ac97_set_rate(chip->ac97, AC97_PCM_LFE_DAC_RATE, runtime->rate); snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); snd_via82xx_channel_reset(chip, viadev); - outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR); + snd_via82xx_set_table_ptr(chip, viadev); fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT; fmt |= runtime->channels << 4; @@ -825,6 +931,8 @@ } /* STOP index is never reached */ outl(0xff000000 | slots, port + VIA_REG_OFFSET_STOP_IDX); + udelay(20); + snd_via82xx_codec_ready(chip, 0); return 0; } @@ -842,7 +950,7 @@ return -EINVAL; snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); snd_via82xx_channel_reset(chip, viadev); - outl((u32)viadev->table_addr, port + VIA_REG_OFFSET_TABLE_PTR); + snd_via82xx_set_table_ptr(chip, viadev); outb(VIA_REG_CAPTURE_FIFO_ENABLE, VIAREG(chip, CAPTURE_FIFO)); outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | @@ -950,7 +1058,7 @@ if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) return err; substream->runtime->hw.channels_max = 6; - if (chip->revision == VIA_REV_8233A) + if (chip->chip_type == TYPE_VIA8233A) snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); return 0; } @@ -1306,6 +1414,12 @@ ac97.clock = chip->ac97_clock; if ((err = snd_ac97_mixer(chip->card, &ac97, &chip->ac97)) < 0) return err; + + if (chip->chip_type != TYPE_VIA686) { + /* use slot 10/11 */ + snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); + } + return 0; } @@ -1365,7 +1479,7 @@ int i, err, caps; unsigned char val; - caps = chip->revision == VIA_REV_8233A ? 1 : 2; + caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; for (i = 0; i < caps; i++) { snd_via8233_capture_source.index = i; err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); @@ -1651,6 +1765,19 @@ return 0; } +struct via823x_info { + int revision; + char *name; + int type; +}; +static struct via823x_info via823x_cards[] __devinitdata = { + { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, + { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, + { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, + { VIA_REV_8233A, "VIA 8233A", TYPE_VIA8233A }, + { VIA_REV_8233, "VIA 8235", TYPE_VIA8233 }, +}; + static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -1658,7 +1785,7 @@ snd_card_t *card; via82xx_t *chip; unsigned char revision; - int chip_type; + int chip_type = 0, card_type; int i, err; if (dev >= SNDRV_CARDS) @@ -1672,24 +1799,31 @@ if (card == NULL) return -ENOMEM; - chip_type = pci_id->driver_data; + card_type = pci_id->driver_data; pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - switch (chip_type) { - case TYPE_VIA686: + switch (card_type) { + case TYPE_CARD_VIA686: strcpy(card->driver, "VIA686A"); strcpy(card->shortname, "VIA 82C686A/B"); + chip_type = TYPE_VIA686; break; - case TYPE_VIA8233: - if (revision == VIA_REV_8233A) { + case TYPE_CARD_VIA8233: + chip_type = TYPE_VIA8233; + sprintf(card->shortname, "VIA 823x rev%d", revision); + for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) { + if (revision == via823x_cards[i].revision) { + chip_type = via823x_cards[i].type; + strcpy(card->shortname, via823x_cards[i].name); + break; + } + } + if (chip_type == VIA_REV_8233A) strcpy(card->driver, "VIA8233A"); - strcpy(card->shortname, "VIA 8233A"); - } else { + else strcpy(card->driver, "VIA8233"); - strcpy(card->shortname, "VIA 8233/C"); - } break; default: - snd_printk(KERN_ERR "invalid chip type %d\n", chip_type); + snd_printk(KERN_ERR "invalid card type %d\n", card_type); err = -EINVAL; goto __error; } @@ -1705,7 +1839,7 @@ (err = snd_via686_init_misc(chip, dev)) < 0) goto __error; } else { - if (revision == VIA_REV_8233A) { + if (chip_type == VIA_REV_8233A) { if ((err = snd_via8233a_pcm_new(chip)) < 0) goto __error; } else { @@ -1792,4 +1926,3 @@ __setup("snd-via82xx=", alsa_card_via82xx_setup); #endif /* ifndef MODULE */ - ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: VIA823x testing 2003-01-28 16:21 ` Takashi Iwai @ 2003-01-28 23:19 ` Tais M. Hansen 0 siblings, 0 replies; 29+ messages in thread From: Tais M. Hansen @ 2003-01-28 23:19 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 28 January 2003 17:21, Takashi Iwai wrote: > > > please check the mixer configuration. > > > there must be any sounds, even though pops/clicks and error messages > > > might come. > > No sound at all. I've tried turning everything up to full volume, > > unmuting everything, tried all three onboard minijacks. Not a peep. > hmm, then it seems something goes wrong completely. > at least, i see the "invalid CURR_PTR" error at each call. > it's weird. did you see this in the log of ogg123? Yes. Lots of those. I also noticed something else. Seems like there's some kind of overflow in the logging or something. I found a few lines that has been truncated like these: Jan 28 17:30:44 proficio kernel: ALSA ../alsa-kernel/pci/via82xx.c:733: invURR_COUNT reg Jan 28 17:30:46 proficio kernel: ALSA ../alsa-kernel/pcURR_COUNT reg Jan 28 17:30:46 proficio kernel: ALSA ../alsa-kernel/p3: invalid CURR_COUNT reg I'm guessing that too much output comes too fast, filling some buffer and truncating the rest. It's probably syslogd which truncates, but I thought I'd mention it anyway. > > - From what I can see when playing with ogg123, it's speeding through the > > ogg-file. It took 4.8s to play 10s ogg-file. > interesting. > the new patch will put the timestamp at each interrupt, so you can > measure the period time between interrupts. > this shoud be (period-size-in-frames * 4 / sample-rate) I edited the patch. You inited a timeval tval, but referred to tv->sec and tv->usec. I'm guessing it should have been tval.tv_sec and tval.tv_usec. > please compare the measured values. I'm not sure what you mean with 'period-size-in-frames', so I just wrote up the numbers here. 8 'period elapsed' from ogg123 test (44100 Hz, 2 ch): 1043795039.736837 idx 0 ptr 0x0 +0.008531 idx+1 ptr+0x1000 1043795039.745368 idx 1 ptr 0x1000 +0.001152 idx+1 ptr+0x1000 1043795039.746520 idx 2 ptr 0x2000 +0.012034 idx+1 ptr+0x1000 1043795039.758554 idx 3 ptr 0x3000 +0.012041 idx+1 ptr+0x1000 1043795039.770595 idx 4 ptr 0x4000 +0.004189 idx+1 ptr+0x1000 1043795039.774784 idx 5 ptr 0x5000 +0.000696 idx+1 ptr+0x1000 1043795039.775480 idx 6 ptr 0x6000 +0.012130 idx+1 ptr+0x1000 1043795039.787610 idx 7 ptr 0x7000 5 'period elapsed' from aplay test (44100 Hz, 2 ch, Signed 16 bit Little Endian) period_size 4410: 1043794327.002204 idx 0 ptr 0x0 +0.012029 idx+5 ptr+0x44e8 1043794327.014233 idx 5 ptr 0x44e8 +0.012031 idx+5 ptr+0x44e8 1043794327.026264 idx 10 ptr 0x89d0 +0.012029 idx+5 ptr+0x44e8 1043794327.038293 idx 15 ptr 0xceb8 +0.012032 idx+6 ptr+0x44e8 1043794327.050325 idx 21 ptr 0x113a0 I'm not sure what to make of this. Sorry. - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjcQGIIvLOJqwYc4AQIWzhAAgk2e6Bpelgc539+zXr3tQhOH6DSPlcQ7 c2J1ta1PkKuqY9OH1uvYqxcIbR2wqQ5wdB6y6zaLsD0pdODQr0adtuY4FX+FiiyB iMpI23E0T8JY21gw09dmn0hrvfFH/0xsW+rFBtIur+1uHYg/eKLdKs6rHo6vng5h 0NgAbiN2Xd9Mx9yZBVTj81VwZm/d7GRFu52xgafhgtRACcLM4bDve4ErouvhleY4 YClGXcZyBhprYMXxKr0Rv/3lSM+iP2bDis/B1lVotVABQRrino5NbM4CCBr7Hrrt Zl/Ay1tphQ9sBuqrSumvMJ7IA9FMnt/BjAxuN+7VIQjDSGguYde1oWuinYPXTo// 4BoKRu46/5WOuJzi13aJXAI3pa2V+DVEVPOvmHoodTc8UV2mOWlAsVaUjw7I+ipy e0R2JvDfL4O2F8XDVUsxjwxwkKlm+70CyM4PtNw1kBrkgDONQ6G9HQkIOe/ie4oh dQR2btvxv273gsrRdz0JSfYDvd8r3uWjPffNsSzxlQk9q9yORgd2KytBkUZvj5bS WHPC8R9KAjiAnju9cv+yX9n507VsyEAX594ISLK179bADdzrpZActJRIkvNvYSBh 8CXU4ZkQRPFOrGk5AF0MhGuiWHazOOshX7clxTTl9Tlf1iOEODz3nosJbpEre9aJ pKqcrOVNBSs= =6lBB -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com ^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: Re: [Alsa-user] Upgrade problems -addendum 2003-01-24 15:45 ` Takashi Iwai 2003-01-24 16:40 ` Tais M. Hansen @ 2003-01-24 16:42 ` Tais M. Hansen 1 sibling, 0 replies; 29+ messages in thread From: Tais M. Hansen @ 2003-01-24 16:42 UTC (permalink / raw) To: Takashi Iwai; +Cc: alsa-devel [-- Attachment #1: Type: text/plain, Size: 1048 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 24 January 2003 16:45, Takashi Iwai wrote: > have fun :) And here're the attached files...! ;) - -- Regards, Tais M. Hansen OSD -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iQIVAwUBPjFs9oIvLOJqwYc4AQJaSg/+P9KCNRSqPMYVpi5DI7BafqTiYXi6zGtY QMER59LquEljx1zLg+5WyURVEZfkJK37AM8HPpfcn3WsotfITKId8zdtbCFHPBPf G3bTvG9tD5WdIDaUmp/i6/tIABVZwhETBdpvrHhKv2L/mUv70QhpY55oDkRdDLVQ pxDhE3ILbTgMTPgYLpRSLXaTuHzO6xersRu0IYrxZY2psauFf/SIVBl7KuIpMFKm c97KGl0SLMtKv20QaFcu0lmiZzmB4RRd7acIGYUI3dgduixJdAlpD+evPkwIJcAT YEJDI7+Mj0Q6EmJHsvj43U8IBXIml9qWoZB6vR+TtugAndL/6fWwz325TxqKOg8Z KTaU3ac+vDIr9B/paHaBOlCPSm8ZIpQlPb5geDvQW8GTDogzfLwvbXCrZHe2i+mv +E/KD3XK0rPT8y68iOzpL2mirsfFCKvc+oTwKQgqdeR1juyahMQsk9tMjzVKitox 5OBjZW3RoCGGvp1Df1pmKk4Y3Igahv4L9gv6IqtlLpwSCikyR8uss+hijaXDPCzn nOYQFWa/Ml6uJiYBI0cGzR5CEANXci0CWYOHc69iYYG2K7YbmZXasmQ+aTRubcJq TzubdkRE+Wo+Lt2Ie8b/0q1hW4b8VB8TMF1jZvIYghjC4udGXnEsuej1yajvb0LD fuhp9XS5BPs= =Xekl -----END PGP SIGNATURE----- [-- Attachment #2: alsa-ogg123-test8-idx0.txt.gz --] [-- Type: application/x-gzip, Size: 3128 bytes --] [-- Attachment #3: alsa-ogg123-test8-idx1.txt.gz --] [-- Type: application/x-gzip, Size: 3132 bytes --] [-- Attachment #4: alsa-ogg123-test8-idx2.txt.gz --] [-- Type: application/x-gzip, Size: 201 bytes --] [-- Attachment #5: alsa-ogg123-test8-idx3.txt.gz --] [-- Type: application/x-gzip, Size: 162 bytes --] ^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2003-01-28 23:19 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200301221234.33054.tais.hansen@osd.dk>
[not found] ` <200301221543.52285.tais.hansen@osd.dk>
[not found] ` <s5hznpt1bn2.wl@alsa2.suse.de>
[not found] ` <200301221647.05780.tais.hansen@osd.dk>
2003-01-22 16:23 ` [Alsa-user] Upgrade problems -addendum Takashi Iwai
2003-01-23 0:35 ` Tais M. Hansen
2003-01-23 10:03 ` Takashi Iwai
2003-01-23 11:15 ` Tais M. Hansen
2003-01-23 11:46 ` Takashi Iwai
2003-01-23 12:36 ` Tais M. Hansen
2003-01-23 15:08 ` Takashi Iwai
2003-01-23 17:50 ` Tais M. Hansen
2003-01-23 18:07 ` Takashi Iwai
2003-01-23 18:43 ` Tais M. Hansen
2003-01-24 9:12 ` Takashi Iwai
2003-01-24 12:41 ` Tais M. Hansen
2003-01-24 13:30 ` Takashi Iwai
2003-01-24 14:12 ` Tais M. Hansen
2003-01-24 15:45 ` Takashi Iwai
2003-01-24 16:40 ` Tais M. Hansen
2003-01-24 17:08 ` Takashi Iwai
2003-01-24 21:24 ` Tais M. Hansen
2003-01-27 10:42 ` Takashi Iwai
2003-01-27 14:42 ` Tais M. Hansen
2003-01-27 15:15 ` Takashi Iwai
2003-01-27 17:01 ` Tais M. Hansen
2003-01-27 17:27 ` Takashi Iwai
2003-01-28 0:43 ` VIA823x testing Tais M. Hansen
2003-01-28 9:31 ` Takashi Iwai
2003-01-28 13:25 ` Tais M. Hansen
2003-01-28 16:21 ` Takashi Iwai
2003-01-28 23:19 ` Tais M. Hansen
2003-01-24 16:42 ` Re: [Alsa-user] Upgrade problems -addendum Tais M. Hansen
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.