From: "Prchal Jiří" <jiri.prchal@aksignal.cz>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: alsa-devel@vger.kernel.org, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
Date: Mon, 04 Apr 2011 10:01:54 +0200 [thread overview]
Message-ID: <4D997AF2.5040601@aksignal.cz> (raw)
In-Reply-To: <20110402082604.GE21737@sirena.org.uk>
Hi,
this is separated generic part of previous patch.
It contains read and write functions for codecs which communicate via SPI with 7bit register address, 1 LSB is
read/write and 2nd byte data.
Dne 2.4.2011 10:26, Mark Brown napsal(a):
>> +/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
>> +static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
>> + unsigned int reg)
>> +{
>> + int ret;
>> + unsigned int val;
>
> This won't apply against the current kernel and should be a separate
> patch, it's a generic thing rather than part of the CODEC driver.
> --
> To unsubscribe from this list: send the line "unsubscribe alsa-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/soc-cache.c
linux-2.6.38-patch/sound/soc/soc-cache.c
--- linux-2.6.38-vanilla/sound/soc/soc-cache.c 2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/soc-cache.c 2011-03-24 09:23:00.984373772 +0100
@@ -99,6 +99,58 @@ static int snd_soc_4_12_spi_write(void *
#define snd_soc_4_12_spi_write NULL
#endif
+/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
+static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
+ unsigned int reg)
+{
+ int ret;
+ unsigned int val;
+
+ if (reg >= codec->driver->reg_cache_size ||
+ snd_soc_codec_volatile_register(codec, reg)) {
+ if (codec->cache_only)
+ return -1;
+
+ BUG_ON(!codec->hw_read);
+ return codec->hw_read(codec, ((reg << 1) | 1));
+ }
+
+ ret = snd_soc_cache_read(codec, reg, &val);
+ if (ret < 0)
+ return -1;
+ return val;
+}
+
+static int snd_soc_7_8_write(struct snd_soc_codec *codec, unsigned int reg,
+ unsigned int value)
+{
+ u8 data[2];
+ int ret;
+
+ data[0] = (reg << 1);
+ data[1] = value;
+
+ if (!snd_soc_codec_volatile_register(codec, reg) &&
+ reg < codec->driver->reg_cache_size) {
+ ret = snd_soc_cache_write(codec, reg, value);
+ if (ret < 0)
+ return -1;
+ }
+
+ if (codec->cache_only) {
+ codec->cache_sync = 1;
+ return 0;
+ }
+
+ ret = codec->hw_write(codec->control_data, data, 2);
+ if (ret == 2)
+ return 0;
+ if (ret < 0)
+ return ret;
+ else
+ return -EIO;
+}
+
static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
unsigned int reg)
{
@@ -661,6 +713,11 @@ static struct {
.spi_write = snd_soc_4_12_spi_write,
},
{
+ .addr_bits = 7, .data_bits = 8,
+ .write = snd_soc_7_8_write, .read = snd_soc_7_8_read,
+ .spi_write = snd_soc_8_8_spi_write,
+ },
+ {
.addr_bits = 7, .data_bits = 9,
.write = snd_soc_7_9_write, .read = snd_soc_7_9_read,
.spi_write = snd_soc_7_9_spi_write,
next prev parent reply other threads:[~2011-04-04 8:01 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 6:54 [PATCH 0/2] mmc: zboot helpers Simon Horman
2011-03-24 6:54 ` Simon Horman
2011-03-24 6:54 ` [PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM " Simon Horman
2011-03-24 6:54 ` Simon Horman
2011-03-24 9:10 ` [PATCH] mmc, AT91: fix init fequency problem Prchal Jiří
2011-03-24 9:10 ` Prchal Jiří
2011-03-24 10:20 ` [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK Prchal Jiří
2011-04-02 8:26 ` Mark Brown
2011-04-02 8:26 ` [alsa-devel] " Mark Brown
2011-04-04 7:49 ` Prchal Jiří
2011-04-04 8:03 ` Mark Brown
2011-04-04 8:01 ` Prchal Jiří [this message]
2011-04-04 8:05 ` [PATCH] ALSA: ASoc: new functions snd_soc_7_8_* Mark Brown
2011-04-04 8:05 ` Mark Brown
2011-03-24 10:43 ` [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X Prchal Jiří
2011-03-24 20:07 ` Ryan Mallon
2011-03-24 20:07 ` Ryan Mallon
2011-04-04 8:57 ` Prchal Jiří
2011-04-04 20:07 ` Ryan Mallon
2011-04-04 20:07 ` Ryan Mallon
2011-04-04 9:10 ` [PATCH] ARCH arm: adding new board: CDU Prchal Jiří
2011-04-04 9:10 ` Prchal Jiří
2011-04-04 9:16 ` Russell King - ARM Linux
2011-04-04 9:16 ` Russell King - ARM Linux
2011-04-04 9:24 ` Russell King - ARM Linux
2011-04-04 9:24 ` Russell King - ARM Linux
2011-04-04 20:25 ` Ryan Mallon
2011-04-04 20:25 ` Ryan Mallon
2011-05-31 13:05 ` PROBLEM: ARM: PCM plugin Ima-ADPCM doesn't work properly Prchal Jiří
2011-03-24 6:54 ` [PATCH 2/2] mmc: Add MMC_PROGRESS_* Simon Horman
2011-03-24 6:54 ` Simon Horman
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=4D997AF2.5040601@aksignal.cz \
--to=jiri.prchal@aksignal.cz \
--cc=alsa-devel@alsa-project.org \
--cc=alsa-devel@vger.kernel.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.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 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.