All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add simplified versions of widget macros
@ 2010-01-21 20:10 Guennadi Liakhovetski
  2010-01-22  9:56 ` Liam Girdwood
  2010-01-23 18:51 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2010-01-21 20:10 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

Many macros from include/sound/soc-dapm.h take an array and a number of 
elements in it as arguments, whereas most users use static arrays and use 
"x, ARRAY_SIZE(x)" as arguments. This patch adds simplified versions of 
those macros, calling ARRAY_SIZE() internally.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index c5c95e1..c0922a0 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -95,6 +95,21 @@
 	.shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
 	.num_kcontrols = 1}
 
+/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
+#define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\
+	 wcontrols) \
+{	.id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
+	.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
+#define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \
+	 wcontrols)\
+{	.id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
+	.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
+#define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \
+	 wcontrols)\
+{       .id = snd_soc_dapm_mixer_named_ctl, .name = wname, .reg = wreg, \
+	.shift = wshift, .invert = winvert, .kcontrols = wcontrols, \
+	.num_kcontrols = ARRAY_SIZE(wcontrols)}
+
 /* path domain with event - event handler must return 0 for success */
 #define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \
 	wncontrols, wevent, wflags) \
@@ -126,6 +141,23 @@
 	.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
 	.event = wevent, .event_flags = wflags}
 
+/* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
+#define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
+	wevent, wflags) \
+{	.id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
+	.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
+	.event = wevent, .event_flags = wflags}
+#define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
+	wevent, wflags) \
+{	.id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
+	.invert = winvert, .kcontrols = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
+	.event = wevent, .event_flags = wflags}
+#define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \
+	wcontrols, wevent, wflags) \
+{       .id = snd_soc_dapm_mixer, .name = wname, .reg = wreg, .shift = wshift, \
+	.invert = winvert, .kcontrols = wcontrols, \
+	.num_kcontrols = ARRAY_SIZE(wcontrols), .event = wevent, .event_flags = wflags}
+
 /* events that are pre and post DAPM */
 #define SND_SOC_DAPM_PRE(wname, wevent) \
 {	.id = snd_soc_dapm_pre, .name = wname, .kcontrols = NULL, \

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

* Re: [PATCH] add simplified versions of widget macros
  2010-01-21 20:10 [PATCH] add simplified versions of widget macros Guennadi Liakhovetski
@ 2010-01-22  9:56 ` Liam Girdwood
  2010-01-23 18:51 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-01-22  9:56 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: alsa-devel, Mark Brown

On Thu, 2010-01-21 at 21:10 +0100, Guennadi Liakhovetski wrote:
> Many macros from include/sound/soc-dapm.h take an array and a number of 
> elements in it as arguments, whereas most users use static arrays and use 
> "x, ARRAY_SIZE(x)" as arguments. This patch adds simplified versions of 
> those macros, calling ARRAY_SIZE() internally.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Both macro patches :-

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>

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

* Re: [PATCH] add simplified versions of widget macros
  2010-01-21 20:10 [PATCH] add simplified versions of widget macros Guennadi Liakhovetski
  2010-01-22  9:56 ` Liam Girdwood
@ 2010-01-23 18:51 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-01-23 18:51 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: alsa-devel, Liam Girdwood

On Thu, Jan 21, 2010 at 09:10:47PM +0100, Guennadi Liakhovetski wrote:
> Many macros from include/sound/soc-dapm.h take an array and a number of 
> elements in it as arguments, whereas most users use static arrays and use 
> "x, ARRAY_SIZE(x)" as arguments. This patch adds simplified versions of 
> those macros, calling ARRAY_SIZE() internally.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

I'll apply both of these, however I think I'll shortly cook up a patch
to switch things around so that the new variant of _PGA becomes the
default since with modern CODECs it's very rare to need the ramping
support for the volumes so the overwhelming majority of PGAs are better
off using the new version.

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

end of thread, other threads:[~2010-01-23 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-21 20:10 [PATCH] add simplified versions of widget macros Guennadi Liakhovetski
2010-01-22  9:56 ` Liam Girdwood
2010-01-23 18:51 ` Mark Brown

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.