[alsa-devel] [PATCH] ASoC: omap-mcbsp: Add support for Left Justified format
Basic support for Left Justified coding for OMAP McBSP.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@nokia.com --- sound/soc/omap/omap-mcbsp.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 2952fb0..d315cc4 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -331,7 +331,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK; wpf = channels = params_channels(params); - if (channels == 2 && format == SND_SOC_DAIFMT_I2S) { + if (channels == 2 && (format == SND_SOC_DAIFMT_I2S || + format == SND_SOC_DAIFMT_LEFT_J)) { /* Use dual-phase frames */ regs->rcr2 |= RPHASE; regs->xcr2 |= XPHASE; @@ -376,6 +377,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, /* Set FS period and length in terms of bit clock periods */ switch (format) { case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_LEFT_J: regs->srgr2 |= FPER(framesize - 1); regs->srgr1 |= FWID((framesize >> 1) - 1); break; @@ -427,6 +429,12 @@ 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_LEFT_J: + /* 0-bit data delay */ + regs->rcr2 |= RDATDLY(0); + regs->xcr2 |= XDATDLY(0); + regs->spcr1 |= RJUST(2); + break; case SND_SOC_DAIFMT_DSP_A: /* 1-bit data delay */ regs->rcr2 |= RDATDLY(1);
On Fri, 19 Mar 2010 11:11:19 +0200 Peter Ujfalusi peter.ujfalusi@nokia.com wrote:
Basic support for Left Justified coding for OMAP McBSP.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@nokia.com
sound/soc/omap/omap-mcbsp.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
I don't point it out immediately but is the FS polarity correct? According to WM8772 spec, the left/right justified modes has inverted FS polarity from I2S.
On Friday 19 March 2010 11:28:54 ext Jarkko Nikula wrote:
On Fri, 19 Mar 2010 11:11:19 +0200
Peter Ujfalusi peter.ujfalusi@nokia.com wrote:
Basic support for Left Justified coding for OMAP McBSP.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@nokia.com
sound/soc/omap/omap-mcbsp.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
I don't point it out immediately but is the FS polarity correct? According to WM8772 spec, the left/right justified modes has inverted FS polarity from I2S.
Yes, that is correct, and I'm aware of that. However, I have done some testing: I have a sample prepared, which only has data on the left channel, than I did tried I2S and LEFT_J...
With: /* I2S mode */ fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM;
The data line has data when the FS is low (when FS is high, that data line has 0). So this is correct I2S.
Now with: /* Left justified */ fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_CBM_CFM;
The data line has data when the FS is high (when FS is low, that data line has 0). So this is correct Left Justified.
At least it seams that McBSP is actually shifting out the data at the correct place, when it is slave..
Oh, and I can not explain why this is working, but I do trust on my scope, and it shows me that it is correct :o
On Fri, 19 Mar 2010 12:00:03 +0200 Peter Ujfalusi peter.ujfalusi@nokia.com wrote:
Now with: /* Left justified */ fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_CBM_CFM;
The data line has data when the FS is high (when FS is low, that data line has 0). So this is correct Left Justified.
At least it seams that McBSP is actually shifting out the data at the correct place, when it is slave..
Oh, and I can not explain why this is working, but I do trust on my scope, and it shows me that it is correct :o
For me it looks it's working because of NB_IF so try again with NB_NF :-)
On Friday 19 March 2010 12:13:08 ext Jarkko Nikula wrote:
On Fri, 19 Mar 2010 12:00:03 +0200
Peter Ujfalusi peter.ujfalusi@nokia.com wrote:
Now with: /* Left justified */ fmt = SND_SOC_DAIFMT_LEFT_J |
SND_SOC_DAIFMT_NB_IF |
SND_SOC_DAIFMT_CBM_CFM;
The data line has data when the FS is high (when FS is low, that data line has 0). So this is correct Left Justified.
At least it seams that McBSP is actually shifting out the data at the correct place, when it is slave..
Oh, and I can not explain why this is working, but I do trust on my scope, and it shows me that it is correct :o
For me it looks it's working because of NB_IF so try again with NB_NF :-)
Oh yes :D You know, I was looking at the diff between the I2S and LEFT_J polarities, but did not noticed NF vs IF... Yes, you are right, I need to invert the FS in a similar fashion as we do with the DSP modes.
Thanks for spotting it, I'll send the fixed patch with inverting the FS in case of LEFT_J
participants (2)
-
Jarkko Nikula
-
Peter Ujfalusi