Skip to content

Commit e60dc98

Browse files
songxiebingtiwai
authored andcommitted
ALSA: hda: conexant: Fix headset auto detect fail in the polling mode
The previous fix (7aeb259) 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: 7aeb259 ("ALSA: hda/conexant: Fix headset auto detect fail in cx8070 and SN6140") Co-developed-by: bo liu <[email protected]> Signed-off-by: bo liu <[email protected]> Signed-off-by: songxiebing <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent e8b96a6 commit e60dc98

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed

sound/pci/hda/patch_conexant.c

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
#include "hda_jack.h"
2222
#include "hda_generic.h"
2323

24-
enum {
25-
CX_HEADSET_NOPRESENT = 0,
26-
CX_HEADSET_PARTPRESENT,
27-
CX_HEADSET_ALLPRESENT,
28-
};
29-
3024
struct conexant_spec {
3125
struct hda_gen_spec gen;
3226

@@ -48,7 +42,6 @@ struct conexant_spec {
4842
unsigned int gpio_led;
4943
unsigned int gpio_mute_led_mask;
5044
unsigned int gpio_mic_led_mask;
51-
unsigned int headset_present_flag;
5245
bool is_cx8070_sn6140;
5346
};
5447

@@ -250,48 +243,19 @@ static void cx_process_headset_plugin(struct hda_codec *codec)
250243
}
251244
}
252245

253-
static void cx_update_headset_mic_vref(struct hda_codec *codec, unsigned int res)
246+
static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_callback *event)
254247
{
255-
unsigned int phone_present, mic_persent, phone_tag, mic_tag;
256-
struct conexant_spec *spec = codec->spec;
248+
unsigned int mic_present;
257249

258250
/* In cx8070 and sn6140, the node 16 can only be config to headphone or disabled,
259251
* the node 19 can only be config to microphone or disabled.
260252
* Check hp&mic tag to process headset pulgin&plugout.
261253
*/
262-
phone_tag = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0);
263-
mic_tag = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0);
264-
if ((phone_tag & (res >> AC_UNSOL_RES_TAG_SHIFT)) ||
265-
(mic_tag & (res >> AC_UNSOL_RES_TAG_SHIFT))) {
266-
phone_present = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_PIN_SENSE, 0x0);
267-
if (!(phone_present & AC_PINSENSE_PRESENCE)) {/* headphone plugout */
268-
spec->headset_present_flag = CX_HEADSET_NOPRESENT;
269-
snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
270-
return;
271-
}
272-
if (spec->headset_present_flag == CX_HEADSET_NOPRESENT) {
273-
spec->headset_present_flag = CX_HEADSET_PARTPRESENT;
274-
} else if (spec->headset_present_flag == CX_HEADSET_PARTPRESENT) {
275-
mic_persent = snd_hda_codec_read(codec, 0x19, 0,
276-
AC_VERB_GET_PIN_SENSE, 0x0);
277-
/* headset is present */
278-
if ((phone_present & AC_PINSENSE_PRESENCE) &&
279-
(mic_persent & AC_PINSENSE_PRESENCE)) {
280-
cx_process_headset_plugin(codec);
281-
spec->headset_present_flag = CX_HEADSET_ALLPRESENT;
282-
}
283-
}
284-
}
285-
}
286-
287-
static void cx_jack_unsol_event(struct hda_codec *codec, unsigned int res)
288-
{
289-
struct conexant_spec *spec = codec->spec;
290-
291-
if (spec->is_cx8070_sn6140)
292-
cx_update_headset_mic_vref(codec, res);
293-
294-
snd_hda_jack_unsol_event(codec, res);
254+
mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
255+
if (!(mic_present & AC_PINSENSE_PRESENCE)) /* mic plugout */
256+
snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
257+
else
258+
cx_process_headset_plugin(codec);
295259
}
296260

297261
static int cx_auto_suspend(struct hda_codec *codec)
@@ -305,7 +269,7 @@ static const struct hda_codec_ops cx_auto_patch_ops = {
305269
.build_pcms = snd_hda_gen_build_pcms,
306270
.init = cx_auto_init,
307271
.free = cx_auto_free,
308-
.unsol_event = cx_jack_unsol_event,
272+
.unsol_event = snd_hda_jack_unsol_event,
309273
.suspend = cx_auto_suspend,
310274
.check_power_status = snd_hda_gen_check_power_status,
311275
};
@@ -1163,7 +1127,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
11631127
case 0x14f11f86:
11641128
case 0x14f11f87:
11651129
spec->is_cx8070_sn6140 = true;
1166-
spec->headset_present_flag = CX_HEADSET_NOPRESENT;
1130+
snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref);
11671131
break;
11681132
}
11691133

0 commit comments

Comments
 (0)