de076303e3d5f0eace1bf11e20321e3a90b23f0f
[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 --- a/sound/soc/soc-core.c
15 +++ b/sound/soc/soc-core.c
16 @@ -3038,8 +3038,8 @@ int snd_soc_info_volsw_range(struct snd_
17  
18         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
19         uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
20 -       uinfo->value.integer.min = 0;
21 -       uinfo->value.integer.max = platform_max - min;
22 +       uinfo->value.integer.min = min;
23 +       uinfo->value.integer.max = platform_max;
24  
25         return 0;
26  }
27 @@ -3070,9 +3070,10 @@ int snd_soc_put_volsw_range(struct snd_k
28         unsigned int val, val_mask;
29         int ret;
30  
31 -       val = ((ucontrol->value.integer.value[0] + min) & mask);
32         if (invert)
33 -               val = max - val;
34 +               val = ((max - ucontrol->value.integer.value[0] + min) & mask);
35 +    else
36 +       val = (ucontrol->value.integer.value[0] & mask);
37         val_mask = mask << shift;
38         val = val << shift;
39  
40 @@ -3081,9 +3082,10 @@ int snd_soc_put_volsw_range(struct snd_k
41                 return ret;
42  
43         if (snd_soc_volsw_is_stereo(mc)) {
44 -               val = ((ucontrol->value.integer.value[1] + min) & mask);
45                 if (invert)
46 -                       val = max - val;
47 +                       val = ((max - ucontrol->value.integer.value[1] + min) & mask);
48 +        else
49 +            val = (ucontrol->value.integer.value[1] & mask);
50                 val_mask = mask << shift;
51                 val = val << shift;
52  
53 @@ -3121,18 +3123,14 @@ int snd_soc_get_volsw_range(struct snd_k
54                 (snd_soc_read(codec, reg) >> shift) & mask;
55         if (invert)
56                 ucontrol->value.integer.value[0] =
57 -                       max - ucontrol->value.integer.value[0];
58 -       ucontrol->value.integer.value[0] =
59 -               ucontrol->value.integer.value[0] - min;
60 +                       max - ucontrol->value.integer.value[0] + min;
61  
62         if (snd_soc_volsw_is_stereo(mc)) {
63                 ucontrol->value.integer.value[1] =
64                         (snd_soc_read(codec, rreg) >> shift) & mask;
65                 if (invert)
66                         ucontrol->value.integer.value[1] =
67 -                               max - ucontrol->value.integer.value[1];
68 -               ucontrol->value.integer.value[1] =
69 -                       ucontrol->value.integer.value[1] - min;
70 +                               max - ucontrol->value.integer.value[1] + min;
71         }
72  
73         return 0;