tlv320aic23b not working on imx6q based board

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

tlv320aic23b not working on imx6q based board

2,104 Views
regangovender
Contributor I

Hi dear Freescale community,

 

I need help getting the above mentioned codec working on my board. I'm running debian linux,  kernel version 3.10.94. This kernel was given to me by  the board manufacturer.

 

my set up/Configuration:

imx6  <====>tlv320aic23b

i2c sda <====> i2c sda

i2c clk <====> i2c clk

 

I2S tx<====>i2s din

I2S rx<====>i2s dout

I2S fsx<====>i2s lrcout

                ||

                 ===>i2s lrc in

I2S blck<====>i2s bclk

 

The codec uses a 12Mhz crystal to generate its own master clock.

 

I've started testing using aplay:

when i list devices it gives me :

aplay -l

**** List of PLAYBACK Hardware Devices ****

card 0: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 []

  Subdevices: 1/1

  Subdevice #0: subdevice #0

card 1: imxtlv320 [imx-tlv320], device 0: TLV320AIC23 tlv320aic23-hifi-0 []

  Subdevices: 1/1

  Subdevice #0: subdevice #0

 

When i try to play a file:

aplay -v -D hw:1,0 crash.wav

Playing WAVE 'crash.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

Hardware PCM card 1 'imx-tlv320' device 0 subdevice 0

Its setup is:

  stream       : PLAYBACK

  access       : RW_INTERLEAVED

  format       : S16_LE

  subformat    : STD

  channels     : 2

  rate         : 48000

  exact rate   : 48000 (48000/1)

  msbits       : 16

  buffer_size  : 16384

  period_size  : 4096

  period_time  : 85333

  tstamp_mode  : NONE

  period_step  : 1

  avail_min    : 4096

  period_event : 0

  start_threshold  : 16384

  stop_threshold   : 16384

  silence_threshold: 0

  silence_size : 0

  boundary     : 1073741824

  appl_ptr     : 0

  hw_ptr       : 0

aplay: pcm_write:1939: write error: Input/output error

 

I've enabled some debug in the codec file. While i exe the aplay command above i get the following debug:

tlv320aic23-codec 0-001a: write 8 = 5d                           

tlv320aic23-codec 0-001a: read 7 => 42                                         

tlv320aic23-codec 0-001a: write 7 = 42                                         

tlv320aic23-codec 0-001a: write 9 = 1                                          

tlv320aic23-codec 0-001a: read 6 => 5f                                         

tlv320aic23-codec 0-001a: read 6 => 5f                                         

tlv320aic23-codec 0-001a: write 6 = 57                                         

tlv320aic23-codec 0-001a: read 6 => 57                                         

tlv320aic23-codec 0-001a: write 6 = 47                                         

tlv320aic23-codec 0-001a: read 6 => 47                                         

tlv320aic23-codec 0-001a: write 6 = 47                                         

tlv320aic23-codec 0-001a: read 5 => 4                                          

tlv320aic23-codec 0-001a: write 5 = 4                                          

tlv320aic23-codec 0-001a: read 5 => 4                                          

tlv320aic23-codec 0-001a: write 5 = c                                          

tlv320aic23-codec 0-001a: read 5 => c                                          

tlv320aic23-codec 0-001a: write 5 = c                                          

tlv320aic23-codec 0-001a: read 5 => c                                          

tlv320aic23-codec 0-001a: write 5 = c                                          

tlv320aic23-codec 0-001a: write 9 = 0                                          

tlv320aic23-codec 0-001a: read 6 => 47                                         

tlv320aic23-codec 0-001a: read 6 => 47                                         

tlv320aic23-codec 0-001a: write 6 = 57                                         

tlv320aic23-codec 0-001a: read 6 => 57                                         

tlv320aic23-codec 0-001a: write 6 = 5f                                         

tlv320aic23-codec 0-001a: read 6 => 5f                                         

tlv320aic23-codec 0-001a: write 6 = 5f.

 

The changes i made to board dtsi tree:

