aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Molton <ian@mnementh.co.uk>2009-01-06 15:11:51 -0500
committerIan Molton <ian@mnementh.co.uk>2009-01-07 16:32:54 -0500
commitca9c1aaec4187fc9922cfb6b283fffef89286943 (patch)
tree99a4fcb97ebb759a97ef97416ab55b626dd94c03
parent227b4dc6432d271eecd0ff0aefe6f0897ec47397 (diff)
ASoC: dapm: Allow explictly named mixer controls
This patch allows you to define the mixer paths as having the same name as the paths they represent. This is required to support codecs such as the wm9705 neatly without extra controls in the alsa mixer. Signed-off-by: Ian Molton <ian@mnementh.co.uk>
-rw-r--r--Documentation/sound/alsa/soc/dapm.txt3
-rw-r--r--include/sound/soc-dapm.h11
-rw-r--r--sound/soc/soc-dapm.c47
3 files changed, 50 insertions, 11 deletions
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt
index 46f9684d0b29..9e6763264a2e 100644
--- a/Documentation/sound/alsa/soc/dapm.txt
+++ b/Documentation/sound/alsa/soc/dapm.txt
@@ -116,6 +116,9 @@ SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0),
116SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls, 116SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls,
117 ARRAY_SIZE(wm8731_output_mixer_controls)), 117 ARRAY_SIZE(wm8731_output_mixer_controls)),
118 118
119If you dont want the mixer elements prefixed with the name of the mixer widget,
120you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same
121as for SND_SOC_DAPM_MIXER.
119 122
1202.3 Platform/Machine domain Widgets 1232.3 Platform/Machine domain Widgets
121----------------------------------- 124-----------------------------------
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 4af1083e3287..cc99dd404934 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -76,6 +76,11 @@
76 wcontrols, wncontrols)\ 76 wcontrols, wncontrols)\
77{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 77{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
78 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} 78 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
79#define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \
80 wcontrols, wncontrols)\
81{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
82 .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
83 .num_kcontrols = wncontrols}
79#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \ 84#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
80{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ 85{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
81 .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0} 86 .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0}
@@ -101,6 +106,11 @@
101{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ 106{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
102 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ 107 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
103 .event = wevent, .event_flags = wflags} 108 .event = wevent, .event_flags = wflags}
109#define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \
110 wcontrols, wncontrols, wevent, wflags) \
111{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
112 .invert = winvert, .kcontrols = wcontrols, \
113 .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags}
104#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ 114#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \
105{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ 115{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
106 .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ 116 .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \
@@ -263,6 +273,7 @@ enum snd_soc_dapm_type {
263 snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ 273 snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */
264 snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ 274 snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */
265 snd_soc_dapm_mixer, /* mixes several analog signals together */ 275 snd_soc_dapm_mixer, /* mixes several analog signals together */
276 snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */
266 snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ 277 snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */
267 snd_soc_dapm_adc, /* analog to digital converter */ 278 snd_soc_dapm_adc, /* analog to digital converter */
268 snd_soc_dapm_dac, /* digital to analog converter */ 279 snd_soc_dapm_dac, /* digital to analog converter */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index ad0d801677c1..6362c7641ce5 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -54,14 +54,15 @@
54static int dapm_up_seq[] = { 54static int dapm_up_seq[] = {
55 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, 55 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
56 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, 56 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac,
57 snd_soc_dapm_mixer, snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, 57 snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_pga,
58 snd_soc_dapm_spk, snd_soc_dapm_post 58 snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post
59}; 59};
60
60static int dapm_down_seq[] = { 61static int dapm_down_seq[] = {
61 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, 62 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
62 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, 63 snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer,
63 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_value_mux, 64 snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias,
64 snd_soc_dapm_post 65 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_post
65}; 66};
66 67
67static int dapm_status = 1; 68static int dapm_status = 1;
@@ -101,7 +102,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
101{ 102{
102 switch (w->id) { 103 switch (w->id) {
103 case snd_soc_dapm_switch: 104 case snd_soc_dapm_switch:
104 case snd_soc_dapm_mixer: { 105 case snd_soc_dapm_mixer:
106 case snd_soc_dapm_mixer_named_ctl: {
105 int val; 107 int val;
106 struct soc_mixer_control *mc = (struct soc_mixer_control *) 108 struct soc_mixer_control *mc = (struct soc_mixer_control *)
107 w->kcontrols[i].private_value; 109 w->kcontrols[i].private_value;
@@ -347,15 +349,33 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
347 if (path->name != (char*)w->kcontrols[i].name) 349 if (path->name != (char*)w->kcontrols[i].name)
348 continue; 350 continue;
349 351
350 /* add dapm control with long name */ 352 /* add dapm control with long name.
351 name_len = 2 + strlen(w->name) 353 * for dapm_mixer this is the concatenation of the
352 + strlen(w->kcontrols[i].name); 354 * mixer and kcontrol name.
355 * for dapm_mixer_named_ctl this is simply the
356 * kcontrol name.
357 */
358 name_len = strlen(w->kcontrols[i].name) + 1;
359 if (w->id == snd_soc_dapm_mixer)
360 name_len += 1 + strlen(w->name);
361
353 path->long_name = kmalloc(name_len, GFP_KERNEL); 362 path->long_name = kmalloc(name_len, GFP_KERNEL);
363
354 if (path->long_name == NULL) 364 if (path->long_name == NULL)
355 return -ENOMEM; 365 return -ENOMEM;
356 366
357 snprintf(path->long_name, name_len, "%s %s", 367 switch (w->id) {
358 w->name, w->kcontrols[i].name); 368 case snd_soc_dapm_mixer:
369 default:
370 snprintf(path->long_name, name_len, "%s %s",
371 w->name, w->kcontrols[i].name);
372 break;
373 case snd_soc_dapm_mixer_named_ctl:
374 snprintf(path->long_name, name_len, "%s",
375 w->kcontrols[i].name);
376 break;
377 }
378
359 path->long_name[name_len - 1] = '\0'; 379 path->long_name[name_len - 1] = '\0';
360 380
361 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, 381 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
@@ -711,6 +731,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
711 case snd_soc_dapm_adc: 731 case snd_soc_dapm_adc:
712 case snd_soc_dapm_pga: 732 case snd_soc_dapm_pga:
713 case snd_soc_dapm_mixer: 733 case snd_soc_dapm_mixer:
734 case snd_soc_dapm_mixer_named_ctl:
714 if (w->name) { 735 if (w->name) {
715 in = is_connected_input_ep(w); 736 in = is_connected_input_ep(w);
716 dapm_clear_walk(w->codec); 737 dapm_clear_walk(w->codec);
@@ -822,6 +843,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
822 int found = 0; 843 int found = 0;
823 844
824 if (widget->id != snd_soc_dapm_mixer && 845 if (widget->id != snd_soc_dapm_mixer &&
846 widget->id != snd_soc_dapm_mixer_named_ctl &&
825 widget->id != snd_soc_dapm_switch) 847 widget->id != snd_soc_dapm_switch)
826 return -ENODEV; 848 return -ENODEV;
827 849
@@ -875,6 +897,7 @@ static ssize_t dapm_widget_show(struct device *dev,
875 case snd_soc_dapm_adc: 897 case snd_soc_dapm_adc:
876 case snd_soc_dapm_pga: 898 case snd_soc_dapm_pga:
877 case snd_soc_dapm_mixer: 899 case snd_soc_dapm_mixer:
900 case snd_soc_dapm_mixer_named_ctl:
878 if (w->name) 901 if (w->name)
879 count += sprintf(buf + count, "%s: %s\n", 902 count += sprintf(buf + count, "%s: %s\n",
880 w->name, w->power ? "On":"Off"); 903 w->name, w->power ? "On":"Off");
@@ -1058,6 +1081,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
1058 break; 1081 break;
1059 case snd_soc_dapm_switch: 1082 case snd_soc_dapm_switch:
1060 case snd_soc_dapm_mixer: 1083 case snd_soc_dapm_mixer:
1084 case snd_soc_dapm_mixer_named_ctl:
1061 ret = dapm_connect_mixer(codec, wsource, wsink, path, control); 1085 ret = dapm_connect_mixer(codec, wsource, wsink, path, control);
1062 if (ret != 0) 1086 if (ret != 0)
1063 goto err; 1087 goto err;
@@ -1135,6 +1159,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1135 switch(w->id) { 1159 switch(w->id) {
1136 case snd_soc_dapm_switch: 1160 case snd_soc_dapm_switch:
1137 case snd_soc_dapm_mixer: 1161 case snd_soc_dapm_mixer:
1162 case snd_soc_dapm_mixer_named_ctl:
1138 dapm_new_mixer(codec, w); 1163 dapm_new_mixer(codec, w);
1139 break; 1164 break;
1140 case snd_soc_dapm_mux: 1165 case snd_soc_dapm_mux: