From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Peter Ujfalusi <peter.ujfalusi@nokia.com>
Subject: [PATCH 21/21] ASoC: TWL4030: Add 4 channel TDM support
Date: Thu, 23 Apr 2009 20:55:55 +0100 [thread overview]
Message-ID: <1240516555-22249-21-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <20090423195420.GA20863@sirena.org.uk>
From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Support for 4 channel TDM (SND_SOC_DAIFMT_DSP_A) for twl4030
codec.
The channel allocations are:
Playback:
TDM i2s TWL RX
Channel 1 Left SDRL2
Channel 3 Right SDRR2
Channel 2 -- SDRL1
Channel 4 -- SDRR1
Capture:
TDM i2s TWL TX
Channel 1 Left TXL1
Channel 3 Right TXR1
Channel 2 -- TXL2
Channel 4 -- TXR2
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/codecs/twl4030.c | 52 ++++++++++++++++++++++++++++++++++++++++++-
sound/soc/codecs/twl4030.h | 11 +++++++++
2 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index fdf88df..e23c20c 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -1251,6 +1251,28 @@ static void twl4030_constraints(struct twl4030_priv *twl4030,
twl4030->channels);
}
+/* In case of 4 channel mode, the RX1 L/R for playback and the TX2 L/R for
+ * capture has to be enabled/disabled. */
+static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction,
+ int enable)
+{
+ u8 reg, mask;
+
+ reg = twl4030_read_reg_cache(codec, TWL4030_REG_OPTION);
+
+ if (direction == SNDRV_PCM_STREAM_PLAYBACK)
+ mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN;
+ else
+ mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN;
+
+ if (enable)
+ reg |= mask;
+ else
+ reg &= ~mask;
+
+ twl4030_write(codec, TWL4030_REG_OPTION, reg);
+}
+
static int twl4030_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -1267,6 +1289,15 @@ static int twl4030_startup(struct snd_pcm_substream *substream,
if (twl4030->configured)
twl4030_constraints(twl4030, twl4030->master_substream);
} else {
+ if (!(twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) &
+ TWL4030_OPTION_1)) {
+ /* In option2 4 channel is not supported, set the
+ * constraint for the first stream for channels, the
+ * second stream will 'inherit' this cosntraint */
+ snd_pcm_hw_constraint_minmax(substream->runtime,
+ SNDRV_PCM_HW_PARAM_CHANNELS,
+ 2, 2);
+ }
twl4030->master_substream = substream;
}
@@ -1292,6 +1323,10 @@ static void twl4030_shutdown(struct snd_pcm_substream *substream,
twl4030->configured = 0;
else if (!twl4030->master_substream->runtime->channels)
twl4030->configured = 0;
+
+ /* If the closing substream had 4 channel, do the necessary cleanup */
+ if (substream->runtime->channels == 4)
+ twl4030_tdm_enable(codec, substream->stream, 0);
}
static int twl4030_hw_params(struct snd_pcm_substream *substream,
@@ -1304,6 +1339,16 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream,
struct twl4030_priv *twl4030 = codec->private_data;
u8 mode, old_mode, format, old_format;
+ /* If the substream has 4 channel, do the necessary setup */
+ if (params_channels(params) == 4) {
+ /* Safety check: are we in the correct operating mode? */
+ if ((twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) &
+ TWL4030_OPTION_1))
+ twl4030_tdm_enable(codec, substream->stream, 1);
+ else
+ return -EINVAL;
+ }
+
if (twl4030->configured)
/* Ignoring hw_params for already configured DAI */
return 0;
@@ -1461,6 +1506,9 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai,
case SND_SOC_DAIFMT_I2S:
format |= TWL4030_AIF_FORMAT_CODEC;
break;
+ case SND_SOC_DAIFMT_DSP_A:
+ format |= TWL4030_AIF_FORMAT_TDM;
+ break;
default:
return -EINVAL;
}
@@ -1642,13 +1690,13 @@ struct snd_soc_dai twl4030_dai[] = {
.playback = {
.stream_name = "Playback",
.channels_min = 2,
- .channels_max = 2,
+ .channels_max = 4,
.rates = TWL4030_RATES | SNDRV_PCM_RATE_96000,
.formats = TWL4030_FORMATS,},
.capture = {
.stream_name = "Capture",
.channels_min = 2,
- .channels_max = 2,
+ .channels_max = 4,
.rates = TWL4030_RATES,
.formats = TWL4030_FORMATS,},
.ops = &twl4030_dai_ops,
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h
index 981ec60..3441115 100644
--- a/sound/soc/codecs/twl4030.h
+++ b/sound/soc/codecs/twl4030.h
@@ -116,6 +116,17 @@
#define TWL4030_OPTION_1 (1 << 0)
#define TWL4030_OPTION_2 (0 << 0)
+/* TWL4030_OPTION (0x02) Fields */
+
+#define TWL4030_ATXL1_EN (1 << 0)
+#define TWL4030_ATXR1_EN (1 << 1)
+#define TWL4030_ATXL2_VTXL_EN (1 << 2)
+#define TWL4030_ATXR2_VTXR_EN (1 << 3)
+#define TWL4030_ARXL1_VRX_EN (1 << 4)
+#define TWL4030_ARXR1_EN (1 << 5)
+#define TWL4030_ARXL2_EN (1 << 6)
+#define TWL4030_ARXR2_EN (1 << 7)
+
/* TWL4030_REG_MICBIAS_CTL (0x04) Fields */
#define TWL4030_MICBIAS2_CTL 0x40
--
1.5.6.3
next prev parent reply other threads:[~2009-04-23 19:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-23 19:54 ASoC updates for 2.6.31 Mark Brown
2009-04-23 19:55 ` [PATCH 01/21] ASoC: Fix warning in wm9705 Mark Brown
2009-04-23 19:55 ` [PATCH 02/21] ASoC: Factor out generic widget power checks Mark Brown
2009-04-23 19:55 ` [PATCH 03/21] ASoC: Factor out DAPM power checks for DACs and ADCs Mark Brown
2009-04-23 19:55 ` [PATCH 04/21] ASoC: Make the DAPM power check an operation on the widget Mark Brown
2009-04-23 19:55 ` [PATCH 05/21] ASoC: Fix offset of freqmode in WM8580 PLL configuration Mark Brown
2009-04-23 19:55 ` [PATCH 06/21] ASoC: Fix WM8580 volume update handling for large register changes Mark Brown
2009-04-23 19:55 ` [PATCH 07/21] ASoC: OMAP: Add checking to detect bufferless pcms Mark Brown
2009-04-23 19:55 ` [PATCH 08/21] ASoC: Add power supply widget to DAPM Mark Brown
2009-04-23 19:55 ` [PATCH 09/21] ASoC: Use DAPM supply widget for WM8903 charge pump Mark Brown
2009-04-23 19:55 ` [PATCH 10/21] ASoC: Support CLK_DSP in WM8903 Mark Brown
2009-04-23 19:55 ` [PATCH 11/21] ASoC: Optimise configuration of WM8903 DC servo Mark Brown
2009-04-23 19:55 ` [PATCH 12/21] ASoC: Actively manage the DC servo for WM8903 Mark Brown
2009-04-23 19:55 ` [PATCH 13/21] ASoC: Remove redundant rate constraint " Mark Brown
2009-04-23 19:55 ` [PATCH 14/21] ASoC: Implement WM8903 digital sidetone support Mark Brown
2009-04-23 19:55 ` [PATCH 15/21] ASoC: remove non-existing referece to CONFIG_SND_SOC_CODEC_WM8991 Mark Brown
2009-04-23 19:55 ` [PATCH 16/21] ASoC: TWL4030: Add VDL path support Mark Brown
2009-04-23 19:55 ` [PATCH 17/21] ASoC: simplify the SSP DMA parameters settings by run-time generation Mark Brown
2009-04-23 19:55 ` [PATCH 18/21] ASoC: change stereo/mono to 32-bit/16-bit for pxa-ssp Mark Brown
2009-04-23 19:55 ` [PATCH 19/21] ASoC: s3c-i2s-v2 needs to declare a license for modular builds Mark Brown
2009-04-23 20:53 ` Ben Dooks
2009-04-24 9:43 ` Mark Brown
2009-04-23 19:55 ` [PATCH 20/21] ASoC: OMAP: Add 4 channel support to mcbsp Mark Brown
2009-04-23 19:55 ` Mark Brown [this message]
2009-04-24 6:10 ` ASoC updates for 2.6.31 Takashi Iwai
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=1240516555-22249-21-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=peter.ujfalusi@nokia.com \
--cc=tiwai@suse.de \
/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