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
@@ -48,7 +42,6 @@ struct conexant_spec {
48
42
unsigned int gpio_led ;
49
43
unsigned int gpio_mute_led_mask ;
50
44
unsigned int gpio_mic_led_mask ;
51
- unsigned int headset_present_flag ;
52
45
bool is_cx8070_sn6140 ;
53
46
};
54
47
@@ -250,48 +243,19 @@ static void cx_process_headset_plugin(struct hda_codec *codec)
250
243
}
251
244
}
252
245
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 )
254
247
{
255
- unsigned int phone_present , mic_persent , phone_tag , mic_tag ;
256
- struct conexant_spec * spec = codec -> spec ;
248
+ unsigned int mic_present ;
257
249
258
250
/* In cx8070 and sn6140, the node 16 can only be config to headphone or disabled,
259
251
* the node 19 can only be config to microphone or disabled.
260
252
* Check hp&mic tag to process headset pulgin&plugout.
261
253
*/
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 );
295
259
}
296
260
297
261
static int cx_auto_suspend (struct hda_codec * codec )
@@ -305,7 +269,7 @@ static const struct hda_codec_ops cx_auto_patch_ops = {
305
269
.build_pcms = snd_hda_gen_build_pcms ,
306
270
.init = cx_auto_init ,
307
271
.free = cx_auto_free ,
308
- .unsol_event = cx_jack_unsol_event ,
272
+ .unsol_event = snd_hda_jack_unsol_event ,
309
273
.suspend = cx_auto_suspend ,
310
274
.check_power_status = snd_hda_gen_check_power_status ,
311
275
};
@@ -1163,7 +1127,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
1163
1127
case 0x14f11f86 :
1164
1128
case 0x14f11f87 :
1165
1129
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 ) ;
1167
1131
break ;
1168
1132
}
1169
1133
0 commit comments