]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - include/sound/soc.h
ASoC: Consolidate enum and value enum controls
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 28 Feb 2014 07:31:03 +0000 (08:31 +0100)
committerMark Brown <broonie@linaro.org>
Sat, 1 Mar 2014 03:03:33 +0000 (12:03 +0900)
commit29ae2fa5533e607a7d97b7564dc015252f1e73f4
treed0d301930177438179ffb297f15c6555e1ed694d
parent8303d769ea9e9626c4f0c3bd13e35e904a1253ab
ASoC: Consolidate enum and value enum controls

The implementations for enum and value enum controls are almost identical. The
only difference is that the value enum uses an additional look-up table to map
the control value to the register value, while the enum control uses a direct
mapping. Enums and value enums can easily be distinguished at runtime, for value
enums the values field of the snd_soc_enum struct contains the look-up table,
while for enums it is NULL. This patch adds two new small helper functions
called snd_soc_enum_item_to_val() and snd_soc_enum_val_to_item() which map
between register value and control item. If the items field of the snd_soc_enum
struct is NULL the function will do a direct mapping otherwise they'll use the
look-up table to do the mapping. Using these small helper functions it is
possible to use the same kcontrol handlers for both enums and value enums. The
functions are added a inline functions in soc.h so they can also be used by the
DAPM code to accomplish similar consolidation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/sound/soc.h
sound/soc/soc-core.c