ASoC: ops: Clarify snd_soc_info_volsw_sx()
Currently snd_soc_info_volsw_sx() is implemented indirectly, wrapping snd_soc_info_volsw() and modifying the values it sets up rather than directly setting up the values reported to userspace. This makes it much harder to follow what the intended behaviour of these controls is. Let's rewrite the function to be self contained with a clarifying comment at the top in an effort to help maintainability. Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220602092921.3302713-1-broonie@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
b661a848a5
commit
99b5c10750
|
@ -203,7 +203,8 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
|
||||||
* Callback to provide information about a single mixer control, or a double
|
* Callback to provide information about a single mixer control, or a double
|
||||||
* mixer control that spans 2 registers of the SX TLV type. SX TLV controls
|
* mixer control that spans 2 registers of the SX TLV type. SX TLV controls
|
||||||
* have a range that represents both positive and negative values either side
|
* have a range that represents both positive and negative values either side
|
||||||
* of zero but without a sign bit.
|
* of zero but without a sign bit. min is the minimum register value, max is
|
||||||
|
* the number of steps.
|
||||||
*
|
*
|
||||||
* Returns 0 for success.
|
* Returns 0 for success.
|
||||||
*/
|
*/
|
||||||
|
@ -212,12 +213,21 @@ int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
|
||||||
{
|
{
|
||||||
struct soc_mixer_control *mc =
|
struct soc_mixer_control *mc =
|
||||||
(struct soc_mixer_control *)kcontrol->private_value;
|
(struct soc_mixer_control *)kcontrol->private_value;
|
||||||
|
int max;
|
||||||
|
|
||||||
snd_soc_info_volsw(kcontrol, uinfo);
|
if (mc->platform_max)
|
||||||
/* Max represents the number of levels in an SX control not the
|
max = mc->platform_max;
|
||||||
* maximum value, so add the minimum value back on
|
else
|
||||||
*/
|
max = mc->max;
|
||||||
uinfo->value.integer.max += mc->min;
|
|
||||||
|
if (max == 1 && !strstr(kcontrol->id.name, " Volume"))
|
||||||
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
||||||
|
else
|
||||||
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
||||||
|
|
||||||
|
uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
|
||||||
|
uinfo->value.integer.min = 0;
|
||||||
|
uinfo->value.integer.max = max;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue