Skip to contentSkip to conversation

ASoC: es9039q2m: Document the FIR coefficient payload format

PATCH In review Karl Asseily 2 participants 2 messages Oct 24 – Nov 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: es9039q2m: Document the FIR coefficient payload format

The programmable FIR controls are TLV byte controls whose payload is the raw coefficient data, with no type/length header. Nothing in the driver says so, and the in-tree precedents differ - wm_adsp takes raw data, SOF expects a header of its own - so user space is left to guess.

The driver cannot catch a wrong guess either. snd_soc_bytes_tlv_callback() clamps the byte count to .max before calling .put, and .max is exactly the size es9039_fir_put() checks for, so an over-long write with a header in front is cut to a valid length and loads the header as the first taps.

Document the format at the control definition. No functional change.

---
 sound/soc/codecs/es9039q2m.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/codecs/es9039q2m.c +14 -0
index 4e9f86cb7..bf206bf95 100644
@@ -632,6 +632,20 @@ static struct es9039_fir_ctl es9039_fir4x = {
 	.stage_4x = true,
 };
 
+/*
+ * The FIR coefficient controls take raw coefficients and nothing else:
+ * tlv[] carries taps * ES9039_COEFF_BYTES bytes with no type/length header.
+ * snd_soc_bytes_tlv_callback() passes the user pointer to .put unchanged,
+ * so a header would be loaded as coefficients. wm_adsp uses the same
+ * convention and SOF embeds a header of its own, so the choice is stated
+ * here rather than left to be inferred.
+ *
+ * The driver cannot enforce it. The callback clamps the count it passes on
+ * to .max, which is exactly taps * ES9039_COEFF_BYTES, so the size check in
+ * es9039_fir_put() can only reject a short write. An over-long one - a
+ * header followed by a full coefficient set - arrives truncated to .max,
+ * passes the check, and loads the header words as the first taps.
+ */
 #define ES9039_FIR(xname, xctl)						\
 {									\
 	.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,				\
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 1 line · Karl Asseily

ASoC: es9039q2m: Document the FIR coefficient payload format

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5

Thanks!

[1/1] ASoC: es9039q2m: Document the FIR coefficient payload format
https://git.kernel.org/broonie/sound/c/cefbad70c7be

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