diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-12-01 11:41:36 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-12-01 11:47:54 -0500 |
commit | 31ef22579302ac42054bebecb528710f46580925 (patch) | |
tree | 8f521b4920f0a1ebbb1e6f9105948a5f38f24404 /sound/pci/hda/patch_conexant.c | |
parent | 358b6e62b86f6313d114e0f6b7d8f8adaf85ed9c (diff) |
ALSA: hda - Integrate input-jack stuff into kctl-jack
Instead of managing input-jack stuff separately, call all stuff inside
the kctl-jack creation, deletion and report. The caller no longer needs
to care about input-jack.
The better integration between input-jack and kctl-jack should be done
in the upper layer in near future, but for now, it's implemented locally
for more tests.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_conexant.c')
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index ae9c028d8254..bf14a0a0ce1c 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -416,40 +416,6 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
416 | &spec->cur_mux[adc_idx]); | 416 | &spec->cur_mux[adc_idx]); |
417 | } | 417 | } |
418 | 418 | ||
419 | static int conexant_init_jacks(struct hda_codec *codec) | ||
420 | { | ||
421 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
422 | struct conexant_spec *spec = codec->spec; | ||
423 | int i; | ||
424 | |||
425 | for (i = 0; i < spec->num_init_verbs; i++) { | ||
426 | const struct hda_verb *hv; | ||
427 | |||
428 | hv = spec->init_verbs[i]; | ||
429 | while (hv->nid) { | ||
430 | int err = 0; | ||
431 | switch (hv->param ^ AC_USRSP_EN) { | ||
432 | case CONEXANT_HP_EVENT: | ||
433 | err = snd_hda_input_jack_add(codec, hv->nid, | ||
434 | SND_JACK_HEADPHONE, NULL); | ||
435 | snd_hda_input_jack_report(codec, hv->nid); | ||
436 | break; | ||
437 | case CXT5051_PORTC_EVENT: | ||
438 | case CONEXANT_MIC_EVENT: | ||
439 | err = snd_hda_input_jack_add(codec, hv->nid, | ||
440 | SND_JACK_MICROPHONE, NULL); | ||
441 | snd_hda_input_jack_report(codec, hv->nid); | ||
442 | break; | ||
443 | } | ||
444 | if (err < 0) | ||
445 | return err; | ||
446 | ++hv; | ||
447 | } | ||
448 | } | ||
449 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ | ||
450 | return 0; | ||
451 | } | ||
452 | |||
453 | static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, | 419 | static void conexant_set_power(struct hda_codec *codec, hda_nid_t fg, |
454 | unsigned int power_state) | 420 | unsigned int power_state) |
455 | { | 421 | { |
@@ -1750,7 +1716,6 @@ static void cxt5051_hp_automute(struct hda_codec *codec) | |||
1750 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, | 1716 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, |
1751 | unsigned int res) | 1717 | unsigned int res) |
1752 | { | 1718 | { |
1753 | int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; | ||
1754 | switch (res >> 26) { | 1719 | switch (res >> 26) { |
1755 | case CONEXANT_HP_EVENT: | 1720 | case CONEXANT_HP_EVENT: |
1756 | cxt5051_hp_automute(codec); | 1721 | cxt5051_hp_automute(codec); |
@@ -1762,7 +1727,6 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |||
1762 | cxt5051_portc_automic(codec); | 1727 | cxt5051_portc_automic(codec); |
1763 | break; | 1728 | break; |
1764 | } | 1729 | } |
1765 | snd_hda_input_jack_report(codec, nid); | ||
1766 | } | 1730 | } |
1767 | 1731 | ||
1768 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { | 1732 | static const struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
@@ -1901,8 +1865,6 @@ static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, | |||
1901 | snd_hda_codec_write(codec, nid, 0, | 1865 | snd_hda_codec_write(codec, nid, 0, |
1902 | AC_VERB_SET_UNSOLICITED_ENABLE, | 1866 | AC_VERB_SET_UNSOLICITED_ENABLE, |
1903 | AC_USRSP_EN | event); | 1867 | AC_USRSP_EN | event); |
1904 | snd_hda_input_jack_add(codec, nid, SND_JACK_MICROPHONE, NULL); | ||
1905 | snd_hda_input_jack_report(codec, nid); | ||
1906 | } | 1868 | } |
1907 | 1869 | ||
1908 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { | 1870 | static const struct hda_verb cxt5051_ideapad_init_verbs[] = { |
@@ -1918,7 +1880,6 @@ static int cxt5051_init(struct hda_codec *codec) | |||
1918 | struct conexant_spec *spec = codec->spec; | 1880 | struct conexant_spec *spec = codec->spec; |
1919 | 1881 | ||
1920 | conexant_init(codec); | 1882 | conexant_init(codec); |
1921 | conexant_init_jacks(codec); | ||
1922 | 1883 | ||
1923 | if (spec->auto_mic & AUTO_MIC_PORTB) | 1884 | if (spec->auto_mic & AUTO_MIC_PORTB) |
1924 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); | 1885 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); |
@@ -3450,7 +3411,6 @@ static int detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) | |||
3450 | hda_nid_t nid = pins[i]; | 3411 | hda_nid_t nid = pins[i]; |
3451 | if (!nid || !is_jack_detectable(codec, nid)) | 3412 | if (!nid || !is_jack_detectable(codec, nid)) |
3452 | break; | 3413 | break; |
3453 | snd_hda_input_jack_report(codec, nid); | ||
3454 | present |= snd_hda_jack_detect(codec, nid); | 3414 | present |= snd_hda_jack_detect(codec, nid); |
3455 | } | 3415 | } |
3456 | return present; | 3416 | return present; |
@@ -3755,8 +3715,6 @@ static void cx_auto_automic(struct hda_codec *codec) | |||
3755 | 3715 | ||
3756 | static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) | 3716 | static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) |
3757 | { | 3717 | { |
3758 | int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; | ||
3759 | |||
3760 | switch (snd_hda_jack_get_action(codec, res >> 26)) { | 3718 | switch (snd_hda_jack_get_action(codec, res >> 26)) { |
3761 | case CONEXANT_HP_EVENT: | 3719 | case CONEXANT_HP_EVENT: |
3762 | cx_auto_hp_automute(codec); | 3720 | cx_auto_hp_automute(codec); |
@@ -3766,7 +3724,6 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) | |||
3766 | break; | 3724 | break; |
3767 | case CONEXANT_MIC_EVENT: | 3725 | case CONEXANT_MIC_EVENT: |
3768 | cx_auto_automic(codec); | 3726 | cx_auto_automic(codec); |
3769 | snd_hda_input_jack_report(codec, nid); | ||
3770 | break; | 3727 | break; |
3771 | } | 3728 | } |
3772 | snd_hda_jack_report_sync(codec); | 3729 | snd_hda_jack_report_sync(codec); |
@@ -4325,6 +4282,7 @@ static int cx_auto_build_input_controls(struct hda_codec *codec) | |||
4325 | 4282 | ||
4326 | static int cx_auto_build_controls(struct hda_codec *codec) | 4283 | static int cx_auto_build_controls(struct hda_codec *codec) |
4327 | { | 4284 | { |
4285 | struct conexant_spec *spec = codec->spec; | ||
4328 | int err; | 4286 | int err; |
4329 | 4287 | ||
4330 | err = cx_auto_build_output_controls(codec); | 4288 | err = cx_auto_build_output_controls(codec); |
@@ -4333,7 +4291,13 @@ static int cx_auto_build_controls(struct hda_codec *codec) | |||
4333 | err = cx_auto_build_input_controls(codec); | 4291 | err = cx_auto_build_input_controls(codec); |
4334 | if (err < 0) | 4292 | if (err < 0) |
4335 | return err; | 4293 | return err; |
4336 | return conexant_build_controls(codec); | 4294 | err = conexant_build_controls(codec); |
4295 | if (err < 0) | ||
4296 | return err; | ||
4297 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); | ||
4298 | if (err < 0) | ||
4299 | return err; | ||
4300 | return 0; | ||
4337 | } | 4301 | } |
4338 | 4302 | ||
4339 | static int cx_auto_search_adcs(struct hda_codec *codec) | 4303 | static int cx_auto_search_adcs(struct hda_codec *codec) |