This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Working with TLV320DAC3100 on Am335x board

Other Parts Discussed in Thread: TLV320DAC3100, TLV320AIC3100

Hello,

In our board (Am335x)  we selected to work with TLV320DAC3100. We took ICS Android.

First of all we noticed that there is no codec supplied with Ti Android.

We written our own codec implementation, but we cant make it work. We take MCLK from external PLL and drive both BCLK and WCLK. With scope we see that BLCK outputs 44.1 KHz clock, that seems fine but we don't see WCLK / Data on MCASP interface.

Maybe you'll give us some hints where to look for the problem. Bellow is the registers dump for our codec configuration:

Thanks

Page 0 Regs from 0 to 95
REG# VALUE
-----------------
0 0x0
1 0x0
2 0x1
3 0x66
4 0x3
5 0x91
6 0x7
7 0x2
8 0x30
9 0x0
10 0x0
11 0x85
12 0x83
13 0x0
14 0x80
15 0x80
16 0x8
17 0x0
18 0x3c
19 0x0
20 0x4
21 0x80
22 0x4
23 0x0
24 0x0
25 0x0
26 0x1
27 0xc
28 0x0
29 0x5
30 0x80
31 0x0
32 0x0
33 0x0
34 0x0
35 0x0
36 0x80
37 0x0
38 0x0
39 0x0
40 0x0
41 0x0
42 0x0
43 0x0
44 0x0
45 0x0
46 0x10
47 0x0
48 0xc0
49 0x0
50 0x0
51 0x2
52 0x32
53 0x12
54 0x3
55 0x2
56 0x2
57 0x11
58 0x10
59 0x0
60 0x2
61 0x4
62 0x0
63 0x14
64 0x0
65 0x0
66 0x0
67 0xe7
68 0x6f
69 0x38
70 0x0
71 0x0
72 0x0
73 0x0
74 0x0
75 0xee
76 0x10
77 0xd8
78 0x7e
79 0xe3
80 0x0
81 0x0
82 0x80
83 0x0
84 0x0
85 0x0
86 0x0
87 0x0
88 0x7f
89 0x0
90 0x0
91 0x0
92 0x0
93 0x0
94 0x0

