Subject: Re: clcs audio problem
To: None <current-users@netbsd.org>
From: =?ISO-8859-1?Q?St=E9phane?= Witzmann <stephane.witzmann@gmail.com>
List: current-users
Date: 08/04/2006 17:23:13
Henry R. Bent wrote:

> Hello all,
> 
> I have an i386 box running 3.99.18 from mid-April that has been having
> audio problems with the clcs driver.  Until very recently the sound
> quality would remain good for a long time, maybe 10 or 15 days, until it
> slowly started to degrade into ringing digitized mush.  Now it will remain
> good for day or so until it very suddenly changes for the worse.  A reboot
> always fixes things, but I use NetBSD so that I don't have to reboot :-)
>
> My questions are as follows:
> 
> -Does anyone know what is happening and why?  Could this be a hardware
> problem?
> -Should I try updating to the latest -current?  My experiences with it on
> other machines lead me to believe that it is not at all stable right now,
> so I am rather hesitant to do that.

I'm sorry for not reading this post sooner.

This is a driver issue (I've been working on it since last year). I spent
much time comparing clcs(4) with its FreeBSD and Linux counterparts. We
fixed a few bugs in clcs, and this one is the last one standing.

Anyway, I have a fix so that you don't have to reboot. Open xmms, play a
mp3, then keep pressing 'c' (play/pause). After a few seconds (a few dozens
start/stop cycles), the sound will be back to normal. This can also be used
to trigger the bug.

The following kernel patch may also delay the bug. I noticed that the more
we set the dac or adc rate, the more the bug happens. mpg123 seems to try
almost all sample rates before playing, so that patch discards the useless
ones to delay the bug. But again, I'm not sure. We definitely need a real
fix.

--- cs4280.c.bak        2006-04-16 05:47:15.000000000 +0200
+++ cs4280.c    2006-05-07 17:01:53.000000000 +0200
@@ -698,8 +698,11 @@ cs4280_set_params(void *addr, int setmod
        }
 
        /* set sample rate */
-       cs4280_set_dac_rate(sc, play->sample_rate);
-       cs4280_set_adc_rate(sc, rec->sample_rate);
+       if (sc->sc_prun)
+               cs4280_set_dac_rate(sc, play->sample_rate);
+       if (sc->sc_rrun)
+               cs4280_set_adc_rate(sc, rec->sample_rate);
+
        return 0;
 }

> Here is a dmesg excerpt:
> 
> clcs0 at pci2 dev 8 function 0: Cirrus Logic CS4280 CrystalClear Audio
> Interface (rev. 0x01)
> clcs0: Turtle Beach Santa Cruz
> clcs0: interrupting at irq 10
> clcs0: ac97: Crystal CS4297A codec; headphone, 20 bit DAC, 18 bit ADC,
> Crystal Semi 3D
> clcs0: ac97: ext id 200<AMAP>
> clcs0: ac97: using inverted AC97_POWER_EAMP bit
> audio0 at clcs0: full duplex, independent
> midi0 at clcs0: CS4280 MIDI UART

I have the exact same sound card, but the bug also happens with all other
clcs boards.

> Thanks in advance for any help anyone can provide.
> 
> -Henry Bent