Skip to content

Commit 6808787

Browse files
hmbeddedpopcornmix
authored andcommitted
Fix volsw_range functions so SOC_DOUBLE_R_RANGE_TLV works.
This is so that the correct rabge of values as specified with the SOC_DOUBLE_R_RANGE_TLV macro are sent to the hardware for both the normal and invert cases.
1 parent 64aecd9 commit 6808787

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

‎sound/soc/soc-core.c‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,8 +3037,8 @@ int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
30373037

30383038
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
30393039
uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
3040-
uinfo->value.integer.min = 0;
3041-
uinfo->value.integer.max = platform_max - min;
3040+
uinfo->value.integer.min = min;
3041+
uinfo->value.integer.max = platform_max;
30423042

30433043
return 0;
30443044
}
@@ -3069,9 +3069,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
30693069
unsigned int val, val_mask;
30703070
int ret;
30713071

3072-
val = ((ucontrol->value.integer.value[0] + min) & mask);
30733072
if (invert)
3074-
val = max - val;
3073+
val = ((max - ucontrol->value.integer.value[0] + min) & mask);
3074+
else
3075+
val = (ucontrol->value.integer.value[0] & mask);
30753076
val_mask = mask << shift;
30763077
val = val << shift;
30773078

@@ -3080,9 +3081,10 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
30803081
return ret;
30813082

30823083
if (snd_soc_volsw_is_stereo(mc)) {
3083-
val = ((ucontrol->value.integer.value[1] + min) & mask);
30843084
if (invert)
3085-
val = max - val;
3085+
val = ((max - ucontrol->value.integer.value[1] + min) & mask);
3086+
else
3087+
val = (ucontrol->value.integer.value[1] & mask);
30863088
val_mask = mask << shift;
30873089
val = val << shift;
30883090

@@ -3120,18 +3122,14 @@ int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
31203122
(snd_soc_read(codec, reg) >> shift) & mask;
31213123
if (invert)
31223124
ucontrol->value.integer.value[0] =
3123-
max - ucontrol->value.integer.value[0];
3124-
ucontrol->value.integer.value[0] =
3125-
ucontrol->value.integer.value[0] - min;
3125+
max - ucontrol->value.integer.value[0] + min;
31263126

31273127
if (snd_soc_volsw_is_stereo(mc)) {
31283128
ucontrol->value.integer.value[1] =
31293129
(snd_soc_read(codec, rreg) >> shift) & mask;
31303130
if (invert)
31313131
ucontrol->value.integer.value[1] =
3132-
max - ucontrol->value.integer.value[1];
3133-
ucontrol->value.integer.value[1] =
3134-
ucontrol->value.integer.value[1] - min;
3132+
max - ucontrol->value.integer.value[1] + min;
31353133
}
31363134

31373135
return 0;

0 commit comments

Comments
 (0)