alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: Remove byte swap in 4x12 SPI write
@ 2011-05-11 11:53 Mark Brown
  2011-05-11 11:53 ` [PATCH 2/2] ASoC: Use spi_write() for SPI writes Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Mark Brown @ 2011-05-11 11:53 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown

snd_soc_4_12_spi_write() contains a byte swap. Since this code was written
for an Analog CODEC on a Blackfin reference board it appears that this is
done because while Blackfin is little endian the CODEC is big endian (as
are most CODECs).

Push this up into the generic 4x12 write function and use cpu_to_be16() to
do the byte swap so things are more regular and things work on both CPU
endiannesses.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/soc-cache.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 6e5e30a..73907e5 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -101,12 +101,11 @@ static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec,
 static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg,
 			      unsigned int value)
 {
-	u8 data[2];
+	u16 data;
 
-	data[0] = (reg << 4) | ((value >> 8) & 0x000f);
-	data[1] = value & 0x00ff;
+	data = cpu_to_be16((reg << 12) | (value & 0xffffff));
 
-	return do_hw_write(codec, reg, value, data, 2);
+	return do_hw_write(codec, reg, value, &data, 2);
 }
 
 #if defined(CONFIG_SPI_MASTER)
@@ -115,8 +114,8 @@ static int snd_soc_4_12_spi_write(void *control_data, const char *data,
 {
 	u8 msg[2];
 
-	msg[0] = data[1];
-	msg[1] = data[0];
+	msg[0] = data[0];
+	msg[1] = data[1];
 
 	return do_spi_write(control_data, msg, len);
 }
-- 
1.7.5.1

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

end of thread, other threads:[~2011-05-11 18:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-11 11:53 [PATCH 1/2] ASoC: Remove byte swap in 4x12 SPI write Mark Brown
2011-05-11 11:53 ` [PATCH 2/2] ASoC: Use spi_write() for SPI writes Mark Brown
2011-05-11 17:16   ` Lars-Peter Clausen
2011-05-11 17:24     ` Mark Brown
2011-05-11 13:37 ` [PATCH 1/2] ASoC: Remove byte swap in 4x12 SPI write Liam Girdwood
2011-05-11 17:35 ` Lars-Peter Clausen
2011-05-11 17:48   ` Mark Brown
2011-05-11 18:02     ` Lars-Peter Clausen
2011-05-11 18:05       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).