From 7be95b3ccc9c2f4bb73f10f78f0c0683295a2370 Mon Sep 17 00:00:00 2001 From: Dimitris Papastamos Date: Mon, 4 Oct 2010 11:25:13 +0100 Subject: [PATCH] --- yaml --- r: 216611 b: refs/heads/master c: f479fd93d4028afccf155dec736c6d49cde92571 h: refs/heads/master i: 216609: 134a229a3f37be0cdb488c873bea8e0232fb759d 216607: 211ece1f63918c3d60da22954af8b2cdb81aea4e v: v3 --- [refs] | 2 +- trunk/sound/soc/soc-cache.c | 96 +++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4c060d2f4021..bd7a7c4847be 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bb5a027026db86b0c676104b2e3f6cc4768d1ac0 +refs/heads/master: f479fd93d4028afccf155dec736c6d49cde92571 diff --git a/trunk/sound/soc/soc-cache.c b/trunk/sound/soc/soc-cache.c index 62f1e2b776c4..d214f02cbb65 100644 --- a/trunk/sound/soc/soc-cache.c +++ b/trunk/sound/soc/soc-cache.c @@ -211,6 +211,36 @@ static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec, return cache[reg]; } +#if defined(CONFIG_SPI_MASTER) +static int snd_soc_8_8_spi_write(void *control_data, const char *data, + int len) +{ + struct spi_device *spi = control_data; + struct spi_transfer t; + struct spi_message m; + u8 msg[2]; + + if (len <= 0) + return 0; + + msg[0] = data[0]; + msg[1] = data[1]; + + spi_message_init(&m); + memset(&t, 0, (sizeof t)); + + t.tx_buf = &msg[0]; + t.len = len; + + spi_message_add_tail(&t, &m); + spi_sync(spi, &m); + + return len; +} +#else +#define snd_soc_8_8_spi_write NULL +#endif + static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { @@ -254,6 +284,37 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec, } } +#if defined(CONFIG_SPI_MASTER) +static int snd_soc_8_16_spi_write(void *control_data, const char *data, + int len) +{ + struct spi_device *spi = control_data; + struct spi_transfer t; + struct spi_message m; + u8 msg[3]; + + if (len <= 0) + return 0; + + msg[0] = data[0]; + msg[1] = data[1]; + msg[2] = data[2]; + + spi_message_init(&m); + memset(&t, 0, (sizeof t)); + + t.tx_buf = &msg[0]; + t.len = len; + + spi_message_add_tail(&t, &m); + spi_sync(spi, &m); + + return len; +} +#else +#define snd_soc_8_16_spi_write NULL +#endif + #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) @@ -518,6 +579,38 @@ static int snd_soc_16_16_write(struct snd_soc_codec *codec, unsigned int reg, return -EIO; } +#if defined(CONFIG_SPI_MASTER) +static int snd_soc_16_16_spi_write(void *control_data, const char *data, + int len) +{ + struct spi_device *spi = control_data; + struct spi_transfer t; + struct spi_message m; + u8 msg[4]; + + if (len <= 0) + return 0; + + msg[0] = data[0]; + msg[1] = data[1]; + msg[2] = data[2]; + msg[3] = data[3]; + + spi_message_init(&m); + memset(&t, 0, (sizeof t)); + + t.tx_buf = &msg[0]; + t.len = len; + + spi_message_add_tail(&t, &m); + spi_sync(spi, &m); + + return len; +} +#else +#define snd_soc_16_16_spi_write NULL +#endif + static struct { int addr_bits; int data_bits; @@ -540,11 +633,13 @@ 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, + .spi_write = snd_soc_8_8_spi_write, }, { .addr_bits = 8, .data_bits = 16, .write = snd_soc_8_16_write, .read = snd_soc_8_16_read, .i2c_read = snd_soc_8_16_read_i2c, + .spi_write = snd_soc_8_16_spi_write, }, { .addr_bits = 16, .data_bits = 8, @@ -556,6 +651,7 @@ static struct { .addr_bits = 16, .data_bits = 16, .write = snd_soc_16_16_write, .read = snd_soc_16_16_read, .i2c_read = snd_soc_16_16_read_i2c, + .spi_write = snd_soc_16_16_spi_write, }, };