lkml.org 
[lkml]   [2002]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Re: auto-muting pcm when not in use
On Sun, Aug 25, 2002 at 12:13:36AM +0200, Frank v Waveren wrote:
> I have an el-cheapo sound card in my desktop machine, which works
> fine for the odd mail notification sound. However, it tends to
> produce quite some white noise and a highpitched tone when not in
> use. [I recall a patch doing this] and if not, would anyone be
> interested in one?

Well, I've made the patch, it's rather kludgy but to do this
properly would require modify quite a lot of the code and possibly
API's (I'd hoped to be easily able to create an extra mixer channel
that was visible to userspace instead of pcm, and whose level would
get written to the pcm mixer channel when the audio device was
opened), but it does work rather nicely for me.

If there's any interest in having it in the main tree (as I said, it's
a kludge, but one that's needed/useful on a lot of machines) I'll put
some kernel option or module paramater if's around it, let me know.

As always, suggestions/fixes/flames welcome.

--
Frank v Waveren Fingerprint: 0EDB 8787
fvw@[var.cx|stack.nl|dse.nl|chello.nl] ICQ#10074100 09B9 6EF5 6425 B855
Public key: hkp://wwwkeys.pgp.net/fvw@var.cx 7179 3036 E136 B85D
diff -urNbB linux/drivers/sound/sb.h linux-fvw/drivers/sound/sb.h
--- linux/drivers/sound/sb.h Sun Sep 1 02:53:53 2002
+++ linux-fvw/drivers/sound/sb.h Sun Sep 1 02:38:24 2002
@@ -114,6 +114,8 @@
int supported_rec_devices, supported_out_devices;
int my_mixerdev;
int sbmixnum;
+ int saved_level_pcm; // for auto-muted pcm
+

/* Audio fields */
unsigned long trg_buf;
diff -urNbB /home/fvw/linux/drivers/sound/sb_audio.c /tmp/linux-fvw/drivers/sound/sb_audio.c
--- linux/drivers/sound/sb_audio.c Sun Sep 1 02:48:08 2002
+++ linux-fvw/drivers/sound/sb_audio.c Sun Sep 1 02:43:23 2002
@@ -60,6 +60,10 @@
return -EBUSY;
}
}
+
+ if (!sb_getmixer(devc, SOUND_MIXER_PCM))
+ sb_setmixer(devc, SOUND_MIXER_PCM, devc->saved_level_pcm);
+
devc->opened = mode;
spin_unlock_irqrestore(&devc->lock, flags);

@@ -122,6 +126,10 @@
sb_setmixer(devc,ALS007_OUTPUT_CTRL2,
sb_getmixer(devc,ALS007_OUTPUT_CTRL2) | 0x06);
}
+
+ devc->saved_level_pcm=sb_getmixer(devc, SOUND_MIXER_PCM);
+ sb_setmixer(devc, SOUND_MIXER_PCM, 0);
+
devc->opened = 0;
}

@@ -1090,4 +1098,10 @@
}
audio_devs[devc->dev]->mixer_dev = devc->my_mixerdev;
audio_devs[devc->dev]->min_fragment = 5;
+
+ sb_setmixer(devc, SOUND_MIXER_PCM, 0);
+ devc->saved_level_pcm=0x0000; /* This should be the *_default_levels value
+ from sb_mixer.c which we can't get at
+ from here */
+
}
\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.041 / U:1.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site