hdaudio: check pin sense on init, don't wait for a switch event

with headphones plugged on boot, sound was still enabled on speakers.
see #9956
This commit is contained in:
Jerome Duval
2013-09-17 14:40:39 +02:00
committed by Rene Gollent
parent 9202a719e1
commit 697c0d7c63
@@ -1174,14 +1174,9 @@ hda_codec_switch_init(hda_audio_group* audioGroup)
} }
static status_t static void
hda_codec_switch_handler(hda_codec* codec) hda_codec_check_sense(hda_codec* codec, bool disable)
{ {
while (acquire_sem(codec->unsol_response_sem) == B_OK) {
uint32 response = codec->unsol_responses[codec->unsol_response_read++];
codec->unsol_response_read %= MAX_CODEC_UNSOL_RESPONSES;
bool disable = response & 1;
hda_audio_group* audioGroup = codec->audio_groups[0]; hda_audio_group* audioGroup = codec->audio_groups[0];
for (uint32 i = 0; i < audioGroup->widget_count; i++) { for (uint32 i = 0; i < audioGroup->widget_count; i++) {
@@ -1227,8 +1222,19 @@ hda_codec_switch_handler(hda_codec* codec)
VID_SET_PIN_WIDGET_CONTROL, disable ? 0 : ctrl); VID_SET_PIN_WIDGET_CONTROL, disable ? 0 : ctrl);
hda_send_verbs(audioGroup->codec, &verb, NULL, 1); hda_send_verbs(audioGroup->codec, &verb, NULL, 1);
} }
} }
static status_t
hda_codec_switch_handler(hda_codec* codec)
{
while (acquire_sem(codec->unsol_response_sem) == B_OK) {
uint32 response = codec->unsol_responses[codec->unsol_response_read++];
codec->unsol_response_read %= MAX_CODEC_UNSOL_RESPONSES;
bool disable = response & 1;
hda_codec_check_sense(codec, disable);
}
return B_OK; return B_OK;
} }
@@ -1521,6 +1527,8 @@ hda_codec_new(hda_controller* controller, uint32 codecAddress)
} }
} }
hda_codec_check_sense(codec, false);
codec->unsol_response_thread = spawn_kernel_thread( codec->unsol_response_thread = spawn_kernel_thread(
(status_t(*)(void*))hda_codec_switch_handler, (status_t(*)(void*))hda_codec_switch_handler,
"hda_codec_unsol_thread", B_LOW_PRIORITY, codec); "hda_codec_unsol_thread", B_LOW_PRIORITY, codec);