Commit ca9c1aae authored by Ian Molton's avatar Ian Molton

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: default avatarIan Molton <ian@mnementh.co.uk>
parent 227b4dc6
...@@ -116,6 +116,9 @@ SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0), ...@@ -116,6 +116,9 @@ SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0),
SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls, SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls,
ARRAY_SIZE(wm8731_output_mixer_controls)), ARRAY_SIZE(wm8731_output_mixer_controls)),
If you dont want the mixer elements prefixed with the name of the mixer widget,
you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same
as for SND_SOC_DAPM_MIXER.
2.3 Platform/Machine domain Widgets 2.3 Platform/Machine domain Widgets
----------------------------------- -----------------------------------
......
...@@ -76,6 +76,11 @@ ...@@ -76,6 +76,11 @@
wcontrols, wncontrols)\ wcontrols, wncontrols)\
{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols} .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols}
#define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \
wcontrols, wncontrols)\
{ .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
.shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
.num_kcontrols = wncontrols}
#define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \ #define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = NULL, .num_kcontrols = 0} .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0}
...@@ -101,6 +106,11 @@ ...@@ -101,6 +106,11 @@
{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \ { .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \ .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = wncontrols, \
.event = wevent, .event_flags = wflags} .event = wevent, .event_flags = wflags}
#define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \
wcontrols, wncontrols, wevent, wflags) \
{ .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = wcontrols, \
.num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags}
#define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \ #define SND_SOC_DAPM_MICBIAS_E(wname, wreg, wshift, winvert, wevent, wflags) \
{ .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \ { .id = snd_soc_dapm_micbias, .name = wname, .reg = wreg, .shift = wshift, \
.invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \ .invert = winvert, .kcontrols = NULL, .num_kcontrols = 0, \
...@@ -263,6 +273,7 @@ enum snd_soc_dapm_type { ...@@ -263,6 +273,7 @@ enum snd_soc_dapm_type {
snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */
snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */
snd_soc_dapm_mixer, /* mixes several analog signals together */ snd_soc_dapm_mixer, /* mixes several analog signals together */
snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */
snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */
snd_soc_dapm_adc, /* analog to digital converter */ snd_soc_dapm_adc, /* analog to digital converter */
snd_soc_dapm_dac, /* digital to analog converter */ snd_soc_dapm_dac, /* digital to analog converter */
......
...@@ -54,14 +54,15 @@ ...@@ -54,14 +54,15 @@
static int dapm_up_seq[] = { static int dapm_up_seq[] = {
snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac,
snd_soc_dapm_mixer, snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_pga,
snd_soc_dapm_spk, snd_soc_dapm_post snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post
}; };
static int dapm_down_seq[] = { static int dapm_down_seq[] = {
snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer,
snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias,
snd_soc_dapm_post snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_post
}; };
static int dapm_status = 1; static int dapm_status = 1;
...@@ -101,7 +102,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, ...@@ -101,7 +102,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
{ {
switch (w->id) { switch (w->id) {
case snd_soc_dapm_switch: case snd_soc_dapm_switch:
case snd_soc_dapm_mixer: { case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl: {
int val; int val;
struct soc_mixer_control *mc = (struct soc_mixer_control *) struct soc_mixer_control *mc = (struct soc_mixer_control *)
w->kcontrols[i].private_value; w->kcontrols[i].private_value;
...@@ -347,15 +349,33 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, ...@@ -347,15 +349,33 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
if (path->name != (char*)w->kcontrols[i].name) if (path->name != (char*)w->kcontrols[i].name)
continue; continue;
/* add dapm control with long name */ /* add dapm control with long name.
name_len = 2 + strlen(w->name) * for dapm_mixer this is the concatenation of the
+ strlen(w->kcontrols[i].name); * mixer and kcontrol name.
* for dapm_mixer_named_ctl this is simply the
* kcontrol name.
*/
name_len = strlen(w->kcontrols[i].name) + 1;
if (w->id == snd_soc_dapm_mixer)
name_len += 1 + strlen(w->name);
path->long_name = kmalloc(name_len, GFP_KERNEL); path->long_name = kmalloc(name_len, GFP_KERNEL);
if (path->long_name == NULL) if (path->long_name == NULL)
return -ENOMEM; return -ENOMEM;
snprintf(path->long_name, name_len, "%s %s", switch (w->id) {
w->name, w->kcontrols[i].name); case snd_soc_dapm_mixer:
default:
snprintf(path->long_name, name_len, "%s %s",
w->name, w->kcontrols[i].name);
break;
case snd_soc_dapm_mixer_named_ctl:
snprintf(path->long_name, name_len, "%s",
w->kcontrols[i].name);
break;
}
path->long_name[name_len - 1] = '\0'; path->long_name[name_len - 1] = '\0';
path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, 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,6 +731,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
case snd_soc_dapm_adc: case snd_soc_dapm_adc:
case snd_soc_dapm_pga: case snd_soc_dapm_pga:
case snd_soc_dapm_mixer: case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl:
if (w->name) { if (w->name) {
in = is_connected_input_ep(w); in = is_connected_input_ep(w);
dapm_clear_walk(w->codec); dapm_clear_walk(w->codec);
...@@ -822,6 +843,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, ...@@ -822,6 +843,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
int found = 0; int found = 0;
if (widget->id != snd_soc_dapm_mixer && if (widget->id != snd_soc_dapm_mixer &&
widget->id != snd_soc_dapm_mixer_named_ctl &&
widget->id != snd_soc_dapm_switch) widget->id != snd_soc_dapm_switch)
return -ENODEV; return -ENODEV;
...@@ -875,6 +897,7 @@ static ssize_t dapm_widget_show(struct device *dev, ...@@ -875,6 +897,7 @@ static ssize_t dapm_widget_show(struct device *dev,
case snd_soc_dapm_adc: case snd_soc_dapm_adc:
case snd_soc_dapm_pga: case snd_soc_dapm_pga:
case snd_soc_dapm_mixer: case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl:
if (w->name) if (w->name)
count += sprintf(buf + count, "%s: %s\n", count += sprintf(buf + count, "%s: %s\n",
w->name, w->power ? "On":"Off"); w->name, w->power ? "On":"Off");
...@@ -1058,6 +1081,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, ...@@ -1058,6 +1081,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
break; break;
case snd_soc_dapm_switch: case snd_soc_dapm_switch:
case snd_soc_dapm_mixer: case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl:
ret = dapm_connect_mixer(codec, wsource, wsink, path, control); ret = dapm_connect_mixer(codec, wsource, wsink, path, control);
if (ret != 0) if (ret != 0)
goto err; goto err;
...@@ -1135,6 +1159,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) ...@@ -1135,6 +1159,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
switch(w->id) { switch(w->id) {
case snd_soc_dapm_switch: case snd_soc_dapm_switch:
case snd_soc_dapm_mixer: case snd_soc_dapm_mixer:
case snd_soc_dapm_mixer_named_ctl:
dapm_new_mixer(codec, w); dapm_new_mixer(codec, w);
break; break;
case snd_soc_dapm_mux: case snd_soc_dapm_mux:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment