All of lore.kernel.org
 help / color / mirror / Atom feed
* WM8731 using I2S on omap3 McBSP2 issues
@ 2009-09-24 17:06 Rick Bronson
  2009-09-24 17:26 ` Mark Brown
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Rick Bronson @ 2009-09-24 17:06 UTC (permalink / raw)
  To: alsa-devel

Hi,

  I'm working on getting a WM8731 (in SLAVE) working using I2S on
omap3 McBSP2 (in MASTER).

Here is the hardware:

http://www.efn.org/~rick/pub/wm8731.jpg

  Here are the PADCONF's and the pins they hook to on the WM8731:

 /*Audio Interface for csb740 */\
 MUX_VAL(CP(McBSP2_FSX),  (OFF_OUT_PD | IDIS | PTU | EN | M0)) /* McBSP2_FSX -> I2S_FRM -> LRCLK -> DACLRC and ADCLRC*/\
 MUX_VAL(CP(McBSP2_CLKX), (OFF_OUT_PD | IDIS | PTU | EN | M0)) /* McBSP2_CLKX -> I2S_CLK -> I2S_BCLK -> BCLK */\
 MUX_VAL(CP(McBSP2_DR),   (OFF_IN_PD  | IEN  | PTD | DIS | M0)) /* McBSP2_DR <- I2S_RXD <- ACDDAT */\
 MUX_VAL(CP(McBSP2_DX),   (OFF_OUT_PD | IDIS | PTU | EN | M0)) /* McBSP2_DX -> I2S_TXD -> DACDAT */\
 MUX_VAL(CP(McBSP_CLKS),  (OFF_IN_PD  | IEN  | PTD | DIS | M0)) /* McBSP_CLKS <- I2S_MCLK <- CLKOUT */\

 My kernel is "2.6.29-rc3-omap1", here's what I see at bootup:

1 WM8731 Audio Codec 0.13<6>asoc: WM8731 <-> omap-mcbsp-dai-0 mapping ok
2 ALSA device list:
3  #0: omap3csb740 (WM8731)
...
4 beagle:~# aplay test48000.wav
5 Playing WAVE 'test48000.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
6 aplay: pcm_write:1269: write error: Input/output error

  I get no audio output, other than a "click" when the 8731 is
initialized upon boot.  When I look at the signals the McBSP2_DX line
just goes low for the duration of the "aplay", it does not toggle. The
other lines look fine.  The file is at
http://www.efn.org/~rick/pub/omap3csb740.c but roughly, here's what
I'm doing:

static struct snd_soc_dai_link omap3csb740_dai = {
...
 .cpu_dai = &omap_mcbsp_dai[0], /* use 1st one */

static int __init omap3csb740_soc_init(void)
...
 *(unsigned int *)omap_mcbsp_dai[0].private_data = 1; /* McBSP2 */
 *(unsigned int *)omap3csb740_dai.cpu_dai->private_data = 1; /* McBSP2 debug only? */

static int omap3csb740_hw_params(struct snd_pcm_substream *substream,
...
 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
  SND_SOC_DAIFMT_NB_NF |  SND_SOC_DAIFMT_CBS_CFS);
 ret = snd_soc_dai_set_fmt(cpu_dai,  SND_SOC_DAIFMT_I2S |
  SND_SOC_DAIFMT_NB_NF |  SND_SOC_DAIFMT_CBS_CFS);
 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 12288000,   SND_SOC_CLOCK_IN);
 ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_EXT, 0,
   SND_SOC_CLOCK_IN);
 ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_MCBSP_CLKGDV, 256);

  Any help is greatly appreciated.

  Rick Bronson

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: WM8731 using I2S on omap3 McBSP2 issues
@ 2009-09-25 14:30 Rick Bronson
  0 siblings, 0 replies; 17+ messages in thread
From: Rick Bronson @ 2009-09-25 14:30 UTC (permalink / raw)
  To: alsa-devel

Hi Peter,

  Thanks very much for the help.

> I think the problem is here.
> The MCBSP_CLKS pin is connected to CLK256FS pin of TWL4030 (or TPA).
> Since you are not using the TWL codec, there will be no clock on the MCBSP_CLKS
> pin, thus no functional clock for McBSP, thus no bits are shifted in or out.
> You can try to use the internal functional clock:
> 
>   ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKS_FCLK, 0,
>     SND_SOC_CLOCK_IN);

  I have checked the CLKOUT (WM8731) -> McBSP_CLKS (OMAP3) pin and it
has a 12288000 clock on it.  I've tried using the internal clock as
you show above, just to see if I get anything out on DX but I get the
same thing: DX just goes low for the "aplay" duration.

  Any idea why I'm not getting DMA interrupts?  This would indeed
cause no data at DX.  omap2_dma_irq_handler() never gets called but
omap_init_dma() and omap_start_dma() get called.  Do you think there
may be any issues with my DMA code (specifically
arch/arm/plat-omap/dma.c).  As I mentioned, I'm at "2.6.29-rc3-omap1"

  Thanks,

  Rick

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: WM8731 using I2S on omap3 McBSP2 issues
@ 2009-09-25 14:31 Rick Bronson
  2009-09-26  7:56 ` Jarkko Nikula
  0 siblings, 1 reply; 17+ messages in thread
From: Rick Bronson @ 2009-09-25 14:31 UTC (permalink / raw)
  To: alsa-devel; +Cc: Peter Ujfalusi

Hi Peter,

  I forgot to tell you that if I deliberately misconfigure the
