Example for invoking SAI driver in ALSA im i.Mx8Mini

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

Example for invoking SAI driver in ALSA im i.Mx8Mini

4,472 Views
rajeshkorabandi
Contributor I

Hi,

I am working on a custom SOC ,in which the audio data is transmitted/received through the SAI component to my Audio card.

In i.Mx8MM evk board if i type cat /proc/asound/cards i could see the ALSA devices listed.


0 [wm8524audio ]: wm8524-audio - wm8524-audio
wm8524-audio
1 [imxspdif ]: imx-spdif - imx-spdif
imx-spdif
2 [imxaudiomicfil ]: imx-audio-micfi - imx-audio-micfil
imx-audio-micfil

 I can open these devices through the ALSA API's and tx/rx data.

But in my SOC I want to see my Audio card detected and listed that is getting in inputs/outputs through the SAI driver.

what changes do i need to make to detect my card and drive the inputs to the card through SAI driver.

if someone could provide me an example it would be of great help.

 

Thanks,

Rajesh

Labels (1)
0 Kudos
Reply
7 Replies

4,436 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello, I hope you are doing well.

If your sound card is working as expected, you should be able to see it using the command:

aplay -l

or

arecord -l

When the sound card is correctly configured and declared on device tree should be enough to see your device on the list.

Best regards.

0 Kudos
Reply

4,406 Views
rajeshkorabandi
Contributor I

Hi Jorge,

Thanks for your reply. Could you please elaborate on your statement "When the sound card is correctly configured and declared on device tree should be enough to see your device on the list".

what are the changes that i would have to make in the device tree. is there any documentation that i could refer to make the necessary changes?

in imx8mm EVK dts file i see the following instantiation of the wm8524 sound card.

do i have to add similar information for my card?

sound-wm8524 {
compatible = "fsl,imx-audio-wm8524";
model = "wm8524-audio";
audio-cpu = <&sai3>;
audio-codec = <&wm8524>;
audio-routing =
"Line Out Jack", "LINEVOUTL",
"Line Out Jack", "LINEVOUTR";
};


what does the following line represents. does it mean the soundcard wm8524 is using the SAI driver for audio data transfer?

audio-cpu = <&sai3>

0 Kudos
Reply

4,374 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

I apologize if I was not clear, on that statement I was referring that you are able to play and record audio with the sound card.

If you need more information related with the documentation on device tree, I suggest you check the i.MX Porting Guide on section 16 "Porting Audio Codecs".

Best regards.

0 Kudos
Reply

4,283 Views
rajeshkorabandi
Contributor I

Hi Jorge,

Thanks for the information. Please help me understand the follow up question.

In i.mx8mini evk board we have a sound card(wm8524-audio) that gets detected by the ALSA -

root@device-05fa4c:~# aplay -l

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

card 0: wm8524audio [wm8524-audio], device 0: HiFi wm8524-hifi-0 []

  Subdevices: 1/1

  Subdevice #0: subdevice #0

 

The node for the wm8524-audio is present in the dts file(fsl-imx8mm-evk-emmc.dts)

Here the audio-cpu is mentioned as sai3 interface as highlighted below.

wm8524: wm8524 {

                              compatible = "wlf,wm8524";

                              clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

                              clock-names = "mclk";

                              wlf,mute-gpios = <&gpio5 21 GPIO_ACTIVE_LOW>;

               };

 

               sound-wm8524 {

                              compatible = "fsl,imx-audio-wm8524";

                              model = "wm8524-audio";

                              audio-cpu = <&sai3>;

                              audio-codec = <&wm8524>;

                              audio-routing =

                                             "Line Out Jack", "LINEVOUTL",

                                             "Line Out Jack", "LINEVOUTR";

               };

 

Does this mean that Audio going to the Lineout in EVK is through the sai3 interface?

 

Thanks,

Rajesh

0 Kudos
Reply

4,268 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Yes, that is correct.

Jorge7u7_0-1696349988572.pngJorge7u7_0-1696349988572.png

Best regards.

0 Kudos
Reply

4,046 Views
rajeshkorabandi
Contributor I

Hi Jorge,

need a help understanding clocks. As you  mentioned in the diagram that you have shared MCLK is the clock that is set on wm8524 codec.

dts file sai3 interface:

sai3: sai@30030000 {


compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai", "fsl,imx6sx-sai";
reg = <0x0 0x30030000 0x0 0x10000>;
interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk IMX8MM_CLK_SAI3_IPG>,
<&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_CLK_SAI3_ROOT>,
<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
dmas = <&sdma2 4 2 0>, <&sdma2 5 2 0>;
dma-names = "rx", "tx";
status = "disabled";
};

as i see in the dts file the clock is defined as.

clocks = <&clk IMX8MM_CLK_SAI3_IPG>,
<&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_CLK_SAI3_ROOT>,
<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";

 

how to define these clocks?

<&clk IMX8MM_CLK_SAI3_ROOT>

<&clk IMX8MM_CLK_DUMMY>

<&clk IMX8MM_CLK_SAI3_IPG>

 

Thank you,

Rajesh

 

0 Kudos
Reply

4,042 Views
rajeshkorabandi
Contributor I

Hi Jorge,

 

please clarify this point as well.

when we define 

clock@0

clock@1

clock@2

in the definition file ,what is the clock source device we are referring to in the dts file

 

dts file clock definitions:

clocks {
#address-cells = <1>;
#size-cells = <0>;

osc_32k: clock@0 {
compatible = "fixed-clock";
reg = <0>;
#clock-cells = <0>;
clock-frequency = <32768>;
clock-output-names = "osc_32k";
};

osc_24m: clock@1 {
compatible = "fixed-clock";
reg = <1>;
#clock-cells = <0>;
clock-frequency = <24000000>;
clock-output-names = "osc_24m";
};

clk_ext1: clock@2 {
compatible = "fixed-clock";
reg = <3>;
#clock-cells = <0>;
clock-frequency = <133000000>;
clock-output-names = "clk_ext1";
};

0 Kudos
Reply