diff options
author | Cliff Cai <cliff.cai@analog.com> | 2010-03-18 16:17:00 +0800 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-18 11:23:15 +0000 |
commit | 85dfcdffc227717fd218b9a86b507d9b7a3c321d (patch) | |
tree | 39e36a2b449d8422771daf1956ede450e7d3ffa3 /sound/soc/soc-cache.c | |
parent | dd76769dd53bdb804a4b02a3eb256f4740f78720 (diff) | |
download | linux-85dfcdffc227717fd218b9a86b507d9b7a3c321d.tar.bz2 |
ASoC: soc-cache: add i2c read entry for 8_8 mode
Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Barry Song <barry.song@analog.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-cache.c')
-rw-r--r-- | sound/soc/soc-cache.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index bf593a834f5a..91db7afb1210 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -226,6 +226,40 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec, } #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) +static unsigned int snd_soc_8_8_read_i2c(struct snd_soc_codec *codec, + unsigned int r) +{ + struct i2c_msg xfer[2]; + u8 reg = r; + u8 data; + int ret; + struct i2c_client *client = codec->control_data; + + /* Write register */ + xfer[0].addr = client->addr; + xfer[0].flags = 0; + xfer[0].len = 1; + xfer[0].buf = ® + + /* Read data */ + xfer[1].addr = client->addr; + xfer[1].flags = I2C_M_RD; + xfer[1].len = 1; + xfer[1].buf = &data; + + ret = i2c_transfer(client->adapter, xfer, 2); + if (ret != 2) { + dev_err(&client->dev, "i2c_transfer() returned %d\n", ret); + return 0; + } + + return data; +} +#else +#define snd_soc_8_8_read_i2c NULL +#endif + +#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) static unsigned int snd_soc_8_16_read_i2c(struct snd_soc_codec *codec, unsigned int r) { @@ -466,6 +500,7 @@ static struct { { .addr_bits = 8, .data_bits = 8, .write = snd_soc_8_8_write, .read = snd_soc_8_8_read, + .i2c_read = snd_soc_8_8_read_i2c, }, { .addr_bits = 8, .data_bits = 16, |