[PATCH 0/2] ASoC: New enum type for bitfield coded enums

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

The first patch adds new enum type to handle non enum coded enums.
The twl4030 codec for example have some of it's input/output mux settings
in a bitfiled, which can not be handled by the standard enum type.

The second patch converts the twl4030 bitfield enums to the new value_enum type.

Technically it could be possible to add the new members (mask, *values) to the
existing soc_enum structure, which could reduce the amount of new code needed to
handle this new type. At least the snd_soc_info_value_enum_double,
dapm_connect_value_mux, dapm_value_mux_update_power functions can be removed if
I modify the soc_enum instead of introducing the new soc_value_enum.

The new type is quite flexible: one can define the normal enum types also with
the VALUE_ENUM (although it does not make any sense):

/* Normal enum */
static const char *normal_mux_texts[] =
		{"Off", "mux1", "mux2", "mux3"};

static const unsigned int normal_mux_values[] =
		{0x0, 0x1, 0x2, 0x3};

static const struct soc_value_enum normal_mux_enum =
	SOC_VALUE_ENUM_SINGLE(REGISTER, 0, 0x3,
			ARRAY_SIZE(normal_mux_texts),
			normal_mux_texts,
			normal_mux_values);

But it makes more sense if one wants to handle the bitfiled
(from twl4030 codec):

/* PreDrive Right */
static const char *twl4030_predriver_texts[] =
		{"Off", "DACR1", "DACR2", "DACL2"};

static const unsigned int twl4030_predriver_values[] =
		{0x0, 0x1, 0x2, 0x4};

static const struct soc_value_enum twl4030_predriver_enum =
	SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7,
			ARRAY_SIZE(twl4030_predriver_texts),
			twl4030_predriver_texts,
			twl4030_predriver_values);

static const struct snd_kcontrol_new twl4030_dapm_predriver_control =
SOC_DAPM_VALUE_ENUM("Route", twl4030_predriver_enum);



_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux