All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O
@ 2009-09-07  3:04 Joonyoung Shim
  2009-09-07 10:15 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Joonyoung Shim @ 2009-09-07  3:04 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, kyungmin.park

This patch is for the AK4671 codec driver using this format.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 sound/soc/soc-cache.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index c8ceddc..404231e 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -77,6 +77,35 @@ static int snd_soc_7_9_spi_write(void *control_data, const char *data,
 #define snd_soc_7_9_spi_write NULL
 #endif
 
+static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg,
+			     unsigned int value)
+{
+	u8 *cache = codec->reg_cache;
+	u8 data[2];
+
+	BUG_ON(codec->volatile_register);
+
+	data[0] = reg & 0xff;
+	data[1] = value & 0xff;
+
+	if (reg < codec->reg_cache_size)
+		cache[reg] = value;
+
+	if (codec->hw_write(codec->control_data, data, 2) == 2)
+		return 0;
+	else
+		return -EIO;
+}
+
+static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec,
+				     unsigned int reg)
+{
+	u8 *cache = codec->reg_cache;
+	if (reg >= codec->reg_cache_size)
+		return -1;
+	return cache[reg];
+}
+
 static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg,
 			      unsigned int value)
 {
@@ -151,6 +180,7 @@ static struct {
 	unsigned int (*i2c_read)(struct snd_soc_codec *, unsigned int);
 } io_types[] = {
 	{ 7, 9, snd_soc_7_9_write, snd_soc_7_9_spi_write, snd_soc_7_9_read },
+	{ 8, 8, snd_soc_8_8_write, NULL, snd_soc_8_8_read, NULL },
 	{ 8, 16, snd_soc_8_16_write, NULL, snd_soc_8_16_read,
 	  snd_soc_8_16_read_i2c },
 };
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O
  2009-09-07  3:04 [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O Joonyoung Shim
@ 2009-09-07 10:15 ` Mark Brown
  2009-09-07 10:40   ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2009-09-07 10:15 UTC (permalink / raw)
  To: Joonyoung Shim; +Cc: alsa-devel, kyungmin.park

On Mon, Sep 07, 2009 at 12:04:37PM +0900, Joonyoung Shim wrote:
> This patch is for the AK4671 codec driver using this format.

> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O
  2009-09-07 10:15 ` Mark Brown
@ 2009-09-07 10:40   ` Takashi Iwai
  2009-09-07 10:50     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2009-09-07 10:40 UTC (permalink / raw)
  To: Mark Brown; +Cc: kyungmin.park, alsa-devel, Joonyoung Shim

At Mon, 7 Sep 2009 11:15:19 +0100,
Mark Brown wrote:
> 
> On Mon, Sep 07, 2009 at 12:04:37PM +0900, Joonyoung Shim wrote:
> > This patch is for the AK4671 codec driver using this format.
> 
> > Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
> 
> Applied, thanks.

Where we are at it: Mark, could you fix the initialization of io_types[]
in C99 style?  For this case, C99 style initialization is suited better
since some fields are optional now.

Also, I find the current unbalanced hw_read/hw_write definitions uneasy.
hw_read takes the codec instance while hw_write takes i2c instance
(and hw_read_t is dead).  It'd be nice if you can fix these as well.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O
  2009-09-07 10:40   ` Takashi Iwai
@ 2009-09-07 10:50     ` Mark Brown
  2009-09-07 10:52       ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2009-09-07 10:50 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: kyungmin.park, alsa-devel, Joonyoung Shim

On Mon, Sep 07, 2009 at 12:40:02PM +0200, Takashi Iwai wrote:

> Where we are at it: Mark, could you fix the initialization of io_types[]
> in C99 style?  For this case, C99 style initialization is suited better
> since some fields are optional now.

Meh, I guess.

> Also, I find the current unbalanced hw_read/hw_write definitions uneasy.
> hw_read takes the codec instance while hw_write takes i2c instance
> (and hw_read_t is dead).  It'd be nice if you can fix these as well.

I don't think it's worth the pain until more of the drivers are using
the shared cache functions - making changes like that more
straightforward is one of the goals of doing this refactoring.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O
  2009-09-07 10:50     ` Mark Brown
@ 2009-09-07 10:52       ` Takashi Iwai
  2009-09-07 10:54         ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2009-09-07 10:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: kyungmin.park, alsa-devel, Joonyoung Shim

At Mon, 7 Sep 2009 11:50:06 +0100,
Mark Brown wrote:
> 
> On Mon, Sep 07, 2009 at 12:40:02PM +0200, Takashi Iwai wrote:
> 
> > Where we are at it: Mark, could you fix the initialization of io_types[]
> > in C99 style?  For this case, C99 style initialization is suited better
> > since some fields are optional now.
> 
> Meh, I guess.
> 
> > Also, I find the current unbalanced hw_read/hw_write definitions uneasy.
> > hw_read takes the codec instance while hw_write takes i2c instance
> > (and hw_read_t is dead).  It'd be nice if you can fix these as well.
> 
> I don't think it's worth the pain until more of the drivers are using
> the shared cache functions - making changes like that more
> straightforward is one of the goals of doing this refactoring.

OK, but at least hw_read_t should be removed or fixed :)


thanks,

Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O
  2009-09-07 10:52       ` Takashi Iwai
@ 2009-09-07 10:54         ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2009-09-07 10:54 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: kyungmin.park, alsa-devel, Joonyoung Shim

On Mon, Sep 07, 2009 at 12:52:37PM +0200, Takashi Iwai wrote:

> OK, but at least hw_read_t should be removed or fixed :)

Yeah, I'll remove it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-07 10:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-07  3:04 [PATCH] ASoC: Factor out I2C 8 bit address 8 bit data I/O Joonyoung Shim
2009-09-07 10:15 ` Mark Brown
2009-09-07 10:40   ` Takashi Iwai
2009-09-07 10:50     ` Mark Brown
2009-09-07 10:52       ` Takashi Iwai
2009-09-07 10:54         ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.