[patch] 2.4 ac97_codec micboost control

Shane Wegner (shane@cm.nu)
Mon, 12 May 2003 15:56:54 -0700


Hi,

Attached is a small patch to enable the built-in mic boost
of the ac97_codec. On my SB-live, it needs this to get
decent mic volume and I imagine this is the case for some
other cards as well. It maps the micboost to
SOUND_MIXER_AGC which, well, isn't used for anything else
at present that I know of.

Applies to 2.4.21-rc2.

S

diff -urN linux.orig/drivers/sound/ac97_codec.c linux/drivers/sound/ac97_codec.c
--- linux.orig/drivers/sound/ac97_codec.c 2003-05-12 15:50:07.000000000 -0700
+++ linux/drivers/sound/ac97_codec.c 2003-05-12 15:50:52.000000000 -0700
@@ -400,6 +400,18 @@
if (left >= mh->scale)
left = mh->scale-1;
val |= left & 0x000e;
+ } else if (oss_channel == SOUND_MIXER_MIC) {
+ val = codec->codec_read(codec , mh->offset) & ~0x801f;
+ if (!left)
+ val |= AC97_MUTE;
+ else {
+ left = ((100 - left) * mh->scale) / 100;
+ if (left >= mh->scale)
+ left = mh->scale-1;
+ val |= left;
+ /* the low bit is optional in the tone sliders and masking
+ it lets us avoid the 0xf 'bypass'.. */
+ }
} else if(left == 0) {
val = AC97_MUTE;
} else if (oss_channel == SOUND_MIXER_SPEAKER) {
@@ -418,14 +430,6 @@
if (left >= mh->scale)
left = mh->scale-1;
val = left;
- } else if (oss_channel == SOUND_MIXER_MIC) {
- val = codec->codec_read(codec , mh->offset) & ~0x801f;
- left = ((100 - left) * mh->scale) / 100;
- if (left >= mh->scale)
- left = mh->scale-1;
- val |= left;
- /* the low bit is optional in the tone sliders and masking
- it lets us avoid the 0xf 'bypass'.. */
}
#ifdef DEBUG
printk(" 0x%04x", val);
@@ -574,6 +578,15 @@
codec->recmask_io(codec, 0, val);

return 0;
+ case _IOC_NR(SOUND_MIXER_AGC): {
+ u16 r = codec->codec_read(codec, AC97_MIC_VOL);
+ if (val)
+ r |= AC97_MICBOOST;
+ else
+ r &= ~AC97_MICBOOST;
+ codec->codec_write(codec, AC97_MIC_VOL, r);
+ return 0;
+ }
default: /* write a specific mixer */
i = _IOC_NR(cmd);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/