On Fri, 2010-03-26 at 03:23 +0100, Marek Vasut wrote:
Register the WM8750 as a SPI or I2C device. This patch mostly shuffles code around. Hugely inspired by WM8753 which was already converted.
Signed-off-by: Marek Vasut marek.vasut@gmail.com
sound/soc/codecs/wm8750.c | 411 +++++++++++++++++++++++++-------------------- 1 files changed, 232 insertions(+), 179 deletions(-)
This looks mostly fine. Just a comment on the codec IO.
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 475c67a..c7ee6d2 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -29,13 +29,6 @@
#include "wm8750.h"
-#define WM8750_VERSION "0.12"
-/* codec private data */ -struct wm8750_priv {
- unsigned int sysclk;
-};
/*
- wm8750 register cache
- We can't read the WM8750 register space when we
@@ -55,6 +48,59 @@ static const u16 wm8750_reg[] = { 0x0079, 0x0079, 0x0079, /* 40 */ };
+/* codec private data */ +struct wm8750_priv {
- unsigned int sysclk;
- struct snd_soc_codec codec;
- u16 reg_cache[ARRAY_SIZE(wm8750_reg)];
+};
+/*
- read wm8750 register cache
- */
+static inline unsigned int wm8750_read_reg_cache(struct snd_soc_codec *codec,
- unsigned int reg)
+{
- u16 *cache = codec->reg_cache;
- if (reg < 1 || reg >= (ARRAY_SIZE(wm8750_reg) + 1))
return -1;
- return cache[reg - 1];
+}
+/*
- write wm8750 register cache
- */
+static inline void wm8750_write_reg_cache(struct snd_soc_codec *codec,
- unsigned int reg, unsigned int value)
+{
- u16 *cache = codec->reg_cache;
- if (reg < 1 || reg >= (ARRAY_SIZE(wm8750_reg) + 1))
return;
- cache[reg - 1] = value;
+}
+/*
- write to the WM8750 register space
- */
+static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg,
- unsigned int value)
+{
- u8 data[2];
- /* data is
* D15..D9 WM8750 register offset
* D8...D0 register data
*/
- data[0] = (reg << 1) | ((value >> 8) & 0x0001);
- data[1] = value & 0x00ff;
- wm8750_write_reg_cache(codec, reg, value);
- if (codec->hw_write(codec->control_data, data, 2) == 2)
return 0;
- else
return -EIO;
+}
We should probably use the codec IO helpers in soc-cache.c for codec read/write() e.g.
snd_soc_codec_set_cache_io(codec, 7, 9, wm8750->control_type);
This can set up the WM8750 for 7 address bits and 9 data bits and mean less code in the driver.
Thanks
Liam