### Page 1 Regs from 30 to 52
REG# VALUE
-----------------
30 0x3
31 0x4
32 0x6
33 0xaf
34 0x70
35 0x0
36 0x7f
37 0x7f
38 0x7f
39 0x7f
40 0x2
41 0x2
42 0x0
43 0x0
44 0x6
45 0x86
46 0x0
47 0x80
48 0x0
49 0x0
50 0x0
51 0x0

  • We worked it out. We ended up with writing DAC3100 codec for linux.

  • Hi, Alex,

    Thanks for letting us know!

    -d2

  • Hi Alex,

    would you be able to share what you learned about the TLV320DAC3100 codec? We're trying to go through the same process at the moment and having issues with building and loading the .bin file that seems to be required by the codec to function.

  • I don't know what bin files are you talking about.

    Linux uses driver, called codec to configure HW to work with ALSA. We took Ti release of ICS 4.0.3 Android, and this specific codec support was missing from the kernel. We ended up hiring engineer to write us kernel driver.

  • Thanks for your reply. I guess we may need to do the same then.

    I was following instructions from http://e2e.ti.com/support/data_converters/audio_converters/f/64/t/266169.aspx to download the ti-codecs kernel source from gitorious, and then ported tlv320aic31xx and aic31xx src files from there to my Linux src and integrated them to build into the kernel.

    I followed instructions on https://gitorious.org/ti-codecs/pages/MkCFW6x to built tlv320aic31xx_fw_v1.bin firmware for our tlv320dac3100 codec and loaded it successfully, but I don't get any sound out.

    I thought it may have to do with the codec register settings and noticed that you posted here register values you were trying. I guess you probably used different code, that didn't require Firmware binaries for the codec. I'm trying that out at the moment using src from https://gitorious.org/ti-codecs/ti-codecs/commit/2a6df0d6bb1c270aba57018fad5d3cde221e4d4f. Seems to have register settings in the header file. Driver is not installing though at the moment.

  • Guys, attached is a codec source from my codebase that is working. I do remember we have some tough time to get all internal PLLs configured correclty.


    In hope it will assist you. I'm a bit busy lately, but I'd try to answer questions if you have.

    7610.tlv320aic3100.c

    7573.tlv320aic3100.h

  • Thank you so much for those! The other source turned out to be a lot more complicated to backport as I'm not familiar with the kernel changes up from 3.2 and it turned out to be a lot of changes.

    I've added your files and have the driver installing now. I've changed the aic31xx_divs array for most sampling freq.'s for our PLL clock input of 24MHz coming from the CPU. It may not be enough though as now it can't attempt to play files due to a hw_params error:

    bash-4.2# aplay Noise.wav
    Playing WAVE 'Noise.wav' : Signed 16 bit Little [ 1364.978542] asoc: machine hw_params failed
    Endian, Rate 48000 Hz, Mono
    aplay: set_params:1145: Unable to install hw params:
    ACCESS:  RW_INTERLEAVED
    FORMAT:  S16_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 16
    FRAME_BITS: 16
    CHANNELS: 1
    RATE: 48000
    PERIOD_TIME: (42666 42667)
    PERIOD_SIZE: 2048
    PERIOD_BYTES: 4096
    PERIODS: 16
    BUFFER_TIME: (682666 682667)
    BUFFER_SIZE: 32768
    BUFFER_BYTES: 65536
    TICK_TIME: 0

    I may be missing something else.

  • I think at this board we work with 12Mhz clock.

    Ensure that new coded is get compiled (it is defined as kernel module), and is correclty associated with the codec on the board. Most probably the codec sits on I2c bus. In such case:

    1. Check what is device id
    2. In board init function (kernel init), associate this id with device name board name. 
    3. I think, on evm boards, ALSA associations are configured in kernel/sound/soc/davinci/davinci-evm.c Most probably yours are also there.
    4. Take a look and configure the device name from (2) to be associated with your codec.
    5. During system boot up take a look at ALSA debug messages and see if its configured to work with codec or not.

    Alex.

  • I had made the changes to the sound/soc/davinci/davinci-aic31xx.c and sound/soc/codecs/tlv320aic31xx.c (renamed your file) to the the I2C driver poll for the codec. It was able to see it during boot-up but just playing the sound wasn't working. I tracked down the issue though! :)

    I did a diff between the sound/soc/davinci/davinci-aic31xx.c that I'd copied from https://gitorious.org/ti-codecs/ti-codecs/commit/a8e9dc847e683318810693ff9e3c0d95fc0d0f85 and the native sound/soc/davinci/davinci-evm.c and noticed in evm_hw_params() funciton that it was using

    ret = snd_soc_dai_set_pll(codec_dai, 0, AIC31XX_PLL_CLKIN_MCLK, 24000000, params_rate(params));

    instead of:
    ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);

    That was returning the error code I was seeing, EINVAL. I changed the line back to using snd_soc_dai_set_sysclk and hunky dory! It's working now.

    Thank you very much for your source. It was really helpful and much easier to follow that the other stuff using binaries.

  • Another one of those small joys of life...

    Very glad to hear and thanks for updating :)

  • Hi Alex,

     We are using TLV320AIC3100 codec driver for our Allwinner A20 board.i downloaded driver your  driver tlv320aic3100.c  and compiled it also.
     my machine driver able to probe codec driver but  i am not getting any audio from codec
    (getting only noise in HPL  and HPR line),my MCLK,BCCLK,WCLK,DIN is ok.
     Here i am attaching my machine driver code, kindly let me know what will be problem.
     Did i need to run any amixer commands.
    Regards

    Punith

  • Hi All,

    Here my actual register output. I think if go though this , it will be easy to point out the problem.
    Here i am attaching my all register programmed value and machine driver code and schematic of codec.

    Once i play mp3 file through codec sound card i am getting 1.46V on HPL and HPR line and going to 0v once i stop audio but not getting any audio signals.

    The value of MCLK=11MHZ BLCK=5.8MHZ and WCLK=58KHZ and getting signals in DIN pin also.

    In our case  all clocks are coming from processor we are not any crystal oscillator to generate the clock.

    Your help will be greatly appreciable.

    Regards

    Punith

  • Hi Punith,

    The code should reflect the actual board HW configuration. Although I don't have the capacity to study the code/HW design, I'll share my thoughts:

    1. You don't need to run amixer or any ALSA utilities to get sound working 

    2. Try to go over the procedure we posted here. Ensure driver is compiled, associated with your I2C device and then gets configured according to your HW. Pay attention to set PLL frequencies correctly. During ALSA init, you should see line indicating codec association.

    3. The chip supports diagnostic feature to output constant frequency to speaker. Another tool to take into consideration.

    Hope this helps,

    Alex

  • Hi Alex,

    Thanks for your reply.

    Yes my driver associate with proper i2c bus. Here my log output.

    root@localhost:/# cat /sys/bus/i2c/devices/i2c-2/2-0018/driver/2-0018/name
    tlv320aic31xx

    root@localhost:/# aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: audiocodec [audiocodec], device 0: M1 PCM [sun7i PCM]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 1: sndhdmi [sndhdmi], device 0: SUN7I-HDMIAUDIO sndhdmi-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 2: sndi2s [sndi2s], device 0: SUN7I-I2S sndi2s-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 3: RX51 [RX-51], device 0: AIC34 tlv320aic31xx-dai-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0

    And i am getting all printk statements from codec driver while playing audio.

    But i am not getting any line which indicates codec initialisation?.

    Can you say which registers i need to look at for PLL frequency setting.

    Regards

    Punith

  • I think I've used this datasheet for PLLs configuration.