aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_sigmatel.c
diff options
context:
space:
mode:
authorMatthew Ranostay <mranostay@embeddedalley.com>2008-08-15 01:43:24 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-15 05:48:28 -0400
commit4682eee0ed64a50668c8645f136972e53fcf5a0a (patch)
treec5213b8fdf49b121a816afb224a06e012dcef1b7 /sound/pci/hda/patch_sigmatel.c
parent0072889a556373b12b687107ac6b24d2ea961ddf (diff)
ALSA: hda: dynamically create capture mux controls
Dynamically create capture mux volume controls when a output amp is detected. Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/hda/patch_sigmatel.c')
-rw-r--r--sound/pci/hda/patch_sigmatel.c52
1 files changed, 36 insertions, 16 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index fac6b3ca5fe2..75112e4b7965 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -795,7 +795,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
795 STAC_INPUT_SOURCE(1), 795 STAC_INPUT_SOURCE(1),
796 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), 796 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
797 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), 797 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
798 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
799 { } /* end */ 798 { } /* end */
800}; 799};
801 800
@@ -909,12 +908,9 @@ static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
909 908
910 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), 909 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
911 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), 910 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
912 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
913 911
914 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), 912 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
915 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), 913 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
916 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
917
918 /* analog pc-beep replaced with digital beep support */ 914 /* analog pc-beep replaced with digital beep support */
919 /* 915 /*
920 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), 916 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
@@ -932,11 +928,9 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
932 928
933 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), 929 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
934 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), 930 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
935 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
936 931
937 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), 932 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
938 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), 933 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
939 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
940 { } /* end */ 934 { } /* end */
941}; 935};
942 936
@@ -944,7 +938,6 @@ static struct snd_kcontrol_new stac925x_mixer[] = {
944 STAC_INPUT_SOURCE(1), 938 STAC_INPUT_SOURCE(1),
945 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), 939 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
946 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), 940 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
947 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
948 { } /* end */ 941 { } /* end */
949}; 942};
950 943
@@ -954,12 +947,9 @@ static struct snd_kcontrol_new stac9205_mixer[] = {
954 947
955 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), 948 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
956 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), 949 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
957 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
958 950
959 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), 951 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
960 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), 952 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
961 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
962
963 { } /* end */ 953 { } /* end */
964}; 954};
965 955
@@ -968,11 +958,9 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
968 STAC_INPUT_SOURCE(2), 958 STAC_INPUT_SOURCE(2),
969 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), 959 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
970 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), 960 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
971 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
972 961
973 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), 962 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
974 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), 963 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
975 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
976 { } /* end */ 964 { } /* end */
977}; 965};
978 966
@@ -983,15 +971,12 @@ static struct snd_kcontrol_new stac927x_mixer[] = {
983 971
984 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), 972 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
985 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), 973 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
986 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
987 974
988 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), 975 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
989 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), 976 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
990 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
991 977
992 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), 978 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
993 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), 979 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
994 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
995 { } /* end */ 980 { } /* end */
996}; 981};
997 982
@@ -2352,7 +2337,8 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2352}; 2337};
2353 2338
2354/* add dynamic controls */ 2339/* add dynamic controls */
2355static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) 2340static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2341 int idx, const char *name, unsigned long val)
2356{ 2342{
2357 struct snd_kcontrol_new *knew; 2343 struct snd_kcontrol_new *knew;
2358 2344
@@ -2372,6 +2358,7 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char
2372 2358
2373 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2359 knew = &spec->kctl_alloc[spec->num_kctl_used];
2374 *knew = stac92xx_control_templates[type]; 2360 *knew = stac92xx_control_templates[type];
2361 knew->index = idx;
2375 knew->name = kstrdup(name, GFP_KERNEL); 2362 knew->name = kstrdup(name, GFP_KERNEL);
2376 if (! knew->name) 2363 if (! knew->name)
2377 return -ENOMEM; 2364 return -ENOMEM;
@@ -2380,6 +2367,14 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char
2380 return 0; 2367 return 0;
2381} 2368}
2382 2369
2370
2371/* add dynamic controls */
2372static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2373 const char *name, unsigned long val)
2374{
2375 return stac92xx_add_control_idx(spec, type, 0, name, val);
2376}
2377
2383/* flag inputs as additional dynamic lineouts */ 2378/* flag inputs as additional dynamic lineouts */
2384static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) 2379static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2385{ 2380{
@@ -2781,6 +2776,26 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2781 return 0; 2776 return 0;
2782} 2777}
2783 2778
2779static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
2780{
2781 struct sigmatel_spec *spec = codec->spec;
2782 int wcaps, nid, i, err = 0;
2783
2784 for (i = 0; i < spec->num_muxes; i++) {
2785 nid = spec->mux_nids[i];
2786 wcaps = get_wcaps(codec, nid);
2787
2788 if (wcaps & AC_WCAP_OUT_AMP) {
2789 err = stac92xx_add_control_idx(spec,
2790 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
2791 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2792 if (err < 0)
2793 return err;
2794 }
2795 }
2796 return 0;
2797};
2798
2784/* labels for dmic mux inputs */ 2799/* labels for dmic mux inputs */
2785static const char *stac92xx_dmic_labels[5] = { 2800static const char *stac92xx_dmic_labels[5] = {
2786 "Analog Inputs", "Digital Mic 1", "Digital Mic 2", 2801 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
@@ -3079,6 +3094,11 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3079 if ((err = stac92xx_auto_create_dmic_input_ctls(codec, 3094 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3080 &spec->autocfg)) < 0) 3095 &spec->autocfg)) < 0)
3081 return err; 3096 return err;
3097 if (spec->num_muxes > 0) {
3098 err = stac92xx_auto_create_mux_input_ctls(codec);
3099 if (err < 0)
3100 return err;
3101 }
3082 3102
3083 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3103 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3084 if (spec->multiout.max_channels > 2) 3104 if (spec->multiout.max_channels > 2)