diff options
-rw-r--r-- | include/sound/soc-dapm.h | 1 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 53 |
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 | ||
177 | struct dapm_kcontrol_data { | 177 | struct 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 | ||
237 | static 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 | |||
244 | static 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); | |||
2786 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | 2807 | int 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); | |||
2839 | int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol, | 2856 | int 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 | } |
2849 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt); | 2862 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt); |
@@ -2858,10 +2871,9 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt); | |||
2858 | int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, | 2871 | int 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); | |||
2938 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | 2949 | int 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; |