6a774263b9e638d705e4a78d44898d1fe64a518b
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.14 / 0050-Fix-volsw_range-functions-so-SOC_DOUBLE_R_RANGE_TLV-.patch
1 From a46efd685fc6c9676b68f02e8ef12c5821809364 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 50/54] Fix volsw_range functions so SOC_DOUBLE_R_RANGE_TLV
5 works.
6
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.
10 ---
11 sound/soc/soc-core.c | 22 ++++++++++------------
12 1 file changed, 10 insertions(+), 12 deletions(-)
13
14 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
15 index fe1df50..c3f41e7 100644
16 --- a/sound/soc/soc-core.c
17 +++ b/sound/soc/soc-core.c
18 @@ -3038,8 +3038,8 @@ int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
19
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;
26
27 return 0;
28 }
29 @@ -3070,9 +3070,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
30 unsigned int val, val_mask;
31 int ret;
32
33 - val = ((ucontrol->value.integer.value[0] + min) & mask);
34 if (invert)
35 - val = max - val;
36 + val = ((max - ucontrol->value.integer.value[0] + min) & mask);
37 + else
38 + val = (ucontrol->value.integer.value[0] & mask);
39 val_mask = mask << shift;
40 val = val << shift;
41
42 @@ -3081,9 +3082,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
43 return ret;
44
45 if (snd_soc_volsw_is_stereo(mc)) {
46 - val = ((ucontrol->value.integer.value[1] + min) & mask);
47 if (invert)
48 - val = max - val;
49 + val = ((max - ucontrol->value.integer.value[1] + min) & mask);
50 + else
51 + val = (ucontrol->value.integer.value[1] & mask);
52 val_mask = mask << shift;
53 val = val << shift;
54
55 @@ -3121,18 +3123,14 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
56 (snd_soc_read(codec, reg) >> shift) & mask;
57 if (invert)
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;
63
64 if (snd_soc_volsw_is_stereo(mc)) {
65 ucontrol->value.integer.value[1] =
66 (snd_soc_read(codec, rreg) >> shift) & mask;
67 if (invert)
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;
73 }
74
75 return 0;
76 --
77 1.9.1
78