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.

Linux/DRA750: Audio interface playback/record with specific serializer

Part Number: DRA750

Tool/software: Linux

Hi exports,

(1) I use MCASP2 with I2S mode to do audio playback / record test.

(2) My DTS configuration (AXR0 tx, AXR1 rx; AXR2 tx, AXR3 rx with LOOPBACK TEST):

-----------------------------------------------------------------

&mcasp2 {
#sound-dai-cells = <0>;
fck_parent = "atl_clkin2_ck";

pinctrl-names = "default";
pinctrl-0 = <&mcasp2_pins>;

status = "okay";

op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>;
/* 16 serializer */
serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */
1 2 1 2
0 0 0 0
0 0 0 0
0 0 0 0
>;
tx-num-evt = <8>;
rx-num-evt = <8>;
};

-----------------------------------------------------------------

(3) I can detect sound card and device node shows

root@wnc-j6:~# ls -la /dev/snd/
drwxr-xr-x 3 root root 140 Jan 1 1970 .
drwxr-xr-x 12 root root 13840 Sep 3 18:41 ..
drwxr-xr-x 2 root root 60 Jan 1 1970 by-path
crw-rw---- 1 root audio 116, 0 Jan 1 1970 controlC0
crw-rw---- 1 root audio 116, 24 Jan 1 1970 pcmC0D0c
crw-rw---- 1 root audio 116, 16 Jan 1 1970 pcmC0D0p
crw-rw---- 1 root audio 116, 33 Jan 1 1970 timer
root@wnc-j6:~#

(4) The following command only can choose card and device, it cannot choose serializer.

aplay -r8000 -D plughw:0,0 /usr/local/bin/2_mins.wav &

arecord -r8000 -f S16_LE -D plughw:0,0 100_sec.wav -d 100 -t wav -vv

(5) How do I use aplay or arecord to choose specific serializer to do playback/record loopback test?

Thank you very much.

BRs

