From 035f064c3797cff1b4474edc22886c65cb58d483 Mon Sep 17 00:00:00 2001 From: Cliff Cai Date: Thu, 18 Mar 2010 16:17:00 +0800 Subject: [PATCH] --- yaml --- r: 193351 b: refs/heads/master c: 85dfcdffc227717fd218b9a86b507d9b7a3c321d h: refs/heads/master i: 193349: bf1448d42c9c51a17d79a4a15ce547696597f30f 193347: f674303c46f891aa727ef26e573da33d123bba8c 193343: 8cc5e1ce68805a68f31080d746820ce01023cfd0 v: v3 --- [refs] | 2 +- trunk/sound/soc/soc-cache.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index fe72d5940d95..1ad5d60e8cef 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: dd76769dd53bdb804a4b02a3eb256f4740f78720 +refs/heads/master: 85dfcdffc227717fd218b9a86b507d9b7a3c321d diff --git a/trunk/sound/soc/soc-cache.c b/trunk/sound/soc/soc-cache.c index bf593a834f5a..91db7afb1210 100644 --- a/trunk/sound/soc/soc-cache.c +++ b/trunk/sound/soc/soc-cache.c @@ -225,6 +225,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,