ASoC: ops: Clarify snd_soc_info_volsw_sx()
Mark Brown
maintainerPATCH 1/1 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.
---
Build tested only.
sound/soc/soc-ops.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
sound/soc/soc-ops.c +16 -6
@@ -203,7 +203,8 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw);* 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 * 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. */
@@ -212,12 +213,21 @@ int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol, {struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int max; -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 -*/ - uinfo->value.integer.max += mc->min; +if (mc->platform_max) + max = mc->platform_max; +else + max = mc->max; + +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 ; }
Signature · 1 line
2.30.2
Quoted 9 lines · Mark Brown
Currently
snd_soc_info_volsw_sx()is implemented indirectly, wrappingsnd_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 <[email protected]>---
I didn't quite get around to testing this today but I will hopefully find a quick minute to test tomorrow/over the weekend. That said it looks good to me.
Thanks,
Charles
Charles Keepax
Tested-byQuoted 8 lines · Charles Keepax
Quoted 7 lines · Mark Brown
Currently
snd_soc_info_volsw_sx()is implemented indirectly, wrappingsnd_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.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Mark Brown <[email protected]>---
Reviewed-by Charles Keepax <[email protected]>
On cs35l41, seems to work fine to me.
Thanks,
Charles
Mark Brown
maintainerQuoted 8 lines · Mark Brown
Currently
snd_soc_info_volsw_sx()is implemented indirectly, wrappingsnd_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.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: ops: Clarify snd_soc_info_volsw_sx()
commit: 99b5c107506c728b8a7d25742cf13f6c9c89d6ea
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark