Skip to contentSkip to conversation

ASoC: OMAP: Finalizing the DSP mode support

PATCH Applied Peter Ujfalusi 4 participants 16 messages Apr 15, 2009 – Apr 16, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ASoC: OMAP: Finalizing the DSP mode support

Hello,

This series should finally got both DSP_A and DSP_B modes working correctly on OMAP platforms.
Big thanks goes to Jarkko to get (and test) the DSP_B mode in a good shape.

But, the DSP modes should use single-phase mode instead of the dual-phase mode, which is intended to be used with I2S, Left-justified, Right-justified modes.

The second patch adds DSP_A mode support to omap-mcbsp.

---
Peter Ujfalusi (2):
ASoC: OMAP: Use single-phase for DSP mode
ASoC: OMAP: Add DSP_A mode support for mcbsp

 sound/soc/omap/omap-mcbsp.c |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)
#1 lore raw

PATCH 1/2 ASoC: OMAP: Use single-phase for DSP mode

Use single-phase mode for the DSP mode and keep the dual phase mode for the I2S mode.

The mono (1 channel) mode already used single phase mode, now it is more cleaner. There is no need to configure the second phase, when the single phase is used.

---
 sound/soc/omap/omap-mcbsp.c |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)
sound/soc/omap/omap-mcbsp.c +18 -12
index 90f4df7..5857c3c 100644
@@ -214,8 +214,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
 	struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
 	int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id;
-	int wlen, channels;
+	int wlen, channels, wpf;
 	unsigned long port;
+	unsigned int format;
 
 	if (cpu_class_is_omap1()) {
 		dma = omap1_dma_reqs[bus_id][substream->stream];
@@ -243,18 +244,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 		return 0;
 	}
 
