aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2009-12-08 10:13:32 -0500
committerJaroslav Kysela <perex@perex.cz>2009-12-15 03:33:04 -0500
commit5b0cb1d850c26893b1468b3a519433a1b7a176be (patch)
treec6f4ab97db6de9230b02d6cfce8976b762f3b485 /sound/pci/hda/patch_realtek.c
parentf40542532e96dda5506eb76badea322f2ae4731c (diff)
ALSA: hda - add more NID->Control mapping
This set of changes add missing NID values to some static control elemenents. Also, it handles all "Capture Source" or "Input Source" controls. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c120
1 files changed, 118 insertions, 2 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 888b6313eeca..6b0b8728f6b7 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -627,6 +627,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
627 627
628#define ALC_PIN_MODE(xname, nid, dir) \ 628#define ALC_PIN_MODE(xname, nid, dir) \
629 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 629 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
630 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
630 .info = alc_pin_mode_info, \ 631 .info = alc_pin_mode_info, \
631 .get = alc_pin_mode_get, \ 632 .get = alc_pin_mode_get, \
632 .put = alc_pin_mode_put, \ 633 .put = alc_pin_mode_put, \
@@ -678,6 +679,7 @@ static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
678} 679}
679#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ 680#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
680 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 681 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
682 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
681 .info = alc_gpio_data_info, \ 683 .info = alc_gpio_data_info, \
682 .get = alc_gpio_data_get, \ 684 .get = alc_gpio_data_get, \
683 .put = alc_gpio_data_put, \ 685 .put = alc_gpio_data_put, \
@@ -732,6 +734,7 @@ static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
732} 734}
733#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ 735#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
737 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
735 .info = alc_spdif_ctrl_info, \ 738 .info = alc_spdif_ctrl_info, \
736 .get = alc_spdif_ctrl_get, \ 739 .get = alc_spdif_ctrl_get, \
737 .put = alc_spdif_ctrl_put, \ 740 .put = alc_spdif_ctrl_put, \
@@ -785,6 +788,7 @@ static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
785 788
786#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ 789#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
787 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
791 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
788 .info = alc_eapd_ctrl_info, \ 792 .info = alc_eapd_ctrl_info, \
789 .get = alc_eapd_ctrl_get, \ 793 .get = alc_eapd_ctrl_get, \
790 .put = alc_eapd_ctrl_put, \ 794 .put = alc_eapd_ctrl_put, \
@@ -2410,6 +2414,15 @@ static const char *alc_slave_sws[] = {
2410 * build control elements 2414 * build control elements
2411 */ 2415 */
2412 2416
2417#define NID_MAPPING (-1)
2418
2419#define SUBDEV_SPEAKER_ (0 << 6)
2420#define SUBDEV_HP_ (1 << 6)
2421#define SUBDEV_LINE_ (2 << 6)
2422#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2423#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2424#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2425
2413static void alc_free_kctls(struct hda_codec *codec); 2426static void alc_free_kctls(struct hda_codec *codec);
2414 2427
2415#ifdef CONFIG_SND_HDA_INPUT_BEEP 2428#ifdef CONFIG_SND_HDA_INPUT_BEEP
@@ -2424,8 +2437,11 @@ static struct snd_kcontrol_new alc_beep_mixer[] = {
2424static int alc_build_controls(struct hda_codec *codec) 2437static int alc_build_controls(struct hda_codec *codec)
2425{ 2438{
2426 struct alc_spec *spec = codec->spec; 2439 struct alc_spec *spec = codec->spec;
2427 int err; 2440 struct snd_kcontrol *kctl;
2428 int i; 2441 struct snd_kcontrol_new *knew;
2442 int i, j, err;
2443 unsigned int u;
2444 hda_nid_t nid;
2429 2445
2430 for (i = 0; i < spec->num_mixers; i++) { 2446 for (i = 0; i < spec->num_mixers; i++) {
2431 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 2447 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
@@ -2494,6 +2510,73 @@ static int alc_build_controls(struct hda_codec *codec)
2494 } 2510 }
2495 2511
2496 alc_free_kctls(codec); /* no longer needed */ 2512 alc_free_kctls(codec); /* no longer needed */
2513
2514 /* assign Capture Source enums to NID */
2515 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2516 if (!kctl)
2517 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2518 for (i = 0; kctl && i < kctl->count; i++) {
2519 err = snd_hda_add_nids(codec, kctl, i, spec->capsrc_nids,
2520 spec->input_mux->num_items);
2521 if (err < 0)
2522 return err;
2523 }
2524 if (spec->cap_mixer) {
2525 const char *kname = kctl ? kctl->id.name : NULL;
2526 for (knew = spec->cap_mixer; knew->name; knew++) {
2527 if (kname && strcmp(knew->name, kname) == 0)
2528 continue;
2529 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2530 for (i = 0; kctl && i < kctl->count; i++) {
2531 err = snd_hda_add_nid(codec, kctl, i,
2532 spec->adc_nids[i]);
2533 if (err < 0)
2534 return err;
2535 }
2536 }
2537 }
2538
2539 /* other nid->control mapping */
2540 for (i = 0; i < spec->num_mixers; i++) {
2541 for (knew = spec->mixers[i]; knew->name; knew++) {
2542 if (knew->iface != NID_MAPPING)
2543 continue;
2544 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2545 if (kctl == NULL)
2546 continue;
2547 u = knew->subdevice;
2548 for (j = 0; j < 4; j++, u >>= 8) {
2549 nid = u & 0x3f;
2550 if (nid == 0)
2551 continue;
2552 switch (u & 0xc0) {
2553 case SUBDEV_SPEAKER_:
2554 nid = spec->autocfg.speaker_pins[nid];
2555 break;
2556 case SUBDEV_LINE_:
2557 nid = spec->autocfg.line_out_pins[nid];
2558 break;
2559 case SUBDEV_HP_:
2560 nid = spec->autocfg.hp_pins[nid];
2561 break;
2562 default:
2563 continue;
2564 }
2565 err = snd_hda_add_nid(codec, kctl, 0, nid);
2566 if (err < 0)
2567 return err;
2568 }
2569 u = knew->private_value;
2570 for (j = 0; j < 4; j++, u >>= 8) {
2571 nid = u & 0xff;
2572 if (nid == 0)
2573 continue;
2574 err = snd_hda_add_nid(codec, kctl, 0, nid);
2575 if (err < 0)
2576 return err;
2577 }
2578 }
2579 }
2497 return 0; 2580 return 0;
2498} 2581}
2499 2582
@@ -3781,6 +3864,7 @@ static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3781#define PIN_CTL_TEST(xname,nid) { \ 3864#define PIN_CTL_TEST(xname,nid) { \
3782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3783 .name = xname, \ 3866 .name = xname, \
3867 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
3784 .info = alc_test_pin_ctl_info, \ 3868 .info = alc_test_pin_ctl_info, \
3785 .get = alc_test_pin_ctl_get, \ 3869 .get = alc_test_pin_ctl_get, \
3786 .put = alc_test_pin_ctl_put, \ 3870 .put = alc_test_pin_ctl_put, \
@@ -3790,6 +3874,7 @@ static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3790#define PIN_SRC_TEST(xname,nid) { \ 3874#define PIN_SRC_TEST(xname,nid) { \
3791 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3792 .name = xname, \ 3876 .name = xname, \
3877 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
3793 .info = alc_test_pin_src_info, \ 3878 .info = alc_test_pin_src_info, \
3794 .get = alc_test_pin_src_get, \ 3879 .get = alc_test_pin_src_get, \
3795 .put = alc_test_pin_src_put, \ 3880 .put = alc_test_pin_src_put, \
@@ -5080,6 +5165,7 @@ static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5080 { 5165 {
5081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5166 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5082 .name = "Master Playback Switch", 5167 .name = "Master Playback Switch",
5168 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
5083 .info = snd_ctl_boolean_mono_info, 5169 .info = snd_ctl_boolean_mono_info,
5084 .get = alc260_hp_master_sw_get, 5170 .get = alc260_hp_master_sw_get,
5085 .put = alc260_hp_master_sw_put, 5171 .put = alc260_hp_master_sw_put,
@@ -5118,6 +5204,7 @@ static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
5118 { 5204 {
5119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5120 .name = "Master Playback Switch", 5206 .name = "Master Playback Switch",
5207 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
5121 .info = snd_ctl_boolean_mono_info, 5208 .info = snd_ctl_boolean_mono_info,
5122 .get = alc260_hp_master_sw_get, 5209 .get = alc260_hp_master_sw_get,
5123 .put = alc260_hp_master_sw_put, 5210 .put = alc260_hp_master_sw_put,
@@ -10188,8 +10275,14 @@ static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10188 .info = snd_ctl_boolean_mono_info, \ 10275 .info = snd_ctl_boolean_mono_info, \
10189 .get = alc262_hp_master_sw_get, \ 10276 .get = alc262_hp_master_sw_get, \
10190 .put = alc262_hp_master_sw_put, \ 10277 .put = alc262_hp_master_sw_put, \
10278 }, \
10279 { \
10280 .iface = NID_MAPPING, \
10281 .name = "Master Playback Switch", \
10282 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
10191 } 10283 }
10192 10284
10285
10193static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 10286static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
10194 ALC262_HP_MASTER_SWITCH, 10287 ALC262_HP_MASTER_SWITCH,
10195 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 10288 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -10347,6 +10440,12 @@ static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10347 .info = snd_ctl_boolean_mono_info, \ 10440 .info = snd_ctl_boolean_mono_info, \
10348 .get = alc262_hippo_master_sw_get, \ 10441 .get = alc262_hippo_master_sw_get, \
10349 .put = alc262_hippo_master_sw_put, \ 10442 .put = alc262_hippo_master_sw_put, \
10443 }, \
10444 { \
10445 .iface = NID_MAPPING, \
10446 .name = "Master Playback Switch", \
10447 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10448 (SUBDEV_SPEAKER(0) << 16), \
10350 } 10449 }
10351 10450
10352static struct snd_kcontrol_new alc262_hippo_mixer[] = { 10451static struct snd_kcontrol_new alc262_hippo_mixer[] = {
@@ -10820,11 +10919,17 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
10820 { 10919 {
10821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10822 .name = "Master Playback Switch", 10921 .name = "Master Playback Switch",
10922 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
10823 .info = snd_hda_mixer_amp_switch_info, 10923 .info = snd_hda_mixer_amp_switch_info,
10824 .get = snd_hda_mixer_amp_switch_get, 10924 .get = snd_hda_mixer_amp_switch_get,
10825 .put = alc262_fujitsu_master_sw_put, 10925 .put = alc262_fujitsu_master_sw_put,
10826 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 10926 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10827 }, 10927 },
10928 {
10929 .iface = NID_MAPPING,
10930 .name = "Master Playback Switch",
10931 .private_value = 0x1b,
10932 },
10828 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 10933 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10829 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 10934 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10830 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
@@ -10855,6 +10960,7 @@ static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10855 { 10960 {
10856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 10961 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10857 .name = "Master Playback Switch", 10962 .name = "Master Playback Switch",
10963 .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
10858 .info = snd_hda_mixer_amp_switch_info, 10964 .info = snd_hda_mixer_amp_switch_info,
10859 .get = snd_hda_mixer_amp_switch_get, 10965 .get = snd_hda_mixer_amp_switch_get,
10860 .put = alc262_lenovo_3000_master_sw_put, 10966 .put = alc262_lenovo_3000_master_sw_put,
@@ -11009,6 +11115,11 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11009 .get = alc_mux_enum_get, 11115 .get = alc_mux_enum_get,
11010 .put = alc262_ultra_mux_enum_put, 11116 .put = alc262_ultra_mux_enum_put,
11011 }, 11117 },
11118 {
11119 .iface = NID_MAPPING,
11120 .name = "Capture Source",
11121 .private_value = 0x15,
11122 },
11012 { } /* end */ 11123 { } /* end */
11013}; 11124};
11014 11125
@@ -12026,6 +12137,7 @@ static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12026 { 12137 {
12027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12028 .name = "Master Playback Switch", 12139 .name = "Master Playback Switch",
12140 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
12029 .info = snd_hda_mixer_amp_switch_info, 12141 .info = snd_hda_mixer_amp_switch_info,
12030 .get = snd_hda_mixer_amp_switch_get, 12142 .get = snd_hda_mixer_amp_switch_get,
12031 .put = alc268_acer_master_sw_put, 12143 .put = alc268_acer_master_sw_put,
@@ -12041,6 +12153,7 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = {
12041 { 12153 {
12042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12154 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12043 .name = "Master Playback Switch", 12155 .name = "Master Playback Switch",
12156 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
12044 .info = snd_hda_mixer_amp_switch_info, 12157 .info = snd_hda_mixer_amp_switch_info,
12045 .get = snd_hda_mixer_amp_switch_get, 12158 .get = snd_hda_mixer_amp_switch_get,
12046 .put = alc268_acer_master_sw_put, 12159 .put = alc268_acer_master_sw_put,
@@ -12058,6 +12171,7 @@ static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12058 { 12171 {
12059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12060 .name = "Master Playback Switch", 12173 .name = "Master Playback Switch",
12174 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
12061 .info = snd_hda_mixer_amp_switch_info, 12175 .info = snd_hda_mixer_amp_switch_info,
12062 .get = snd_hda_mixer_amp_switch_get, 12176 .get = snd_hda_mixer_amp_switch_get,
12063 .put = alc268_acer_master_sw_put, 12177 .put = alc268_acer_master_sw_put,
@@ -13010,6 +13124,7 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13010 { 13124 {
13011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13012 .name = "Master Playback Switch", 13126 .name = "Master Playback Switch",
13127 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
13013 .info = snd_hda_mixer_amp_switch_info, 13128 .info = snd_hda_mixer_amp_switch_info,
13014 .get = snd_hda_mixer_amp_switch_get, 13129 .get = snd_hda_mixer_amp_switch_get,
13015 .put = alc268_acer_master_sw_put, 13130 .put = alc268_acer_master_sw_put,
@@ -13030,6 +13145,7 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13030 { 13145 {
13031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13032 .name = "Master Playback Switch", 13147 .name = "Master Playback Switch",
13148 .subdevice = HDA_SUBDEV_NID_FLAG | 0x14,
13033 .info = snd_hda_mixer_amp_switch_info, 13149 .info = snd_hda_mixer_amp_switch_info,
13034 .get = snd_hda_mixer_amp_switch_get, 13150 .get = snd_hda_mixer_amp_switch_get,
13035 .put = alc268_acer_master_sw_put, 13151 .put = alc268_acer_master_sw_put,