diff options
author | Dimitris Papastamos <dp@opensource.wolfsonmicro.com> | 2010-12-16 10:53:39 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-12-17 12:36:28 -0500 |
commit | 24ff33ac696802e478714480f505c00a50a89c75 (patch) | |
tree | 3b2e9d3232331b556b2f4cb423dae1ead5565e0c | |
parent | 1ec9bc35a6a01555836fa1e4d0f00a3501835b0b (diff) |
ASoC: soc-dapm: Introduce the new snd_soc_dapm_virt_mux type
This new type is a virtual version of snd_soc_dapm_mux. It is used
when a backing register value is not necessary for deciding which
input path to connect. A simple virtual enumeration control e.g.
SOC_DAPM_ENUM_VIRT() can be exposed to userspace which will be used
to choose which path to connect.
The snd_soc_dapm_virt_mux type ensures that during the initial
path setup, the first (which is also the default) input path will
be connected.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | include/sound/soc-dapm.h | 9 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 19 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 540872fc1390..8031769ac485 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
@@ -93,6 +93,9 @@ | |||
93 | #define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ | 93 | #define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \ |
94 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ | 94 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ |
95 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} | 95 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} |
96 | #define SND_SOC_DAPM_VIRT_MUX(wname, wreg, wshift, winvert, wcontrols) \ | ||
97 | { .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \ | ||
98 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1} | ||
96 | #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \ | 99 | #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \ |
97 | { .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \ | 100 | { .id = snd_soc_dapm_value_mux, .name = wname, .reg = wreg, \ |
98 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ | 101 | .shift = wshift, .invert = winvert, .kcontrols = wcontrols, \ |
@@ -148,6 +151,11 @@ | |||
148 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ | 151 | { .id = snd_soc_dapm_mux, .name = wname, .reg = wreg, .shift = wshift, \ |
149 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ | 152 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ |
150 | .event = wevent, .event_flags = wflags} | 153 | .event = wevent, .event_flags = wflags} |
154 | #define SND_SOC_DAPM_VIRT_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ | ||
155 | wevent, wflags) \ | ||
156 | { .id = snd_soc_dapm_virt_mux, .name = wname, .reg = wreg, .shift = wshift, \ | ||
157 | .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \ | ||
158 | .event = wevent, .event_flags = wflags} | ||
151 | 159 | ||
152 | /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ | 160 | /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ |
153 | #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ | 161 | #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \ |
@@ -357,6 +365,7 @@ enum snd_soc_dapm_type { | |||
357 | snd_soc_dapm_input = 0, /* input pin */ | 365 | snd_soc_dapm_input = 0, /* input pin */ |
358 | snd_soc_dapm_output, /* output pin */ | 366 | snd_soc_dapm_output, /* output pin */ |
359 | snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ | 367 | snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ |
368 | snd_soc_dapm_virt_mux, /* virtual version of snd_soc_dapm_mux */ | ||
360 | snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ | 369 | snd_soc_dapm_value_mux, /* selects 1 analog signal from many inputs */ |
361 | snd_soc_dapm_mixer, /* mixes several analog signals together */ | 370 | snd_soc_dapm_mixer, /* mixes several analog signals together */ |
362 | snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ | 371 | snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 1debc3b05665..50f5c785cb61 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -56,6 +56,7 @@ static int dapm_up_seq[] = { | |||
56 | [snd_soc_dapm_aif_out] = 3, | 56 | [snd_soc_dapm_aif_out] = 3, |
57 | [snd_soc_dapm_mic] = 4, | 57 | [snd_soc_dapm_mic] = 4, |
58 | [snd_soc_dapm_mux] = 5, | 58 | [snd_soc_dapm_mux] = 5, |
59 | [snd_soc_dapm_virt_mux] = 5, | ||
59 | [snd_soc_dapm_value_mux] = 5, | 60 | [snd_soc_dapm_value_mux] = 5, |
60 | [snd_soc_dapm_dac] = 6, | 61 | [snd_soc_dapm_dac] = 6, |
61 | [snd_soc_dapm_mixer] = 7, | 62 | [snd_soc_dapm_mixer] = 7, |
@@ -81,6 +82,7 @@ static int dapm_down_seq[] = { | |||
81 | [snd_soc_dapm_mic] = 7, | 82 | [snd_soc_dapm_mic] = 7, |
82 | [snd_soc_dapm_micbias] = 8, | 83 | [snd_soc_dapm_micbias] = 8, |
83 | [snd_soc_dapm_mux] = 9, | 84 | [snd_soc_dapm_mux] = 9, |
85 | [snd_soc_dapm_virt_mux] = 9, | ||
84 | [snd_soc_dapm_value_mux] = 9, | 86 | [snd_soc_dapm_value_mux] = 9, |
85 | [snd_soc_dapm_aif_in] = 10, | 87 | [snd_soc_dapm_aif_in] = 10, |
86 | [snd_soc_dapm_aif_out] = 10, | 88 | [snd_soc_dapm_aif_out] = 10, |
@@ -216,6 +218,20 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
216 | } | 218 | } |
217 | } | 219 | } |
218 | break; | 220 | break; |
221 | case snd_soc_dapm_virt_mux: { | ||
222 | struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value; | ||
223 | |||
224 | p->connect = 0; | ||
225 | /* since a virtual mux has no backing registers to | ||
226 | * decide which path to connect, it will try to match | ||
227 | * with the first enumeration. This is to ensure | ||
228 | * that the default mux choice (the first) will be | ||
229 | * correctly powered up during initialization. | ||
230 | */ | ||
231 | if (!strcmp(p->name, e->texts[0])) | ||
232 | p->connect = 1; | ||
233 | } | ||
234 | break; | ||
219 | case snd_soc_dapm_value_mux: { | 235 | case snd_soc_dapm_value_mux: { |
220 | struct soc_enum *e = (struct soc_enum *) | 236 | struct soc_enum *e = (struct soc_enum *) |
221 | w->kcontrols[i].private_value; | 237 | w->kcontrols[i].private_value; |
@@ -1228,6 +1244,7 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | |||
1228 | int found = 0; | 1244 | int found = 0; |
1229 | 1245 | ||
1230 | if (widget->id != snd_soc_dapm_mux && | 1246 | if (widget->id != snd_soc_dapm_mux && |
1247 | widget->id != snd_soc_dapm_virt_mux && | ||
1231 | widget->id != snd_soc_dapm_value_mux) | 1248 | widget->id != snd_soc_dapm_value_mux) |
1232 | return -ENODEV; | 1249 | return -ENODEV; |
1233 | 1250 | ||
@@ -1534,6 +1551,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, | |||
1534 | path->connect = 1; | 1551 | path->connect = 1; |
1535 | return 0; | 1552 | return 0; |
1536 | case snd_soc_dapm_mux: | 1553 | case snd_soc_dapm_mux: |
1554 | case snd_soc_dapm_virt_mux: | ||
1537 | case snd_soc_dapm_value_mux: | 1555 | case snd_soc_dapm_value_mux: |
1538 | ret = dapm_connect_mux(dapm, wsource, wsink, path, control, | 1556 | ret = dapm_connect_mux(dapm, wsource, wsink, path, control, |
1539 | &wsink->kcontrols[0]); | 1557 | &wsink->kcontrols[0]); |
@@ -1623,6 +1641,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm) | |||
1623 | dapm_new_mixer(dapm, w); | 1641 | dapm_new_mixer(dapm, w); |
1624 | break; | 1642 | break; |
1625 | case snd_soc_dapm_mux: | 1643 | case snd_soc_dapm_mux: |
1644 | case snd_soc_dapm_virt_mux: | ||
1626 | case snd_soc_dapm_value_mux: | 1645 | case snd_soc_dapm_value_mux: |
1627 | w->power_check = dapm_generic_check_power; | 1646 | w->power_check = dapm_generic_check_power; |
1628 | dapm_new_mux(dapm, w); | 1647 | dapm_new_mux(dapm, w); |