McBXP_CLKS pin so that it's an output, the FSX -> DACLRC/ADCLRC signal
stops.  This should indicate that the CLKOUT signal is actually making
it to the CLKS pin on the OMAP.  Right?

  Rick

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: WM8731 using I2S on omap3 McBSP2 issues
@ 2009-09-26 15:59 Rick Bronson
  2009-09-28  5:50 ` Jarkko Nikula
  0 siblings, 1 reply; 17+ messages in thread
From: Rick Bronson @ 2009-09-26 15:59 UTC (permalink / raw)
  To: alsa-devel; +Cc: Peter Ujfalusi

Hi Peter,

> Yes it is indicating so. I read through this thread I didn't find any
> simple reason why it's not working. Your setup is similar with the
> Pandora, i.e. McBSP functional clock is coming the codec and codec is
> slave.

  Yes, I pretty much used the pandora as an example to write mine.

> The McBSP is operating if the FSX and CLKX are toggling in this setup.
> Is it so that you don't get any DMA interrupts or just few of them?

  I don't get any DMA int's:

~# cat /proc/interrupts                                                  
           CPU0                                                                 
 11:          0        INTC  prcm                                               
 12:          0        INTC  DMA                                                
 25:          0        INTC  dispc                                              
 37:       5003        INTC  gp timer                                           
 56:       3425        INTC  i2c_omap                                           
 62:          0        INTC  McBSP                                              
 63:          0        INTC  McBSP                                              


> Your CLKGDV divisor value 256 means too low bit clock and sample rate
> for both external 12.288 MHz and internal 96 MHz but still the DMA
> should be running (if there is no bug with this divisor value).
> Can you try divisor value 8 does it work then? For 48 kHz sample rate
> with I2S you need a bit clock of 48 kHz*2*16 = 1.536 MHz and this you
> get by dividing the 12.288 MHz with 8.
> 

  Yes, I had tried 8 before and just tried it now.  Same result.  It
really seems like there is a DMA issue.  Can you think of anything
else to try before I dive into the DMA code?

  Rick

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: WM8731 using I2S on omap3 McBSP2 issues
@ 2009-09-28 16:07 Rick Bronson
  2009-09-28 16:13 ` Mark Brown
  0 siblings, 1 reply; 17+ messages in thread
From: Rick Bronson @ 2009-09-28 16:07 UTC (permalink / raw)
  To: alsa-devel; +Cc: Peter Ujfalusi

Hi Peter,

  Thanks for the help.

  I don't believe it's possible for me to try the master/slave switch.
Please take a look at http://www.efn.org/~rick/pub/wm8731.jpg Note
that DACLRC and ADCLRC are connected.  This requires me to run as
slave, right?  Our bit clock line is buffered so I don't think that
will be a problem.

  Rick

> >   Yes, I had tried 8 before and just tried it now.  Same result.  It
> > really seems like there is a DMA issue.  Can you think of anything
> > else to try before I dive into the DMA code?
> >
> Ok, that wasn't the reason.
> 
> Have you tried to reverse roles of codec and omap? I.e. by using
> the codec as a master and omap as a slave with SND_SOC_DAIFMT_CBM_CFM.
> 
> I don't think there is any HW reason as you have seen the bit-clock and
> frame sync signals toggling but I remember one case few years back
> where codec had slight too high capacitive load on the bit-clock line.
> That was then causing unstable frame sync as it was internally derived
> directly from the bit-clock pin without any buffer. Bit-clock signal
> looked just fine on oscilloscope but wasn't well enough for internal
> circuits of the cpu.
> 
> So if assuming similar problem here, I could imagine that if the FSX is
> used similar way directly inside the omap and if signal is not well
> enough, the McBSP and DMA may not be running.
> 
> This migh be a bit far reason to look for but at least easy to try by
> switching the roles as then the codec is driving the both bit-clock and
> fs.
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: WM8731 using I2S on omap3 McBSP2 issues
@ 2009-09-28 21:15 Rick Bronson
  2009-09-29  8:43 ` Peter Ujfalusi
  0 siblings, 1 reply; 17+ messages in thread
From: Rick Bronson @ 2009-09-28 21:15 UTC (permalink / raw)
  To: alsa-devel; +Cc: Peter Ujfalusi

Peter,

  I'm getting a XUNDFLSTAT (indicates a real underflow condition) and
XEMPTYEOF (Transmit buffer empty at end of frame) in
MCBSPLP_IRQSTATUS_REG.  Does this tell you anything?

  Rick

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-09-29  8:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 17:06 WM8731 using I2S on omap3 McBSP2 issues Rick Bronson
2009-09-24 17:26 ` Mark Brown
2009-09-24 18:00 ` Rick Bronson
2009-09-24 18:52   ` Mark Brown
2009-09-24 22:37 ` Rick Bronson
2009-09-25  5:53   ` Mark Brown
2009-09-25  6:03 ` Peter Ujfalusi
2009-09-25  9:12   ` Peter Ujfalusi
  -- strict thread matches above, loose matches on Subject: below --
2009-09-25 14:30 Rick Bronson
2009-09-25 14:31 Rick Bronson
2009-09-26  7:56 ` Jarkko Nikula
2009-09-26 15:59 Rick Bronson
2009-09-28  5:50 ` Jarkko Nikula
2009-09-28 16:07 Rick Bronson
2009-09-28 16:13 ` Mark Brown
2009-09-28 21:15 Rick Bronson
2009-09-29  8:43 ` Peter Ujfalusi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.