aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f90139b5f50d..873e6e76ee87 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -141,6 +141,28 @@ void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason)
141} 141}
142EXPORT_SYMBOL_GPL(dapm_mark_dirty); 142EXPORT_SYMBOL_GPL(dapm_mark_dirty);
143 143
144void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm)
145{
146 struct snd_soc_card *card = dapm->card;
147 struct snd_soc_dapm_widget *w;
148
149 mutex_lock(&card->dapm_mutex);
150
151 list_for_each_entry(w, &card->widgets, list) {
152 switch (w->id) {
153 case snd_soc_dapm_input:
154 case snd_soc_dapm_output:
155 dapm_mark_dirty(w, "Rechecking inputs and outputs");
156 break;
157 default:
158 break;
159 }
160 }
161
162 mutex_unlock(&card->dapm_mutex);
163}
164EXPORT_SYMBOL_GPL(dapm_mark_io_dirty);
165
144/* create a new dapm widget */ 166/* create a new dapm widget */
145static inline struct snd_soc_dapm_widget *dapm_cnew_widget( 167static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
146 const struct snd_soc_dapm_widget *_widget) 168 const struct snd_soc_dapm_widget *_widget)
@@ -336,12 +358,10 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
336 case snd_soc_dapm_mux: { 358 case snd_soc_dapm_mux: {
337 struct soc_enum *e = (struct soc_enum *) 359 struct soc_enum *e = (struct soc_enum *)
338 w->kcontrol_news[i].private_value; 360 w->kcontrol_news[i].private_value;
339 int val, item, bitmask; 361 int val, item;
340 362
341 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
342 ;
343 val = soc_widget_read(w, e->reg); 363 val = soc_widget_read(w, e->reg);
344 item = (val >> e->shift_l) & (bitmask - 1); 364 item = (val >> e->shift_l) & e->mask;
345 365
346 p->connect = 0; 366 p->connect = 0;
347 for (i = 0; i < e->max; i++) { 367 for (i = 0; i < e->max; i++) {
@@ -2658,15 +2678,13 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
2658 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); 2678 struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
2659 struct snd_soc_dapm_widget *widget = wlist->widgets[0]; 2679 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2660 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2680 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2661 unsigned int val, bitmask; 2681 unsigned int val;
2662 2682
2663 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2664 ;
2665 val = snd_soc_read(widget->codec, e->reg); 2683 val = snd_soc_read(widget->codec, e->reg);
2666 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); 2684 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & e->mask;
2667 if (e->shift_l != e->shift_r) 2685 if (e->shift_l != e->shift_r)
2668 ucontrol->value.enumerated.item[1] = 2686 ucontrol->value.enumerated.item[1] =
2669 (val >> e->shift_r) & (bitmask - 1); 2687 (val >> e->shift_r) & e->mask;
2670 2688
2671 return 0; 2689 return 0;
2672} 2690}
@@ -2690,22 +2708,20 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
2690 struct snd_soc_card *card = codec->card; 2708 struct snd_soc_card *card = codec->card;
2691 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2709 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2692 unsigned int val, mux, change; 2710 unsigned int val, mux, change;
2693 unsigned int mask, bitmask; 2711 unsigned int mask;
2694 struct snd_soc_dapm_update update; 2712 struct snd_soc_dapm_update update;
2695 int wi; 2713 int wi;
2696 2714
2697 for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
2698 ;
2699 if (ucontrol->value.enumerated.item[0] > e->max - 1) 2715 if (ucontrol->value.enumerated.item[0] > e->max - 1)
2700 return -EINVAL; 2716 return -EINVAL;
2701 mux = ucontrol->value.enumerated.item[0]; 2717 mux = ucontrol->value.enumerated.item[0];
2702 val = mux << e->shift_l; 2718 val = mux << e->shift_l;
2703 mask = (bitmask - 1) << e->shift_l; 2719 mask = e->mask << e->shift_l;
2704 if (e->shift_l != e->shift_r) { 2720 if (e->shift_l != e->shift_r) {
2705 if (ucontrol->value.enumerated.item[1] > e->max - 1) 2721 if (ucontrol->value.enumerated.item[1] > e->max - 1)
2706 return -EINVAL; 2722 return -EINVAL;
2707 val |= ucontrol->value.enumerated.item[1] << e->shift_r; 2723 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
2708 mask |= (bitmask - 1) << e->shift_r; 2724 mask |= e->mask << e->shift_r;
2709 } 2725 }
2710 2726
2711 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2727 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);