SAI padding bits configuration on imx93

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

SAI padding bits configuration on imx93

Jump to solution
138 Views
julienblanc
Contributor III

I'm having a hard time correctly configuring the sai link between the imx and the codec under linux.

 

The codec is an AK4619, used in 4 channels TDM mode. Playback is ok at 48KHz / 32 bits TDM mode, MSB first and MSB justified.

For capture, the AK4619 only supports 24 bits. The data is MSB justified, which means that non significant bits comes after the relevant bits (significative bits are 8-31). On the other side, the sai sets the FBT to 23, which means that the significative bits are 0-23.

I tried to find the relevant settings, but could not. I understand that FBT tells where the relevant data starts, but i can't find which register sets the data size (which, in my case, is 24, as opposed to the word size which is 32).

What register needs to be set, or what config must be set in the device tree ? Here's the relevant config i actually use :

&sai3 {
#sound-dai-cells = <0>;
clocks = <&clk IMX93_CLK_SAI3_IPG>, <&clk IMX93_CLK_DUMMY>,
<&clk IMX93_CLK_SAI3_GATE>, <&clk IMX93_CLK_DUMMY>,
<&clk IMX93_CLK_DUMMY>, <&clk IMX93_CLK_AUDIO_PLL>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3", "pll8k";
assigned-clocks = <&clk IMX93_CLK_SAI3>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>;
assigned-clock-parents = <&clk IMX93_CLK_AUDIO_PLL>;
assigned-clock-rates = <24576000>;
fsl,sai-mclk-direction-output;
fsl,sai-asynchronous;

status = "okay";
};
simple-audio-card,dai-link {
link-name = "AK-4CHANNELS";
format = "i2s";
dai-tdm-slot-num = <4>;
dai-tdm-slot-width = <32>;
fsl,mclk-equal-bclk;
cpu {
sound-dai = <&sai3>;
dai-tdm-slot-num = <4>;
dai-tdm-slot-width = <32>;
assigned-clocks = <&clk IMX93_CLK_SAI3>;
};
codec {
sound-dai = <&ak4619>;
system-clock-frequency = <24576000>;
assigned-clocks = <&clk IMX93_CLK_SAI3>;
dai-tdm-slot-num = <4>;
dai-tdm-slot-width = <32>;
};
};

I've checked with a scope, and the data on the sai line looks correct.

 

Any hints on this would be really appreciated.

0 Kudos
Reply
1 Solution
70 Views
julienblanc
Contributor III

Actually, it seems that the extra bits do not cause any issue. I could get audio to work correctly after altering the driver to write the correct value in FBT.

Best regards,

View solution in original post

0 Kudos
Reply
3 Replies
118 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Did you try to use -f S32_LE with ALSA during recording/playback?

This configuration is not done in device tree, if you want to configure it from the driver, you need to modify register TCR5/RCR5 here:

https://github.com/nxp-imx/linux-imx/blob/b096ce610e956cc2596006343df8a2a26ed6e019/sound/soc/fsl/fsl...

https://github.com/nxp-imx/linux-imx/blob/b096ce610e956cc2596006343df8a2a26ed6e019/sound/soc/fsl/fsl...

Best regards.

0 Kudos
Reply
76 Views
julienblanc
Contributor III

Thanks.

The problem is that i don't know what to write in this register. The only doc i can find is

julienblanc_0-1789720432684.pngjulienblanc_0-1789720432684.png

I've highlighted the relevant line in my case. So yes, i should write 0b11111 in FBT, but how do i tell that only 24 bits are relevant ? My understanding is that i cannot use W0W and WNW as they tell the word size, which in my case is 32 bits. In can't find anything relevant in neither of the RCRx registers.

Regards,

Julien

0 Kudos
Reply
71 Views
julienblanc
Contributor III

Actually, it seems that the extra bits do not cause any issue. I could get audio to work correctly after altering the driver to write the correct value in FBT.

