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 | |
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')
-rw-r--r-- | sound/pci/hda/hda_jack.c | 159 | ||||
-rw-r--r-- | sound/pci/hda/hda_local.h | 20 | ||||
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 52 | ||||
-rw-r--r-- | sound/pci/hda/patch_hdmi.c | 22 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 52 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 46 |
6 files changed, 74 insertions, 277 deletions
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 394901515d9e..d8a35da0803f 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
@@ -90,15 +90,19 @@ snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid) | |||
90 | } | 90 | } |
91 | EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_new); | 91 | EXPORT_SYMBOL_HDA(snd_hda_jack_tbl_new); |
92 | 92 | ||
93 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
94 | static void snd_hda_input_jack_free(struct hda_codec *codec); | ||
95 | #else | ||
96 | #define snd_hda_input_jack_free(codec) | ||
97 | #endif | ||
98 | |||
99 | void snd_hda_jack_tbl_clear(struct hda_codec *codec) | 93 | void snd_hda_jack_tbl_clear(struct hda_codec *codec) |
100 | { | 94 | { |
101 | snd_hda_input_jack_free(codec); | 95 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
96 | /* free jack instances manually when clearing/reconfiguring */ | ||
97 | if (!codec->bus->shutdown && codec->jacktbl.list) { | ||
98 | struct hda_jack_tbl *jack = codec->jacktbl.list; | ||
99 | int i; | ||
100 | for (i = 0; i < codec->jacktbl.used; i++, jack++) { | ||
101 | if (jack->jack) | ||
102 | snd_device_free(codec->bus->card, jack->jack); | ||
103 | } | ||
104 | } | ||
105 | #endif | ||
102 | snd_array_free(&codec->jacktbl); | 106 | snd_array_free(&codec->jacktbl); |
103 | } | 107 | } |
104 | 108 | ||
@@ -199,10 +203,44 @@ void snd_hda_jack_report_sync(struct hda_codec *codec) | |||
199 | continue; | 203 | continue; |
200 | state = get_jack_plug_state(jack->pin_sense); | 204 | state = get_jack_plug_state(jack->pin_sense); |
201 | snd_kctl_jack_report(codec->bus->card, jack->kctl, state); | 205 | snd_kctl_jack_report(codec->bus->card, jack->kctl, state); |
206 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
207 | if (jack->jack) | ||
208 | snd_jack_report(jack->jack, | ||
209 | state ? jack->type : 0); | ||
210 | #endif | ||
202 | } | 211 | } |
203 | } | 212 | } |
204 | EXPORT_SYMBOL_HDA(snd_hda_jack_report_sync); | 213 | EXPORT_SYMBOL_HDA(snd_hda_jack_report_sync); |
205 | 214 | ||
215 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
216 | /* guess the jack type from the pin-config */ | ||
217 | static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid) | ||
218 | { | ||
219 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
220 | switch (get_defcfg_device(def_conf)) { | ||
221 | case AC_JACK_LINE_OUT: | ||
222 | case AC_JACK_SPEAKER: | ||
223 | return SND_JACK_LINEOUT; | ||
224 | case AC_JACK_HP_OUT: | ||
225 | return SND_JACK_HEADPHONE; | ||
226 | case AC_JACK_SPDIF_OUT: | ||
227 | case AC_JACK_DIG_OTHER_OUT: | ||
228 | return SND_JACK_AVOUT; | ||
229 | case AC_JACK_MIC_IN: | ||
230 | return SND_JACK_MICROPHONE; | ||
231 | default: | ||
232 | return SND_JACK_LINEIN; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | static void hda_free_jack_priv(struct snd_jack *jack) | ||
237 | { | ||
238 | struct hda_jack_tbl *jacks = jack->private_data; | ||
239 | jacks->nid = 0; | ||
240 | jacks->jack = NULL; | ||
241 | } | ||
242 | #endif | ||
243 | |||
206 | /** | 244 | /** |
207 | * snd_hda_jack_add_kctl - Add a kctl for the given pin | 245 | * snd_hda_jack_add_kctl - Add a kctl for the given pin |
208 | * | 246 | * |
@@ -214,6 +252,7 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, | |||
214 | { | 252 | { |
215 | struct hda_jack_tbl *jack; | 253 | struct hda_jack_tbl *jack; |
216 | struct snd_kcontrol *kctl; | 254 | struct snd_kcontrol *kctl; |
255 | int err, state; | ||
217 | 256 | ||
218 | jack = snd_hda_jack_tbl_new(codec, nid); | 257 | jack = snd_hda_jack_tbl_new(codec, nid); |
219 | if (!jack) | 258 | if (!jack) |
@@ -223,11 +262,21 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, | |||
223 | kctl = snd_kctl_jack_new(name, idx, codec); | 262 | kctl = snd_kctl_jack_new(name, idx, codec); |
224 | if (!kctl) | 263 | if (!kctl) |
225 | return -ENOMEM; | 264 | return -ENOMEM; |
226 | if (snd_hda_ctl_add(codec, nid, kctl) < 0) | 265 | err = snd_hda_ctl_add(codec, nid, kctl); |
227 | return -ENOMEM; | 266 | if (err < 0) |
267 | return err; | ||
228 | jack->kctl = kctl; | 268 | jack->kctl = kctl; |
229 | snd_kctl_jack_report(codec->bus->card, kctl, | 269 | state = snd_hda_jack_detect(codec, nid); |
230 | snd_hda_jack_detect(codec, nid)); | 270 | snd_kctl_jack_report(codec->bus->card, kctl, state); |
271 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
272 | jack->type = get_input_jack_type(codec, nid); | ||
273 | err = snd_jack_new(codec->bus->card, name, jack->type, &jack->jack); | ||
274 | if (err < 0) | ||
275 | return err; | ||
276 | jack->jack->private_data = jack; | ||
277 | jack->jack->private_free = hda_free_jack_priv; | ||
278 | snd_jack_report(jack->jack, state ? jack->type : 0); | ||
279 | #endif | ||
231 | return 0; | 280 | return 0; |
232 | } | 281 | } |
233 | EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl); | 282 | EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctl); |
@@ -302,91 +351,3 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec, | |||
302 | return 0; | 351 | return 0; |
303 | } | 352 | } |
304 | EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls); | 353 | EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls); |
305 | |||
306 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
307 | /* | ||
308 | * Input-jack notification support | ||
309 | */ | ||
310 | static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid, | ||
311 | int type) | ||
312 | { | ||
313 | switch (type) { | ||
314 | case SND_JACK_HEADPHONE: | ||
315 | return "Headphone"; | ||
316 | case SND_JACK_MICROPHONE: | ||
317 | return "Mic"; | ||
318 | case SND_JACK_LINEOUT: | ||
319 | return "Line-out"; | ||
320 | case SND_JACK_LINEIN: | ||
321 | return "Line-in"; | ||
322 | case SND_JACK_HEADSET: | ||
323 | return "Headset"; | ||
324 | case SND_JACK_VIDEOOUT: | ||
325 | return "HDMI/DP"; | ||
326 | default: | ||
327 | return "Misc"; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | static void hda_free_jack_priv(struct snd_jack *jack) | ||
332 | { | ||
333 | struct hda_jack_tbl *jacks = jack->private_data; | ||
334 | jacks->nid = 0; | ||
335 | jacks->jack = NULL; | ||
336 | } | ||
337 | |||
338 | int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type, | ||
339 | const char *name) | ||
340 | { | ||
341 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid); | ||
342 | int err; | ||
343 | |||
344 | if (!jack) | ||
345 | return -ENOMEM; | ||
346 | if (!name) | ||
347 | name = get_jack_default_name(codec, nid, type); | ||
348 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); | ||
349 | if (err < 0) | ||
350 | return err; | ||
351 | jack->type = type; | ||
352 | jack->jack->private_data = jack; | ||
353 | jack->jack->private_free = hda_free_jack_priv; | ||
354 | return 0; | ||
355 | } | ||
356 | EXPORT_SYMBOL_HDA(snd_hda_input_jack_add); | ||
357 | |||
358 | void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid) | ||
359 | { | ||
360 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid); | ||
361 | unsigned int pin_ctl; | ||
362 | unsigned int present; | ||
363 | int type; | ||
364 | |||
365 | if (!jack || !jack->jack) | ||
366 | return; | ||
367 | |||
368 | present = snd_hda_jack_detect(codec, nid); | ||
369 | type = jack->type; | ||
370 | if (type == (SND_JACK_HEADPHONE | SND_JACK_LINEOUT)) { | ||
371 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | ||
372 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
373 | type = (pin_ctl & AC_PINCTL_HP_EN) ? | ||
374 | SND_JACK_HEADPHONE : SND_JACK_LINEOUT; | ||
375 | } | ||
376 | snd_jack_report(jack->jack, present ? type : 0); | ||
377 | } | ||
378 | EXPORT_SYMBOL_HDA(snd_hda_input_jack_report); | ||
379 | |||
380 | /* free jack instances manually when clearing/reconfiguring */ | ||
381 | static void snd_hda_input_jack_free(struct hda_codec *codec) | ||
382 | { | ||
383 | if (!codec->bus->shutdown && codec->jacktbl.list) { | ||
384 | struct hda_jack_tbl *jack = codec->jacktbl.list; | ||
385 | int i; | ||
386 | for (i = 0; i < codec->jacktbl.used; i++, jack++) { | ||
387 | if (jack->jack) | ||
388 | snd_device_free(codec->bus->card, jack->jack); | ||
389 | } | ||
390 | } | ||
391 | } | ||
392 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ | ||
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index ef09716aeb6f..e1abc07f7436 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -674,24 +674,4 @@ static inline void snd_hda_eld_proc_free(struct hda_codec *codec, | |||
674 | #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 | 674 | #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 |
675 | void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen); | 675 | void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen); |
676 | 676 | ||
677 | /* | ||
678 | * Input-jack notification support | ||
679 | */ | ||
680 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
681 | int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type, | ||
682 | const char *name); | ||
683 | void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid); | ||
684 | #else /* CONFIG_SND_HDA_INPUT_JACK */ | ||
685 | static inline int snd_hda_input_jack_add(struct hda_codec *codec, | ||
686 | hda_nid_t nid, int type, | ||
687 | const char *name) | ||
688 | { | ||
689 | return 0; | ||
690 | } | ||
691 | static inline void snd_hda_input_jack_report(struct hda_codec *codec, | ||
692 | hda_nid_t nid) | ||
693 | { | ||
694 | } | ||
695 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ | ||
696 | |||
697 | #endif /* __SOUND_HDA_LOCAL_H */ | 677 | #endif /* __SOUND_HDA_LOCAL_H */ |
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) |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index bb8cfc68cd73..66dc7e651758 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -1005,8 +1005,6 @@ static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, bool retry) | |||
1005 | msecs_to_jiffies(300)); | 1005 | msecs_to_jiffies(300)); |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | |||
1009 | snd_hda_input_jack_report(codec, pin_nid); | ||
1010 | } | 1008 | } |
1011 | 1009 | ||
1012 | static void hdmi_repoll_eld(struct work_struct *work) | 1010 | static void hdmi_repoll_eld(struct work_struct *work) |
@@ -1232,21 +1230,15 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) | |||
1232 | 1230 | ||
1233 | static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx) | 1231 | static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx) |
1234 | { | 1232 | { |
1235 | int err; | 1233 | char hdmi_str[32] = "HDMI/DP"; |
1236 | char hdmi_str[32]; | ||
1237 | struct hdmi_spec *spec = codec->spec; | 1234 | struct hdmi_spec *spec = codec->spec; |
1238 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1235 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; |
1239 | int pcmdev = spec->pcm_rec[pin_idx].device; | 1236 | int pcmdev = spec->pcm_rec[pin_idx].device; |
1240 | 1237 | ||
1241 | snprintf(hdmi_str, sizeof(hdmi_str), "HDMI/DP,pcm=%d", pcmdev); | 1238 | if (pcmdev > 0) |
1242 | 1239 | sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev); | |
1243 | err = snd_hda_input_jack_add(codec, per_pin->pin_nid, | ||
1244 | SND_JACK_VIDEOOUT, pcmdev > 0 ? hdmi_str : NULL); | ||
1245 | if (err < 0) | ||
1246 | return err; | ||
1247 | 1240 | ||
1248 | hdmi_present_sense(per_pin, false); | 1241 | return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, 0); |
1249 | return 0; | ||
1250 | } | 1242 | } |
1251 | 1243 | ||
1252 | static int generic_hdmi_build_controls(struct hda_codec *codec) | 1244 | static int generic_hdmi_build_controls(struct hda_codec *codec) |
@@ -1276,10 +1268,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) | |||
1276 | 1268 | ||
1277 | if (err < 0) | 1269 | if (err < 0) |
1278 | return err; | 1270 | return err; |
1279 | err = snd_hda_jack_add_kctl(codec, per_pin->pin_nid, | 1271 | |
1280 | "HDMI", pin_idx); | 1272 | hdmi_present_sense(per_pin, false); |
1281 | if (err < 0) | ||
1282 | return err; | ||
1283 | } | 1273 | } |
1284 | 1274 | ||
1285 | return 0; | 1275 | return 0; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 933c8cf23b27..641c8295b643 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -461,46 +461,6 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
461 | } | 461 | } |
462 | 462 | ||
463 | /* | 463 | /* |
464 | * Jack-reporting via input-jack layer | ||
465 | */ | ||
466 | |||
467 | /* initialization of jacks; currently checks only a few known pins */ | ||
468 | static int alc_init_jacks(struct hda_codec *codec) | ||
469 | { | ||
470 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
471 | struct alc_spec *spec = codec->spec; | ||
472 | int err; | ||
473 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | ||
474 | unsigned int mic_nid = spec->ext_mic_pin; | ||
475 | unsigned int dock_nid = spec->dock_mic_pin; | ||
476 | |||
477 | if (hp_nid) { | ||
478 | err = snd_hda_input_jack_add(codec, hp_nid, | ||
479 | SND_JACK_HEADPHONE, NULL); | ||
480 | if (err < 0) | ||
481 | return err; | ||
482 | snd_hda_input_jack_report(codec, hp_nid); | ||
483 | } | ||
484 | |||
485 | if (mic_nid) { | ||
486 | err = snd_hda_input_jack_add(codec, mic_nid, | ||
487 | SND_JACK_MICROPHONE, NULL); | ||
488 | if (err < 0) | ||
489 | return err; | ||
490 | snd_hda_input_jack_report(codec, mic_nid); | ||
491 | } | ||
492 | if (dock_nid) { | ||
493 | err = snd_hda_input_jack_add(codec, dock_nid, | ||
494 | SND_JACK_MICROPHONE, NULL); | ||
495 | if (err < 0) | ||
496 | return err; | ||
497 | snd_hda_input_jack_report(codec, dock_nid); | ||
498 | } | ||
499 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ | ||
500 | return 0; | ||
501 | } | ||
502 | |||
503 | /* | ||
504 | * Jack detections for HP auto-mute and mic-switch | 464 | * Jack detections for HP auto-mute and mic-switch |
505 | */ | 465 | */ |
506 | 466 | ||
@@ -513,7 +473,6 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) | |||
513 | hda_nid_t nid = pins[i]; | 473 | hda_nid_t nid = pins[i]; |
514 | if (!nid) | 474 | if (!nid) |
515 | break; | 475 | break; |
516 | snd_hda_input_jack_report(codec, nid); | ||
517 | present |= snd_hda_jack_detect(codec, nid); | 476 | present |= snd_hda_jack_detect(codec, nid); |
518 | } | 477 | } |
519 | return present; | 478 | return present; |
@@ -653,10 +612,6 @@ static void alc_mic_automute(struct hda_codec *codec) | |||
653 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); | 612 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
654 | else | 613 | else |
655 | alc_mux_select(codec, 0, spec->int_mic_idx, false); | 614 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
656 | |||
657 | snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]); | ||
658 | if (spec->dock_mic_idx >= 0) | ||
659 | snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]); | ||
660 | } | 615 | } |
661 | 616 | ||
662 | /* unsolicited event for HP jack sensing */ | 617 | /* unsolicited event for HP jack sensing */ |
@@ -4686,7 +4641,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
4686 | if (board_config == ALC_MODEL_AUTO) | 4641 | if (board_config == ALC_MODEL_AUTO) |
4687 | spec->init_hook = alc_auto_init_std; | 4642 | spec->init_hook = alc_auto_init_std; |
4688 | 4643 | ||
4689 | alc_init_jacks(codec); | ||
4690 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4644 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4691 | if (!spec->loopback.amplist) | 4645 | if (!spec->loopback.amplist) |
4692 | spec->loopback.amplist = alc882_loopbacks; | 4646 | spec->loopback.amplist = alc882_loopbacks; |
@@ -4866,7 +4820,6 @@ static int patch_alc262(struct hda_codec *codec) | |||
4866 | spec->init_hook = alc_auto_init_std; | 4820 | spec->init_hook = alc_auto_init_std; |
4867 | spec->shutup = alc_eapd_shutup; | 4821 | spec->shutup = alc_eapd_shutup; |
4868 | 4822 | ||
4869 | alc_init_jacks(codec); | ||
4870 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4823 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4871 | if (!spec->loopback.amplist) | 4824 | if (!spec->loopback.amplist) |
4872 | spec->loopback.amplist = alc262_loopbacks; | 4825 | spec->loopback.amplist = alc262_loopbacks; |
@@ -4979,8 +4932,6 @@ static int patch_alc268(struct hda_codec *codec) | |||
4979 | spec->init_hook = alc_auto_init_std; | 4932 | spec->init_hook = alc_auto_init_std; |
4980 | spec->shutup = alc_eapd_shutup; | 4933 | spec->shutup = alc_eapd_shutup; |
4981 | 4934 | ||
4982 | alc_init_jacks(codec); | ||
4983 | |||
4984 | return 0; | 4935 | return 0; |
4985 | 4936 | ||
4986 | error: | 4937 | error: |
@@ -5538,7 +5489,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
5538 | spec->init_hook = alc_auto_init_std; | 5489 | spec->init_hook = alc_auto_init_std; |
5539 | spec->shutup = alc269_shutup; | 5490 | spec->shutup = alc269_shutup; |
5540 | 5491 | ||
5541 | alc_init_jacks(codec); | ||
5542 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 5492 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5543 | if (!spec->loopback.amplist) | 5493 | if (!spec->loopback.amplist) |
5544 | spec->loopback.amplist = alc269_loopbacks; | 5494 | spec->loopback.amplist = alc269_loopbacks; |
@@ -6153,8 +6103,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
6153 | spec->init_hook = alc_auto_init_std; | 6103 | spec->init_hook = alc_auto_init_std; |
6154 | spec->shutup = alc_eapd_shutup; | 6104 | spec->shutup = alc_eapd_shutup; |
6155 | 6105 | ||
6156 | alc_init_jacks(codec); | ||
6157 | |||
6158 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 6106 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6159 | if (!spec->loopback.amplist) | 6107 | if (!spec->loopback.amplist) |
6160 | spec->loopback.amplist = alc662_loopbacks; | 6108 | spec->loopback.amplist = alc662_loopbacks; |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 0988dc4890a1..2d4156c583c6 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -1084,13 +1084,10 @@ static const char * const slave_sws[] = { | |||
1084 | }; | 1084 | }; |
1085 | 1085 | ||
1086 | static void stac92xx_free_kctls(struct hda_codec *codec); | 1086 | static void stac92xx_free_kctls(struct hda_codec *codec); |
1087 | static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type); | ||
1088 | 1087 | ||
1089 | static int stac92xx_build_controls(struct hda_codec *codec) | 1088 | static int stac92xx_build_controls(struct hda_codec *codec) |
1090 | { | 1089 | { |
1091 | struct sigmatel_spec *spec = codec->spec; | 1090 | struct sigmatel_spec *spec = codec->spec; |
1092 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
1093 | hda_nid_t nid; | ||
1094 | int err; | 1091 | int err; |
1095 | int i; | 1092 | int i; |
1096 | 1093 | ||
@@ -1176,32 +1173,6 @@ static int stac92xx_build_controls(struct hda_codec *codec) | |||
1176 | 1173 | ||
1177 | stac92xx_free_kctls(codec); /* no longer needed */ | 1174 | stac92xx_free_kctls(codec); /* no longer needed */ |
1178 | 1175 | ||
1179 | /* create jack input elements */ | ||
1180 | if (spec->hp_detect) { | ||
1181 | for (i = 0; i < cfg->hp_outs; i++) { | ||
1182 | int type = SND_JACK_HEADPHONE; | ||
1183 | nid = cfg->hp_pins[i]; | ||
1184 | /* jack detection */ | ||
1185 | if (cfg->hp_outs == i) | ||
1186 | type |= SND_JACK_LINEOUT; | ||
1187 | err = stac92xx_add_jack(codec, nid, type); | ||
1188 | if (err < 0) | ||
1189 | return err; | ||
1190 | } | ||
1191 | } | ||
1192 | for (i = 0; i < cfg->line_outs; i++) { | ||
1193 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], | ||
1194 | SND_JACK_LINEOUT); | ||
1195 | if (err < 0) | ||
1196 | return err; | ||
1197 | } | ||
1198 | for (i = 0; i < cfg->num_inputs; i++) { | ||
1199 | nid = cfg->inputs[i].pin; | ||
1200 | err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE); | ||
1201 | if (err < 0) | ||
1202 | return err; | ||
1203 | } | ||
1204 | |||
1205 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); | 1176 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
1206 | if (err < 0) | 1177 | if (err < 0) |
1207 | return err; | 1178 | return err; |
@@ -4158,22 +4129,6 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, | |||
4158 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ | 4129 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
4159 | } | 4130 | } |
4160 | 4131 | ||
4161 | static int stac92xx_add_jack(struct hda_codec *codec, | ||
4162 | hda_nid_t nid, int type) | ||
4163 | { | ||
4164 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
4165 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
4166 | int connectivity = get_defcfg_connect(def_conf); | ||
4167 | |||
4168 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) | ||
4169 | return 0; | ||
4170 | |||
4171 | return snd_hda_input_jack_add(codec, nid, type, NULL); | ||
4172 | #else | ||
4173 | return 0; | ||
4174 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ | ||
4175 | } | ||
4176 | |||
4177 | static int stac_add_event(struct hda_codec *codec, hda_nid_t nid, | 4132 | static int stac_add_event(struct hda_codec *codec, hda_nid_t nid, |
4178 | unsigned char type, int data) | 4133 | unsigned char type, int data) |
4179 | { | 4134 | { |
@@ -4778,7 +4733,6 @@ static void handle_unsol_event(struct hda_codec *codec, | |||
4778 | case STAC_PWR_EVENT: | 4733 | case STAC_PWR_EVENT: |
4779 | if (spec->num_pwrs > 0) | 4734 | if (spec->num_pwrs > 0) |
4780 | stac92xx_pin_sense(codec, event->nid); | 4735 | stac92xx_pin_sense(codec, event->nid); |
4781 | snd_hda_input_jack_report(codec, event->nid); | ||
4782 | 4736 | ||
4783 | switch (codec->subsystem_id) { | 4737 | switch (codec->subsystem_id) { |
4784 | case 0x103c308f: | 4738 | case 0x103c308f: |