-	channels = params_channels(params);
+	format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
+	wpf = channels = params_channels(params);
 	switch (channels) {
 	case 2:
-		/* Use dual-phase frames */
-		regs->rcr2	|= RPHASE;
-		regs->xcr2	|= XPHASE;
+		if (format == SND_SOC_DAIFMT_I2S) {
+			/* Use dual-phase frames */
+			regs->rcr2	|= RPHASE;
+			regs->xcr2	|= XPHASE;
+			/* Set 1 word per (McBSP) frame for phase1 and phase2 */
+			wpf--;
+			regs->rcr2	|= RFRLEN2(wpf - 1);
+			regs->xcr2	|= XFRLEN2(wpf - 1);
+		}
 	case 1:
-		/* Set 1 word per (McBSP) frame */
-		regs->rcr2	|= RFRLEN2(1 - 1);
-		regs->rcr1	|= RFRLEN1(1 - 1);
-		regs->xcr2	|= XFRLEN2(1 - 1);
-		regs->xcr1	|= XFRLEN1(1 - 1);
+		/* Set word per (McBSP) frame for phase1 */
+		regs->rcr1	|= RFRLEN1(wpf - 1);
+		regs->xcr1	|= XFRLEN1(wpf - 1);
 		break;
 	default:
 		/* Unsupported number of channels */
@@ -276,9 +282,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	/* Set FS period and length in terms of bit clock periods */
-	switch (mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	switch (format) {
 	case SND_SOC_DAIFMT_I2S:
-		regs->srgr2	|= FPER(wlen * 2 - 1);
+		regs->srgr2	|= FPER(wlen * channels - 1);
 		regs->srgr1	|= FWID(wlen - 1);
 		break;
 	case SND_SOC_DAIFMT_DSP_B:
Signature · 1 line
1.6.2.3
#2 lore raw

PATCH 2/2 ASoC: OMAP: Add DSP_A mode support for mcbsp

DSP_A mode is similar to the DSP_B, but the MSB is delayed with one bclk (appears after the FS pulse and not under it).

---
 sound/soc/omap/omap-mcbsp.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
sound/soc/omap/omap-mcbsp.c +8 -0
index 5857c3c..4d6ef0b 100644
@@ -287,6 +287,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 		regs->srgr2	|= FPER(wlen * channels - 1);
 		regs->srgr1	|= FWID(wlen - 1);
 		break;
+	case SND_SOC_DAIFMT_DSP_A:
 	case SND_SOC_DAIFMT_DSP_B:
 		regs->srgr2	|= FPER(wlen * channels - 1);
 		regs->srgr1	|= FWID(0);
@@ -331,6 +332,13 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		regs->rcr2	|= RDATDLY(1);
 		regs->xcr2	|= XDATDLY(1);
 		break;
+	case SND_SOC_DAIFMT_DSP_A:
+		/* 1-bit data delay */
+		regs->rcr2      |= RDATDLY(1);
+		regs->xcr2      |= XDATDLY(1);
+		/* Invert FS polarity configuration */
+		temp_fmt ^= SND_SOC_DAIFMT_NB_IF;
+		break;
 	case SND_SOC_DAIFMT_DSP_B:
 		/* 0-bit data delay */
 		regs->rcr2      |= RDATDLY(0);
Signature · 1 line
1.6.2.3
Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] ASoC: OMAP: Add DSP_A mode support for mcbsp

Quoted 5 lines · On Wed, 15 Apr 2009 14:38:56 +0200 "Ujfalusi Peter (Nokia-D/Tampere)"…

DSP_A mode is similar to the DSP_B, but the MSB is delayed with one bclk (appears after the FS pulse and not under it).

---

Tested with Beagle and oscilloscope and with N810 where codec were used both as a master and slave. All worked and with correct bit polarities.

Acked-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

In reply to Peter Ujfalusi
Quoted 9 lines · On Wed, 15 Apr 2009 14:38:55 +0200 "Ujfalusi Peter (Nokia-D/Tampere)"…

Use single-phase mode for the DSP mode and keep the dual phase mode for the I2S mode.

The mono (1 channel) mode already used single phase mode, now it is more cleaner. There is no need to configure the second phase, when the single phase is used.

---

I did a little bit of hacking and testing with this to see are can this even be a fix on top of my DSP_B fix for 2.6.30 but looks like there is no currently any difference or potential bug fix are we using single or dual phase mode for stereo samples. For testing I hacked to use word length of 20-bits (only the interface, not samples) and both phase modes produced the same bit stream.

But as this is more generic case and only option for multichannel configuration let's start to use it and let only I2S to continue use the dual-phase mode.

Applied
#5 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

Quoted 2 lines · Jarkko Nikula

I did a little bit of hacking and testing with this to see are can this even be a fix on top of my DSP_B fix for 2.6.30 but looks like there is

Hrm. I'd merged your DSP_B fix for 2.6.31 not 2.6.30 since it seemed to be needed for new things like the TWL4030 4 channel mode and the existing boards were apparently OK in 2.6.29. Do you think it's urgent enough to pull over to 2.6.30 (I've not pushed to Takashi yet)?

I've applied both Peter's patches - thanks.

#6 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

Quoted 8 lines · On Thursday 16 April 2009 12:31:21 ext Mark Brown wrote:
Quoted 2 lines · Jarkko Nikula

I did a little bit of hacking and testing with this to see are can this even be a fix on top of my DSP_B fix for 2.6.30 but looks like there is

Hrm. I'd merged your DSP_B fix for 2.6.31 not 2.6.30 since it seemed to be needed for new things like the TWL4030 4 channel mode and the existing boards were apparently OK in 2.6.29. Do you think it's urgent enough to pull over to 2.6.30 (I've not pushed to Takashi yet)?

Well, the DSP_B mode was broken for OMAP, the osk5912 with DSP_B mode was also broken in 2.6.29. I think the reason that we have not heard any screams regarding to broken DSP_B mode, that no one actually used osk5912 with 2.6.29?

Quoted 2 lines

I've applied both Peter's patches - thanks.

Signature · 1 line
Péter
#7 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

Quoted 3 lines · Peter Ujfalusi

Well, the DSP_B mode was broken for OMAP, the osk5912 with DSP_B mode was also broken in 2.6.29. I think the reason that we have not heard any screams regarding to broken DSP_B mode, that no one actually used osk5912 with 2.6.29?

Presumably OSK5912 has been broken since it was merged? Either that or the incorrectly inverted FS polarity happened to result in a setup which gives functional audio.

#8 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

Quoted 3 lines · On Thursday 16 April 2009 12:48:47 ext Mark Brown wrote:

Presumably OSK5912 has been broken since it was merged? Either that or the incorrectly inverted FS polarity happened to result in a setup which gives functional audio.

I would not say that, I guess it was working at the time when it was merged - I also got the DSP_A mode working with 'incorrect' mcbsp code and configuration...
But it does not really matter, how and when this DSP_B mode got into the wrong track.
Now it is correct for both DSP_A and DSP_B modes, we need to keep it that way for the time being ;)

I would say that at least Jarkko's two patches should go as soon as possible to avoid further confusions regarding to DSP_B mode.

Signature · 1 line
Péter
#9 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

In reply to Mark Brown
Quoted 11 lines · On Thu, 16 Apr 2009 11:31:21 +0200 ext Mark Brown <[email protected]> wrote:
Quoted 3 lines · Jarkko Nikula

I did a little bit of hacking and testing with this to see are can this even be a fix on top of my DSP_B fix for 2.6.30 but looks like there is

Hrm. I'd merged your DSP_B fix for 2.6.31 not 2.6.30 since it seemed to be needed for new things like the TWL4030 4 channel mode and the existing boards were apparently OK in 2.6.29. Do you think it's urgent enough to pull over to 2.6.30 (I've not pushed to Takashi yet)?

I would say my two 2.6.30-rc2 patches are for 2.6.30 since DSP_B is broken there and at least OSK5912 is using it.

I also believe that quite many developers may be using linux-omap tree only for developing e.g. new machine or codec driver and there is a risk that then error might populate into those drivers as well and we don't catch it when patches are based on topic/asoc and sent here for review.

Jarkko

#10 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

Quoted 5 lines · Jarkko Nikula

I also believe that quite many developers may be using linux-omap tree only for developing e.g. new machine or codec driver and there is a risk that then error might populate into those drivers as well and we don't catch it when patches are based on topic/asoc and sent here for review.

*sigh*, that's true - a lot of the OMAP folks don't seem to want to move outside of linux-omap so I'd expect a lot of stuff wouldn't get pushed here at all. I've pulled the changes over.

#11 lore raw

Re: [PATCH 1/2] ASoC: OMAP: Use single-phase for DSP mode

Quoted 9 lines · On Thu, 16 Apr 2009 12:07:01 +0200 ext Mark Brown <[email protected]> wrote:
Quoted 5 lines

I also believe that quite many developers may be using linux-omap tree only for developing e.g. new machine or codec driver and there is a risk that then error might populate into those drivers as well and we don't catch it when patches are based on topic/asoc and sent here for review.

*sigh*, that's true - a lot of the OMAP folks don't seem to want to move outside of linux-omap so I'd expect a lot of stuff wouldn't get pushed here at all. I've pulled the changes over.

Yes true, it has been previously junkyard for all kind of code but luckily this is changing and linux-omap is gradually moving towards queue for mainline since Tony is not accepting code anymore outside of OMAP core :-)

Jarkko

#12 lore raw
In reply to Peter Ujfalusi
Quoted 4 lines · On Wed, 15 Apr 2009 14:38:54 +0200 "Ujfalusi Peter (Nokia-D/Tampere)"…

But, the DSP modes should use single-phase mode instead of the dual-phase mode, which is intended to be used with I2S, Left-justified, Right-justified modes.

At quick testing seems correct with Beagle but I'll give some more testing tomorrow and let you know.

Quoted 2 lines

The second patch adds DSP_A mode support to omap-mcbsp.

This looks ok.

Jarkko

#13 lore raw
Quoted 9 lines · Jarkko Nikula
Quoted 4 lines · On Wed, 15 Apr 2009 14:38:54 +0200 "Ujfalusi Peter (Nokia-D/Tampere)"…

But, the DSP modes should use single-phase mode instead of the dual-phase mode, which is intended to be used with I2S, Left-justified, Right-justified modes.

At quick testing seems correct with Beagle but I'll give some more testing tomorrow and let you know.

I'll also try to test it on osk5912, i m trying to get a proper commit to test on l-o tree.

Quoted 12 lines
Quoted 3 lines

The second patch adds DSP_A mode support to omap-mcbsp.

This looks ok.

Jarkko
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#14 lore raw
In reply to Jarkko Nikula
Quoted 6 lines · Jarkko Nikula

At quick testing seems correct with Beagle but I'll give some more testing tomorrow and let you know.

Quoted 1 line

The second patch adds DSP_A mode support to omap-mcbsp.

This looks ok.

I'll apply the second patch and hold off on the first until Jarkko has a chance to test - thanks.

#15 lore raw
Quoted 2 lines · Mark Brown

I'll apply the second patch and hold off on the first until Jarkko has a chance to test - thanks.

Actually, the two depend on each other so I'll hold off on the second one too for now.