Louis

  • Hi Louis,

    I have forwarded your question to Audio experts.

    Regards,
    Yordan
  • Louis,

    The audio samples in the McASP AFIFO for all serializers in a given direction are stored in an interleaved fashion (i.e. sample 0 for AXR0, sample 0 for AXR2, sample 1 for AXR0, sample 1 for AXR2, etc.). The McASP driver exposes a single PCM device for each stream direction, so the data to be played by the kernel driver is assumed to be already interleaved. In other words, the task of interleaving the samples must be done in user-space. Likewise for audio capture, except that the data is to be deinterleaved.

    So, it's not possible with the aplay/arecord utilities, you'd have to write your own applications that take care of the interleaving/de-interleaving part.

  • Hi Misael,

    1. The following is our schematic:

    2. DTS configuration as below

    ****** MCASP2 (Use 4 serializers, 2 TX, 2 RX) ******

    &mcasp2 {

            #sound-dai-cells = <0>;

            fck_parent = "atl_clkin2_ck";

     

            pinctrl-names = "default";

            pinctrl-0 = <&mcasp2_pins>;

     

            status = "okay";

     

            op-mode = <0>;          /* MCASP_IIS_MODE */

            tdm-slots = <2>;

            /* 16 serializer */

            serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */

                    1 2 1 2

                    0 0 0 0

                    0 0 0 0

                    0 0 0 0

            >;  

            tx-num-evt = <8>;

            rx-num-evt = <8>;

    };

    ****** machine driver (Use “sound/soc/generic/simple-card.c”) ******

            snd2: sound@2 {

                    compatible = "simple-audio-card-mcasp2";

                    simple-audio-card,name = "DRA7xx-EVM-MCASP2";

    #if 0

                    /* we do not have codec */

                    simple-audio-card,mclk-fs = <256>;

    #endif

                    simple-audio-card,widgets =

                            "Headphone", "Headphone Jack",

                            "Line", "Line Out",

                            "Microphone", "Mic Jack",

                            "Line", "Line In";

                    simple-audio-card,routing =

                            "Headphone Jack",       "HPLOUT",

                            "Headphone Jack",       "HPROUT",

                            "Line Out",             "LLOUT",

                            "Line Out",             "RLOUT",

                            "MIC3L",                "Mic Jack",

                            "MIC3R",                "Mic Jack",

                            "Mic Jack",             "Mic Bias",

                            "LINE1L",               "Line In",

                            "LINE1R",               "Line In";

                    status = "okay";

     

                    simple-audio-card,dai-link@0 {

                            format = "i2s";

                            bitclock-master = <&sound2_master>;

                            frame-master = <&sound2_master>;

                            bitclock-inversion;

     

                            sound2_master: cpu {

                                    sound-dai = <&mcasp2>;

                                    system-clock-frequency = <8192000>;

                            };

     

                            codec {

                                    sound-dai = <&btsco_mcasp2>;

                            };

                    };

            };

    ****** codec driver, dummy codec, do not have codec chip, only driver support (Use “sound/soc/codec/bt-sco.c”) ******

            btsco_mcasp2: btsco_mcasp2@0 {

                    #sound-dai-cells = <0>;

                    compatible = "delta,dfbmcs320-mcasp2";

                    status = "okay";

            };

    3. To above configuration, /dev/snd shows

    root@wnc-j6:~# ls -al /dev/snd/
    drwxr-xr-x 3 root root 140 Jan 1 1970 .
    drwxr-xr-x 11 root root 13860 Sep 3 18:41 ..
    drwxr-xr-x 2 root root 60 Jan 1 1970 by-path
    crw-rw---- 1 root audio 116, 0 Jan 1 1970 controlC0
    crw-rw---- 1 root audio 116, 24 Jan 1 1970 pcmC0D0c
    crw-rw---- 1 root audio 116, 16 Jan 1 1970 pcmC0D0p
    crw-rw---- 1 root audio 116, 33 Jan 1 1970 timer
    root@wnc-j6:~#

    I cannot indicate AXR0, AXR1, AXR2, AXR3 to do audio play/record

    4. My question is: 

    Because of aplay/arecord ALSA utility need to access user space device node, how to I generate 4 device node such as:

    “/dev/snd/pcmC0D0c for AXR0”

    “/dev/snd/pcmC0D0p for AXR1”

    “/dev/sndpcmC0D1c for AXR2”

    “/dev/snd/pcmC0D1p for AXR3”

    Thank you.

    BRs

    Louis

  • Louis,
    What you described in point 4 is not possible for the reasons I gave in my previous post: if you have more than one serializer active for a given stream direction (i.e. playback), the data will be interleaved and passed to/from the userspace through a single PCM device.

    In other words, for a given McASP one can have one capture and one playback PCM device regardless of the number of active serializers.

    One possibility for what you're trying to do might be using a plugin (i.e. route or other) or a combination of them (i.e. dmix + route). Take a look here: www.alsa-project.org/.../pcm_plugins.html.
  • Hi Misael,

     

    I want to double confirm the below information:

       My request is run time choose different serializer (PIN) to play/record audio in "one mcasp" (i.e. mcasp1, mcasp1 has AXR0, AXR3 for Tx, AXR1, AXR2 for Rx).

       Once "pcm plugins" implement finished, I can run time change different mcasp1 serializer to play/record audio?

     

    BRs

    Louis

  • Louis,

    When you say "choose a different serializer (at runtime)", do you mean that only one serializer will be active at once?

    In other words, do you have an usecase where mcasp1 both, AXR0 and AXR1, transfer TX data?

    My expectation is that with plugins one could have two virtual devices (each corresponding to a serializer).  And the plugin could manage the interleaving of the channels as needed for McASP.

  • Hi Misael,

    My use case as below:

    1. Yes, mcasp1 has 5 serializer, but one serializer will be active at once, use case please refer item 2

    2. mcasp1 has 5 serializer, 3 TX (Adapter Board play and Carrier Board record), 2 RX (Adapter Board record and Carrier Board play), all digital to digital connect.
    2.1 use case to MCASP1
    1. Adapter Board play by AXR0 Carrier Board record by AXR0
    2. Turn off Adapter Board play, Carrier Board record

    3. Adapter Board play by AXR1 Carrier Board record by AXR1
    4. Turn off Adapter Board play, Carrier Board record

    5. Adapter Board play by AXR2 Carrier Board record by AXR2
    6. Turn off Adapter Board play, Carrier Board record

    7. Adapter Board record by AXR3 Carrier Board play by AXR3
    8. Turn off Adapter Board record, Carrier Board play

    9. Adapter Board record by AXR4 Carrier Board play by AXR4
    10. Turn off Adapter Board record, Carrier Board play

    2.2 The above are use case in our test plan, cannot reboot change DTS file to achieve them.

    BRs
    Louis
  • Louis,
    I think the ALSA plugins approach is the first option to try. A backup option would be adding a kcontrol in the McASP driver where one could specify which serializer to use, but it's a hack. I think of that as a last resort, only if the plugin approach is ruled out.
  • Louis,

    Please take a look at the attached asoundrc file. I believe it can help with the Adapter Board side. The Carrier Board side would similar changes, but with different stream direction.

    The new PCM devices are called axr0p, axr1p, ..., and you can directly use them with the -D argument in aplay/arecord. The virtual PCM devices would re-route the channels to a hardware PCM device (which you need to change in the asoundrc file to the index in your system). I'm assuming that the Adapter Board supports 6 playback and 4 capture channels; and that the Carrier Board supports 4 playback and 6 capture channels.

    asoundrc.zip

  • Hi Misael,

    I capture part of "asoundrc" and have some questions:

    ================== asoundrc ================
    pcm.jamr {
    type hw;
    card 3;
    }

    pcm.axr0p {
    type route;
    slave.pcm jamr;
    slave.channels 6;
    ttable.0.0 1;
    ttable.1.3 1;
    }

    ...
    ...
    ...
    ===========================================

    Could you please help the below 3 questions:

    question 1:
    What does "channels" stand for? a PIN (a serializer)?

    question 2:
    What does "ttable.1.3 1" stand for? how to use it?
    --> ttable.X.Y Z, X means input channel, what is input channel? Y mean output channel, what is output channel? A serializer?

    question 3:
    In my condition, mcasp2 only use 4 serializers in Adapter Board (AXR0, AXR1, AXR2, AXR3), and all direction config to Rx.
    Do I only have to add pcm.axr0c, pcm.axr1c, pcm.axr2c, pcm.axr3c?
  • "channels" refers to the number of channels that will be used in the hardware PCM device.

    ttable.X.Y Z -> X=input channel index, Y=output channel index, Z=volume (0.0-1.0), where input refers to the virtual device and output to the hw device.

    The goal was to create pcm devices that could be used to transmit data through a specific McASP serializer. Let's consider a setup that has 3 active TX serializers and 2 TDM slots. For every 6 samples that McASP receives, it will shifts them out in the following order: sample0->AXR0, sample1->AXR1, sample2->AXR2, sample3->AXR0, sample4->AXR1, sample5->AXR2.

    So, if we want to transmit valid stereo data through only one serializer at a time:

    • AXR0 serializer: L 0 0 R 0 0 (L=left channel, R=right channel)
    • AXR1 serializer: 0 L 0 0 R 0
    • AXR2 serializer: 0 0 L 0 0 R

    In other words, we want to have virtual stereo devices that route the two channels to the corresponding slot index in a 6-channel stream. So, for the above example:

    • AXR0 serializer's ttable: 0.0 1 and 1.3 1
    • AXR1 serializer's ttable: 0.1 1 and 1.4 1
    • AXR2 serializer's ttable: 0.2 1 and 1.5 1

    Regarding the 4 RX serializers you have in the Adapter Board, yes, you'd need to create 4 virtual devices for each serializer. In this case, the 'channels' parameter would be 8 (assuming you have tdm-slots=2). Again, these specific virtual devices will work if only one serializer is used at a time.

  • Hi Misael,

    Finally, I can run time change serializer by hacking davinci-mcasp driver.

    All information that you provide really help.

    Thank you very much.

    BRs
    Louis