Author: korli Date: 2010-02-20 01:28:46 +0100 (Sat, 20 Feb 2010) New Revision: 35528 Changeset: http://dev.haiku-os.org/changeset/35528/haiku Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h Log: We now pin sense the headphone pin widget to check if something is plugged in. Use this to disable/enable speakers. Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.cpp 2010-02-19 22:48:35 UTC (rev 35527) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec.cpp 2010-02-20 00:28:46 UTC (rev 35528) @@ -1105,11 +1105,31 @@ for (uint32 i = 0; i < audioGroup->widget_count; i++) { hda_widget& widget = audioGroup->widgets[i]; - if (widget.type != WT_PIN_COMPLEX || !PIN_CAP_IS_OUTPUT(widget.d.pin.capabilities)) + if (widget.type != WT_PIN_COMPLEX + || !PIN_CAP_IS_OUTPUT(widget.d.pin.capabilities) + || CONF_DEFAULT_DEVICE(widget.d.pin.config) + != PIN_DEV_HEAD_PHONE_OUT) continue; + corb_t verb = MAKE_VERB(audioGroup->codec->addr, widget.node_id, + VID_GET_PINSENSE, 0); + uint32 response; + hda_send_verbs(audioGroup->codec, &verb, &response, 1); + disable = response & PIN_SENSE_PRESENCE_DETECT; + TRACE("hda: sensed pin widget %ld, %d\n", widget.node_id, disable); + break; + } + + for (uint32 i = 0; i < audioGroup->widget_count; i++) { + hda_widget& widget = audioGroup->widgets[i]; + + if (widget.type != WT_PIN_COMPLEX + || !PIN_CAP_IS_OUTPUT(widget.d.pin.capabilities)) + continue; + int device = CONF_DEFAULT_DEVICE(widget.d.pin.config); - if (device != PIN_DEV_SPEAKER + if (device != PIN_DEV_AUX + && device != PIN_DEV_SPEAKER && device != PIN_DEV_LINE_OUT) continue; Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h 2010-02-19 22:48:35 UTC (rev 35527) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_codec_defs.h 2010-02-20 00:28:46 UTC (rev 35528) @@ -281,6 +281,9 @@ /* Unsolicited Response */ #define UNSOLRESP_ENABLE (1L << 7) +/* Pin sense */ +#define PIN_SENSE_PRESENCE_DETECT (1L << 31) + /* Supported power states */ #define POWER_STATE_D0 (1L << 0) #define POWER_STATE_D1 (1L << 1)