* [PATCH 0/3] ASoC: 4 channel support for twl4030 and omap-mcbsp - Try2 @ 2009-04-23 11:36 Peter Ujfalusi 2009-04-23 11:36 ` [PATCH 1/3] ASoC: OMAP: Add 4 channel support to mcbsp Peter Ujfalusi 0 siblings, 1 reply; 6+ messages in thread From: Peter Ujfalusi @ 2009-04-23 11:36 UTC (permalink / raw) To: alsa-devel; +Cc: sakoman, broonie, jarkko.nikula Hello, This series adds support for 4 channel DSP mode (A or B) to OMAP McBSP and also to the twl4030 codec driver. As an example the Beagle board file is modified to be able to use 4 channel mode. The change in twl4030 is made in a way, that it will not enable the 4 channel mode when the codec is in OPTION2 mode. Since some of the bits in the OPTION register are shared and have different effect in OPTION1 and OPTION2 modes, an extra care is taken to prevent unvanted modification to the register. Note: The series is on top of Mark's tree in regard of the twl4030 codec, so it is on top of the 'ASoC: TWL4030: Add VDL path support' from Joonyoung Shim. --- Peter Ujfalusi (2): ASoC: OMAP: Add 4 channel support to mcbsp ASoC: TWL4030: Add 4 channel TDM support Ujfalusi Peter (Nokia-D/Tampere) (1): ASoC: Beagle: Add support for 4 channel mode sound/soc/codecs/twl4030.c | 52 ++++++++++++++++++++++++++++++++++++++++- sound/soc/codecs/twl4030.h | 11 +++++++++ sound/soc/omap/omap-mcbsp.c | 5 ++- sound/soc/omap/omap3beagle.c | 26 ++++++++++++++------ 4 files changed, 82 insertions(+), 12 deletions(-) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] ASoC: OMAP: Add 4 channel support to mcbsp 2009-04-23 11:36 [PATCH 0/3] ASoC: 4 channel support for twl4030 and omap-mcbsp - Try2 Peter Ujfalusi @ 2009-04-23 11:36 ` Peter Ujfalusi 2009-04-23 11:36 ` [PATCH 2/3] ASoC: TWL4030: Add 4 channel TDM support Peter Ujfalusi 0 siblings, 1 reply; 6+ messages in thread From: Peter Ujfalusi @ 2009-04-23 11:36 UTC (permalink / raw) To: alsa-devel; +Cc: sakoman, broonie, jarkko.nikula Add 4 channel support to omap-mcbsp. This mode is going to be used by the twl4030 codec, when it is configured in Option1 mode. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> --- sound/soc/omap/omap-mcbsp.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 495192a..a5d46a7 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -259,6 +259,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, regs->xcr2 |= XFRLEN2(wpf - 1); } case 1: + case 4: /* Set word per (McBSP) frame for phase1 */ regs->rcr1 |= RFRLEN1(wpf - 1); regs->xcr1 |= XFRLEN1(wpf - 1); @@ -506,13 +507,13 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { .id = (link_id), \ .playback = { \ .channels_min = 1, \ - .channels_max = 2, \ + .channels_max = 4, \ .rates = OMAP_MCBSP_RATES, \ .formats = SNDRV_PCM_FMTBIT_S16_LE, \ }, \ .capture = { \ .channels_min = 1, \ - .channels_max = 2, \ + .channels_max = 4, \ .rates = OMAP_MCBSP_RATES, \ .formats = SNDRV_PCM_FMTBIT_S16_LE, \ }, \ -- 1.6.2.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] ASoC: TWL4030: Add 4 channel TDM support 2009-04-23 11:36 ` [PATCH 1/3] ASoC: OMAP: Add 4 channel support to mcbsp Peter Ujfalusi @ 2009-04-23 11:36 ` Peter Ujfalusi 2009-04-23 11:36 ` [PATCH 3/3] ASoC: Beagle: Add support for 4 channel mode Peter Ujfalusi 0 siblings, 1 reply; 6+ messages in thread From: Peter Ujfalusi @ 2009-04-23 11:36 UTC (permalink / raw) To: alsa-devel; +Cc: sakoman, broonie, jarkko.nikula 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> --- 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.6.2.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] ASoC: Beagle: Add support for 4 channel mode 2009-04-23 11:36 ` [PATCH 2/3] ASoC: TWL4030: Add 4 channel TDM support Peter Ujfalusi @ 2009-04-23 11:36 ` Peter Ujfalusi 2009-04-23 11:40 ` Peter Ujfalusi 0 siblings, 1 reply; 6+ messages in thread From: Peter Ujfalusi @ 2009-04-23 11:36 UTC (permalink / raw) To: alsa-devel Cc: sakoman, Ujfalusi Peter (Nokia-D/Tampere), broonie, jarkko.nikula From: Ujfalusi Peter (Nokia-D/Tampere) <peter.ujfalusi@nokia.com> This patch adds support for the four channel TDM mode on Beagle board. Depending on the channel count, the interface needs to be configured differently (I2S for stereo DSP_A for four channels) Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> --- sound/soc/omap/omap3beagle.c | 26 ++++++++++++++++++-------- 1 files changed, 18 insertions(+), 8 deletions(-) diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c index 6aa428e..b0cff9f 100644 --- a/sound/soc/omap/omap3beagle.c +++ b/sound/soc/omap/omap3beagle.c @@ -41,23 +41,33 @@ static int omap3beagle_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + unsigned int fmt; int ret; + switch (params_channels(params)) { + case 2: /* Stereo I2S mode */ + fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBM_CFM; + break; + case 4: /* Four channel TDM mode */ + fmt = SND_SOC_DAIFMT_DSP_A | + SND_SOC_DAIFMT_IB_NF | + SND_SOC_DAIFMT_CBM_CFM; + break; + default: + return -EINVAL; + } + /* Set codec DAI configuration */ - ret = snd_soc_dai_set_fmt(codec_dai, - SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); + ret = snd_soc_dai_set_fmt(codec_dai, fmt); if (ret < 0) { printk(KERN_ERR "can't set codec DAI configuration\n"); return ret; } /* Set cpu DAI configuration */ - ret = snd_soc_dai_set_fmt(cpu_dai, - SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); + ret = snd_soc_dai_set_fmt(cpu_dai, fmt); if (ret < 0) { printk(KERN_ERR "can't set cpu DAI configuration\n"); return ret; -- 1.6.2.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] ASoC: Beagle: Add support for 4 channel mode 2009-04-23 11:36 ` [PATCH 3/3] ASoC: Beagle: Add support for 4 channel mode Peter Ujfalusi @ 2009-04-23 11:40 ` Peter Ujfalusi 2009-04-23 11:47 ` Mark Brown 0 siblings, 1 reply; 6+ messages in thread From: Peter Ujfalusi @ 2009-04-23 11:40 UTC (permalink / raw) To: alsa-devel@alsa-project.org Cc: sakoman@gmail.com, broonie@opensource.wolfsonmicro.com, Nikula Jarkko (Nokia-D/Helsinki) On Thursday 23 April 2009 14:36:50 Ujfalusi Peter (Nokia-D/Tampere) wrote: > From: Ujfalusi Peter (Nokia-D/Tampere) <peter.ujfalusi@nokia.com> > > This patch adds support for the four channel TDM mode > on Beagle board. > > Depending on the channel count, the interface needs to be > configured differently (I2S for stereo DSP_A for four channels) Our mail server messed up this one, I will resend the series after the review. -- Péter ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] ASoC: Beagle: Add support for 4 channel mode 2009-04-23 11:40 ` Peter Ujfalusi @ 2009-04-23 11:47 ` Mark Brown 0 siblings, 0 replies; 6+ messages in thread From: Mark Brown @ 2009-04-23 11:47 UTC (permalink / raw) To: Peter Ujfalusi Cc: sakoman@gmail.com, alsa-devel@alsa-project.org, Nikula Jarkko (Nokia-D/Helsinki) On Thu, Apr 23, 2009 at 02:40:16PM +0300, Peter Ujfalusi wrote: > Our mail server messed up this one, I will resend the series after the review. These all look fine to me; I've applied your first two patches. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-04-23 11:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-23 11:36 [PATCH 0/3] ASoC: 4 channel support for twl4030 and omap-mcbsp - Try2 Peter Ujfalusi 2009-04-23 11:36 ` [PATCH 1/3] ASoC: OMAP: Add 4 channel support to mcbsp Peter Ujfalusi 2009-04-23 11:36 ` [PATCH 2/3] ASoC: TWL4030: Add 4 channel TDM support Peter Ujfalusi 2009-04-23 11:36 ` [PATCH 3/3] ASoC: Beagle: Add support for 4 channel mode Peter Ujfalusi 2009-04-23 11:40 ` Peter Ujfalusi 2009-04-23 11:47 ` Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox