1 From 4c91cfe1cfa38f4e17e96cd7d78ac2a4fa86d5c9 Mon Sep 17 00:00:00 2001
2 From: Howard Mitchell <hm@hmbedded.co.uk>
3 Date: Fri, 28 Mar 2014 16:27:57 +0000
4 Subject: [PATCH 186/196] Fix volsw_range functions so SOC_DOUBLE_R_RANGE_TLV
7 This is so that the correct rabge of values as specified
8 with the SOC_DOUBLE_R_RANGE_TLV macro are sent to the
9 hardware for both the normal and invert cases.
11 sound/soc/soc-core.c | 22 ++++++++++------------
12 1 file changed, 10 insertions(+), 12 deletions(-)
14 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
15 index d18272c..be302e1 100644
16 --- a/sound/soc/soc-core.c
17 +++ b/sound/soc/soc-core.c
18 @@ -2925,8 +2925,8 @@ int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
20 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
21 uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
22 - uinfo->value.integer.min = 0;
23 - uinfo->value.integer.max = platform_max - min;
24 + uinfo->value.integer.min = min;
25 + uinfo->value.integer.max = platform_max;
29 @@ -2957,9 +2957,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
30 unsigned int val, val_mask;
33 - val = ((ucontrol->value.integer.value[0] + min) & mask);
36 + val = ((max - ucontrol->value.integer.value[0] + min) & mask);
38 + val = (ucontrol->value.integer.value[0] & mask);
39 val_mask = mask << shift;
42 @@ -2968,9 +2969,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
45 if (snd_soc_volsw_is_stereo(mc)) {
46 - val = ((ucontrol->value.integer.value[1] + min) & mask);
49 + val = ((max - ucontrol->value.integer.value[1] + min) & mask);
51 + val = (ucontrol->value.integer.value[1] & mask);
52 val_mask = mask << shift;
55 @@ -3008,18 +3010,14 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
56 (snd_soc_read(codec, reg) >> shift) & mask;
58 ucontrol->value.integer.value[0] =
59 - max - ucontrol->value.integer.value[0];
60 - ucontrol->value.integer.value[0] =
61 - ucontrol->value.integer.value[0] - min;
62 + max - ucontrol->value.integer.value[0] + min;
64 if (snd_soc_volsw_is_stereo(mc)) {
65 ucontrol->value.integer.value[1] =
66 (snd_soc_read(codec, rreg) >> shift) & mask;
68 ucontrol->value.integer.value[1] =
69 - max - ucontrol->value.integer.value[1];
70 - ucontrol->value.integer.value[1] =
71 - ucontrol->value.integer.value[1] - min;
72 + max - ucontrol->value.integer.value[1] + min;