Adding CMX655D codec to Jetson Nano 2gb

I’m trying to set up the audio clock from Jetson to generate the appropriate output frequency. If my understanding is correct, AUD_MCLK pin from Jetson Nano corresponds to <&tegra_car TEGRA210_CLK_EXTERN1> - is this correct?
In the existing device tree for Jetson Nano b0, the set frequency for this clock in the sound node is 12,288,000, which is exactly half of the desired 24,576,000:
clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
<&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA210_CLK_EXTERN1>;
clock-names = “pll_a”, “pll_a_out0”, “extern1”;
assigned-clocks = <&tegra_car TEGRA210_CLK_EXTERN1>,
<&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA210_CLK_PLL_A>;
assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
assigned-clock-rates = <12288000>, <49152000>, <368640000>;
My idea was to use internal PLL on the codec to increase the frequency to the required, but two problems arose:

  1. the clock frequency, when read with clk_get_rate(clk) is 11289563, which is significantly lower than the specified frequency from the device tree
  2. oscilloscope measurement of the AUD_MCLK pin is ~32MHz, which is more or less nonsensical.
    I tried changing the frequency in the device tree to 24576000, but both values (from driver and from oscilloscope remain the same).
    I assume that I’m doing something obviously wrong, but I don’t understand why.
    Any help is welcome.

Hi nikola,
Yes, TEGRA210_CLK_EXTERN1 is the AUD_MCLK clock.

“assigned-clock-rates” values specified in the dts for clocks are only applicable during boot time. After that the aud_mclk clock rate will change based on the sampling rate of audio and the “mclk-fs = <256>;” factor (i.e mclk-fs * Fs). If you need to double the freq (i.e to 24576000) you can use mclk-fs = <512>;

Can you paste the clock tree dump, The aud_mclk rate depends on how PLLA and PLL_A_OUT0 clock rates are set, as these are the parent for AUD_MCLK clock.

hi @mkumard

We managed to get the codec driver to be functional and are still trying to port the controls into the aSoC system.

What would be the subset of controls in the asound.state file which would apply to just the first device:
card 1: tegrasndt210ref [tegra-snd-t210ref-mobile-cmx655], device 0: ADMAIF1 CIF ADMAIF1-0

We are uninterested in the other 9 devices now and would like to disable those, where would that setting be?

We are able to control certain states like the master mode, sampling rate etc, how would we incorporate controls specific to our driver? As shown in cmx655d line 862-904, taking line 879 as an example we have:

    // Playback +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    SOC_SINGLE_TLV("Master Playback Volume", CMX655_VOLUME,     0, 91,  0, 
                                                                auiCmx655Vol),

I tried inserting this state in the asound.state file but it wasn’t recognized:

control.1 {
    iface MIXER
    name 'Master Playback Volume'
    value 67
    comment {
        access 'read write'
        type INTEGER
        count 1
       range '0 -91'
       dbmin -9999999
       dmax 0
       dbvalue.0 -9999999
    }
}
    

Is there another component in the aSoC driver, besides the codec driver, or another setting where this would need to be incorporated?

Thank you,
Abdo

cmx655d.dts (2.4 KB)
install_overlay.sh (210 Bytes)
cmx655d.c (34.2 KB)
cmx655d.h (4.5 KB)
tegra_machine_driver_mobile.c (20.5 KB)

Hi Abdo,
That’s good news from your side.

Below is what I understand.

  • You were able to run the audio playback on codec speaker/headset with alsa utility like aplay/speaker-test tools by manually setting codec mixer controls?.

  • Currently, you are looking to perform the audio playback from Userspace like ubuntu desktop gui, for which you require the info to add in alsa configuration files?.

Please let me know if my above understanding is correct, So I can provide you with necessary support as soon as possible.

Reason for above question is, looks like you directly changing asound.state which may not work. Also even though 10 pcm devices are exposed, we can still use the specific pcm device needed for the audio usecase. So more info on, what you trying would help

Hi @mkumard

Yes, with the previously attached files we were able to run the audio playback on codec speaker, we haven’t tested recording.

# playing 16khz sample
aplay canned_16k.wav -Dhw:CARD=tegrasndt210ref,DEV=0
Playing WAVE 'canned_16k.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
# playing 32 khz sample
aplay canned_32k.wav -Dhw:CARD=tegrasndt210ref,DEV=0
Playing WAVE 'canned_32k.wav' : Signed 16 bit Little Endian, Rate 32000 Hz, Stereo
# playing master mode
amixer -c tegrasndt210ref cset name="I2S4 codec master mode" 1
aplay tone600hz.wav -Dhw:CARD=tegrasndt210ref,DEV=0 -r 16000 
  ; type=ENUMERATED,access=rw------,values=1,items=3
  ; Item #0 'None'
  ; Item #1 'cbm-cfm'
  ; Item #2 'cbs-cfs'
  : values=1
# playing slave mode
Playing WAVE 'tone600hz.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
amixer -c tegrasndt210ref cset name="I2S4 codec master mode" 2
aplay tone900hz.wav -Dhw:CARD=tegrasndt210ref,DEV=0 -r 16000 
  ; type=ENUMERATED,access=rw------,values=1,items=3
  ; Item #0 'None'
  ; Item #1 'cbm-cfm'
  ; Item #2 'cbs-cfs'
  : values=2
Playing WAVE 'tone900hz.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono

Currently we are looking to control the parameters in the example cmx655D.state file which would look like the image attached when using:

alsamixer -c tegrasndt210ref

Since many parameters in the default /var/lib/alsa/asound.state do not apply to our codec, we are looking to both incorporate our controls and filter out the ones not needed.

cmx655D.state (5.9 KB)

Thank you,
Abdo

Hi Abdo,
Thanks! for your explanation.

  • “asound.state” file is read/written by alsa-store/restore.service and is not suitable for editing by users.

  • ADMAIF1-10 dais are part of sound card, partial disablement is not recommended or this might required changes in DTS and audio drivers extensively as the dai structures needs to be modified.

If you just looking for Playback and Capture on Ubuntu GUI players for your codec, then best way is to add support in the alsa configuration files (for e.g l4t/release/rfs/usr/share/alsa/init/postinit/01-tegra-rt565x.conf ). Similar change can be done for your codec to automatically set mixer controls during playback or capture from ubuntu GUI player which will be taken care by pulseaudio server.

If above is what you looking, we can further proceed with the support of CMX655d controls in alsa conf files. Please let me know if any disconnect here.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.