aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
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 /sound/soc/soc-dapm.c
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>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c47
1 files changed, 36 insertions, 11 deletions
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: