i.MX6 I2S output

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX6 I2S output

8,286 Views
pawelkrzyzanows
Contributor II

Hi,

I am using I.MX6sl processor and would like to stream some I2S audio. How to do this in simplest way?

Since board I use is similar to imx6slevk board, I start with small changes to wm8962 codec.

I comment checking ID where code was 'goto err_enable'

Results I have: wm8962 is seen and available form Linux user-space

 

Linux :~# aplay -L null     Discard all samples (playback) or generate zero samples (capture) sysdefault:CARD=wm8962audio     wm8962-audio,      Default Audio Device Linux :~# ./ada_reset.sh  wm8962 1-001a: DSPCLK is 11289600Hz, BCLK 1411200Hz, LRCLK: 44100Hz. wm8962 1-001a: DSPCLK is 11289600Hz, BCLK 1411200Hz, LRCLK: 44100Hz. POST_PMU: HPOUTL PGA event failed: -5 POST_PMU: HPOUTR PGA event failed: -5 POST_PMU: SPKOUTL PGA event failed: -5 POST_PMU: SPKOUTR PGA event failed: -5 wm8962 1-001a: DC servo timed out Playing WAVE 'audiocheck.net_sin_1000Hz_-3dBFS_10s.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono

 

But I don't see correct output (totally nothing on BCLK/LRCLK/DATA and 10MHz on MCLK) form i.MX on oscilloscope. PGA event's are for mic and speaker so I can skip it now (am I right?). Strange for me is double printf "wm8962 1-001a: DSPCLK is 11289600Hz, BCLK 1411200Hz, LRCLK: 44100Hz" Since I have it in one place  (in function wm8962_configure_bclk).

 

 

As it comes to hardware I have AUD3 routed (hw.jpg). And my setting during initialization.

static struct mxc_audio_platform_data wm8962_data = {   .ssi_num = 1,   .src_port = 2,   .ext_port = 3,   .hp_gpio = -1,   .hp_active_low = 1,   .mic_gpio = -1,   .mic_active_low = 1,   .init = mxc_wm8962_init,   .clock_enable = wm8962_clk_enable, };

Which looks ok for me and I change Master clock:

//rate = clk_round_rate(extern_audio_root, 26000000);  //org rate = clk_round_rate(extern_audio_root, 11289600);    // mine

 

Any ideas why I don't have I2S audio out? (I don't have anything connected to output yet).

Original Attachment has been moved to: audi_dmesg.txt.zip

Labels (1)
Tags (2)
0 Kudos
Reply
5 Replies

6,224 Views
smithwen
Contributor I

hi ,did you solve your problem。 if,yes。 would u tell me how to do?

Freescale i.MX Release Distro 3.14.52-1.1.0 imx6qdlsolo /dev/ttymxc0

imx6qdlsolo login: root
root@imx6qdlsolo:~# cd /
root@imx6qdlsolo:/# aplay 1.wav
wm8962 0-001a: Failed to read DSPCLK: -1
wm8962 0-001a: ASoC: POST_PMU: SPKOUTR PGA event failed: -110
wm8962 0-001a: ASoC: POST_PMU: SPKOUTL PGA event failed: -110
Playing WAVE '1.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

could u help me

0 Kudos
Reply

6,224 Views
igorpadykov
NXP Employee
NXP Employee

Hi Pawel

general steps may be checking mxc_wm8962_init procedure

and testing extern_audio_clk (AUD_MCLK), it should be generated by i.MX6.

One can add debug printfs (or connect with jtag) and check CCM, SSI registers.

Best regards

igor

0 Kudos
Reply

6,224 Views
pawelkrzyzanows
Contributor II

Hi Igor,

this is what I have been trying to do.

In mxc_wm8962_init procedure I have changed AUD_MCLK from 26MHz to 11.289MHz. With oscilloscope I can probe that setting 11.289MHz gives me 10MHz output while setting 26MHz give me 26MHz output. But printing set rate of clock give ma 11.289Mhz so the value I set. Printing rest of values give me right ones:

In hw_params: sysclk 2Hz, BCLK 1411200Hz, LRCLK: 44100Hz, MCLK: 11289600Hz

I can add prints, since I don't have any Jtag, and try to track where program goes and why it is not giving output, but don't know how to print direct register value form memory.

I am checking configuration and find that in:

wm8962_set_dai_fmt

codec sets I2S, normal bit and codec, codec clk & FRM master -->

FMT_I2S

NB_NF_2

CBM_CFM

If I understand this correctly iMX is set as a slave, while I would like to have it as a master. so I commend line:

  //aif0 |= WM8962_MSTR;

which I hope set i.MX as a master (although probing with oscilloscope gives same result).

0 Kudos
Reply

6,224 Views
pawelkrzyzanows
Contributor II

Hi,

since previous idea fails (at least without any hints or answers), I try with different approach.

I would like to add support to sgtl5000. Since it is support with kernell. : (from menuconfig)

