alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
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,

  parent reply	other threads:[~2011-04-04  8:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1300949648-15078-1-git-send-email-horms@verge.net.au>
     [not found] ` <1300949648-15078-2-git-send-email-horms@verge.net.au>
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-04  7:49       ` [alsa-devel] " 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-03-24 10:43   ` [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X Prchal Jiří
2011-03-24 20:07     ` Ryan Mallon
2011-04-04  8:57       ` Prchal Jiří
2011-04-04 20:07         ` Ryan Mallon
2011-05-31 13:05       ` PROBLEM: ARM: PCM plugin Ima-ADPCM doesn't work properly Prchal Jiří

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 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).