aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc-dapm.h14
-rw-r--r--sound/soc/soc-dapm.c19
2 files changed, 33 insertions, 0 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index f8223fae580..b2849538cbf 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -130,6 +130,13 @@
130{ .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \ 130{ .id = snd_soc_dapm_adc, .name = wname, .sname = stname, .reg = wreg, \
131 .shift = wshift, .invert = winvert} 131 .shift = wshift, .invert = winvert}
132 132
133/* generic register modifier widget */
134#define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \
135{ .id = wid, .name = wname, .kcontrols = NULL, .num_kcontrols = 0, \
136 .reg = -((wreg) + 1), .shift = wshift, .mask = wmask, \
137 .on_val = won_val, .off_val = woff_val, .event = dapm_reg_event, \
138 .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
139
133/* dapm kcontrol types */ 140/* dapm kcontrol types */
134#define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \ 141#define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \
135{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 142{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -227,6 +234,10 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
227/* dapm sys fs - used by the core */ 234/* dapm sys fs - used by the core */
228int snd_soc_dapm_sys_add(struct device *dev); 235int snd_soc_dapm_sys_add(struct device *dev);
229 236
237/* event handler for register modifier widget - used by the soc-dapm */
238int dapm_reg_event(struct snd_soc_dapm_widget *w,
239 struct snd_kcontrol *kcontrol, int event);
240
230/* dapm audio endpoint control */ 241/* dapm audio endpoint control */
231int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec, 242int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec,
232 char *pin, int status); 243 char *pin, int status);
@@ -298,6 +309,9 @@ struct snd_soc_dapm_widget {
298 unsigned char shift; /* bits to shift */ 309 unsigned char shift; /* bits to shift */
299 unsigned int saved_value; /* widget saved value */ 310 unsigned int saved_value; /* widget saved value */
300 unsigned int value; /* widget current value */ 311 unsigned int value; /* widget current value */
312 unsigned int mask; /* non-shifted mask */
313 unsigned int on_val; /* on state value */
314 unsigned int off_val; /* off state value */
301 unsigned char power:1; /* block power status */ 315 unsigned char power:1; /* block power status */
302 unsigned char invert:1; /* invert the power bit */ 316 unsigned char invert:1; /* invert the power bit */
303 unsigned char active:1; /* active stream on DAC, ADC's */ 317 unsigned char active:1; /* active stream on DAC, ADC's */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 728f3ac2f30..25363829e60 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -443,6 +443,25 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget)
443} 443}
444 444
445/* 445/*
446 * Handler for generic register modifier widget.
447 */
448int dapm_reg_event(struct snd_soc_dapm_widget *w,
449 struct snd_kcontrol *kcontrol, int event)
450{
451 unsigned int val;
452
453 if (SND_SOC_DAPM_EVENT_ON(event))
454 val = w->on_val;
455 else
456 val = w->off_val;
457
458 snd_soc_update_bits(w->codec, -(w->reg + 1),
459 w->mask << w->shift, val << w->shift);
460
461 return 0;
462}
463
464/*
446 * Scan each dapm widget for complete audio path. 465 * Scan each dapm widget for complete audio path.
447 * A complete path is a route that has valid endpoints i.e.:- 466 * A complete path is a route that has valid endpoints i.e.:-
448 * 467 *