Skip to contentSkip to conversation

ASoC: core: Add new SOC_DOUBLE_SX_TLV macro

PATCH In review Charles Keepax 2 participants 3 messages Mar 11, 2022

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

PATCH 1/1 ASoC: core: Add new SOC_DOUBLE_SX_TLV macro

Currently macros only exist for SX style (implicit sign bit 2's compliment) volume controls where the volumes for left and right are in separate registers. Some future Cirrus devices will have both volumes in the same register, as such add a new macro to support this.

---
 include/sound/soc.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/sound/soc.h +12 -0
index 7a1650b303f14..5e187236c2ad6 100644
@@ -136,6 +136,18 @@
 	.put = snd_soc_put_volsw, \
 	.private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
 					  max, invert, 0) }
+#define SOC_DOUBLE_SX_TLV(xname, xreg, shift_left, shift_right, xmin, xmax, tlv_array) \
+{       .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
+	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
+	SNDRV_CTL_ELEM_ACCESS_READWRITE, \
+	.tlv.p  = (tlv_array), \
+	.info = snd_soc_info_volsw_sx, \
+	.get = snd_soc_get_volsw_sx, \
+	.put = snd_soc_put_volsw_sx, \
+	.private_value = (unsigned long)&(struct soc_mixer_control) \
+		{.reg = xreg, .rreg = xreg, \
+		.shift = shift_left, .rshift = shift_right, \
+		.max = xmax, .min = xmin} }
 #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
 	.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 5 lines · Charles Keepax

Currently macros only exist for SX style (implicit sign bit 2's compliment) volume controls where the volumes for left and right are in separate registers. Some future Cirrus devices will have both volumes in the same register, as such add a new macro to support this.

Have you tested the bounds checking on _SX controls with mixer-test?

#2 lore raw
Quoted 8 lines · Mark Brown
Quoted 5 lines · Charles Keepax

Currently macros only exist for SX style (implicit sign bit 2's compliment) volume controls where the volumes for left and right are in separate registers. Some future Cirrus devices will have both volumes in the same register, as such add a new macro to support this.

Have you tested the bounds checking on _SX controls with mixer-test?

I have tested against some experimental code for a future CODEC, but this is a good point. Let me run some tests through mixer-test before we apply.

Thanks,
Charles