alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org
Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
	Cliff Cai <cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>,
	Barry Song <barry.song-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 3/4] soc-cache: add i2c read entry for 8_8 mode
Date: Thu, 18 Mar 2010 16:17:00 +0800	[thread overview]
Message-ID: <1268900221-6833-4-git-send-email-21cnbao@gmail.com> (raw)
In-Reply-To: <1268900221-6833-3-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

From: Cliff Cai <cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Cliff Cai <cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Barry Song <barry.song-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
 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 bf593a8..91db7af 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 = &reg;
+
+	/* 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,
-- 
1.5.6.3

  parent reply	other threads:[~2010-03-18  8:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18  8:16 [PATCH 0/4] extend ad1938 codec/machine driver to ad193x supporting ad1936/7/8/9 Barry Song
     [not found] ` <1268900221-6833-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-03-18  8:16   ` [PATCH 1/4] extend ad1938 codec " Barry Song
     [not found]     ` <1268900221-6833-2-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-03-18  8:16       ` [PATCH 2/4] change bf5xx-ad1938 machine driver to bf5xx-ad193x machine driver Barry Song
     [not found]         ` <1268900221-6833-3-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-03-18  8:17           ` Barry Song [this message]
2010-03-18  8:17             ` [PATCH 4/4] soc-cache: let reg be AND'ed by 0xff instead of data buffer for 8_8 mode Barry Song
2010-03-18  9:00               ` Liam Girdwood
2010-03-18 11:30                 ` Mark Brown
2010-03-18  8:51             ` [PATCH 3/4] soc-cache: add i2c read entry " Liam Girdwood
2010-03-18 11:29               ` Mark Brown
2010-03-18 11:22         ` [PATCH 2/4] change bf5xx-ad1938 machine driver to bf5xx-ad193x machine driver Mark Brown
2010-03-18  8:48     ` [PATCH 1/4] extend ad1938 codec driver to ad193x supporting ad1936/7/8/9 Liam Girdwood
2010-03-18  9:08       ` Barry Song
2010-03-18 11:18         ` Mark Brown
2010-03-18 15:57           ` [Uclinux-dist-devel] " Mike Frysinger
2010-03-18 16:20             ` Mark Brown
2010-03-18 17:17               ` Mike Frysinger
2010-03-18 18:05                 ` Mark Brown
2010-03-18 18:08                   ` Mike Frysinger
2010-03-19  3:30                     ` Barry Song
2010-03-19  7:07                       ` Barry Song
2010-03-19  9:03                         ` Liam Girdwood
2010-03-19 12:24                         ` Mark Brown
2010-03-22  5:50                           ` Barry Song
2010-03-22 12:52                             ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268900221-6833-4-git-send-email-21cnbao@gmail.com \
    --to=21cnbao-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=barry.song-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=cliff.cai-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org \
    --cc=uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).