Skip to contentSkip to conversation

V2, Convert bitfields in ASOC into full int width

PATCH In review Jon Smirl 2 participants 4 messages Jul 23, 2008

Subsystems (2)
lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

PATCH 1/1 V2, Convert bitfields in ASOC into full int width

Convert bitfields in ASOC into full int width. This is a simple mechanical conversion. Two places in the DAPM code were fixed to properly use mask.

---

 include/sound/soc.h  |   50 ++++++++++++++++++-----------
 sound/soc/soc-core.c |   86 ++++++++++++++++++++++++++++++--------------------
 sound/soc/soc-dapm.c |   52 ++++++++++++++++++------------
 3 files changed, 114 insertions(+), 74 deletions(-)
include/sound/soc.h +31 -19
index 1890d87..d2a6531 100644
@@ -26,10 +26,12 @@
 /*
  * Convenience kcontrol builders
  */
-#define SOC_SINGLE_VALUE(reg, shift, max, invert) ((reg) | ((shift) << 8) |\
-	((shift) << 12) | ((max) << 16) | ((invert) << 24))
-#define SOC_SINGLE_VALUE_EXT(reg, max, invert) ((reg) | ((max) << 16) |\
-	((invert) << 31))
+#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
+	((unsigned long)&(struct soc_mixer_control) \
+	{.reg = xreg, .shift = xshift, .max = xmax, .invert = xinvert})
+#define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
+	((unsigned long)&(struct soc_mixer_control) \
+	{.reg = xreg, .max = xmax, .invert = xinvert})
 #define SOC_SINGLE(xname, reg, shift, max, invert) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
@@ -43,45 +45,49 @@
 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
 	.put = snd_soc_put_volsw, \
 	.private_value =  SOC_SINGLE_VALUE(reg, shift, max, invert) }
-#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
+#define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
 	.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
 	.put = snd_soc_put_volsw, \
-	.private_value = (reg) | ((shift_left) << 8) | \
-		((shift_right) << 12) | ((max) << 16) | ((invert) << 24) }
-#define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, max, invert) \
+	.private_value = (unsigned long)&(struct soc_mixer_control) \
+		{.reg = xreg, .shift = shift_left, .rshift = shift_right, \
+		 .max = xmax, .invert = xinvert} }
+#define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
 	.info = snd_soc_info_volsw_2r, \
 	.get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
-	.private_value = (reg_left) | ((shift) << 8)  | \
-		((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
-#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
+	.private_value = (unsigned long)&(struct soc_mixer_control) \
+		{.reg = reg_left, .rreg = reg_right, .shift = xshift, \
+		.max = xmax, .invert = xinvert} }
+#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, 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, .get = snd_soc_get_volsw, \
 	.put = snd_soc_put_volsw, \
-	.private_value = (reg) | ((shift_left) << 8) | \
-		((shift_right) << 12) | ((max) << 16) | ((invert) << 24) }
-#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, shift, max, invert, tlv_array) \
+	.private_value = (unsigned long)&(struct soc_mixer_control) \
+		{.reg = xreg, .shift = shift_left, .rshift = right_shift,
+		 .max = xmax, .invert = xinvert} }
+#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 |\
 		 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
 	.tlv.p = (tlv_array), \
 	.info = snd_soc_info_volsw_2r, \
 	.get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
-	.private_value = (reg_left) | ((shift) << 8)  | \
-		((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
-#define SOC_DOUBLE_S8_TLV(xname, reg, min, max, tlv_array) \
+	.private_value = (unsigned long)&(struct soc_mixer_control) \
+		{.reg = reg_left, .rreg = reg_right, .shift = xshift, \
+		.max = xmax, .invert = xinvert} }
+#define SOC_DOUBLE_S8_TLV(xname, xreg, 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_s8, .get = snd_soc_get_volsw_s8, \
 	.put    = snd_soc_put_volsw_s8, \
-	.private_value = (reg) | (((signed char)max) << 16) | \
-			 (((signed char)min) << 24) }
+	.private_value = (unsigned long)&(struct soc_mixer_control) \
+		{.reg = xreg, .min = xmin, .max = xmax} }
 #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
 {	.reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
 	.mask = xmask, .texts = xtexts }
@@ -516,6 +522,12 @@ struct snd_soc_pcm_runtime {
 	struct snd_soc_device *socdev;
 };
 
+/* mixer control */
+struct soc_mixer_control {
+	int min, max;
+	uint reg, rreg, shift, rshift, invert;
+};
+
 /* enumerated kcontrol */
 struct soc_enum {
 	unsigned short reg;
sound/soc/soc-core.c +52 -34

146 lines not on this page · raw message

sound/soc/soc-dapm.c +31 -21

80 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · Jon Smirl

Convert bitfields in ASOC into full int width. This is a simple mechanical conversion. Two places in the DAPM code were fixed to properly use mask.

CHECK sound/soc/soc-core.c
include/sound/soc.h:71:4: error: Expected ; end of type declaration include/sound/soc.h:71:4: error: got .
sound/soc/soc-core.c:295:6: error: undefined identifier 'SND_SOC_BIAS_PREPARE' sound/soc/soc-core.c:308:6: error: undefined identifier 'SND_SOC_BIAS_STANDBY' sound/soc/soc-core.c:369:7: error: undefined identifier 'SND_SOC_BIAS_STANDBY' sound/soc/soc-core.c:441:28: error: undefined identifier 'SND_SOC_BIAS_ON' sound/soc/soc-core.c:444:11: error: undefined identifier 'SND_SOC_BIAS_PREPARE' sound/soc/soc-core.c:455:40: error: undefined identifier 'SND_SOC_BIAS_ON'
CC sound/soc/soc-core.o
In file included from sound/soc/soc-core.c:34:
include/sound/soc.h:71: error: expected identifier or ‘(’ before ‘.’ token include/sound/soc.h:71: error: expected identifier or ‘(’ before ‘}’ token

The fix was trivial enough so I've made and applied it (and done some brief testing of my own) - please be more careful in future.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author
#2 lore raw
Quoted 20 lines · Mark Brown
Quoted 3 lines · Jon Smirl

Convert bitfields in ASOC into full int width. This is a simple mechanical conversion. Two places in the DAPM code were fixed to properly use mask.

CHECK sound/soc/soc-core.c
include/sound/soc.h:71:4: error: Expected ; end of type declaration include/sound/soc.h:71:4: error: got .
sound/soc/soc-core.c:295:6: error: undefined identifier 'SND_SOC_BIAS_PREPARE' sound/soc/soc-core.c:308:6: error: undefined identifier 'SND_SOC_BIAS_STANDBY' sound/soc/soc-core.c:369:7: error: undefined identifier 'SND_SOC_BIAS_STANDBY' sound/soc/soc-core.c:441:28: error: undefined identifier 'SND_SOC_BIAS_ON' sound/soc/soc-core.c:444:11: error: undefined identifier 'SND_SOC_BIAS_PREPARE' sound/soc/soc-core.c:455:40: error: undefined identifier 'SND_SOC_BIAS_ON'
CC sound/soc/soc-core.o
In file included from sound/soc/soc-core.c:34:
include/sound/soc.h:71: error: expected identifier or '(' before '.' token include/sound/soc.h:71: error: expected identifier or '(' before '}' token

Quoted 2 lines

The fix was trivial enough so I've made and applied it (and done some brief testing of my own) - please be more careful in future.

I did that making checkpatch happy. I don't have easily buildable test cases for powerpc so I'm doing this via inspection. I'll see if I can mess with Kconfig and force all of the codecs to build.

So this one is ok with the \ added? Next round I need to clean everything up to make it 32 bit safe instead of only 16 bit. It will probably touch some of the same code and needs to apply on top of this patch.

Signature · 2 lines
Jon Smirl
[email protected]
#3 lore raw
Quoted 3 lines · Jon Smirl

I did that making checkpatch happy. I don't have easily buildable test cases for powerpc so I'm doing this via inspection. I'll see if I can mess with Kconfig and force all of the codecs to build.

Check the upstream branch of:

git://opensource.wolfsonicro.com/linux-2.6-asoc

which contains a patch that does just that.

Quoted 4 lines

So this one is ok with the \ added? Next round I need to clean everything up to make it 32 bit safe instead of only 16 bit. It will probably touch some of the same code and needs to apply on top of this patch.

Yes. Like I say, I've applied it.