ASoC: sound: soc: fix incorrect max value
1. Max value stands for number of levels in SX control. The value was adjusted inappropriately, which causes inconsistency between max and min value. 2. Code assumes negative value of mc->min. Positive mc->min leads to incorrect number of levels. The fix covers the risk. CRs-Fixed: 1053735 Change-Id: I71bd8f11ff9faff9252129d84c1a80845fc2fe2a Signed-off-by: Xiaojun Sang <xsang@codeaurora.org>
This commit is contained in:
parent
ef634bf628
commit
c9b0b7c45d
1 changed files with 4 additions and 6 deletions
|
@ -201,7 +201,7 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
|
|||
|
||||
uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
|
||||
uinfo->value.integer.min = 0;
|
||||
if (mc->min < 0 && (uinfo->type == SNDRV_CTL_ELEM_TYPE_INTEGER))
|
||||
if (uinfo->type == SNDRV_CTL_ELEM_TYPE_INTEGER)
|
||||
uinfo->value.integer.max = platform_max - mc->min;
|
||||
else
|
||||
uinfo->value.integer.max = platform_max;
|
||||
|
@ -224,14 +224,12 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
|
|||
int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_info *uinfo)
|
||||
{
|
||||
struct soc_mixer_control *mc =
|
||||
(struct soc_mixer_control *)kcontrol->private_value;
|
||||
|
||||
snd_soc_info_volsw(kcontrol, uinfo);
|
||||
/* Max represents the number of levels in an SX control not the
|
||||
* maximum value, so add the minimum value back on
|
||||
* maximum value.
|
||||
* uinfo->value.integer.max is set to number of levels
|
||||
* in snd_soc_info_volsw_sx. No further adjustment is necessary.
|
||||
*/
|
||||
uinfo->value.integer.max += mc->min;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue