Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: hda: conexant: Fix headset auto detect fail in the polling mode

The previous fix (7aeb25908648) only handles the unsol_event reporting
during interrupts and does not include the polling mode used to set
jackroll_ms, so now we are replacing it with
snd_hda_jack_detect_enable_callback.

Fixes: 7aeb25908648 ("ALSA: hda/conexant: Fix headset auto detect fail in cx8070 and SN6140")
Co-developed-by: bo liu <bo.liu@senarytech.com>
Signed-off-by: bo liu <bo.liu@senarytech.com>
Signed-off-by: songxiebing <songxiebing@kylinos.cn>
Link: https://patch.msgid.link/20240726100726.50824-1-soxiebing@163.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

songxiebing and committed by
Takashi Iwai
e60dc981 e8b96a66

+9 -45
+9 -45
sound/pci/hda/patch_conexant.c
··· 21 21 #include "hda_jack.h" 22 22 #include "hda_generic.h" 23 23 24 - enum { 25 - CX_HEADSET_NOPRESENT = 0, 26 - CX_HEADSET_PARTPRESENT, 27 - CX_HEADSET_ALLPRESENT, 28 - }; 29 - 30 24 struct conexant_spec { 31 25 struct hda_gen_spec gen; 32 26 ··· 42 48 unsigned int gpio_led; 43 49 unsigned int gpio_mute_led_mask; 44 50 unsigned int gpio_mic_led_mask; 45 - unsigned int headset_present_flag; 46 51 bool is_cx8070_sn6140; 47 52 }; 48 53 ··· 243 250 } 244 251 } 245 252 246 - static void cx_update_headset_mic_vref(struct hda_codec *codec, unsigned int res) 253 + static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_callback *event) 247 254 { 248 - unsigned int phone_present, mic_persent, phone_tag, mic_tag; 249 - struct conexant_spec *spec = codec->spec; 255 + unsigned int mic_present; 250 256 251 257 /* In cx8070 and sn6140, the node 16 can only be config to headphone or disabled, 252 258 * the node 19 can only be config to microphone or disabled. 253 259 * Check hp&mic tag to process headset pulgin&plugout. 254 260 */ 255 - phone_tag = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0); 256 - mic_tag = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0); 257 - if ((phone_tag & (res >> AC_UNSOL_RES_TAG_SHIFT)) || 258 - (mic_tag & (res >> AC_UNSOL_RES_TAG_SHIFT))) { 259 - phone_present = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_PIN_SENSE, 0x0); 260 - if (!(phone_present & AC_PINSENSE_PRESENCE)) {/* headphone plugout */ 261 - spec->headset_present_flag = CX_HEADSET_NOPRESENT; 262 - snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20); 263 - return; 264 - } 265 - if (spec->headset_present_flag == CX_HEADSET_NOPRESENT) { 266 - spec->headset_present_flag = CX_HEADSET_PARTPRESENT; 267 - } else if (spec->headset_present_flag == CX_HEADSET_PARTPRESENT) { 268 - mic_persent = snd_hda_codec_read(codec, 0x19, 0, 269 - AC_VERB_GET_PIN_SENSE, 0x0); 270 - /* headset is present */ 271 - if ((phone_present & AC_PINSENSE_PRESENCE) && 272 - (mic_persent & AC_PINSENSE_PRESENCE)) { 273 - cx_process_headset_plugin(codec); 274 - spec->headset_present_flag = CX_HEADSET_ALLPRESENT; 275 - } 276 - } 277 - } 278 - } 279 - 280 - static void cx_jack_unsol_event(struct hda_codec *codec, unsigned int res) 281 - { 282 - struct conexant_spec *spec = codec->spec; 283 - 284 - if (spec->is_cx8070_sn6140) 285 - cx_update_headset_mic_vref(codec, res); 286 - 287 - snd_hda_jack_unsol_event(codec, res); 261 + mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0); 262 + if (!(mic_present & AC_PINSENSE_PRESENCE)) /* mic plugout */ 263 + snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20); 264 + else 265 + cx_process_headset_plugin(codec); 288 266 } 289 267 290 268 static int cx_auto_suspend(struct hda_codec *codec) ··· 269 305 .build_pcms = snd_hda_gen_build_pcms, 270 306 .init = cx_auto_init, 271 307 .free = cx_auto_free, 272 - .unsol_event = cx_jack_unsol_event, 308 + .unsol_event = snd_hda_jack_unsol_event, 273 309 .suspend = cx_auto_suspend, 274 310 .check_power_status = snd_hda_gen_check_power_status, 275 311 }; ··· 1127 1163 case 0x14f11f86: 1128 1164 case 0x14f11f87: 1129 1165 spec->is_cx8070_sn6140 = true; 1130 - spec->headset_present_flag = CX_HEADSET_NOPRESENT; 1166 + snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref); 1131 1167 break; 1132 1168 } 1133 1169