diff options
author | Cliff Cai <cliff.cai@analog.com> | 2010-03-18 04:17:00 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-18 07:23:15 -0400 |
commit | 85dfcdffc227717fd218b9a86b507d9b7a3c321d (patch) | |
tree | 39e36a2b449d8422771daf1956ede450e7d3ffa3 /sound/soc/soc-cache.c | |
parent | dd76769dd53bdb804a4b02a3eb256f4740f78720 (diff) |
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, | |||
226 | } | 226 | } |
227 | 227 | ||
228 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) | 228 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) |
229 | static unsigned int snd_soc_8_8_read_i2c(struct snd_soc_codec *codec, | ||
230 | unsigned int r) | ||
231 | { | ||
232 | struct i2c_msg xfer[2]; | ||
233 | u8 reg = r; | ||
234 | u8 data; | ||
235 | int ret; | ||
236 | struct i2c_client *client = codec->control_data; | ||
237 | |||
238 | /* Write register */ | ||
239 | xfer[0].addr = client->addr; | ||
240 | xfer[0].flags = 0; | ||
241 | xfer[0].len = 1; | ||
242 | xfer[0].buf = ® | ||
243 | |||
244 | /* Read data */ | ||
245 | xfer[1].addr = client->addr; | ||
246 | xfer[1].flags = I2C_M_RD; | ||
247 | xfer[1].len = 1; | ||
248 | xfer[1].buf = &data; | ||
249 | |||
250 | ret = i2c_transfer(client->adapter, xfer, 2); | ||
251 | if (ret != 2) { | ||
252 | dev_err(&client->dev, "i2c_transfer() returned %d\n", ret); | ||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | return data; | ||
257 | } | ||
258 | #else | ||
259 | #define snd_soc_8_8_read_i2c NULL | ||
260 | #endif | ||
261 | |||
262 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) | ||
229 | static unsigned int snd_soc_8_16_read_i2c(struct snd_soc_codec *codec, | 263 | static unsigned int snd_soc_8_16_read_i2c(struct snd_soc_codec *codec, |
230 | unsigned int r) | 264 | unsigned int r) |
231 | { | 265 | { |
@@ -466,6 +500,7 @@ static struct { | |||
466 | { | 500 | { |
467 | .addr_bits = 8, .data_bits = 8, | 501 | .addr_bits = 8, .data_bits = 8, |
468 | .write = snd_soc_8_8_write, .read = snd_soc_8_8_read, | 502 | .write = snd_soc_8_8_write, .read = snd_soc_8_8_read, |
503 | .i2c_read = snd_soc_8_8_read_i2c, | ||
469 | }, | 504 | }, |
470 | { | 505 | { |
471 | .addr_bits = 8, .data_bits = 16, | 506 | .addr_bits = 8, .data_bits = 16, |