aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-07-29 11:13:59 -0400
committerMark Brown <broonie@linaro.org>2013-07-29 13:41:00 -0400
commitcf7c1de20c576477d42deae255cbc6e439bb5dc0 (patch)
treef55b12427e74cc6ecc1e8db4714b8e0673237d92
parente84357f7608f230b905acb18fe668609c9b811f0 (diff)
ASoC: dapm: Move 'value' field from widget to control
The 'value' field is really per control and not per widget. Currently it is only used for virtual MUXes, which only have one control per widget. So in that case there is not so much of a difference between whether it is stored per widget or per control. Moving the 'value' field from the widget to the control will allow us to use it also for cases where we have more than one control per widget. E.g. for mixers with multiple input controls. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--include/sound/soc-dapm.h1
-rw-r--r--sound/soc/soc-dapm.c53
2 files changed, 30 insertions, 24 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index ebfae8f3fda7..d7d26cc8e3fc 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -523,7 +523,6 @@ struct snd_soc_dapm_widget {
523 /* dapm control */ 523 /* dapm control */
524 int reg; /* negative reg = no direct dapm */ 524 int reg; /* negative reg = no direct dapm */
525 unsigned char shift; /* bits to shift */ 525 unsigned char shift; /* bits to shift */
526 unsigned int value; /* widget current value */
527 unsigned int mask; /* non-shifted mask */ 526 unsigned int mask; /* non-shifted mask */
528 unsigned int on_val; /* on state value */ 527 unsigned int on_val; /* on state value */
529 unsigned int off_val; /* off state value */ 528 unsigned int off_val; /* off state value */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index da35b10ce6d1..bad6f6db74c9 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -175,6 +175,7 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
175} 175}
176 176
177struct dapm_kcontrol_data { 177struct dapm_kcontrol_data {
178 unsigned int value;
178 struct snd_soc_dapm_widget_list wlist; 179 struct snd_soc_dapm_widget_list wlist;
179}; 180};
180 181
@@ -233,6 +234,26 @@ static int dapm_kcontrol_add_widget(struct snd_kcontrol *kcontrol,
233 return 0; 234 return 0;
234} 235}
235 236
237static unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol *kcontrol)
238{
239 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kcontrol);
240
241 return data->value;
242}
243
244static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol,
245 unsigned int value)
246{
247 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kcontrol);
248
249 if (data->value == value)
250 return false;
251
252 data->value = value;
253
254 return true;
255}
256
236/** 257/**
237 * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol 258 * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol
238 * @kcontrol: The kcontrol 259 * @kcontrol: The kcontrol
@@ -2786,9 +2807,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
2786int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, 2807int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
2787 struct snd_ctl_elem_value *ucontrol) 2808 struct snd_ctl_elem_value *ucontrol)
2788{ 2809{
2789 struct snd_soc_dapm_widget_list *wlist = dapm_kcontrol_get_wlist(kcontrol); 2810 struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
2790 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2791 struct snd_soc_codec *codec = widget->codec;
2792 struct snd_soc_card *card = codec->card; 2811 struct snd_soc_card *card = codec->card;
2793 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2812 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2794 unsigned int val, mux, change; 2813 unsigned int val, mux, change;
@@ -2811,8 +2830,6 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
2811 2830
2812 change = snd_soc_test_bits(codec, e->reg, mask, val); 2831 change = snd_soc_test_bits(codec, e->reg, mask, val);
2813 if (change) { 2832 if (change) {
2814 widget->value = val;
2815
2816 update.kcontrol = kcontrol; 2833 update.kcontrol = kcontrol;
2817 update.reg = e->reg; 2834 update.reg = e->reg;
2818 update.mask = mask; 2835 update.mask = mask;
@@ -2839,11 +2856,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
2839int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol, 2856int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
2840 struct snd_ctl_elem_value *ucontrol) 2857 struct snd_ctl_elem_value *ucontrol)
2841{ 2858{
2842 struct snd_soc_dapm_widget_list *wlist = dapm_kcontrol_get_wlist(kcontrol); 2859 ucontrol->value.enumerated.item[0] = dapm_kcontrol_get_value(kcontrol);
2843 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2844
2845 ucontrol->value.enumerated.item[0] = widget->value;
2846
2847 return 0; 2860 return 0;
2848} 2861}
2849EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt); 2862EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt);
@@ -2858,10 +2871,9 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt);
2858int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, 2871int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
2859 struct snd_ctl_elem_value *ucontrol) 2872 struct snd_ctl_elem_value *ucontrol)
2860{ 2873{
2861 struct snd_soc_dapm_widget_list *wlist = dapm_kcontrol_get_wlist(kcontrol); 2874 struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
2862 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2863 struct snd_soc_codec *codec = widget->codec;
2864 struct snd_soc_card *card = codec->card; 2875 struct snd_soc_card *card = codec->card;
2876 unsigned int value;
2865 struct soc_enum *e = 2877 struct soc_enum *e =
2866 (struct soc_enum *)kcontrol->private_value; 2878 (struct soc_enum *)kcontrol->private_value;
2867 int change; 2879 int change;
@@ -2871,11 +2883,10 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
2871 2883
2872 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2884 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
2873 2885
2874 change = widget->value != ucontrol->value.enumerated.item[0]; 2886 value = ucontrol->value.enumerated.item[0];
2875 if (change) { 2887 change = dapm_kcontrol_set_value(kcontrol, value);
2876 widget->value = ucontrol->value.enumerated.item[0]; 2888 if (change)
2877 soc_dapm_mux_update_power(card, kcontrol, widget->value, e); 2889 soc_dapm_mux_update_power(card, kcontrol, value, e);
2878 }
2879 2890
2880 mutex_unlock(&card->dapm_mutex); 2891 mutex_unlock(&card->dapm_mutex);
2881 return change; 2892 return change;
@@ -2938,9 +2949,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double);
2938int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, 2949int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
2939 struct snd_ctl_elem_value *ucontrol) 2950 struct snd_ctl_elem_value *ucontrol)
2940{ 2951{
2941 struct snd_soc_dapm_widget_list *wlist = dapm_kcontrol_get_wlist(kcontrol); 2952 struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
2942 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
2943 struct snd_soc_codec *codec = widget->codec;
2944 struct snd_soc_card *card = codec->card; 2953 struct snd_soc_card *card = codec->card;
2945 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 2954 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
2946 unsigned int val, mux, change; 2955 unsigned int val, mux, change;
@@ -2963,8 +2972,6 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
2963 2972
2964 change = snd_soc_test_bits(codec, e->reg, mask, val); 2973 change = snd_soc_test_bits(codec, e->reg, mask, val);
2965 if (change) { 2974 if (change) {
2966 widget->value = val;
2967
2968 update.kcontrol = kcontrol; 2975 update.kcontrol = kcontrol;
2969 update.reg = e->reg; 2976 update.reg = e->reg;
2970 update.mask = mask; 2977 update.mask = mask;