ASoC: meson: Fix issues with LibreTech Saphire
Mark Brown
maintainercover ASoC: meson: Fix issues with LibreTech Saphire
This fixes a few issues I identified when integrating a LibreTech Saphire (based on S905D3) into my CI.
---
Mark Brown (4):
ASoC: meson: g12a-toacodec: Validate written enum values
ASoC: meson: g12a-tohdmitx: Validate written enum values
ASoC: meson: g12a-toacodec: Fix event generation
ASoC: meson: g12a-tohdmitx: Fix event generation for S/PDIF mux
sound/soc/meson/g12a-toacodec.c | 5 ++++- sound/soc/meson/g12a-tohdmitx.c | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-)
---
base-commit: 610a9b8f49fbcf1100716370d3b5f6f884a2835a
change-id: 20240103-meson-enum-val-c8e4b2f01077
Best regards,
Signature · 1 line
Mark Brown <[email protected]>
Mark Brown
maintainerPATCH 1/4 ASoC: meson: g12a-toacodec: Validate written enum values
When writing to an enum we need to verify that the value written is valid for the enumeration, the helper function snd_soc_item_enum_to_val() doesn't do it since it needs to return an unsigned (and in any case we'd need to check the return value).
--- sound/soc/meson/g12a-toacodec.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/meson/g12a-toacodec.c +3 -0
@@ -71,6 +71,9 @@ static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int mux, reg; +if (ucontrol->value.enumerated.item[0 ] >= e->items) +return -EINVAL ; + mux =snd_soc_enum_item_to_val (e, ucontrol->value.enumerated.item[0 ]);regmap_field_read (priv->field_dat_sel, ®);
Signature · 1 line
2.39.2
Mark Brown
maintainerPATCH 2/4 ASoC: meson: g12a-tohdmitx: Validate written enum values
In reply to Mark BrownWhen writing to an enum we need to verify that the value written is valid for the enumeration, the helper function snd_soc_item_enum_to_val() doesn't do it since it needs to return an unsigned (and in any case we'd need to check the return value).
--- sound/soc/meson/g12a-tohdmitx.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/meson/g12a-tohdmitx.c +6 -0
@@ -45,6 +45,9 @@ static int g12a_tohdmitx_i2s_mux_put_enum(struct snd_kcontrol *kcontrol,struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int mux, changed; +if (ucontrol->value.enumerated.item[0 ] >= e->items) +return -EINVAL ; + mux =snd_soc_enum_item_to_val (e, ucontrol->value.enumerated.item[0 ]); changed = snd_soc_component_test_bits(component, e->reg, CTRL0_I2S_DAT_SEL,
@@ -93,6 +96,9 @@ static int g12a_tohdmitx_spdif_mux_put_enum(struct snd_kcontrol *kcontrol,struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int mux, changed; +if (ucontrol->value.enumerated.item[0 ] >= e->items) +return -EINVAL ; + mux =snd_soc_enum_item_to_val (e, ucontrol->value.enumerated.item[0 ]); changed = snd_soc_component_test_bits(component, TOHDMITX_CTRL0, CTRL0_SPDIF_SEL,
Signature · 1 line
2.39.2
Mark Brown
maintainerPATCH 3/4 ASoC: meson: g12a-toacodec: Fix event generation
In reply to Mark BrownWhen a control changes value the return value from _put() should be 1 so we get events generated to userspace notifying applications of the change. We are checking if there has been a change and exiting early if not but we are not providing the correct return value in the latter case, fix this.
--- sound/soc/meson/g12a-toacodec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/meson/g12a-toacodec.c +1 -1
@@ -104,7 +104,7 @@ static int g12a_toacodec_mux_put_enum(struct snd_kcontrol *kcontrol,snd_soc_dapm_mux_update_power (dapm, kcontrol, mux, e,NULL ); -return 0 ; +return 1 ; } static SOC_ENUM_SINGLE_DECL(g12a_toacodec_mux_enum, TOACODEC_CTRL0,
Signature · 1 line
2.39.2
Mark Brown
maintainerPATCH 4/4 ASoC: meson: g12a-tohdmitx: Fix event generation for S/PDIF mux
In reply to Mark BrownWhen a control changes value the return value from _put() should be 1 so we get events generated to userspace notifying applications of the change. While the I2S mux gets this right the S/PDIF mux does not, fix the return value.
--- sound/soc/meson/g12a-tohdmitx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/meson/g12a-tohdmitx.c +1 -1
@@ -118,7 +118,7 @@ static int g12a_tohdmitx_spdif_mux_put_enum(struct snd_kcontrol *kcontrol,snd_soc_dapm_mux_update_power (dapm, kcontrol, mux, e,NULL ); -return 0 ; +return 1 ; } static SOC_ENUM_SINGLE_DECL(g12a_tohdmitx_spdif_mux_enum, TOHDMITX_CTRL0,
Signature · 1 line
2.39.2
Mark Brown
maintainerQuoted 4 lines · Mark Brown
This fixes a few issues I identified when integrating a LibreTech Saphire (based on S905D3) into my CI.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: meson: g12a-toacodec: Validate written enum values
commit: 3150b70e944ead909260285dfb5707d0bedcf87b
[2/4] ASoC: meson: g12a-tohdmitx: Validate written enum values
commit: 1e001206804be3f3d21f4a1cf16e5d059d75643f
[3/4] ASoC: meson: g12a-toacodec: Fix event generation
commit: 172c88244b5f2d3375403ebb504d407be0fded59
[4/4] ASoC: meson: g12a-tohdmitx: Fix event generation for S/PDIF mux
commit: b036d8ef3120b996751495ce25994eea58032a98All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark