summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2009-05-12 09:32:29 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2009-05-12 09:32:29 +0000
commit836f5e1646b9c7e966a92a64d56b444c2a2b4238 (patch)
treed84aef9ac15d0a0c475196fd5ebe7b8cb3c968ac /sys/dev
parent800492dc66a1f5baa2b7d697c43660e404dc6804 (diff)
- try to identify a "main input mixer"
- don't unmute input from a built-in mic on the main input mixer intended to stop possible feedback loops between buit-in speakers and built-in mics. built-in mics also tend to capture machine noise, especially fans. actual recording should not be affected.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/azalia.c53
-rw-r--r--sys/dev/pci/azalia.h3
-rw-r--r--sys/dev/pci/azalia_codec.c5
3 files changed, 58 insertions, 3 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c
index a31bc21133a..ff7f296f1ad 100644
--- a/sys/dev/pci/azalia.c
+++ b/sys/dev/pci/azalia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia.c,v 1.130 2009/05/01 04:00:40 jakemsr Exp $ */
+/* $OpenBSD: azalia.c,v 1.131 2009/05/12 09:32:28 jakemsr Exp $ */
/* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */
/*-
@@ -213,6 +213,7 @@ int azalia_codec_init_volgroups(codec_t *);
int azalia_codec_sort_pins(codec_t *);
int azalia_codec_select_micadc(codec_t *);
int azalia_codec_select_spkrdac(codec_t *);
+int azalia_codec_find_inputmixer(codec_t *);
int azalia_widget_init(widget_t *, const codec_t *, int);
int azalia_widget_label_widgets(codec_t *);
@@ -1356,6 +1357,10 @@ azalia_codec_init(codec_t *this)
if (err)
return err;
+ err = azalia_codec_find_inputmixer(this);
+ if (err)
+ return err;
+
err = azalia_codec_select_spkrdac(this);
if (err)
return err;
@@ -1390,6 +1395,52 @@ azalia_codec_init(codec_t *this)
}
int
+azalia_codec_find_inputmixer(codec_t *this)
+{
+ widget_t *w;
+ int i, j;
+
+ this->input_mixer = -1;
+
+ FOR_EACH_WIDGET(this, i) {
+ w = &this->w[i];
+ if (w->type != COP_AWTYPE_AUDIO_MIXER)
+ continue;
+
+ /* can input from a pin */
+ for (j = 0; j < this->nipins; j++) {
+ if (azalia_codec_fnode(this, this->ipins[j].nid,
+ w->nid, 0) != -1)
+ break;
+ }
+ if (j == this->nipins)
+ continue;
+
+ /* can output to a pin */
+ for (j = 0; j < this->nopins; j++) {
+ if (azalia_codec_fnode(this, w->nid,
+ this->opins[j].nid, 0) != -1)
+ break;
+ }
+ if (j == this->nopins)
+ continue;
+
+ /* can output to an ADC */
+ for (j = 0; j < this->na_adcs; j++) {
+ if (azalia_codec_fnode(this, w->nid,
+ this->a_adcs[j], 0) != -1)
+ break;
+ }
+ if (j == this->na_adcs)
+ continue;
+
+ this->input_mixer = i;
+ break;
+ }
+ return(0);
+}
+
+int
azalia_codec_select_micadc(codec_t *this)
{
widget_t *w;
diff --git a/sys/dev/pci/azalia.h b/sys/dev/pci/azalia.h
index 42780cf1806..52d3fafab3b 100644
--- a/sys/dev/pci/azalia.h
+++ b/sys/dev/pci/azalia.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia.h,v 1.44 2009/05/01 02:55:16 jakemsr Exp $ */
+/* $OpenBSD: azalia.h,v 1.45 2009/05/12 09:32:28 jakemsr Exp $ */
/* $NetBSD: azalia.h,v 1.6 2006/01/16 14:15:26 kent Exp $ */
/*-
@@ -668,6 +668,7 @@ typedef struct codec_t {
nid_t mic_adc;
nid_t speaker; /* fixed (internal) speaker */
nid_t spkr_dac;
+ nid_t input_mixer;
int spkr_muters;
int spkr_mute_method;
diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c
index 81035c6e932..7480ac9cd44 100644
--- a/sys/dev/pci/azalia_codec.c
+++ b/sys/dev/pci/azalia_codec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia_codec.c,v 1.122 2009/05/01 03:45:17 jakemsr Exp $ */
+/* $OpenBSD: azalia_codec.c,v 1.123 2009/05/12 09:32:28 jakemsr Exp $ */
/* $NetBSD: azalia_codec.c,v 1.8 2006/05/10 11:17:27 kent Exp $ */
/*-
@@ -1278,6 +1278,9 @@ azalia_generic_mixer_default(codec_t *this)
for (j = 0; j < w->nconnections; j++) {
if (!azalia_widget_enabled(this, w->connections[j]))
continue;
+ if (w->nid == this->input_mixer &&
+ w->connections[j] == this->mic)
+ continue;
mc.un.mask |= 1 << j;
}
azalia_generic_mixer_set(this, m->nid, m->target, &mc);