diff mbox

[04/11] ASoC: Add macros for defining virtual enums

Message ID 1393168221-23018-5-git-send-email-lars@metafoo.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lars-Peter Clausen Feb. 23, 2014, 3:10 p.m. UTC
With the upcoming consolidation of normal MUXs and virtual MUXs we need to be
able to distinguish between enums with and without a backing register at the
enum level. Use the same approach as used for virtual mixer controls by setting
the reg field of the enum to SND_SOC_NOPM for enums without a backing register.
This patch adds a set of helper macros that can be used to define such enums.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Takashi Iwai Feb. 24, 2014, 9:29 a.m. UTC | #1
At Sun, 23 Feb 2014 16:10:14 +0100,
Lars-Peter Clausen wrote:
> 
> With the upcoming consolidation of normal MUXs and virtual MUXs we need to be
> able to distinguish between enums with and without a backing register at the
> enum level. Use the same approach as used for virtual mixer controls by setting
> the reg field of the enum to SND_SOC_NOPM for enums without a backing register.
> This patch adds a set of helper macros that can be used to define such enums.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
>  include/sound/soc.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index e005196..a25de13 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -189,6 +189,8 @@
>  	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
>  #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
>  	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
> +#define SOC_ENUM_SINGLE_VIRT(xmax, xtexts) \
> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xmax, xtexts)

Could you replace "max" with "items"?


Takashi
Lars-Peter Clausen Feb. 24, 2014, 11:50 a.m. UTC | #2
On 02/24/2014 10:29 AM, Takashi Iwai wrote:
> At Sun, 23 Feb 2014 16:10:14 +0100,
> Lars-Peter Clausen wrote:
>>
>> With the upcoming consolidation of normal MUXs and virtual MUXs we need to be
>> able to distinguish between enums with and without a backing register at the
>> enum level. Use the same approach as used for virtual mixer controls by setting
>> the reg field of the enum to SND_SOC_NOPM for enums without a backing register.
>> This patch adds a set of helper macros that can be used to define such enums.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>>   include/sound/soc.h | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/sound/soc.h b/include/sound/soc.h
>> index e005196..a25de13 100644
>> --- a/include/sound/soc.h
>> +++ b/include/sound/soc.h
>> @@ -189,6 +189,8 @@
>>   	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
>>   #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
>>   	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
>> +#define SOC_ENUM_SINGLE_VIRT(xmax, xtexts) \
>> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xmax, xtexts)
>
> Could you replace "max" with "items"?

Yep, missed that one when I rebased things on top of your changes.

- Lars
diff mbox

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index e005196..a25de13 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -189,6 +189,8 @@ 
 	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
 #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
 	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
+#define SOC_ENUM_SINGLE_VIRT(xmax, xtexts) \
+	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xmax, xtexts)
 #define SOC_ENUM(xname, xenum) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
 	.info = snd_soc_info_enum_double, \
@@ -293,6 +295,8 @@ 
 							ARRAY_SIZE(xtexts), xtexts, xvalues)
 #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
 	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
+#define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
+	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
 
 /*
  * Component probe and remove ordering levels for components with runtime
@@ -1090,7 +1094,7 @@  struct soc_mreg_control {
 
 /* enumerated kcontrol */
 struct soc_enum {
-	unsigned short reg;
+	int reg;
 	unsigned char shift_l;
 	unsigned char shift_r;
 	unsigned int items;