sound {/* Audio codec on LEC-Base R2 carrier */
//compatible = "fsl,imx-audio-sgtl5000";
//model = "imx-i2s-sgtl5000";
compatible = "fsl,imx-audio-tlv320";

        model = "imx-tlv320";

cpu-dai = <&ssi2>;
mux-int-port = <2>;
mux-ext-port = <3>;
audio-codec = <&codec>;
audio-routing =
"MICIN", "Mic Jack",
//"Mic Jack", "Mic Bias",
"LLINEIN", "Line In Left",
"RLINEIN", "Line In Right",
//"Headphone Jack", "HP_OUT",
"Line Out Left", "LOUT",
"Line Out Right", "ROUT",
"Line Out HP Left", "LHPOUT",
"Line Out HP Right", "RHPOUT";
};

       

 

//codec: sgtl5000@0a {/* Audio codec on LEC-Base R2 carrier */
//compatible = "fsl,sgtl5000";
  codec:  tlv320aic23@1a {/* Audio codec on LEC-Base R1 carrier */

        compatible = "ti,tlv320aic23";

reg = <0x1a>;
clocks = <&clks 201>; /* SMARC AUDIO_MCK, actually unused on carrier */
clock-frequency = <12000000>;
VDDA-supply = <&reg_base_3v3>;
VDDIO-supply = <&reg_base_1v8>;
VDDD-supply = <&reg_base_1v8>;
};
&audmux {/* SMARC I2S0 (or SPI0) */
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_audmux_2>;
status = "okay";

};

 

In imx6qdl.dtsi:

