Skip to contentSkip to conversation

ASoC: meson: Fix issues with LibreTech Saphire

PATCH In review Mark Brown 1 participant 6 messages Jan 3, 2024

Subsystems (4)
lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

cover 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]>
author maintainer
#1 lore raw

PATCH 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).

Fixes af2618a2eee8 ("ASoC: meson: g12a: add internal DAC glue driver")
---
 sound/soc/meson/g12a-toacodec.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/meson/g12a-toacodec.c +3 -0
index 6c4503766fdc..dd7f07de2685 100644
@@ -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, &reg);
 
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH 2/4 ASoC: meson: g12a-tohdmitx: Validate written enum values

In reply to Mark Brown

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).

Fixes c8609f3870f7 ("ASoC: meson: add g12a tohdmitx control")
---
 sound/soc/meson/g12a-tohdmitx.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/meson/g12a-tohdmitx.c +6 -0
index f7ef9aa1eed8..51b7703e1834 100644
@@ -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
author maintainer
#3 lore raw

PATCH 3/4 ASoC: meson: g12a-toacodec: Fix event generation

In reply to Mark Brown

When 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.

Fixes af2618a2eee8 ("ASoC: meson: g12a: add internal DAC glue driver")
---
 sound/soc/meson/g12a-toacodec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/meson/g12a-toacodec.c +1 -1
index dd7f07de2685..531bb8707a3e 100644
@@ -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
author maintainer
#4 lore raw

PATCH 4/4 ASoC: meson: g12a-tohdmitx: Fix event generation for S/PDIF mux

In reply to Mark Brown

When 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.

Fixes c8609f3870f7 ("ASoC: meson: add g12a tohdmitx control")
---
 sound/soc/meson/g12a-tohdmitx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/meson/g12a-tohdmitx.c +1 -1
index 51b7703e1834..b92434125fac 100644
@@ -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
author maintainer
#5 lore raw
In reply to Mark Brown
Quoted 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: b036d8ef3120b996751495ce25994eea58032a98

All 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