aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_analog.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-03-01 06:38:49 -0500
committerTakashi Iwai <tiwai@suse.de>2010-03-01 06:38:49 -0500
commit12c2a682b55a40f2a986e36d6632110029bc63a5 (patch)
treeba21f049e4859411f6c135d597dc26260963ce7c /sound/pci/hda/patch_analog.c
parenta86ba28583987b85845ed61be5f12aafb5fc4971 (diff)
parentaefbd3e823d4fe219bb6420b0cac505847270507 (diff)
Merge branch 'topic/misc' into for-linus
Diffstat (limited to 'sound/pci/hda/patch_analog.c')
-rw-r--r--sound/pci/hda/patch_analog.c115
1 files changed, 110 insertions, 5 deletions
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 69a941c7b158..214301d568fa 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -174,6 +174,7 @@ static struct snd_kcontrol_new ad_beep_mixer[] = {
174static int ad198x_build_controls(struct hda_codec *codec) 174static int ad198x_build_controls(struct hda_codec *codec)
175{ 175{
176 struct ad198x_spec *spec = codec->spec; 176 struct ad198x_spec *spec = codec->spec;
177 struct snd_kcontrol *kctl;
177 unsigned int i; 178 unsigned int i;
178 int err; 179 int err;
179 180
@@ -208,9 +209,7 @@ static int ad198x_build_controls(struct hda_codec *codec)
208 if (!kctl) 209 if (!kctl)
209 return -ENOMEM; 210 return -ENOMEM;
210 kctl->private_value = spec->beep_amp; 211 kctl->private_value = spec->beep_amp;
211 err = snd_hda_ctl_add(codec, 212 err = snd_hda_ctl_add(codec, 0, kctl);
212 get_amp_nid_(spec->beep_amp),
213 kctl);
214 if (err < 0) 213 if (err < 0)
215 return err; 214 return err;
216 } 215 }
@@ -239,6 +238,27 @@ static int ad198x_build_controls(struct hda_codec *codec)
239 } 238 }
240 239
241 ad198x_free_kctls(codec); /* no longer needed */ 240 ad198x_free_kctls(codec); /* no longer needed */
241
242 /* assign Capture Source enums to NID */
243 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
244 if (!kctl)
245 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
246 for (i = 0; kctl && i < kctl->count; i++) {
247 err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]);
248 if (err < 0)
249 return err;
250 }
251
252 /* assign IEC958 enums to NID */
253 kctl = snd_hda_find_mixer_ctl(codec,
254 SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source");
255 if (kctl) {
256 err = snd_hda_add_nid(codec, kctl, 0,
257 spec->multiout.dig_out_nid);
258 if (err < 0)
259 return err;
260 }
261
242 return 0; 262 return 0;
243} 263}
244 264
@@ -421,6 +441,11 @@ static int ad198x_build_pcms(struct hda_codec *codec)
421 return 0; 441 return 0;
422} 442}
423 443
444static inline void ad198x_shutup(struct hda_codec *codec)
445{
446 snd_hda_shutup_pins(codec);
447}
448
424static void ad198x_free_kctls(struct hda_codec *codec) 449static void ad198x_free_kctls(struct hda_codec *codec)
425{ 450{
426 struct ad198x_spec *spec = codec->spec; 451 struct ad198x_spec *spec = codec->spec;
@@ -434,6 +459,46 @@ static void ad198x_free_kctls(struct hda_codec *codec)
434 snd_array_free(&spec->kctls); 459 snd_array_free(&spec->kctls);
435} 460}
436 461
462static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
463 hda_nid_t hp)
464{
465 struct ad198x_spec *spec = codec->spec;
466 snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
467 !spec->inv_eapd ? 0x00 : 0x02);
468 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
469 !spec->inv_eapd ? 0x00 : 0x02);
470}
471
472static void ad198x_power_eapd(struct hda_codec *codec)
473{
474 /* We currently only handle front, HP */
475 switch (codec->vendor_id) {
476 case 0x11d41882:
477 case 0x11d4882a:
478 case 0x11d41884:
479 case 0x11d41984:
480 case 0x11d41883:
481 case 0x11d4184a:
482 case 0x11d4194a:
483 case 0x11d4194b:
484 ad198x_power_eapd_write(codec, 0x12, 0x11);
485 break;
486 case 0x11d41981:
487 case 0x11d41983:
488 ad198x_power_eapd_write(codec, 0x05, 0x06);
489 break;
490 case 0x11d41986:
491 ad198x_power_eapd_write(codec, 0x1b, 0x1a);
492 break;
493 case 0x11d41988:
494 case 0x11d4198b:
495 case 0x11d4989a:
496 case 0x11d4989b:
497 ad198x_power_eapd_write(codec, 0x29, 0x22);
498 break;
499 }
500}
501
437static void ad198x_free(struct hda_codec *codec) 502static void ad198x_free(struct hda_codec *codec)
438{ 503{
439 struct ad198x_spec *spec = codec->spec; 504 struct ad198x_spec *spec = codec->spec;
@@ -441,11 +506,29 @@ static void ad198x_free(struct hda_codec *codec)
441 if (!spec) 506 if (!spec)
442 return; 507 return;
443 508
509 ad198x_shutup(codec);
444 ad198x_free_kctls(codec); 510 ad198x_free_kctls(codec);
445 kfree(spec); 511 kfree(spec);
446 snd_hda_detach_beep_device(codec); 512 snd_hda_detach_beep_device(codec);
447} 513}
448 514
515#ifdef SND_HDA_NEEDS_RESUME
516static int ad198x_suspend(struct hda_codec *codec, pm_message_t state)
517{
518 ad198x_shutup(codec);
519 ad198x_power_eapd(codec);
520 return 0;
521}
522
523static int ad198x_resume(struct hda_codec *codec)
524{
525 ad198x_init(codec);
526 snd_hda_codec_resume_amp(codec);
527 snd_hda_codec_resume_cache(codec);
528 return 0;
529}
530#endif
531
449static struct hda_codec_ops ad198x_patch_ops = { 532static struct hda_codec_ops ad198x_patch_ops = {
450 .build_controls = ad198x_build_controls, 533 .build_controls = ad198x_build_controls,
451 .build_pcms = ad198x_build_pcms, 534 .build_pcms = ad198x_build_pcms,
@@ -454,6 +537,11 @@ static struct hda_codec_ops ad198x_patch_ops = {
454#ifdef CONFIG_SND_HDA_POWER_SAVE 537#ifdef CONFIG_SND_HDA_POWER_SAVE
455 .check_power_status = ad198x_check_power_status, 538 .check_power_status = ad198x_check_power_status,
456#endif 539#endif
540#ifdef SND_HDA_NEEDS_RESUME
541 .suspend = ad198x_suspend,
542 .resume = ad198x_resume,
543#endif
544 .reboot_notify = ad198x_shutup,
457}; 545};
458 546
459 547
@@ -701,6 +789,7 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
701 { 789 {
702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 790 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
703 .name = "External Amplifier", 791 .name = "External Amplifier",
792 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
704 .info = ad198x_eapd_info, 793 .info = ad198x_eapd_info,
705 .get = ad198x_eapd_get, 794 .get = ad198x_eapd_get,
706 .put = ad198x_eapd_put, 795 .put = ad198x_eapd_put,
@@ -808,6 +897,7 @@ static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
808 { 897 {
809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
810 .name = "Master Playback Switch", 899 .name = "Master Playback Switch",
900 .subdevice = HDA_SUBDEV_AMP_FLAG,
811 .info = snd_hda_mixer_amp_switch_info, 901 .info = snd_hda_mixer_amp_switch_info,
812 .get = snd_hda_mixer_amp_switch_get, 902 .get = snd_hda_mixer_amp_switch_get,
813 .put = ad1986a_hp_master_sw_put, 903 .put = ad1986a_hp_master_sw_put,
@@ -1612,6 +1702,7 @@ static struct snd_kcontrol_new ad1981_hp_mixers[] = {
1612 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol), 1702 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol),
1613 { 1703 {
1614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1705 .subdevice = HDA_SUBDEV_NID_FLAG | 0x05,
1615 .name = "Master Playback Switch", 1706 .name = "Master Playback Switch",
1616 .info = ad198x_eapd_info, 1707 .info = ad198x_eapd_info,
1617 .get = ad198x_eapd_get, 1708 .get = ad198x_eapd_get,
@@ -2136,6 +2227,7 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
2136 { 2227 {
2137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2138 .name = "External Amplifier", 2229 .name = "External Amplifier",
2230 .subdevice = HDA_SUBDEV_NID_FLAG | 0x12,
2139 .info = ad198x_eapd_info, 2231 .info = ad198x_eapd_info,
2140 .get = ad198x_eapd_get, 2232 .get = ad198x_eapd_get,
2141 .put = ad198x_eapd_put, 2233 .put = ad198x_eapd_put,
@@ -2257,6 +2349,7 @@ static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = {
2257 { 2349 {
2258 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2259 .name = "IEC958 Playback Source", 2351 .name = "IEC958 Playback Source",
2352 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
2260 .info = ad1988_spdif_playback_source_info, 2353 .info = ad1988_spdif_playback_source_info,
2261 .get = ad1988_spdif_playback_source_get, 2354 .get = ad1988_spdif_playback_source_get,
2262 .put = ad1988_spdif_playback_source_put, 2355 .put = ad1988_spdif_playback_source_put,
@@ -2372,6 +2465,12 @@ static struct hda_verb ad1988_spdif_init_verbs[] = {
2372 { } 2465 { }
2373}; 2466};
2374 2467
2468static struct hda_verb ad1988_spdif_in_init_verbs[] = {
2469 /* unmute SPDIF input pin */
2470 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2471 { }
2472};
2473
2375/* AD1989 has no ADC -> SPDIF route */ 2474/* AD1989 has no ADC -> SPDIF route */
2376static struct hda_verb ad1989_spdif_init_verbs[] = { 2475static struct hda_verb ad1989_spdif_init_verbs[] = {
2377 /* SPDIF-1 out pin */ 2476 /* SPDIF-1 out pin */
@@ -2589,7 +2688,7 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name,
2589 if (! knew->name) 2688 if (! knew->name)
2590 return -ENOMEM; 2689 return -ENOMEM;
2591 if (get_amp_nid_(val)) 2690 if (get_amp_nid_(val))
2592 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); 2691 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2593 knew->private_value = val; 2692 knew->private_value = val;
2594 return 0; 2693 return 0;
2595} 2694}
@@ -3107,8 +3206,11 @@ static int patch_ad1988(struct hda_codec *codec)
3107 ad1988_spdif_init_verbs; 3206 ad1988_spdif_init_verbs;
3108 } 3207 }
3109 } 3208 }
3110 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) 3209 if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) {
3111 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; 3210 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers;
3211 spec->init_verbs[spec->num_init_verbs++] =
3212 ad1988_spdif_in_init_verbs;
3213 }
3112 3214
3113 codec->patch_ops = ad198x_patch_ops; 3215 codec->patch_ops = ad198x_patch_ops;
3114 switch (board_config) { 3216 switch (board_config) {
@@ -3747,6 +3849,7 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3747 { 3849 {
3748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3749 .name = "Master Playback Switch", 3851 .name = "Master Playback Switch",
3852 .subdevice = HDA_SUBDEV_AMP_FLAG,
3750 .info = snd_hda_mixer_amp_switch_info, 3853 .info = snd_hda_mixer_amp_switch_info,
3751 .get = snd_hda_mixer_amp_switch_get, 3854 .get = snd_hda_mixer_amp_switch_get,
3752 .put = ad1884a_mobile_master_sw_put, 3855 .put = ad1884a_mobile_master_sw_put,
@@ -3775,6 +3878,7 @@ static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3775 { 3878 {
3776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3777 .name = "Master Playback Switch", 3880 .name = "Master Playback Switch",
3881 .subdevice = HDA_SUBDEV_AMP_FLAG,
3778 .info = snd_hda_mixer_amp_switch_info, 3882 .info = snd_hda_mixer_amp_switch_info,
3779 .get = snd_hda_mixer_amp_switch_get, 3883 .get = snd_hda_mixer_amp_switch_get,
3780 .put = ad1884a_mobile_master_sw_put, 3884 .put = ad1884a_mobile_master_sw_put,
@@ -4116,6 +4220,7 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = {
4116/* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ 4220/* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/
4117 { 4221 {
4118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4222 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4223 .subdevice = HDA_SUBDEV_AMP_FLAG,
4119 .name = "Master Playback Switch", 4224 .name = "Master Playback Switch",
4120 .info = snd_hda_mixer_amp_switch_info, 4225 .info = snd_hda_mixer_amp_switch_info,
4121 .get = snd_hda_mixer_amp_switch_get, 4226 .get = snd_hda_mixer_amp_switch_get,