CONFIG_SND_SOC_IMX_SGTL5000:                                                                                                  │

  │                                                                                                                           │

  │ Say Y if you want to add support for SoC audio on an i.MX board with                                                      │

  │ a sgtl5000 codec.                                                                                                         │

  │                                                                                                                           │

  │ Symbol: SND_SOC_IMX_SGTL5000 [=y]                                                                                         │

  │ Type  : tristate                                                                                                          │

  │ Prompt: SoC Audio support for i.MX boards with sgtl5000                                                                   │

  │  Defined at sound/soc/imx/Kconfig:53                                                                                      │

  │  Depends on: SOUND [=y] && !M68K && SND [=y] && SND_SOC [=y] && SND_IMX_SOC [=y] && I2C [=y] && (MACH_MX35_3DS [=n] || \  │

  │ MACH_MX51_BABBAGE [=n] || MACH_MX6Q_SABRELITE [=n] || MACH_MX6Q_ARM2 [=y])                                                │

  │  Location:                                                                                                                │

  │    -> Device Drivers                                                                                                      │

  │      -> Sound card support (SOUND [=y])                                                                                   │

  │        -> Advanced Linux Sound Architecture (SND [=y])                                                                    │

  │          -> ALSA for SoC audio support (SND_SOC [=y])                                                                     │

  │            -> SoC Audio for Freescale i.MX CPUs (SND_IMX_SOC [=y])                                                        │

  │  Selects: SND_SOC_SGTL5000 [=y] && SND_MXC_SOC_MX2 [=y]      

So I am enable it and sgtl5000 drivers are building same as imx-sgtl5000.

I also add support in board.c file:

static int sgtl5000_clk_enable(int enable)

{

pr_err("enable clk: %d", enable);

  if (enable)

  clk_enable(extern_audio_root);

  else

  clk_disable(extern_audio_root);

  return 0;

}

static struct imx_ssi_platform_data stgl5000_pdata = {

  .flags = IMX_SSI_DMA | IMX_SSI_SYN,

};

static struct mxc_audio_platform_data stgl5000_data;

static int sab_sgtl5000_init(void)

{

        struct clk *clko;

        int rate;

  printk("----sab_sgtl5000_init\n");

        clko = clk_get(NULL, "clko_clk");

        if (IS_ERR(clko))

                pr_err("can't get CLKO clock.\n");

  extern_audio_root = clk_get(NULL, "extern_audio_clk");

        if (IS_ERR(extern_audio_root))

                pr_err("can't get extern_audio_root clock.\n");

  //clk_set_parent(extern_audio_root, clko);

  extern_audio_root=clko;

        rate = clk_round_rate(clko, 24000000);

        stgl5000_data.sysclk = rate;

        clk_set_rate(clko, rate);

        clk_enable(clko);

        printk("----enable clko_clk.\n");

  return 0;

}

static struct platform_device stgl5000_device = {

  .name = "imx-sgtl5000",

};

static struct mxc_audio_platform_data stgl5000_data = {

  .ssi_num = 1,

  .src_port = 2,

  .ext_port = 3,

        .hp_gpio = -1,

  .mic_gpio = -1,

        .init = sab_sgtl5000_init,

  .clock_enable = sgtl5000_clk_enable,

};

and during boot I change from probing wm8962 to sgtl5000.

static int __init imx6q_init_audio(void)

{

/* platform_device_register(&sabresd_vwm8962_reg_devices);

  mxc_register_device(&mx6_sabresd_audio_wm8962_device,

     &wm8962_data);

  imx6q_add_imx_ssi(1, &mx6_sabresd_ssi_pdata);*/

        mxc_register_device(&stgl5000_device,

                            &stgl5000_data);

        imx6q_add_imx_ssi(1, &stgl5000_pdata);

  return 0;

}

So I have enable sgtl5000 during boot. It;s initiating (checked by adding printk in imx-sgtl5000.c init function), but it is not registered as a sound card...

Linux :~# cat /proc/asound/cards

--- no soundcards ---

Linux :~# aplay -l

aplay: device_list:268: no soundcards found...

and dmesg part:

wm8962 1-001a: Device is not a WM8962, ID 0 != 6243

wm8962 1-001a: asoc: failed to probe CODEC wm8962.1-001a: -22

asoc: failed to instantiate card wm8962-audio: -22

sgtl5000 imx-init

----sab_sgtl5000_init

----enable clko_clk.

init_ret: 0

init_ret2: 0

imx_3stack asoc driver

Initialize HDMI-audio failed. Load HDMI-video first!

ALSA device list:

  No soundcards found.

0 Kudos
Reply

6,224 Views
pawelkrzyzanows
Contributor II

OK, I am one step closer. I have MCLK, BCLK and LRCLK.

But the values measured are wrong.

MCLK is 10MHz

BCLK 16MHz

LRCLK 250kHz.

when driver set those clocks I print them on debug screen:

MCLK: 11289600

BCLK 1411200

LRCLK: 44100

I think the main problem starts with MCLK which is set wrongly. (and from this one rest should be calculated). Source I use:

ssi_num = 1

so I have changed in:

static struct clk ssi1_clk

.parent = &pll4_audio_main_clk

To use audio clock. Then I am using:

clk_set_parent(extern_audio_root, pll4);

rate = clk_round_rate(extern_audio_root, 11289600);

clk_set_rate(extern_audio_root, rate);

And I get 10MHz instead of 11.2896MHz. Any hints why?

0 Kudos
Reply