diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2009-05-01 02:55:17 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2009-05-01 02:55:17 +0000 |
commit | 6d410f7d6372bae1272a5a228f8ed28bf9d5dce8 (patch) | |
tree | 2c1ad7df540717f7d542c591313a51d138a0d769 /sys | |
parent | 16ddb2df214a31dcae5a99afc5e5c45534c38ffa (diff) |
allow jack sensing to mute the DAC the speaker is connected to by
default, as long is the first output pin is not also connected to
that DAC. cleanup a bit now that there are multiple muting methods.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/azalia.h | 7 | ||||
-rw-r--r-- | sys/dev/pci/azalia_codec.c | 40 |
2 files changed, 36 insertions, 11 deletions
diff --git a/sys/dev/pci/azalia.h b/sys/dev/pci/azalia.h index a3bc08cd13c..42780cf1806 100644 --- a/sys/dev/pci/azalia.h +++ b/sys/dev/pci/azalia.h @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.h,v 1.43 2009/04/24 16:05:06 jakemsr Exp $ */ +/* $OpenBSD: azalia.h,v 1.44 2009/05/01 02:55:16 jakemsr Exp $ */ /* $NetBSD: azalia.h,v 1.6 2006/01/16 14:15:26 kent Exp $ */ /*- @@ -670,6 +670,11 @@ typedef struct codec_t { nid_t spkr_dac; int spkr_muters; + int spkr_mute_method; +#define AZ_SPKR_MUTE_NONE 0 +#define AZ_SPKR_MUTE_SPKR_MUTE 1 +#define AZ_SPKR_MUTE_SPKR_DIR 2 +#define AZ_SPKR_MUTE_DAC_MUTE 3 volgroup_t playvols; volgroup_t recvols; diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c index 16d2cb276f2..83f82560f9c 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.120 2009/04/27 23:49:04 jakemsr Exp $ */ +/* $OpenBSD: azalia_codec.c,v 1.121 2009/05/01 02:55:16 jakemsr Exp $ */ /* $NetBSD: azalia_codec.c,v 1.8 2006/05/10 11:17:27 kent Exp $ */ /*- @@ -445,15 +445,22 @@ azalia_generic_unsol(codec_t *this, int tag) } if (err) break; - if ((this->w[this->speaker].widgetcap & COP_AWCAP_OUTAMP) && - (this->w[this->speaker].outamp_cap & COP_AMPCAP_MUTE)) { + switch(this->spkr_mute_method) { + case AZ_SPKR_MUTE_SPKR_MUTE: mc.un.ord = vol; err = azalia_generic_mixer_set(this, this->speaker, MI_TARGET_OUTAMP, &mc); - } else { + break; + case AZ_SPKR_MUTE_SPKR_DIR: mc.un.ord = vol ? 0 : 1; err = azalia_generic_mixer_set(this, this->speaker, MI_TARGET_PINDIR, &mc); + break; + case AZ_SPKR_MUTE_DAC_MUTE: + mc.un.ord = vol; + err = azalia_generic_mixer_set(this, this->spkr_dac, + MI_TARGET_OUTAMP, &mc); + break; } break; @@ -893,12 +900,25 @@ azalia_generic_mixer_init(codec_t *this) } /* spkr mute by jack sense */ - w = &this->w[this->speaker]; - if (this->nsense_pins > 0 && this->speaker != -1 && - (((w->widgetcap & COP_AWCAP_OUTAMP) && - (w->outamp_cap & COP_AMPCAP_MUTE)) || - ((w->d.pin.cap & COP_PINCAP_OUTPUT) && - (w->d.pin.cap & COP_PINCAP_INPUT)))) { + this->spkr_mute_method = AZ_SPKR_MUTE_NONE; + if (this->speaker != -1 && this->spkr_dac != -1 && this->nsense_pins > 0) { + w = &this->w[this->speaker]; + if ((w->widgetcap & COP_AWCAP_OUTAMP) && + (w->outamp_cap & COP_AMPCAP_MUTE)) + this->spkr_mute_method = AZ_SPKR_MUTE_SPKR_MUTE; + else if ((w->d.pin.cap & COP_PINCAP_OUTPUT) && + (w->d.pin.cap & COP_PINCAP_INPUT)) + this->spkr_mute_method = AZ_SPKR_MUTE_SPKR_DIR; + else { + w = &this->w[this->spkr_dac]; + if (w->nid != this->dacs.groups[0].conv[0] && + (w->widgetcap & COP_AWCAP_OUTAMP) && + (w->outamp_cap & COP_AMPCAP_MUTE)) + this->spkr_mute_method = AZ_SPKR_MUTE_DAC_MUTE; + } + } + if (this->spkr_mute_method != AZ_SPKR_MUTE_NONE) { + w = &this->w[this->speaker]; MIXER_REG_PROLOG; m->nid = w->nid; snprintf(d->label.name, sizeof(d->label.name), |