diff options
author | Howard Mitchell <hm@hmbedded.co.uk> | 2014-09-19 07:50:31 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-09-24 04:37:03 -0400 |
commit | 5c7c343a1159d1cb7604b6137cf547b2c1e2375d (patch) | |
tree | 692c0e9671eb90da2889caf384e4b58d83958863 | |
parent | 8c8f2f6fc1c8eec9e14810f21386fe295a42a40f (diff) |
ASoC: core: Fix volsw_range funcs so SOC_DOUBLE_R_RANGE_TLV works.
This fixes a bug when using the SOC_DOUBLE_R_RANGE_TLV macro in
the invert mode. In the non-invert case, e.g.
SOC_DOUBLE_R_RANGE_TLV("<name>", <reg_l>, <reg_r>,
0, 40, 255, 0, <tlv>)
the range sent to the hardware is 40..255, but in the invert case:
SOC_DOUBLE_R_RANGE_TLV("<name>", <reg_l>, <reg_r>,
0, 40, 255, 1, <tlv>)
the range 215..0 was being sent to the hardware. This commit
corrects this to 255..40 so it is consistent with the non-invert
case.
Signed-off-by: Howard Mitchell <hm@hmbedded.co.uk>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/soc-core.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3c57f5cf2779..dde4b82ad41d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -3019,9 +3019,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |||
3019 | unsigned int val, val_mask; | 3019 | unsigned int val, val_mask; |
3020 | int ret; | 3020 | int ret; |
3021 | 3021 | ||
3022 | val = ((ucontrol->value.integer.value[0] + min) & mask); | ||
3023 | if (invert) | 3022 | if (invert) |
3024 | val = max - val; | 3023 | val = (max - ucontrol->value.integer.value[0]) & mask; |
3024 | else | ||
3025 | val = ((ucontrol->value.integer.value[0] + min) & mask); | ||
3025 | val_mask = mask << shift; | 3026 | val_mask = mask << shift; |
3026 | val = val << shift; | 3027 | val = val << shift; |
3027 | 3028 | ||
@@ -3030,9 +3031,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, | |||
3030 | return ret; | 3031 | return ret; |
3031 | 3032 | ||
3032 | if (snd_soc_volsw_is_stereo(mc)) { | 3033 | if (snd_soc_volsw_is_stereo(mc)) { |
3033 | val = ((ucontrol->value.integer.value[1] + min) & mask); | ||
3034 | if (invert) | 3034 | if (invert) |
3035 | val = max - val; | 3035 | val = (max - ucontrol->value.integer.value[1]) & mask; |
3036 | else | ||
3037 | val = ((ucontrol->value.integer.value[1] + min) & mask); | ||
3036 | val_mask = mask << shift; | 3038 | val_mask = mask << shift; |
3037 | val = val << shift; | 3039 | val = val << shift; |
3038 | 3040 | ||
@@ -3077,8 +3079,9 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | |||
3077 | if (invert) | 3079 | if (invert) |
3078 | ucontrol->value.integer.value[0] = | 3080 | ucontrol->value.integer.value[0] = |
3079 | max - ucontrol->value.integer.value[0]; | 3081 | max - ucontrol->value.integer.value[0]; |
3080 | ucontrol->value.integer.value[0] = | 3082 | else |
3081 | ucontrol->value.integer.value[0] - min; | 3083 | ucontrol->value.integer.value[0] = |
3084 | ucontrol->value.integer.value[0] - min; | ||
3082 | 3085 | ||
3083 | if (snd_soc_volsw_is_stereo(mc)) { | 3086 | if (snd_soc_volsw_is_stereo(mc)) { |
3084 | ret = snd_soc_component_read(component, rreg, &val); | 3087 | ret = snd_soc_component_read(component, rreg, &val); |
@@ -3089,8 +3092,9 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol, | |||
3089 | if (invert) | 3092 | if (invert) |
3090 | ucontrol->value.integer.value[1] = | 3093 | ucontrol->value.integer.value[1] = |
3091 | max - ucontrol->value.integer.value[1]; | 3094 | max - ucontrol->value.integer.value[1]; |
3092 | ucontrol->value.integer.value[1] = | 3095 | else |
3093 | ucontrol->value.integer.value[1] - min; | 3096 | ucontrol->value.integer.value[1] = |
3097 | ucontrol->value.integer.value[1] - min; | ||
3094 | } | 3098 | } |
3095 | 3099 | ||
3096 | return 0; | 3100 | return 0; |