diff options
Diffstat (limited to 'sound/pci/hda/patch_conexant.c')
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 124 |
1 files changed, 14 insertions, 110 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 4d5004e693f0..d08cf31596f3 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -49,14 +49,6 @@ | |||
49 | #define AUTO_MIC_PORTB (1 << 1) | 49 | #define AUTO_MIC_PORTB (1 << 1) |
50 | #define AUTO_MIC_PORTC (1 << 2) | 50 | #define AUTO_MIC_PORTC (1 << 2) |
51 | 51 | ||
52 | struct conexant_jack { | ||
53 | |||
54 | hda_nid_t nid; | ||
55 | int type; | ||
56 | struct snd_jack *jack; | ||
57 | |||
58 | }; | ||
59 | |||
60 | struct pin_dac_pair { | 52 | struct pin_dac_pair { |
61 | hda_nid_t pin; | 53 | hda_nid_t pin; |
62 | hda_nid_t dac; | 54 | hda_nid_t dac; |
@@ -111,9 +103,6 @@ struct conexant_spec { | |||
111 | 103 | ||
112 | unsigned int spdif_route; | 104 | unsigned int spdif_route; |
113 | 105 | ||
114 | /* jack detection */ | ||
115 | struct snd_array jacks; | ||
116 | |||
117 | /* dynamic controls, init_verbs and input_mux */ | 106 | /* dynamic controls, init_verbs and input_mux */ |
118 | struct auto_pin_cfg autocfg; | 107 | struct auto_pin_cfg autocfg; |
119 | struct hda_input_mux private_imux; | 108 | struct hda_input_mux private_imux; |
@@ -393,71 +382,9 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
393 | &spec->cur_mux[adc_idx]); | 382 | &spec->cur_mux[adc_idx]); |
394 | } | 383 | } |
395 | 384 | ||
396 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
397 | static void conexant_free_jack_priv(struct snd_jack *jack) | ||
398 | { | ||
399 | struct conexant_jack *jacks = jack->private_data; | ||
400 | jacks->nid = 0; | ||
401 | jacks->jack = NULL; | ||
402 | } | ||
403 | |||
404 | static int conexant_add_jack(struct hda_codec *codec, | ||
405 | hda_nid_t nid, int type) | ||
406 | { | ||
407 | struct conexant_spec *spec; | ||
408 | struct conexant_jack *jack; | ||
409 | const char *name; | ||
410 | int i, err; | ||
411 | |||
412 | spec = codec->spec; | ||
413 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | ||
414 | |||
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 */ | ||
419 | |||
420 | jack = snd_array_new(&spec->jacks); | ||
421 | name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ; | ||
422 | |||
423 | if (!jack) | ||
424 | return -ENOMEM; | ||
425 | |||
426 | jack->nid = nid; | ||
427 | jack->type = type; | ||
428 | |||
429 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); | ||
430 | if (err < 0) | ||
431 | return err; | ||
432 | jack->jack->private_data = jack; | ||
433 | jack->jack->private_free = conexant_free_jack_priv; | ||
434 | return 0; | ||
435 | } | ||
436 | |||
437 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | ||
438 | { | ||
439 | struct conexant_spec *spec = codec->spec; | ||
440 | struct conexant_jack *jacks = spec->jacks.list; | ||
441 | |||
442 | if (jacks) { | ||
443 | int i; | ||
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); | ||
448 | |||
449 | present = (present) ? jacks->type : 0 ; | ||
450 | |||
451 | snd_jack_report(jacks->jack, | ||
452 | present); | ||
453 | } | ||
454 | jacks++; | ||
455 | } | ||
456 | } | ||
457 | } | ||
458 | |||
459 | static int conexant_init_jacks(struct hda_codec *codec) | 385 | static int conexant_init_jacks(struct hda_codec *codec) |
460 | { | 386 | { |
387 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
461 | struct conexant_spec *spec = codec->spec; | 388 | struct conexant_spec *spec = codec->spec; |
462 | int i; | 389 | int i; |
463 | 390 | ||
@@ -469,15 +396,15 @@ static int conexant_init_jacks(struct hda_codec *codec) | |||
469 | int err = 0; | 396 | int err = 0; |
470 | switch (hv->param ^ AC_USRSP_EN) { | 397 | switch (hv->param ^ AC_USRSP_EN) { |
471 | case CONEXANT_HP_EVENT: | 398 | case CONEXANT_HP_EVENT: |
472 | err = conexant_add_jack(codec, hv->nid, | 399 | err = snd_hda_input_jack_add(codec, hv->nid, |
473 | SND_JACK_HEADPHONE); | 400 | SND_JACK_HEADPHONE, NULL); |
474 | conexant_report_jack(codec, hv->nid); | 401 | snd_hda_input_jack_report(codec, hv->nid); |
475 | break; | 402 | break; |
476 | case CXT5051_PORTC_EVENT: | 403 | case CXT5051_PORTC_EVENT: |
477 | case CONEXANT_MIC_EVENT: | 404 | case CONEXANT_MIC_EVENT: |
478 | err = conexant_add_jack(codec, hv->nid, | 405 | err = snd_hda_input_jack_add(codec, hv->nid, |
479 | SND_JACK_MICROPHONE); | 406 | SND_JACK_MICROPHONE, NULL); |
480 | conexant_report_jack(codec, hv->nid); | 407 | snd_hda_input_jack_report(codec, hv->nid); |
481 | break; | 408 | break; |
482 | } | 409 | } |
483 | if (err < 0) | 410 | if (err < 0) |
@@ -485,19 +412,9 @@ static int conexant_init_jacks(struct hda_codec *codec) | |||
485 | ++hv; | 412 | ++hv; |
486 | } | 413 | } |
487 | } | 414 | } |
488 | return 0; | 415 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ |
489 | |||
490 | } | ||
491 | #else | ||
492 | static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | ||
493 | { | ||
494 | } | ||
495 | |||
496 | static inline int conexant_init_jacks(struct hda_codec *codec) | ||
497 | { | ||
498 | return 0; | 416 | return 0; |
499 | } | 417 | } |
500 | #endif | ||
501 | 418 | ||
502 | static int conexant_init(struct hda_codec *codec) | 419 | static int conexant_init(struct hda_codec *codec) |
503 | { | 420 | { |
@@ -511,18 +428,7 @@ static int conexant_init(struct hda_codec *codec) | |||
511 | 428 | ||
512 | static void conexant_free(struct hda_codec *codec) | 429 | static void conexant_free(struct hda_codec *codec) |
513 | { | 430 | { |
514 | #ifdef CONFIG_SND_HDA_INPUT_JACK | 431 | snd_hda_input_jack_free(codec); |
515 | struct conexant_spec *spec = codec->spec; | ||
516 | if (spec->jacks.list) { | ||
517 | struct conexant_jack *jacks = spec->jacks.list; | ||
518 | int i; | ||
519 | for (i = 0; i < spec->jacks.used; i++, jacks++) { | ||
520 | if (jacks->jack) | ||
521 | snd_device_free(codec->bus->card, jacks->jack); | ||
522 | } | ||
523 | snd_array_free(&spec->jacks); | ||
524 | } | ||
525 | #endif | ||
526 | snd_hda_detach_beep_device(codec); | 432 | snd_hda_detach_beep_device(codec); |
527 | kfree(codec->spec); | 433 | kfree(codec->spec); |
528 | } | 434 | } |
@@ -1787,7 +1693,7 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |||
1787 | cxt5051_portc_automic(codec); | 1693 | cxt5051_portc_automic(codec); |
1788 | break; | 1694 | break; |
1789 | } | 1695 | } |
1790 | conexant_report_jack(codec, nid); | 1696 | snd_hda_input_jack_report(codec, nid); |
1791 | } | 1697 | } |
1792 | 1698 | ||
1793 | static struct snd_kcontrol_new cxt5051_playback_mixers[] = { | 1699 | static struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
@@ -1959,10 +1865,8 @@ static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, | |||
1959 | snd_hda_codec_write(codec, nid, 0, | 1865 | snd_hda_codec_write(codec, nid, 0, |
1960 | AC_VERB_SET_UNSOLICITED_ENABLE, | 1866 | AC_VERB_SET_UNSOLICITED_ENABLE, |
1961 | AC_USRSP_EN | event); | 1867 | AC_USRSP_EN | event); |
1962 | #ifdef CONFIG_SND_HDA_INPUT_JACK | 1868 | snd_hda_input_jack_add(codec, nid, SND_JACK_MICROPHONE, NULL); |
1963 | conexant_add_jack(codec, nid, SND_JACK_MICROPHONE); | 1869 | snd_hda_input_jack_report(codec, nid); |
1964 | conexant_report_jack(codec, nid); | ||
1965 | #endif | ||
1966 | } | 1870 | } |
1967 | 1871 | ||
1968 | static struct hda_verb cxt5051_ideapad_init_verbs[] = { | 1872 | static struct hda_verb cxt5051_ideapad_init_verbs[] = { |
@@ -3477,11 +3381,11 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) | |||
3477 | switch (res >> 26) { | 3381 | switch (res >> 26) { |
3478 | case CONEXANT_HP_EVENT: | 3382 | case CONEXANT_HP_EVENT: |
3479 | cx_auto_hp_automute(codec); | 3383 | cx_auto_hp_automute(codec); |
3480 | conexant_report_jack(codec, nid); | 3384 | snd_hda_input_jack_report(codec, nid); |
3481 | break; | 3385 | break; |
3482 | case CONEXANT_MIC_EVENT: | 3386 | case CONEXANT_MIC_EVENT: |
3483 | cx_auto_automic(codec); | 3387 | cx_auto_automic(codec); |
3484 | conexant_report_jack(codec, nid); | 3388 | snd_hda_input_jack_report(codec, nid); |
3485 | break; | 3389 | break; |
3486 | } | 3390 | } |
3487 | } | 3391 | } |