[alsa-devel] SOC_VALUE_ENUM usages in cs42l52 & cs42l73 drivers
Hi,
as I audited through ASoC codec drivers recently, I noticed that cs42l52 and cs42l73 drivers have some strange SOC_VALUE_ENUM usages.
For example, cs42l52.c has the following code snippet:
static const char * const left_swap_text[] = { "Left", "LR 2", "Right"}; .... static const unsigned int swap_values[] = { 0, 1, 3 };
static const struct soc_enum adca_swap_enum = SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 2, 1, ARRAY_SIZE(left_swap_text), left_swap_text, swap_values);
Note that the third argument of SOC_VALUE_ENUM_SINGLE() is the mask bits. Passing 1 means only the least bit is evaluated no matter what value is assigned while swap_values can be 0, 1 or 3. I suppose here meant 3, but would like to know how the code is supposed to work. There are three value-enum definitions in cs42l52.c, and all pass 1 there.
Similarly, cs42l73.c has four definitions, but with different masks:
SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 6, 1, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 4, 3, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 2, 5, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 0, 7, ...
while values can be either 0, 1 or 2. Something really fishy here.
thanks,
Takashi
On Tue, 18 Feb 2014, Takashi Iwai wrote:
Hi,
as I audited through ASoC codec drivers recently, I noticed that cs42l52 and cs42l73 drivers have some strange SOC_VALUE_ENUM usages.
For example, cs42l52.c has the following code snippet:
static const char * const left_swap_text[] = { "Left", "LR 2", "Right"}; .... static const unsigned int swap_values[] = { 0, 1, 3 };
static const struct soc_enum adca_swap_enum = SOC_VALUE_ENUM_SINGLE(CS42L52_ADC_PCM_MIXER, 2, 1, ARRAY_SIZE(left_swap_text), left_swap_text, swap_values);
Note that the third argument of SOC_VALUE_ENUM_SINGLE() is the mask bits. Passing 1 means only the least bit is evaluated no matter what value is assigned while swap_values can be 0, 1 or 3. I suppose here meant 3, but would like to know how the code is supposed to work. There are three value-enum definitions in cs42l52.c, and all pass 1 there.
Similarly, cs42l73.c has four definitions, but with different masks:
SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 6, 1, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 4, 3, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 2, 5, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 0, 7, ...
while values can be either 0, 1 or 2. Something really fishy here.
thanks,
Takashi
Let me bring up a board and see how the registers get set. To be honest, I don't know why the 3 value is the way it is...
-Brian
Similarly, cs42l73.c has four definitions, but with different masks:
SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 6, 1, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 4, 3, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 2, 5, ... SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 0, 7, ...
The 3rd argument appears to line up with the register offset for each block. Don't really know why, but I'll check
Thanks, Brian
participants (2)
-
Brian Austin
-
Takashi Iwai