&iomuxc {

  audmux {

  pinctrl_audmux_1: audmux-1 {

  fsl,pins = <

  MX6QDL_PAD_SD2_DAT0__AUD4_RXD  0x130b0

  MX6QDL_PAD_SD2_DAT3__AUD4_TXC  0x130b0

  MX6QDL_PAD_SD2_DAT2__AUD4_TXD  0x110b0

  MX6QDL_PAD_SD2_DAT1__AUD4_TXFS 0x130b0

  >;

  };

 

 

  pinctrl_audmux_2: audmux-2 {

  fsl,pins = <

  MX6QDL_PAD_CSI0_DAT7__AUD3_RXD  0x130b0

  MX6QDL_PAD_CSI0_DAT4__AUD3_TXC  0x130b0

  MX6QDL_PAD_CSI0_DAT5__AUD3_TXD  0x110b0

  MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0

  >;

  };

 

 

  pinctrl_audmux_3: audmux-3 {

  fsl,pins = <

  MX6QDL_PAD_DISP0_DAT16__AUD5_TXC  0x130b0

  MX6QDL_PAD_DISP0_DAT18__AUD5_TXFS 0x130b0

  MX6QDL_PAD_DISP0_DAT19__AUD5_RXD  0x130b0

  >;

  };

  };

 

My kernel log for the codec:

dmesg | grep tlv

[    3.386271] tlv320aic23-codec 0-001a: codec register 0-001a

[    3.390582] tlv320aic23-codec 0-001a: ASoC: dai register 0-001a #1

[    3.395508] tlv320aic23-codec 0-001a: ASoC: Mapped DAI tlv320aic23-hifi to CODEC tlv320aic23-codec.0-001a

[    3.403811] tlv320aic23-codec 0-001a: ASoC: Registered DAI 'tlv320aic23-hifi'

[    3.409670] tlv320aic23-codec 0-001a: ASoC: Registered codec 'tlv320aic23-codec.0-001a'

[   13.800901] tlv320aic23-codec 0-001a: codec clk_frequency = 24000000

[   13.807278] imx-tlv320 sound.29: ASoC: binding tlv320aic23 at idx 0

[   13.813656] tlv320aic23-codec 0-001a: write f = 0

[   13.823372] tlv320aic23-codec 0-001a: read 6 => 7

[   13.823379] tlv320aic23-codec 0-001a: write 6 = 47

[   13.823591] tlv320aic23-codec 0-001a: write 5 = 4

[   13.823801] tlv320aic23-codec 0-001a: read 0 => 97

[   13.823808] tlv320aic23-codec 0-001a: write 0 = 17

[   13.824151] tlv320aic23-codec 0-001a: read 1 => 97

[   13.824158] tlv320aic23-codec 0-001a: write 1 = 17

[   13.827881] tlv320aic23-codec 0-001a: read 4 => 1a

[   13.827888] tlv320aic23-codec 0-001a: write 4 = 10

[   13.828106] tlv320aic23-codec 0-001a: write 2 = 70

[   13.828317] tlv320aic23-codec 0-001a: write 3 = 70

[   13.831060] tlv320aic23-codec 0-001a: write 9 = 1

[   13.831389] tlv320aic23-codec 0-001a: read 4 => 10

[   13.831401] tlv320aic23-codec 0-001a: read 4 => 10

[   13.831410] tlv320aic23-codec 0-001a: read 4 => 10

[   13.831433] tlv320aic23-codec 0-001a: read 4 => 10

[   13.831442] tlv320aic23-codec 0-001a: read 4 => 10

[   13.831487] imx-tlv320 sound.29: ASoC: probe imx-tlv320 dai link 0 late -2

[   13.831495] imx-tlv320 sound.29: ASoC: probe imx-tlv320 dai link 0 late -1

[   13.831502] imx-tlv320 sound.29: ASoC: probe imx-tlv320 dai link 0 late 0

[   13.831511] imx-tlv320 sound.29: ASoC: probe imx-tlv320 dai link 0 late 1

[   13.831518] imx-tlv320 sound.29: ASoC: probe imx-tlv320 dai link 0 late 2

[   13.831569] tlv320aic23-codec 0-001a: read 6 => 47

[   13.831581] tlv320aic23-codec 0-001a: read 6 => 47

[   13.831613] tlv320aic23-codec 0-001a: read 6 => 47

[   13.831652] tlv320aic23-codec 0-001a: read 6 => 47

[   13.831664] tlv320aic23-codec 0-001a: read 6 => 47

[   13.831774] tlv320aic23-codec 0-001a: read 6 => 47

[   13.831781] tlv320aic23-codec 0-001a: write 6 = 57

[   13.832262] tlv320aic23-codec 0-001a: read 6 => 57

[   13.832269] tlv320aic23-codec 0-001a: write 6 = 5f

[   13.975160] imx-tlv320 sound.29:  tlv320aic23-hifi <-> 202c000.ssi mapping ok

[   13.981848] tlv320aic23-codec 0-001a: read 7 => 1

[   13.985692] tlv320aic23-codec 0-001a: write 7 = 42

[   15.071203] tlv320aic23-codec 0-001a: read 4 => 10

[   15.074933] tlv320aic23-codec 0-001a: read 4 => 10

[   15.078622] tlv320aic23-codec 0-001a: write 4 = 14

[   15.083105] tlv320aic23-codec 0-001a: ASoC: Capture Source DAPM update failed: -5

 

I'm still checking whether i2c reads/writes to the codc are actually working because if i change the i2c address in the codec node part in dtsi file:

codec:  tlv320aic23@1a {

to

codec:  tlv320aic23@2a {

for example, the kernel does not complain. It still enumerates the device somehow. Also note that i have already checked out this post which relates to my issue:

How to enable TLV320 on IMX6Q?

 

Well there you have it. If anyones got time to check this out and give me some pointers , it'll be great.

 

Thanks for your time.

Original Attachment has been moved to: lec-imx6.dtsi.zip

Original Attachment has been moved to: tlv320aic23.c.zip

Original Attachment has been moved to: imx-tlv320.c.zip

Original Attachment has been moved to: imx6qdl.dtsi.zip

0 Kudos
Reply
2 Replies

1,147 Views
regangovender
Contributor I

This time the issue was that i wasn't enabling capture on the line in using alsamixer. So you need to go on line in and hit spacebar then you see the L/R capture text in red.

0 Kudos
Reply

1,147 Views
regangovender
Contributor I

The issue was that the i2c writes to the codec were failing. I moved the codec node into the correct i2c bus node in my board .dtsi file. Now i am able to play audio successfully.

My issue now is that i'm recording stereo audio but when i play it back its playing as mono.

To play i'm using mplayer:

mplayer -ao alsa:device=hw=1.0 -srate 48000  Stereo-Audio-Test-Left-Right--4bJ0dvAl98k-www.mp3tunes.tk.m4a

and at the same time i run arecord(line out connected to line in on my board):

arecord -f S16_LE -c2 -r48000 --max-file-time 100 -D hw:1,0 -V stereo test.wav.

Now when i play back test.wav left and right channels are combined and i get mono. I dont know whether the codec  or whether alsa/linux audio driver is combining it.

Am i missing something? Does anyone have any ideas?

0 Kudos
Reply