112
104
unsigned int spdif_route;
115
struct snd_array jacks;
117
106
/* dynamic controls, init_verbs and input_mux */
118
107
struct auto_pin_cfg autocfg;
119
108
struct hda_input_mux private_imux;
393
382
&spec->cur_mux[adc_idx]);
396
#ifdef CONFIG_SND_HDA_INPUT_JACK
397
static void conexant_free_jack_priv(struct snd_jack *jack)
399
struct conexant_jack *jacks = jack->private_data;
404
static int conexant_add_jack(struct hda_codec *codec,
405
hda_nid_t nid, int type)
407
struct conexant_spec *spec;
408
struct conexant_jack *jack;
413
snd_array_init(&spec->jacks, sizeof(*jack), 32);
415
jack = spec->jacks.list;
416
for (i = 0; i < spec->jacks.used; i++, jack++)
417
if (jack->nid == nid)
418
return 0 ; /* already present */
420
jack = snd_array_new(&spec->jacks);
421
name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
429
err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
432
jack->jack->private_data = jack;
433
jack->jack->private_free = conexant_free_jack_priv;
437
static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
439
struct conexant_spec *spec = codec->spec;
440
struct conexant_jack *jacks = spec->jacks.list;
444
for (i = 0; i < spec->jacks.used; i++) {
445
if (jacks->nid == nid) {
446
unsigned int present;
447
present = snd_hda_jack_detect(codec, nid);
449
present = (present) ? jacks->type : 0 ;
451
snd_jack_report(jacks->jack,
459
385
static int conexant_init_jacks(struct hda_codec *codec)
387
#ifdef CONFIG_SND_HDA_INPUT_JACK
461
388
struct conexant_spec *spec = codec->spec;
470
397
switch (hv->param ^ AC_USRSP_EN) {
471
398
case CONEXANT_HP_EVENT:
472
err = conexant_add_jack(codec, hv->nid,
474
conexant_report_jack(codec, hv->nid);
399
err = snd_hda_input_jack_add(codec, hv->nid,
400
SND_JACK_HEADPHONE, NULL);
401
snd_hda_input_jack_report(codec, hv->nid);
476
403
case CXT5051_PORTC_EVENT:
477
404
case CONEXANT_MIC_EVENT:
478
err = conexant_add_jack(codec, hv->nid,
479
SND_JACK_MICROPHONE);
480
conexant_report_jack(codec, hv->nid);
405
err = snd_hda_input_jack_add(codec, hv->nid,
406
SND_JACK_MICROPHONE, NULL);
407
snd_hda_input_jack_report(codec, hv->nid);
492
static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
496
static inline int conexant_init_jacks(struct hda_codec *codec)
415
#endif /* CONFIG_SND_HDA_INPUT_JACK */
502
419
static int conexant_init(struct hda_codec *codec)
512
429
static void conexant_free(struct hda_codec *codec)
514
#ifdef CONFIG_SND_HDA_INPUT_JACK
515
struct conexant_spec *spec = codec->spec;
516
if (spec->jacks.list) {
517
struct conexant_jack *jacks = spec->jacks.list;
519
for (i = 0; i < spec->jacks.used; i++, jacks++) {
521
snd_device_free(codec->bus->card, jacks->jack);
523
snd_array_free(&spec->jacks);
431
snd_hda_input_jack_free(codec);
526
432
snd_hda_detach_beep_device(codec);
527
433
kfree(codec->spec);
1787
1693
cxt5051_portc_automic(codec);
1790
conexant_report_jack(codec, nid);
1696
snd_hda_input_jack_report(codec, nid);
1793
1699
static struct snd_kcontrol_new cxt5051_playback_mixers[] = {
1959
1865
snd_hda_codec_write(codec, nid, 0,
1960
1866
AC_VERB_SET_UNSOLICITED_ENABLE,
1961
1867
AC_USRSP_EN | event);
1962
#ifdef CONFIG_SND_HDA_INPUT_JACK
1963
conexant_add_jack(codec, nid, SND_JACK_MICROPHONE);
1964
conexant_report_jack(codec, nid);
1868
snd_hda_input_jack_add(codec, nid, SND_JACK_MICROPHONE, NULL);
1869
snd_hda_input_jack_report(codec, nid);
1968
1872
static struct hda_verb cxt5051_ideapad_init_verbs[] = {
3130
3034
SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD),
3131
3035
SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS),
3132
3036
SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD),
3037
SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT5066_THINKPAD),
3038
SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT5066_THINKPAD),
3133
3039
SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G560", CXT5066_ASUS),
3134
3040
SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT5066_IDEAPAD), /* Fallback for Lenovos without dock mic */
3477
3383
switch (res >> 26) {
3478
3384
case CONEXANT_HP_EVENT:
3479
3385
cx_auto_hp_automute(codec);
3480
conexant_report_jack(codec, nid);
3386
snd_hda_input_jack_report(codec, nid);
3482
3388
case CONEXANT_MIC_EVENT:
3483
3389
cx_auto_automic(codec);
3484
conexant_report_jack(codec, nid);
3390
snd_hda_input_jack_report(codec, nid);