From alsa-devel-owner@alsa.jcu.cz  Fri Jul 17 22:38:04 1998
Received: from entry.jcu.cz (perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.8.8/8.8.8) with SMTP id WAA09311
	for <alsa-devel@jcu.cz>; Fri, 17 Jul 1998 22:38:01 +0200
Date: Fri, 17 Jul 1998 22:38:01 +0200 (MET DST)
From: Jaroslav Kysela <perex@jcu.cz>
To: alsa-devel@jcu.cz
Subject: Re: Bug in snd_cs4231_mute ?
In-Reply-To: <35AF11B4.183E69F9@ats.nld.alcatel.nl>
Message-ID: <Pine.LNX.3.96.980717223012.941D-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

On Fri, 17 Jul 1998, joris jansen wrote:

> Hi Jaroslav,
> 
> I'm still busy with the addaptions for the ad1845 chip in the cs4231
> code. Too bad OI don't have that much time for it, therefore I'm not
> going that fast on this ...
> Checking the code for addaptions to be made I ran into the 
> snd_cs4231_mute function and I thinh I found a bug:
> For muting mask is sent to the regl and/or regr registers instead of
> the mute value in channel->hw.private_value. Below I fixed it.
> (Look for lines starting with ##) in the code beneath.
> 

> Furthermore I have a question, why do you use the mono input channel
> (meant for pc-speaker input if I'm right) as line input ?

GUS MAX uses mono input for MIC and I made this as default in cs4231.c
code. Some cards have connected input sources differently, so you should
change sources in main soundcard module (look to InterWave module how
can be MIC changed to stereo, if hardware supports it).

> As far as I know do both cs4231 and ad1845 have stereo mic input. Though

It depends on soundcard.

> static void snd_cs4231_mute( snd_kmixer_t *mixer, snd_kmixer_channel_t
> *channel, unsigned int mute )
> {
>   unsigned long flags;
>   unsigned char regl, regr, mask;
>   cs4231_t *codec;
> 
>   regl = (unsigned char)(channel -> hw.private_value >> 24);
>   regr = (unsigned char)(channel -> hw.private_value >> 16);
>   mask = (unsigned char)(channel -> hw.private_value);
>   if ( channel -> hw.private_value & 0x1000 ) mute ^= SND_MIX_MUTE;
> #if 0
>   snd_printk( "mute: regl = 0x%x(0x%x), regr = 0x%x(0x%x), mask = 0x%x,
> mute = 0x%x\n", regl, snd_cs4231_in( mixer -> private_data, regl ),
> regr, snd_cs4231_in( mixer -> private_data, regr ), mask, mute );
> #endif
>   codec = (cs4231_t *)mixer -> private_data;
>   snd_spin_lock( codec, reg, &flags );
> ##snd_cs4231_outm( codec, regl, ~mask, (mute & SND_MIX_MUTE_LEFT) ? mask
> : 0 ); 
>   snd_cs4231_outm( codec, regl, ~mask, (mute & SND_MIX_MUTE_LEFT) ?
>                                         channel->hw.private_value & 0xFF
> : 0 ); 
>   if ( channel -> hw.stereo )
> ##  snd_cs4231_outm( codec, regr, ~mask, (mute & SND_MIX_MUTE_RIGHT) ?
> mask : 0 );
>     snd_cs4231_outm( codec, regr, ~mask, (mute & SND_MIX_MUTE_RIGHT) ?
>                                         channel->hw.private_value & 0xFF
> : 0 ); 

Wrong code. The outm word means 'out with mask', so if I have mask (mute
bit) 0x80, I need leave other bits --> ~0x80 = 0x7f and set (if I want
turn mute on) mask 0x80. My code is tested and works well.

						Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


