Commit c3de683c authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: rt1011: Fix 'I2S Reference' enum control caused error

Access to 'I2S Reference' enum causes alsamixer to fail to load:
$ alsamixer
cannot load mixer controls: Invalid argument

cml_rt1011_rt5682 cml_rt1011_rt5682: control 2:0:0:TL I2S Reference:0: access overflow

The reason is that the original patch adding the code was using
ucontrol->value.integer.value[0]
instead the correct
ucontrol->value.enumerated.item[0]

for an ENUM control.

Fixes: 87f40af2 ("ASoC: rt1011: add i2s reference control for rt1011")
Reported-by: default avatarSeppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20211011144518.2518-1-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 45ea8620
...@@ -1311,12 +1311,11 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol, ...@@ -1311,12 +1311,11 @@ static int rt1011_r0_load_info(struct snd_kcontrol *kcontrol,
.put = rt1011_r0_load_mode_put \ .put = rt1011_r0_load_mode_put \
} }
static const char * const rt1011_i2s_ref[] = { static const char * const rt1011_i2s_ref_texts[] = {
"None", "Left Channel", "Right Channel" "None", "Left Channel", "Right Channel"
}; };
static SOC_ENUM_SINGLE_DECL(rt1011_i2s_ref_enum, 0, 0, static SOC_ENUM_SINGLE_EXT_DECL(rt1011_i2s_ref_enum, rt1011_i2s_ref_texts);
rt1011_i2s_ref);
static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol, static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
...@@ -1325,7 +1324,7 @@ static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol, ...@@ -1325,7 +1324,7 @@ static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
snd_soc_kcontrol_component(kcontrol); snd_soc_kcontrol_component(kcontrol);
struct rt1011_priv *rt1011 = struct rt1011_priv *rt1011 =
snd_soc_component_get_drvdata(component); snd_soc_component_get_drvdata(component);
int i2s_ref_ch = ucontrol->value.integer.value[0]; int i2s_ref_ch = ucontrol->value.enumerated.item[0];
switch (i2s_ref_ch) { switch (i2s_ref_ch) {
case RT1011_I2S_REF_LEFT_CH: case RT1011_I2S_REF_LEFT_CH:
...@@ -1344,7 +1343,7 @@ static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol, ...@@ -1344,7 +1343,7 @@ static int rt1011_i2s_ref_put(struct snd_kcontrol *kcontrol,
dev_info(component->dev, "I2S Reference: Do nothing\n"); dev_info(component->dev, "I2S Reference: Do nothing\n");
} }
rt1011->i2s_ref = ucontrol->value.integer.value[0]; rt1011->i2s_ref = ucontrol->value.enumerated.item[0];
return 0; return 0;
} }
...@@ -1357,7 +1356,7 @@ static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol, ...@@ -1357,7 +1356,7 @@ static int rt1011_i2s_ref_get(struct snd_kcontrol *kcontrol,
struct rt1011_priv *rt1011 = struct rt1011_priv *rt1011 =
snd_soc_component_get_drvdata(component); snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = rt1011->i2s_ref; ucontrol->value.enumerated.item[0] = rt1011->i2s_ref;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment