All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wss_lib: snd_wss_calibrate_mute improvement
@ 2008-08-17 20:38 Krzysztof Helt
  2008-08-18  8:50 ` Rene Herman
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Helt @ 2008-08-17 20:38 UTC (permalink / raw)
  To: Alsa-devel; +Cc: Rene Herman

From: Krzysztof Helt <krzysztof.h1@wp.pl>

Mute sound by setting mute bit without
setting volume to 0. It makes both source code
and binary shorter.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
---


diff -urp alsa-ref/sound/isa/wss/wss_lib.c alsa-driver/sound/isa/wss/wss_lib.c
--- alsa-ref/sound/isa/wss/wss_lib.c	2008-08-14 00:05:30.000000000 +0200
+++ alsa-driver/sound/isa/wss/wss_lib.c	2008-08-17 22:33:24.620085406 +0200
@@ -574,7 +574,7 @@ static void snd_wss_calibrate_mute(struc
 {
 	unsigned long flags;
 
-	mute = mute ? 1 : 0;
+	mute = mute ? 0x80 : 0;
 	spin_lock_irqsave(&chip->reg_lock, flags);
 	if (chip->calibrate_mute == mute) {
 		spin_unlock_irqrestore(&chip->reg_lock, flags);
@@ -589,34 +589,34 @@ static void snd_wss_calibrate_mute(struc
 			     chip->image[CS4231_LOOPBACK]);
 	}
 	snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT,
-		     mute ? 0x80 : chip->image[CS4231_AUX1_LEFT_INPUT]);
+		     mute | chip->image[CS4231_AUX1_LEFT_INPUT]);
 	snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT,
-		     mute ? 0x80 : chip->image[CS4231_AUX1_RIGHT_INPUT]);
+		     mute | chip->image[CS4231_AUX1_RIGHT_INPUT]);
 	snd_wss_dout(chip, CS4231_AUX2_LEFT_INPUT,
-		     mute ? 0x80 : chip->image[CS4231_AUX2_LEFT_INPUT]);
+		     mute | chip->image[CS4231_AUX2_LEFT_INPUT]);
 	snd_wss_dout(chip, CS4231_AUX2_RIGHT_INPUT,
-		     mute ? 0x80 : chip->image[CS4231_AUX2_RIGHT_INPUT]);
+		     mute | chip->image[CS4231_AUX2_RIGHT_INPUT]);
 	snd_wss_dout(chip, CS4231_LEFT_OUTPUT,
-		     mute ? 0x80 : chip->image[CS4231_LEFT_OUTPUT]);
+		     mute | chip->image[CS4231_LEFT_OUTPUT]);
 	snd_wss_dout(chip, CS4231_RIGHT_OUTPUT,
-		     mute ? 0x80 : chip->image[CS4231_RIGHT_OUTPUT]);
+		     mute | chip->image[CS4231_RIGHT_OUTPUT]);
 	if (!(chip->hardware & WSS_HW_AD1848_MASK)) {
 		snd_wss_dout(chip, CS4231_LEFT_LINE_IN,
-			     mute ? 0x80 : chip->image[CS4231_LEFT_LINE_IN]);
+			     mute | chip->image[CS4231_LEFT_LINE_IN]);
 		snd_wss_dout(chip, CS4231_RIGHT_LINE_IN,
-			     mute ? 0x80 : chip->image[CS4231_RIGHT_LINE_IN]);
+			     mute | chip->image[CS4231_RIGHT_LINE_IN]);
 		snd_wss_dout(chip, CS4231_MONO_CTRL,
 			     mute ? 0xc0 : chip->image[CS4231_MONO_CTRL]);
 	}
 	if (chip->hardware == WSS_HW_INTERWAVE) {
 		snd_wss_dout(chip, CS4231_LEFT_MIC_INPUT,
-			     mute ? 0x80 : chip->image[CS4231_LEFT_MIC_INPUT]);
+			     mute | chip->image[CS4231_LEFT_MIC_INPUT]);
 		snd_wss_dout(chip, CS4231_RIGHT_MIC_INPUT,
-			     mute ? 0x80 : chip->image[CS4231_RIGHT_MIC_INPUT]);
+			     mute | chip->image[CS4231_RIGHT_MIC_INPUT]);
 		snd_wss_dout(chip, CS4231_LINE_LEFT_OUTPUT,
-			mute ? 0x80 : chip->image[CS4231_LINE_LEFT_OUTPUT]);
+			     mute | chip->image[CS4231_LINE_LEFT_OUTPUT]);
 		snd_wss_dout(chip, CS4231_LINE_RIGHT_OUTPUT,
-			mute ? 0x80 : chip->image[CS4231_LINE_RIGHT_OUTPUT]);
+			     mute | chip->image[CS4231_LINE_RIGHT_OUTPUT]);
 	}
 	chip->calibrate_mute = mute;
 	spin_unlock_irqrestore(&chip->reg_lock, flags);

---------------------------------------------------------------------- 
Igrzyska na Dzikim Zachodzie!
Sprawdz >> http://link.interia.pl/f1edc 
	

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wss_lib: snd_wss_calibrate_mute improvement
  2008-08-17 20:38 [PATCH] wss_lib: snd_wss_calibrate_mute improvement Krzysztof Helt
@ 2008-08-18  8:50 ` Rene Herman
  2008-08-18 10:16   ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Rene Herman @ 2008-08-18  8:50 UTC (permalink / raw)
  To: Krzysztof Helt; +Cc: Alsa-devel

On 17-08-08 22:38, Krzysztof Helt wrote:

> From: Krzysztof Helt <krzysztof.h1@wp.pl>
> 
> Mute sound by setting mute bit without
> setting volume to 0. It makes both source code
> and binary shorter.
> 
> Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>

Grmmbbled-over-by: Rene Herman <rene.herman@gmail.com>

This should be safe and the current function indeed generates crap code 
but in the sense of always expecting the worst broken hardware variants 
to be out there I must say I'd rather have seen that GCC were beter. But 
yes, sure.


Rene.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wss_lib: snd_wss_calibrate_mute improvement
  2008-08-18  8:50 ` Rene Herman
@ 2008-08-18 10:16   ` Takashi Iwai
  2008-08-18 11:04     ` Rene Herman
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2008-08-18 10:16 UTC (permalink / raw)
  To: Rene Herman; +Cc: Alsa-devel, Krzysztof Helt

At Mon, 18 Aug 2008 10:50:15 +0200,
Rene Herman wrote:
> 
> On 17-08-08 22:38, Krzysztof Helt wrote:
> 
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > 
> > Mute sound by setting mute bit without
> > setting volume to 0. It makes both source code
> > and binary shorter.
> > 
> > Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
> 
> Grmmbbled-over-by: Rene Herman <rene.herman@gmail.com>
> 
> This should be safe and the current function indeed generates crap code 
> but in the sense of always expecting the worst broken hardware variants 
> to be out there I must say I'd rather have seen that GCC were beter. But 
> yes, sure.

Yeah, the slightest concern is the intention of using 0x80 there.
If this patch was already tested on some real hardwares (and I guess
it should work), I'm willing to apply it.  Krzystof, was this tested
on your machines?


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wss_lib: snd_wss_calibrate_mute improvement
  2008-08-18 10:16   ` Takashi Iwai
@ 2008-08-18 11:04     ` Rene Herman
  0 siblings, 0 replies; 6+ messages in thread
From: Rene Herman @ 2008-08-18 11:04 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Alsa-devel, Krzysztof Helt

On 18-08-08 12:16, Takashi Iwai wrote:

> At Mon, 18 Aug 2008 10:50:15 +0200,
> Rene Herman wrote:
>> On 17-08-08 22:38, Krzysztof Helt wrote:
>>
>>> From: Krzysztof Helt <krzysztof.h1@wp.pl>
>>>
>>> Mute sound by setting mute bit without
>>> setting volume to 0. It makes both source code
>>> and binary shorter.
>>>
>>> Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
>> Grmmbbled-over-by: Rene Herman <rene.herman@gmail.com>
>>
>> This should be safe and the current function indeed generates crap code 
>> but in the sense of always expecting the worst broken hardware variants 
>> to be out there I must say I'd rather have seen that GCC were beter. But 
>> yes, sure.
> 
> Yeah, the slightest concern is the intention of using 0x80 there.

Yes, shared that same concern but it's very likely not significant. The 
original thought may just have been that you have to write _something_ 
so you might as well simply write 0x80 instead or or-ing in a bit and 
with volume at 0, your're even "doubly safe"...

> If this patch was already tested on some real hardwares (and I guess
> it should work), I'm willing to apply it.  Krzystof, was this tested
> on your machines?

Not (yet) on any of mine at least but actually having something where it 
does not work would be surprising. I could sort of imagine something 
being out there that ignores the mute bit but I doubt that either of us 
is actually going to have it even if it is.

Avoiding cargo-cult programming isn't unimportant so let's not be _too_ 
cautious I guess. It does currently make for crap code (GCC could be 
using cmov here it seems but it doesn't) which is an excuse...

Rene.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wss_lib: snd_wss_calibrate_mute improvement
@ 2008-08-18 11:16 krzysztof.h1
  2008-08-18 12:00 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: krzysztof.h1 @ 2008-08-18 11:16 UTC (permalink / raw)
  To: Takashi Iwai, Rene Herman; +Cc: Alsa-devel, Krzysztof Helt

> At Mon, 18 Aug 2008 10:50:15 +0200,
> Rene Herman wrote:
> > 
> > On 17-08-08 22:38, Krzysztof Helt wrote:
> > 
> > > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > > 
> > > Mute sound by setting mute bit without
> > > setting volume to 0. It makes both source code
> > > and binary shorter.
> > > 
> > > Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
> > 
> > Grmmbbled-over-by: Rene Herman <rene.herman@gmail.com>
> > 
> > This should be safe and the current function indeed generates crap code
> 
> > but in the sense of always expecting the worst broken hardware variants
> 
> > to be out there I must say I'd rather have seen that GCC were beter. But
> 
> > yes, sure.
> 
> Yeah, the slightest concern is the intention of using 0x80 there.
> If this patch was already tested on some real hardwares (and I guess
> it should work), I'm willing to apply it.  Krzystof, was this tested
> on your machines?
> 

I have tested it only on cs4236 (inside laptop) and opti931 I have in the old PC at the moment. If you want I can retest on more hardware.

The second check I noticed that for some registers the volume is defined as gain (so 0 is the least audible) and for some (CS4231_MONO_CTRL, CS4231_LEFT/RIGHT_OUTPUT) is defined as attentuation (the 0 is the most audible). In two cases, the old code set volume to the loudest and mute it with mute bit, probably the opposite what was intended.

It is not a crucial patch. You may drop it.

Regards,
Krzysztof

----------------------------------------------------------------------
Wygraj laptopa lub iPoda! Wez udzial w igrzyskach!
Kliknij >>> http://link.interia.pl/f1eda 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] wss_lib: snd_wss_calibrate_mute improvement
  2008-08-18 11:16 krzysztof.h1
@ 2008-08-18 12:00 ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2008-08-18 12:00 UTC (permalink / raw)
  To: krzysztof.h1; +Cc: Rene Herman, Alsa-devel

At 18 Aug 2008 13:16:56 +0200,
krzysztof.h1@poczta.fm wrote:
> 
> > At Mon, 18 Aug 2008 10:50:15 +0200,
> > Rene Herman wrote:
> > > 
> > > On 17-08-08 22:38, Krzysztof Helt wrote:
> > > 
> > > > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > > > 
> > > > Mute sound by setting mute bit without
> > > > setting volume to 0. It makes both source code
> > > > and binary shorter.
> > > > 
> > > > Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
> > > 
> > > Grmmbbled-over-by: Rene Herman <rene.herman@gmail.com>
> > > 
> > > This should be safe and the current function indeed generates crap code
> > 
> > > but in the sense of always expecting the worst broken hardware variants
> > 
> > > to be out there I must say I'd rather have seen that GCC were beter. But
> > 
> > > yes, sure.
> > 
> > Yeah, the slightest concern is the intention of using 0x80 there.
> > If this patch was already tested on some real hardwares (and I guess
> > it should work), I'm willing to apply it.  Krzystof, was this tested
> > on your machines?
> > 
> 
> I have tested it only on cs4236 (inside laptop) and opti931 I have in the old PC at the moment. If you want I can retest on more hardware.
> 
> The second check I noticed that for some registers the volume is defined as gain (so 0 is the least audible) and for some (CS4231_MONO_CTRL, CS4231_LEFT/RIGHT_OUTPUT) is defined as attentuation (the 0 is the most audible). In two cases, the old code set volume to the loudest and mute it with mute bit, probably the opposite what was intended.
> 
> It is not a crucial patch. You may drop it.

Oh, no, your patch is actually a correct fix.

The thing is that I wanted to be sure that this doesn't introduce an
obvious breakage.


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-18 12:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-17 20:38 [PATCH] wss_lib: snd_wss_calibrate_mute improvement Krzysztof Helt
2008-08-18  8:50 ` Rene Herman
2008-08-18 10:16   ` Takashi Iwai
2008-08-18 11:04     ` Rene Herman
  -- strict thread matches above, loose matches on Subject: below --
2008-08-18 11:16 krzysztof.h1
2008-08-18 12:00 ` Takashi Iwai

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.