[ltp] Re: How to eliminate the clicks from CS423x

Thomas Hood linux-thinkpad@www.bm-soft.com
Fri, 26 Nov 1999 07:14:25 -0500


I recently communicated with one of the ALSA developers about
the click-causing bit of code that I mentioned before and
he informed me that the code had been modified. I checked the
most recent sources out of CVS and inserted the new modified
fragment of snd_cs4231_close() in place of the fragment
that I had found to be the culprit (shown below).  I
recompiled this and found that the new code does not
produce the clicks!   Great!!

My plan is to use this slightly patched version of release
0.4.1e until the next official release of the ALSA drivers.

--
Thomas Hood


---- previous message ----

There was some discussion recently in the linux-tp600 list
about the problem of the "click" that follows each sound
effect.  One solution proposed was to give the "-as 100000"
option to esd so that it would keep the sound device open
for a long time (100000 seconds) after playing something.
This solution has some drawbacks.  The first is that so
long as the sound device is open, suspend is inhibited.
The second is that KDE users are using kaudioserver,
not esd, and kaudioserver does not have anything like
an "-as" option.

The proper solution is to eliminate the click by fixing
the audio driver.  I have managed to do this to the ALSA
driver for the CS4237B in my ThinkPad 600.  No more click.

The fix is to remove a section of code from the function
snd_cs4231_close() in the file 
.../alsa-driver-0.4.1e/lowlevel/isa/cs4231.c .
I show here the section of code in question, removed by
slapping "#if 0 ... #endif" around it:

-----------------------------------------------------
#if 0
        /* now disable record & playback */
        snd_cs4231_mce_up(codec);
        spin_lock_irqsave(&codec->reg_lock, flags);
        codec->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE |
CS4231_PLAYBACK_PIO |
                             CS4231_RECORD_ENABLE | CS4231_RECORD_PIO);
        snd_cs4231_out(codec, CS4231_IFACE_CTRL,
codec->image[CS4231_IFACE_CTRL]);
        spin_unlock_irqrestore(&codec->reg_lock, flags);
        snd_cs4231_mce_down(codec);
#endif                                                                          
------------------------------------------------------

CAVEAT: I don't really know what all the implications are
of removing this bit of code.  It's a total hack.  Nevertheless
my intuition tells me that not "disabling record and playback"
when the device file is closed is no big deal.  Record and
playback will just be enabled again when the device is opened,
the next time it is needed.

It seems to work, and the clicks are gone.

Thomas Hood
jdthood@mail.com
----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html