Best regards,

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2414378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ESAI%26nbsp%3Bpadding%20bits%20configuration%20on%20imx93%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2414378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20having%20a%20hard%20time%20correctly%20configuring%20the%20sai%20link%20between%20the%20imx%20and%20the%20codec%20under%20linux.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20codec%20is%20an%20AK4619%2C%20used%20in%204%20channels%20TDM%20mode.%20Playback%20is%20ok%20at%2048KHz%20%2F%2032%20bits%20TDM%20mode%2C%20MSB%20first%20and%20MSB%20justified.%3C%2FP%3E%3CP%3EFor%20capture%2C%20the%20AK4619%20only%20supports%2024%20bits.%20The%20data%20is%20MSB%20justified%2C%20which%20means%20that%20non%20significant%20bits%20comes%20%3CSTRONG%3Eafter%3C%2FSTRONG%3E%26nbsp%3Bthe%20relevant%20bits%20(significative%20bits%20are%208-31).%20On%20the%20other%20side%2C%20the%20sai%20sets%20the%20FBT%20to%2023%2C%20which%20means%20that%20the%20significative%20bits%20are%200-23.%3C%2FP%3E%3CP%3EI%20tried%20to%20find%20the%20relevant%20settings%2C%20but%20could%20not.%20I%20understand%20that%20FBT%20tells%20where%20the%20relevant%20data%20starts%2C%20but%20i%20can't%20find%20which%20register%20sets%20the%20data%20size%20(which%2C%20in%20my%20case%2C%20is%2024%2C%20as%20opposed%20to%20the%20word%20size%20which%20is%2032).%3C%2FP%3E%3CP%3EWhat%20register%20needs%20to%20be%20set%2C%20or%20what%20config%20must%20be%20set%20in%20the%20device%20tree%20%3F%20Here's%20the%20relevant%20config%20i%20actually%20use%20%3A%3C%2FP%3E%3CPRE%3E%26amp%3Bsai3%20%7B%3CBR%20%2F%3E%23sound-dai-cells%20%3D%20%26lt%3B0%26gt%3B%3B%3CBR%20%2F%3Eclocks%20%3D%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_SAI3_IPG%26gt%3B%2C%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_DUMMY%26gt%3B%2C%3CBR%20%2F%3E%26lt%3B%26amp%3Bclk%20IMX93_CLK_SAI3_GATE%26gt%3B%2C%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_DUMMY%26gt%3B%2C%3CBR%20%2F%3E%26lt%3B%26amp%3Bclk%20IMX93_CLK_DUMMY%26gt%3B%2C%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_AUDIO_PLL%26gt%3B%3B%3CBR%20%2F%3Eclock-names%20%3D%20%22bus%22%2C%20%22mclk0%22%2C%20%22mclk1%22%2C%20%22mclk2%22%2C%20%22mclk3%22%2C%20%22pll8k%22%3B%3CBR%20%2F%3Eassigned-clocks%20%3D%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_SAI3%26gt%3B%3B%3CBR%20%2F%3Epinctrl-names%20%3D%20%22default%22%3B%3CBR%20%2F%3E%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_sai3%26gt%3B%3B%3CBR%20%2F%3E%20%20assigned-clock-parents%20%3D%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_AUDIO_PLL%26gt%3B%3B%3CBR%20%2F%3E%20%20assigned-clock-rates%20%3D%20%26lt%3B24576000%26gt%3B%3B%3CBR%20%2F%3E%20%20fsl%2Csai-mclk-direction-output%3B%3CBR%20%2F%3E%20%20fsl%2Csai-asynchronous%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20%20status%20%3D%20%22okay%22%3B%3CBR%20%2F%3E%7D%3B%3CBR%20%2F%3Esimple-audio-card%2Cdai-link%20%7B%3CBR%20%2F%3E%20%20%20link-name%20%3D%20%22AK-4CHANNELS%22%3B%3CBR%20%2F%3E%20%20%20format%20%3D%20%22i2s%22%3B%3CBR%20%2F%3E%20%20%20dai-tdm-slot-num%20%3D%20%26lt%3B4%26gt%3B%3B%3CBR%20%2F%3E%20%20%20dai-tdm-slot-width%20%3D%20%26lt%3B32%26gt%3B%3B%3CBR%20%2F%3E%20%20%20fsl%2Cmclk-equal-bclk%3B%3CBR%20%2F%3E%20%20%20cpu%20%7B%3CBR%20%2F%3E%20%20%20%20%20%20sound-dai%20%3D%20%26lt%3B%26amp%3Bsai3%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20dai-tdm-slot-num%20%3D%20%26lt%3B4%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20dai-tdm-slot-width%20%3D%20%26lt%3B32%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20assigned-clocks%20%3D%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_SAI3%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%7D%3B%3CBR%20%2F%3E%20%20%20codec%20%7B%3CBR%20%2F%3E%20%20%20sound-dai%20%3D%20%26lt%3B%26amp%3Bak4619%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20system-clock-frequency%20%3D%20%26lt%3B24576000%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20assigned-clocks%20%3D%20%26lt%3B%26amp%3Bclk%20IMX93_CLK_SAI3%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20dai-tdm-slot-num%20%3D%20%26lt%3B4%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%20%20%20dai-tdm-slot-width%20%3D%20%26lt%3B32%26gt%3B%3B%3CBR%20%2F%3E%20%20%20%7D%3B%3CBR%20%2F%3E%7D%3B%3C%2FPRE%3E%3CP%3EI've%20checked%20with%20a%20scope%2C%20and%20the%20data%20on%20the%20sai%20line%20looks%20correct.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAny%20hints%20on%20this%20would%20be%20really%20appreciated.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2414526%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SAI%26nbsp%3Bpadding%20bits%20configuration%20on%20imx93%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2414526%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks.%3C%2FP%3E%3CP%3EThe%20problem%20is%20that%20i%20don't%20know%20what%20to%20write%20in%20this%20register.%20The%20only%20doc%20i%20can%20find%20is%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22julienblanc_0-1789720432684.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22julienblanc_0-1789720432684.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22julienblanc_0-1789720432684.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F396561iC297B84EEFD25F15%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22julienblanc_0-1789720432684.png%22%20alt%3D%22julienblanc_0-1789720432684.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Ejulienblanc_0-1789720432684.png%3C%2Fspan%3E%3C%2Fspan%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Ejulienblanc_0-1789720432684.png%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Ejulienblanc_0-1789720432684.png%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI've%20highlighted%20the%20relevant%20line%20in%20my%20case.%20So%20yes%2C%20i%20should%20write%200b11111%20in%20FBT%2C%20but%20how%20do%20i%20tell%20that%20only%2024%20bits%20are%20relevant%20%3F%20My%20understanding%20is%20that%20i%20cannot%20use%20W0W%20and%20WNW%20as%20they%20tell%20the%20word%20size%2C%20which%20in%20my%20case%20is%2032%20bits.%20In%20can't%20find%20anything%20relevant%20in%20neither%20of%20the%20RCRx%20registers.%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EJulien%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2414421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SAI%26nbsp%3Bpadding%20bits%20configuration%20on%20imx93%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2414421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EDid%20you%20try%20to%20use%20-f%20S32_LE%20with%20ALSA%20during%20recording%2Fplayback%3F%3C%2FP%3E%0A%3CP%3EThis%20configuration%20is%20not%20done%20in%20device%20tree%2C%20if%20you%20want%20to%20configure%20it%20from%20the%20driver%2C%20you%20need%20to%20modify%20register%20TCR5%2FRCR5%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Flinux-imx%2Fblob%2Fb096ce610e956cc2596006343df8a2a26ed6e019%2Fsound%2Fsoc%2Ffsl%2Ffsl_sai.h%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fnxp-imx%2Flinux-imx%2Fblob%2Fb096ce610e956cc2596006343df8a2a26ed6e019%2Fsound%2Fsoc%2Ffsl%2Ffsl_sai.h%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx%2Flinux-imx%2Fblob%2Fb096ce610e956cc2596006343df8a2a26ed6e019%2Fsound%2Fsoc%2Ffsl%2Ffsl_sai.c%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fnxp-imx%2Flinux-imx%2Fblob%2Fb096ce610e956cc2596006343df8a2a26ed6e019%2Fsound%2Fsoc%2Ffsl%2Ffsl_sai.c%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EBest%20regards.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2414627%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SAI%26nbsp%3Bpadding%20bits%20configuration%20on%20imx93%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2414627%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EActually%2C%20it%20seems%20that%20the%20extra%20bits%20do%20not%20cause%20any%20issue.%20I%20could%20get%20audio%20to%20work%20correctly%20after%20altering%20the%20driver%20to%20write%20the%20correct%20value%20in%20FBT.%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E