All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: core: Add new SOC_DOUBLE_SX_TLV macro
@ 2022-03-11 16:32 Charles Keepax
  2022-03-11 16:39 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Keepax @ 2022-03-11 16:32 UTC (permalink / raw)
  To: broonie; +Cc: patches, alsa-devel, lgirdwood

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.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 include/sound/soc.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 7a1650b303f14..5e187236c2ad6 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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 |\
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: core: Add new SOC_DOUBLE_SX_TLV macro
  2022-03-11 16:32 [PATCH] ASoC: core: Add new SOC_DOUBLE_SX_TLV macro Charles Keepax
@ 2022-03-11 16:39 ` Mark Brown
  2022-03-11 16:42   ` Charles Keepax
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2022-03-11 16:39 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, alsa-devel, lgirdwood

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

On Fri, Mar 11, 2022 at 04:32:58PM +0000, Charles Keepax wrote:
> 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?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: core: Add new SOC_DOUBLE_SX_TLV macro
  2022-03-11 16:39 ` Mark Brown
@ 2022-03-11 16:42   ` Charles Keepax
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2022-03-11 16:42 UTC (permalink / raw)
  To: Mark Brown; +Cc: patches, alsa-devel, lgirdwood

On Fri, Mar 11, 2022 at 04:39:57PM +0000, Mark Brown wrote:
> On Fri, Mar 11, 2022 at 04:32:58PM +0000, Charles Keepax wrote:
> > 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-11 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 16:32 [PATCH] ASoC: core: Add new SOC_DOUBLE_SX_TLV macro Charles Keepax
2022-03-11 16:39 ` Mark Brown
2022-03-11 16:42   ` Charles Keepax

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.