diff options
author | Deanna Phillips <deanna@cvs.openbsd.org> | 2007-07-23 02:03:43 +0000 |
---|---|---|
committer | Deanna Phillips <deanna@cvs.openbsd.org> | 2007-07-23 02:03:43 +0000 |
commit | bcc609107f724e0c79ac8f84ea1045004e235ffa (patch) | |
tree | 1d1cd35ae029559e26778d376ab017fd7d2a55a9 /sys/dev | |
parent | b4375cec7e9617f93861387f019e62e5ebaf3c00 (diff) |
We will never make a mixer item out of the pin control operation, so
move it out of azalia_generic_mixer_set into its own function,
azalia_generic_mixer_pinctrl. From kent@netbsd.
In azalia_stac9200_mixer_init, let the unsolicited event handler make
the initial headphone vs speaker choice. Removes some duplicate code.
These changes only affect STAC9200. Tested by krw@ on a Latitude
D620.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/azalia.h | 9 | ||||
-rw-r--r-- | sys/dev/pci/azalia_codec.c | 93 |
2 files changed, 27 insertions, 75 deletions
diff --git a/sys/dev/pci/azalia.h b/sys/dev/pci/azalia.h index edc6d8f3a8f..8ef16858305 100644 --- a/sys/dev/pci/azalia.h +++ b/sys/dev/pci/azalia.h @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.h,v 1.10 2007/05/02 17:01:22 deanna Exp $ */ +/* $OpenBSD: azalia.h,v 1.11 2007/07/23 02:03:42 deanna Exp $ */ /* $NetBSD: azalia.h,v 1.6 2006/01/16 14:15:26 kent Exp $ */ /*- @@ -507,10 +507,9 @@ typedef struct { #define MI_TARGET_CONNLIST 0x101 #define MI_TARGET_PINDIR 0x102 /* for bidirectional pin */ #define MI_TARGET_PINBOOST 0x103 /* for headphone pin */ -#define MI_TARGET_PINCTRL 0x104 /* for enabling/disabling pins */ -#define MI_TARGET_DAC 0x105 -#define MI_TARGET_ADC 0x106 -#define MI_TARGET_VOLUME 0x107 +#define MI_TARGET_DAC 0x104 +#define MI_TARGET_ADC 0x105 +#define MI_TARGET_VOLUME 0x106 } mixer_item_t; #define VALID_WIDGET_NID(nid, codec) (nid == (codec)->audiofunc || \ diff --git a/sys/dev/pci/azalia_codec.c b/sys/dev/pci/azalia_codec.c index 67007d0e8e4..c3306d450f9 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.22 2007/07/07 16:33:38 deanna Exp $ */ +/* $OpenBSD: azalia_codec.c,v 1.23 2007/07/23 02:03:42 deanna Exp $ */ /* $NetBSD: azalia_codec.c,v 1.8 2006/05/10 11:17:27 kent Exp $ */ /*- @@ -77,6 +77,7 @@ int azalia_generic_mixer_delete(codec_t *); int azalia_generic_mixer_ensure_capacity(codec_t *, size_t); int azalia_generic_mixer_get(const codec_t *, nid_t, int, mixer_ctrl_t *); int azalia_generic_mixer_set(codec_t *, nid_t, int, const mixer_ctrl_t *); +int azalia_generic_mixer_pinctrl(codec_t *, nid_t, uint32_t); u_char azalia_generic_mixer_from_device_value (const codec_t *, nid_t, int, uint32_t ); uint32_t azalia_generic_mixer_to_device_value @@ -1221,28 +1222,6 @@ azalia_generic_mixer_set(codec_t *this, nid_t nid, int target, const mixer_ctrl_ return err; } - /* - * pin control: enable/disable. for bidirectional pins, set - * direction with MI_TARGET_PINDIR after enabling. - */ - - else if (target == MI_TARGET_PINCTRL) { - if (mc->un.ord >= 2) - return EINVAL; - err = this->comresp(this, nid, - CORB_GET_PIN_WIDGET_CONTROL, 0, &result); - if (err) - return err; - if (mc->un.ord == 0) /* disable */ - result &= ~(CORB_PWC_OUTPUT | CORB_PWC_INPUT); - else - result |= CORB_PWC_OUTPUT | CORB_PWC_INPUT; - err = this->comresp(this, nid, - CORB_SET_PIN_WIDGET_CONTROL, result, &result); - if (err) - return err; - } - /* pin headphone-boost */ else if (target == MI_TARGET_PINBOOST) { if (mc->un.ord >= 2) @@ -1305,6 +1284,21 @@ azalia_generic_mixer_set(codec_t *this, nid_t nid, int target, const mixer_ctrl_ return 0; } +int +azalia_generic_mixer_pinctrl(codec_t *this, nid_t nid, uint32_t value) +{ + int err; + uint32_t result; + + err = this->comresp(this, nid, CORB_GET_PIN_WIDGET_CONTROL, 0, &result); + if (err) + return err; + result &= ~(CORB_PWC_OUTPUT | CORB_PWC_INPUT); + result |= value & (CORB_PWC_OUTPUT | CORB_PWC_INPUT); + return this->comresp(this, nid, + CORB_SET_PIN_WIDGET_CONTROL, result, NULL); +} + u_char azalia_generic_mixer_from_device_value(const codec_t *this, nid_t nid, int target, uint32_t dv) @@ -2362,8 +2356,6 @@ int azalia_stac9200_mixer_init(codec_t *this) { mixer_ctrl_t mc; - int err; - uint32_t value; this->nmixers = sizeof(stac9200_mixer_items) / sizeof(mixer_item_t); this->mixers = malloc(sizeof(mixer_item_t) * this->nmixers, @@ -2401,31 +2393,8 @@ azalia_stac9200_mixer_init(codec_t *this) CORB_SET_UNSOLICITED_RESPONSE, CORB_UNSOL_ENABLE | STAC9200_EVENT_HP, NULL); - /* make initial hp vs speaker choice */ + azalia_stac9200_unsol_event(this, STAC9200_EVENT_HP); - err = this->comresp(this, STAC9200_NID_HP, - CORB_GET_PIN_SENSE, 0, &value); - if (err) - return err; - if (value & CORB_PS_PRESENCE) { - mc.un.ord = 0; - azalia_generic_mixer_set(this, STAC9200_NID_SPEAKER, - MI_TARGET_PINCTRL, &mc); - mc.un.ord = 1; - azalia_generic_mixer_set(this, STAC9200_NID_HP, - MI_TARGET_PINCTRL, &mc); - azalia_generic_mixer_set(this, STAC9200_NID_HP, - MI_TARGET_PINDIR, &mc); - } else { - mc.un.ord = 0; - azalia_generic_mixer_set(this, STAC9200_NID_HP, - MI_TARGET_PINCTRL, &mc); - mc.un.ord = 1; - azalia_generic_mixer_set(this, STAC9200_NID_SPEAKER, - MI_TARGET_PINCTRL, &mc); - azalia_generic_mixer_set(this, STAC9200_NID_SPEAKER, - MI_TARGET_PINDIR, &mc); - } return 0; } int @@ -2433,37 +2402,21 @@ azalia_stac9200_unsol_event(codec_t *this, int tag) { int err; uint32_t value; - mixer_ctrl_t mc; switch (tag) { case STAC9200_EVENT_HP: err = this->comresp(this, STAC9200_NID_HP, CORB_GET_PIN_SENSE, 0, &value); if (err) - return err; + break; if (value & CORB_PS_PRESENCE) { DPRINTF(("%s: headphone inserted\n", __func__)); - mc.un.ord = 0; /* disable */ - azalia_generic_mixer_set(this, - STAC9200_NID_SPEAKER, - MI_TARGET_PINCTRL, &mc); - mc.un.ord = 1; /* enable and direction output */ - azalia_generic_mixer_set(this, STAC9200_NID_HP, - MI_TARGET_PINCTRL, &mc); - azalia_generic_mixer_set(this, STAC9200_NID_HP, - MI_TARGET_PINDIR, &mc); + azalia_generic_mixer_pinctrl(this, + STAC9200_NID_SPEAKER, 0); } else { DPRINTF(("%s: headphone pulled\n", __func__)); - mc.un.ord = 0; - azalia_generic_mixer_set(this, STAC9200_NID_HP, - MI_TARGET_PINCTRL, &mc); - mc.un.ord = 1; - azalia_generic_mixer_set(this, - STAC9200_NID_SPEAKER, - MI_TARGET_PINCTRL, &mc); - azalia_generic_mixer_set(this, - STAC9200_NID_SPEAKER, - MI_TARGET_PINDIR, &mc); + azalia_generic_mixer_pinctrl(this, + STAC9200_NID_SPEAKER, CORB_PWC_OUTPUT); } break; default: |