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.

TLV320AIC34: TDM configuration and play sound

Part Number: TLV320AIC34
Other Parts Discussed in Thread: TLV320AIC3104, TAS2781

Hi, 

We are working whit a custom board based on the imx8mp that has the TLV320AIC34 codec connected to the SAI3. The OS has been generated using Yocto hardknott and the NXP BSP. We are using the kernel version 5.10.72.

We cannot configure a sound card in device-tree for the codec. Since this codec internally is composed of two tlv320aic3104, we first tried to follow an approach that consists of creating a single "simple-audio-card" node card that has two dai-links one for each codec block and using TDM. Following this approach we wanted to have a single card with four independent channels.

The device tree we have built is:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
sound-codec {
compatible = "simple-audio-card";
simple-audio-card,name = "ep200-audio";
status = "okay";
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Line", "Line Out",
"Line", "Line In",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
"MIC2L a", "Mic Jack",
"MIC2L b", "Mic Jack",
"MIC2L a", "Mic Jack",
"MIC2L b", "Mic Jack",
"Mic Jack", "Mic Bias a",
"Mic Jack", "Mic Bias b",
"Line Out", "LLOUT a",
"Line Out", "LLOUT b",
"Line Out", "RLOUT a",
"Line Out", "RLOUT b",
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And in the i2c node:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&i2c3 {
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";
tlv320aic3104a: tlv320aic3104a@18 {
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tlv320>;
compatible = "ti,tlv320aic3104_a";
reg = <0x18>;
status = "okay";
reset-gpios = <&gpio3 24 GPIO_ACTIVE_LOW>;
};
tlv320aic3104b: tlv320aic3104b@19 {
#sound-dai-cells = <0>;
//pinctrl-names = "default";
//pinctrl-0 = <&pinctrl_tlv320>;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

We have had to create a new tlv320aic3104 driver where we have added the sufix "_a" and "_b" in order to avoid to have controls with the same name.

When the system is booted, we can see one card (ep200audio) with two devices:

card 1: ep200audio [ep200-audio], device 0: 30c30000.sai-tlv320aic3x-hifi tlv3 20aic3x-hifi-0 [30c30000.sai-tlv320aic3x-hifi tlv320aic3x-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ep200audio [ep200-audio], device 1: 30c30000.sai-tlv320aic3x-b-hifi tl v320aic3x-b-hifi-1 [30c30000.sai-tlv320aic3x-b-hifi tlv320aic3x-b-hifi-1]
Subdevices: 1/1
Subdevice #0: subdevice #0

The card has the controls duplicated that allow us to control each codec block independently, by example "PCM Playback Volume a" and "PCM Playback Volume b". The problem we have is when we try to play two sounds at the same time using the two card devices, if we run the following commands in two separated consoles, no sound is played and the commands don't finish:
aplay /usr/share/sounds/alsa/Front_Center.wav -Dplughw:ep200audio,0
aplay /usr/share/sounds/alsa/Front_Center.wav -Dplughw:ep200audio,1

Is our approach correct? How can we solve this problem? In our application we need to play sound in the two devices at the same time.

Regards,

Gustavo Plaza.

  • Hi, 

    I don't think the issue in devicetree. I wonder whether the two devices share the same driver code. If so, you will convert all the global variables into local ones.

    Your application need modifying the driver code to support two hardware instances. You would add some log into the driver to check the working flowing of the code.

  • Hi MR. Ding,

    When you say "modifying the driver code to support two hardware instances", which driver do you mean? "simple-audio-card" o "sai" driver? What modification do we have to implement?

    In which file or driver can we add logs? 

    Regards, 

    Gustavo.

  • Only tlv320aic3104 driver

  • We have added "#define DEBUG" to TLV driver but no logs are showed. 

    We have also added ""#define DEBUG"" to   linux-imx/sound/soc/soc-core.c and linux-imx/sound/soc/generic/simple-card.c and the logs we get are:

    [ 46.150822] tlv320aic31-a-codec 2-0018: supply IOVDD a not found, using dummy regulator
    [ 46.159062] tlv320aic31-a-codec 2-0018: supply DVDD a not found, using dummy regulator
    [ 46.167146] tlv320aic31-a-codec 2-0018: supply AVDD a not found, using dummy regulator
    [ 46.175180] tlv320aic31-a-codec 2-0018: supply DRVDD a not found, using dummy regulator
    [ 46.183334] tlv320aic31-a-codec 2-0018: Invalid supply voltage(s) AVDD: -22, DVDD: -22
    [ 46.191300] tlv320aic31-a-codec 2-0018: ASoC: dynamically register DAI 2-0018
    [ 46.198461] tlv320aic31-a-codec 2-0018: ASoC: Registered DAI 'tlv320aic31-a-hifi'
    [ 46.207066] asoc-simple-card sound-codec: link 2, dais 4, ccnf 0
    [ 46.213246] asoc-simple-card sound-codec: link_of (/sound-codec/simple-audio-card,dai-link@0)
    [ 46.223159] asoc-simple-card sound-codec: link_of (/sound-codec/simple-audio-card,dai-link@1)
    [ 48.932942] tlv320aic31-b-codec 2-0019: supply IOVDD b not found, using dummy regulator
    [ 48.941343] tlv320aic31-b-codec 2-0019: supply DVDD b not found, using dummy regulator
    [ 48.949842] tlv320aic31-b-codec 2-0019: supply AVDD b not found, using dummy regulator
    [ 48.957926] tlv320aic31-b-codec 2-0019: supply DRVDD b not found, using dummy regulator
    [ 48.966130] tlv320aic31-b-codec 2-0019: Invalid supply voltage(s) AVDD: -22, DVDD: -22
    [ 48.974222] tlv320aic31-b-codec 2-0019: ASoC: dynamically register DAI 2-0019
    [ 48.981428] tlv320aic31-b-codec 2-0019: ASoC: Registered DAI 'tlv320aic31-b-hifi'
    [ 48.989792] asoc-simple-card sound-codec: link 2, dais 4, ccnf 0
    [ 48.997776] asoc-simple-card sound-codec: link_of (/sound-codec/simple-audio-card,dai-link@0)
    [ 49.007228] asoc-simple-card sound-codec: link_of (/sound-codec/simple-audio-card,dai-link@1)
    [ 49.016705] asoc-simple-card sound-codec: Card Name: ep200-audio
    [ 49.023510] asoc-simple-card sound-codec: DAI0
    [ 49.028730] asoc-simple-card sound-codec: cpu sysclk = 400000000
    [ 49.035553] asoc-simple-card sound-codec: cpu direction = IN
    [ 49.042043] asoc-simple-card sound-codec: cpu slots = 4
    [ 49.048023] asoc-simple-card sound-codec: cpu slot width = 32
    [ 49.053844] asoc-simple-card sound-codec: cpu tx slot mask = 15
    [ 49.059792] asoc-simple-card sound-codec: cpu rx slot mask = 15
    [ 49.065729] asoc-simple-card sound-codec: codec sysclk = 24576000
    [ 49.071848] asoc-simple-card sound-codec: codec direction = IN
    [ 49.077700] asoc-simple-card sound-codec: codec tx slot mask = 3
    [ 49.083736] asoc-simple-card sound-codec: codec rx slot mask = 3
    [ 49.089804] asoc-simple-card sound-codec: codec clk 24576000Hz
    [ 49.095701] asoc-simple-card sound-codec: dai name = 30c30000.sai-tlv320aic31-a-hifi
    [ 49.103575] asoc-simple-card sound-codec: dai format = 4001
    [ 49.109196] asoc-simple-card sound-codec: mclk-fs = 256
    [ 49.114480] asoc-simple-card sound-codec: DAI1
    [ 49.119098] asoc-simple-card sound-codec: cpu sysclk = 400000000
    [ 49.125233] asoc-simple-card sound-codec: cpu direction = IN
    [ 49.131038] asoc-simple-card sound-codec: cpu slots = 4
    [ 49.136386] asoc-simple-card sound-codec: cpu slot width = 32
    [ 49.142248] asoc-simple-card sound-codec: cpu tx slot mask = 15
    [ 49.148306] asoc-simple-card sound-codec: cpu rx slot mask = 15
    [ 49.154366] asoc-simple-card sound-codec: codec sysclk = 24576000
    [ 49.160589] asoc-simple-card sound-codec: codec direction = IN
    [ 49.166545] asoc-simple-card sound-codec: codec tx slot mask = 12
    [ 49.172753] asoc-simple-card sound-codec: codec rx slot mask = 12
    [ 49.178975] asoc-simple-card sound-codec: codec clk 24576000Hz
    [ 49.185869] asoc-simple-card sound-codec: dai name = 30c30000.sai-tlv320aic31-b-hifi
    [ 49.193792] asoc-simple-card sound-codec: dai format = 4001
    [ 49.199493] asoc-simple-card sound-codec: mclk-fs = 256
    [ 49.204873] asoc-simple-card sound-codec: ASoC: binding 30c30000.sai-tlv320aic31-a-hifi
    [ 49.212999] asoc-simple-card sound-codec: ASoC: binding 30c30000.sai-tlv320aic31-b-hifi
    [ 49.222093] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 0 late -2
    [ 49.230000] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 1 late -2
    [ 49.237896] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 0 late -1
    [ 49.245766] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 1 late -1
    [ 49.253617] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 0 late 0
    [ 49.261327] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 1 late 0
    [ 49.269023] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 0 late 1
    [ 49.276700] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 1 late 1
    [ 49.284384] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 0 late 2
    [ 49.292061] asoc-simple-card sound-codec: ASoC: probe ep200-audio dai link 1 late 2

    We only see logs when driver is loaded but we cannot see any new log when we play a sound using aplay.

    Any idea? Do you have a device tree configuration for TLV320AIC34?

    Regards, 

    Gustavo.

  • According to the log, I think another TLV320AIC34 drivers can use sound-dai, when sound-dai once has been occupied by one- of the two TLV320AIC34 drivers. You can write a driver to support two tlv320aic3104. Add a kcontrol the control three states, both work, codec A work, codec b work. like following

    +   i2c {

    > +     /* example with quad support, such as tablet or pad device */

    > +     #address-cells = <1>;

    > +     #size-cells = <0>;

    > +     quad: codec@38 {

    > +       compatible = "ti,tas2781";

    > +       reg = < 0x38 /* Audio slot 0 */

    > +               0x3a /* Audio slot 1 */

    > +               >;

    > +       #sound-dai-cells = <1>;

    > +       reset-gpios = < &gpio1 10 GPIO_ACTIVE_HIGH >;

     

  • Hi Mr. Ding,

    I am not an audio driver expert and I don't know what do you mean when you say " I think another TLV320AIC34 drivers can use sound-dai, when sound-dai once has been occupied by one- of the two TLV320AIC34 drivers", could you give us a more detailed explanation?

    When you say "Add a kcontrol the control three states, both work, codec A work, codec b work. like following", do you mean to use only one driver for controlling codec A and codec B?

    Regards, 

    Gustavo.

  • Yes, one driver to control both A and B.

  • Hi Gustavo, I am working on the same task as you, using the same codecs but on the iMX7D platform. Did you finally find a solution to make them work together?

  • Hi Mathieu, I don't know if you have already done the integration these days.

    We have finally made it work, what we have done is to use two instances of the tlv320aic3x drivers adding the suffixes _a and _b. Then we have started from the "fsl,imx-audio-card" driver to create our own audio card that allows to use two codec drivers and a processor SAI.

    I don't know if my answer is clear enough. 

  • Hi Gustavo,

    I am at the first step, I've created a driver _a and _b for both codecs.

    Can you please give more details about this "fsl,imx-audio-card" driver? Or maybe just show your changes.

    Many thanks.