Dmic and dspk not able to record and play on TX2

how i can use internal mic and speaker on TX2.

any help will be appreciated.

Please refer to Welcome — Jetson Linux<br/>Developer Guide 34.1 documentation

we are following these but internal mic and speaker is not working in our TX2 EVK.
how to select proper mixer,we are able to record it but no sound is coming in recorded audio,can you please guide in this?

we are using dmic and dspk interface for mic and speaker

we are using speaker with amplifier MAX98358ETE we are getting clock and data but we are not getting any sound on speaker

we are running below commands

amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
aplay -D hw:tegrasndt186ref,1 sample4.wav

can we get help on this.

Hello!

If you are using ADMAIF1 then you should use the following playback command …

$ aplay -D hw:tegrasndt186ref,0 sample4.wav

You may find that by default that the I2S1 is connect to ADMAIF1 and so you may wish to unset its mux …

$ amixer -c tegrasndt186ref cget name=“I2S1 Mux”
$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” None

Regards,
Jon

how to identify our mixer,we are using whatever is mention in nvidia doc.
can you please suggest how we can identify our mixer and run speaker.

Hello!

I am not sure I understand your question. Do you mean what subdevice is being used for playback?

If you are using ADMAIF1 then playback will be on subdevice 0 or tegrasndt186ref,0. If you are using ADMAIF2, then subdevice 1 or tegrasndt186ref,1, and so on. Due to the flexibility in the audio processing engine, we can route the PCM data from any ADMAIF to any interface such as DSPK, I2S, etc by setting the appropriate muxes. So the route between the ADMAIF (which the DMA send the data to/from) and the external interface (eg. DSPK) can be configured via userspace at runtime. So this is not fixed.

Regards
Jon

we are using internal sound card present in TX2 EVK.

we have certain queries please clarify on that

root@localhost:/home/ubuntu# cat /proc/asound/cards
0 [tegrahda ]: tegra-hda - tegra-hda
tegra-hda at 0x3518000 irq 383
1 [tegrasndt186ref]: tegra-snd-t186r - tegra-snd-t186ref-mobile-rt565x
tegra-snd-t186ref-mobile-rt565x

1.we are assuming card 1 is for internal codec and card 0 is for HDMI,is it correct understanding?

  1. We are using internal DMIC. Using below commands we got the mic working and able to capture the audio on the TX2 EVK.
    ===========working mic recording commands================
    amixer -c tegrasndt186ref cset name=“MVC1 Mux” DMIC3
    amixer -c tegrasndt186ref cset name=“ADMAIF1 Mux” MVC1
    amixer -c tegrasndt186ref cset name=“DMIC3 Boost Gain” 50
    amixer -c tegrasndt186ref cset name=“MVC1 Vol” 12602
    amixer -c tegrasndt186ref cset name=“MVC1 input bit format” 32
    amixer -c tegrasndt186ref cset name=“DMIC3 output bit format” 32
    arecord -D hw:tegrasndt186ref,0 -r 48000 -c 1 -f S16_LE sample.wav
    =========================================

  2. So now we also have a speaker with PDM amplifier attached to the DSPK interface on TX2.
    → So we are assuming the mixer ADMAIF1 is the mixer used in our case as it worked for mic.
    So thats why we run below commands to verify speaker

amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
aplay -D hw:tegrasndt186ref,1 sample4.wav

But with above two commands our speaker is not playing.
Even with your shared commands in last response also didn’t work for our speaker.

Can you suggest further how can we validate our speaker with proper mixer settings.

Hello!

Yes that is correct.

So you are using both ADMAIF1 for capture and playback, which is fine. However, please note that each ADMAIF has a playback and capture interface. So in your playback command you should be using hw:tegrasndt186ref,0 as well for playback and not hw:tegrasndt186ref,1.

Please note that …

ADMAIF1 → hw:tegrasndt186ref,0 (both playback and capture)
ADMAIF2 → hw:tegrasndt186ref,1 (both playback and capture)
ADMAIF3 → hw:tegrasndt186ref,2 (both playback and capture)
ADMAIF4 → hw:tegrasndt186ref,3 (both playback and capture)
etc

So …

# playback
$ amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
# capture
amixer -c tegrasndt186ref cset name=“MVC1 Mux” DMIC3
amixer -c tegrasndt186ref cset name=“ADMAIF1 Mux” MVC1
amixer -c tegrasndt186ref cset name=“DMIC3 Boost Gain” 50
amixer -c tegrasndt186ref cset name=“MVC1 Vol” 12602
arecord -D hw:tegrasndt186ref,0 -r 48000 -c 1 -f S16_LE sample.wav & aplay -D hw:tegrasndt186ref,0 sample4.wav

Regards,
Jon

These are the response for the command we tried for playback.

oot@localhost:/home/ubuntu# amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
numid=1042,iface=MIXER,name=‘DSPK1 Mux’
; type=ENUMERATED,access=rw------,values=1,items=81
; Item #0 ‘None’
; Item #1 ‘ADMAIF1’
; Item #2 ‘ADMAIF2’
; Item #3 ‘ADMAIF3’
; Item #4 ‘ADMAIF4’
; Item #5 ‘ADMAIF5’
; Item #6 ‘ADMAIF6’
; Item #7 ‘ADMAIF7’
; Item #8 ‘ADMAIF8’
; Item #9 ‘ADMAIF9’
; Item #10 ‘ADMAIF10’
; Item #11 ‘ADMAIF11’
; Item #12 ‘ADMAIF12’
; Item #13 ‘ADMAIF13’
; Item #14 ‘ADMAIF14’
; Item #15 ‘ADMAIF15’
; Item #16 ‘ADMAIF16’
; Item #17 ‘I2S1’
; Item #18 ‘I2S2’
; Item #19 ‘I2S3’
; Item #20 ‘I2S4’
; Item #21 ‘I2S5’
; Item #22 ‘I2S6’
; Item #23 ‘SFC1’
; Item #24 ‘SFC2’
; Item #25 ‘SFC3’
; Item #26 ‘SFC4’
; Item #27 ‘MIXER1-1’
; Item #28 ‘MIXER1-2’
; Item #29 ‘MIXER1-3’
; Item #30 ‘MIXER1-4’
; Item #31 ‘MIXER1-5’
; Item #32 ‘AMX1’
; Item #33 ‘AMX2’
; Item #34 ‘AMX3’
; Item #35 ‘AMX4’
; Item #36 ‘ARAD1’
; Item #37 ‘AFC1’
; Item #38 ‘AFC2’
; Item #39 ‘AFC3’
; Item #40 ‘AFC4’
; Item #41 ‘AFC5’
; Item #42 ‘AFC6’
; Item #43 ‘OPE1’
; Item #44 ‘SPKPROT1’
; Item #45 ‘MVC1’
; Item #46 ‘MVC2’
; Item #47 ‘IQC1-1’
; Item #48 ‘IQC1-2’
; Item #49 ‘IQC2-1’
; Item #50 ‘IQC2-2’
; Item #51 ‘DMIC1’
; Item #52 ‘DMIC2’
; Item #53 ‘DMIC3’
; Item #54 ‘DMIC4’
; Item #55 ‘ADX1-1’
; Item #56 ‘ADX1-2’
; Item #57 ‘ADX1-3’
; Item #58 ‘ADX1-4’
; Item #59 ‘ADX2-1’
; Item #60 ‘ADX2-2’
; Item #61 ‘ADX2-3’
; Item #62 ‘ADX2-4’
; Item #63 ‘ADX3-1’
; Item #64 ‘ADX3-2’
; Item #65 ‘ADX3-3’
; Item #66 ‘ADX3-4’
; Item #67 ‘ADX4-1’
; Item #68 ‘ADX4-2’
; Item #69 ‘ADX4-3’
; Item #70 ‘ADX4-4’
; Item #71 ‘ADMAIF17’
; Item #72 ‘ADMAIF18’
; Item #73 ‘ADMAIF19’
; Item #74 ‘ADMAIF20’
; Item #75 ‘ASRC1-1’
; Item #76 ‘ASRC1-2’
; Item #77 ‘ASRC1-3’
; Item #78 ‘ASRC1-4’
; Item #79 ‘ASRC1-5’
; Item #80 ‘ASRC1-6’
: values=1

=========
root@localhost:/home/ubuntu# aplay -D hw:tegrasndt186ref,0 sample4.wav -vv
Playing WAVE ‘sample4.wav’ : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
Hardware PCM card 1 ‘tegra-snd-t186ref-mobile-rt565x’ device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 16384
period_size : 4096
period_time : 85333
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 4096
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
appl_ptr : 0
hw_ptr : 0
#+ | 01%
root@localhost:/home/ubuntu#

this are the response coming but we are not getting any sound from the speaker,can you suggest further

Hello!

Did you say that you see the DSPK data and clk signals being driven? If so then the DSPK is working and you need to check your external amplifier is connected and configured as necessary. You may need to contact the vendor of the amplifier to help with that.

Regards,
Jon

with below command or hw:tegrasndt186ref,1 we are seeing some activity on clock and data side on the scope.
aplay -D hw:tegrasndt186ref,1 sample4.wav

but with hardware id as hw:tegrasndt186ref,0: we are not getting any activity on clock and data.

What could be the possible reason for the clock not coming on this hardware id hw:tegrasndt186ref,0 , if it is correct as per our use case.

Hello!

That is odd. If you run the following commands then we should be able to see what is going on …

$ amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
$ echo 0 | sudo tee /sys/kernel/debug/tracing/trace
$ echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
$ echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
$ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable
$ aplay -D hw:tegrasndt186ref,0 sample4.wav
$ aplay -D hw:tegrasndt186ref,1 sample4.wav
$ sudo cat /sys/kernel/debug/tracing/trace

Regards,
Jon

Hi Jonathan,

after enabling the mixer and traces shared in your last response. below is the response we received from the trace.

root@linux:/home/ubuntu# sudo cat /sys/kernel/debug/tracing/trace

tracer: nop

entries-in-buffer/entries-written: 52/52 #P:6

_-----=> irqs-off

/ _----=> need-resched

| / _—=> hardirq/softirq

|| / _–=> preempt-depth

||| / delay

TASK-PID CPU# |||| TIMESTAMP FUNCTION

| | | |||| | |

       aplay-7093  [000] ....    59.408527: snd_soc_dapm_widget_power: widget=Playback 1 val=1
       aplay-7093  [000] ....    59.408538: snd_soc_dapm_widget_power: widget=ADMAIF1 Receive val=1
       aplay-7093  [000] ....    59.408544: snd_soc_dapm_widget_power: widget=ADMAIF1 RX val=1
       aplay-7093  [000] ....    59.408560: snd_soc_dapm_widget_power: widget=DSPK1 Mux val=1
       aplay-7093  [000] ....    59.408572: snd_soc_dapm_widget_power: widget=I2S1 Mux val=1
       aplay-7093  [000] ....    59.408576: snd_soc_dapm_widget_power: widget=DSPK1 TX val=1
       aplay-7093  [000] ....    59.408580: snd_soc_dapm_widget_power: widget=I2S1 TX val=1
       aplay-7093  [000] ....    59.408583: snd_soc_dapm_widget_power: widget=DSPK1 Transmit val=1
       aplay-7093  [000] ....    59.408587: snd_soc_dapm_widget_power: widget=I2S1 Transmit val=1
       aplay-7093  [000] ....    59.408591: snd_soc_dapm_widget_power: widget=DSPK1 Transmit-DSPK1 CIF Receive val=1
       aplay-7093  [000] ....    59.408594: snd_soc_dapm_widget_power: widget=I2S1 Transmit-I2S1 CIF Receive val=1
       aplay-7093  [000] ....    59.408598: snd_soc_dapm_widget_power: widget=DSPK1 CIF Receive val=1
       aplay-7093  [000] ....    59.408621: snd_soc_dapm_widget_power: widget=I2S1 CIF Receive val=1
       aplay-7093  [000] ....    59.408625: snd_soc_dapm_widget_power: widget=DSPK1 DAP TX val=1
       aplay-7093  [000] ....    59.408629: snd_soc_dapm_widget_power: widget=I2S1 CIF RX val=1
       aplay-7093  [000] ....    59.408632: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit val=1
       aplay-7093  [000] ....    59.408636: snd_soc_dapm_widget_power: widget=I2S1 DAP TX val=1
       aplay-7093  [000] ....    59.408640: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit-d3 Playback val=1
       aplay-7093  [000] ....    59.408643: snd_soc_dapm_widget_power: widget=I2S1 DAP Transmit val=1
       aplay-7093  [000] ....    59.408647: snd_soc_dapm_widget_power: widget=d3 Playback val=1
       aplay-7093  [000] ....    59.408651: snd_soc_dapm_widget_power: widget=I2S1 DAP Transmit-x Playback val=1
       aplay-7093  [000] ....    59.408654: snd_soc_dapm_widget_power: widget=d3 OUT val=1
       aplay-7093  [000] ....    59.408657: snd_soc_dapm_widget_power: widget=x Playback val=1
       aplay-7093  [000] ....    59.408661: snd_soc_dapm_widget_power: widget=d3 Headphone val=1
       aplay-7093  [000] ....    59.408665: snd_soc_dapm_widget_power: widget=x OUT val=1
       aplay-7093  [000] ....    59.408668: snd_soc_dapm_widget_power: widget=x Headphone val=1
       aplay-7093  [000] ....    72.988380: snd_soc_dapm_widget_power: widget=Playback 1 val=0
       aplay-7093  [000] ....    72.988463: snd_soc_dapm_widget_power: widget=ADMAIF1 Receive val=0
       aplay-7093  [000] ....    72.988471: snd_soc_dapm_widget_power: widget=ADMAIF1 RX val=0
       aplay-7093  [000] ....    72.988528: snd_soc_dapm_widget_power: widget=DSPK1 Mux val=0
       aplay-7093  [000] ....    72.988577: snd_soc_dapm_widget_power: widget=I2S1 Mux val=0
       aplay-7093  [000] ....    72.988582: snd_soc_dapm_widget_power: widget=DSPK1 TX val=0
       aplay-7093  [000] ....    72.988590: snd_soc_dapm_widget_power: widget=I2S1 TX val=0
       aplay-7093  [000] ....    72.988600: snd_soc_dapm_widget_power: widget=DSPK1 Transmit val=0
       aplay-7093  [000] ....    72.988607: snd_soc_dapm_widget_power: widget=I2S1 Transmit val=0
       aplay-7093  [000] ....    72.988614: snd_soc_dapm_widget_power: widget=DSPK1 Transmit-DSPK1 CIF Receive val=0
       aplay-7093  [000] ....    72.988621: snd_soc_dapm_widget_power: widget=I2S1 Transmit-I2S1 CIF Receive val=0
       aplay-7093  [000] ....    72.988629: snd_soc_dapm_widget_power: widget=DSPK1 CIF Receive val=0
       aplay-7093  [000] ....    72.988636: snd_soc_dapm_widget_power: widget=I2S1 CIF Receive val=0
       aplay-7093  [000] ....    72.988643: snd_soc_dapm_widget_power: widget=DSPK1 DAP TX val=0
       aplay-7093  [000] ....    72.988655: snd_soc_dapm_widget_power: widget=I2S1 CIF RX val=0
       aplay-7093  [000] ....    72.988663: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit val=0
       aplay-7093  [000] ....    72.988672: snd_soc_dapm_widget_power: widget=I2S1 DAP TX val=0
       aplay-7093  [000] ....    72.988680: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit-d3 Playback val=0
       aplay-7093  [000] ....    72.988687: snd_soc_dapm_widget_power: widget=I2S1 DAP Transmit val=0
       aplay-7093  [000] ....    72.988698: snd_soc_dapm_widget_power: widget=d3 Playback val=0
       aplay-7093  [000] ....    72.988705: snd_soc_dapm_widget_power: widget=I2S1 DAP Transmit-x Playback val=0
       aplay-7093  [000] ....    72.988713: snd_soc_dapm_widget_power: widget=d3 OUT val=0
       aplay-7093  [000] ....    72.988720: snd_soc_dapm_widget_power: widget=x Playback val=0
       aplay-7093  [000] ....    72.988726: snd_soc_dapm_widget_power: widget=d3 Headphone val=0
       aplay-7093  [000] ....    72.988733: snd_soc_dapm_widget_power: widget=x OUT val=0
       aplay-7093  [000] ....    72.988740: snd_soc_dapm_widget_power: widget=x Headphone val=0

==================================================================================

Please share your feedback on this.

Hello!

Thanks. Did you execute both aplay commands because I only see aplay run once in the trace.

In the above trace, I can see that both the I2S1 and DSPK1 are active. This is probably because you have ADMAIF1 routed to both I2S1 (the default for ADMAIF1) and DSPK1.

So can you try …

$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” None
$ amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
$ echo 0 | sudo tee /sys/kernel/debug/tracing/trace
$ echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
$ echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
$ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable
$ aplay -D hw:tegrasndt186ref,0 sample4.wav
$ aplay -D hw:tegrasndt186ref,1 sample4.wav
$ sudo cat /sys/kernel/debug/tracing/trace

Thanks
Jon

Hi Jon,

please find the trace after running your set of debug trace and mixer setting.

root@localhost:/home/ubuntu# sudo cat /sys/kernel/debug/tracing/trace

_-----=> irqs-off

/ _----=> need-resched

| / _—=> hardirq/softirq

|| / _–=> preempt-depth

||| / delay

TASK-PID CPU# |||| TIMESTAMP FUNCTION

| | | |||| | |

       aplay-6718  [004] ....   271.489573: snd_soc_dapm_widget_power: widget=Playback 1 val=1
       aplay-6718  [004] ....   271.489586: snd_soc_dapm_widget_power: widget=ADMAIF1 Receive val=1
       aplay-6718  [004] ....   271.489592: snd_soc_dapm_widget_power: widget=ADMAIF1 RX val=1
       aplay-6718  [004] ....   271.489605: snd_soc_dapm_widget_power: widget=DSPK1 Mux val=1
       aplay-6718  [004] ....   271.489611: snd_soc_dapm_widget_power: widget=DSPK1 TX val=1
       aplay-6718  [004] ....   271.489615: snd_soc_dapm_widget_power: widget=DSPK1 Transmit val=1
       aplay-6718  [004] ....   271.489618: snd_soc_dapm_widget_power: widget=DSPK1 Transmit-DSPK1 CIF Receive val=1
       aplay-6718  [004] ....   271.489622: snd_soc_dapm_widget_power: widget=DSPK1 CIF Receive val=1
       aplay-6718  [004] ....   271.489625: snd_soc_dapm_widget_power: widget=DSPK1 DAP TX val=1
       aplay-6718  [004] ....   271.489629: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit val=1
       aplay-6718  [004] ....   271.489632: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit-d3 Playback val=1
       aplay-6718  [004] ....   271.489636: snd_soc_dapm_widget_power: widget=d3 Playback val=1
       aplay-6718  [004] ....   271.489640: snd_soc_dapm_widget_power: widget=d3 OUT val=1
       aplay-6718  [004] ....   271.489644: snd_soc_dapm_widget_power: widget=d3 Headphone val=1
       aplay-6718  [000] ....   282.507768: snd_soc_dapm_widget_power: widget=Playback 1 val=0
       aplay-6718  [000] ....   282.507850: snd_soc_dapm_widget_power: widget=ADMAIF1 Receive val=0
       aplay-6718  [000] ....   282.507858: snd_soc_dapm_widget_power: widget=ADMAIF1 RX val=0
       aplay-6718  [000] ....   282.507912: snd_soc_dapm_widget_power: widget=DSPK1 Mux val=0
       aplay-6718  [000] ....   282.507924: snd_soc_dapm_widget_power: widget=DSPK1 TX val=0
       aplay-6718  [000] ....   282.507931: snd_soc_dapm_widget_power: widget=DSPK1 Transmit val=0
       aplay-6718  [000] ....   282.507938: snd_soc_dapm_widget_power: widget=DSPK1 Transmit-DSPK1 CIF Receive val=0
       aplay-6718  [000] ....   282.507946: snd_soc_dapm_widget_power: widget=DSPK1 CIF Receive val=0
       aplay-6718  [000] ....   282.507952: snd_soc_dapm_widget_power: widget=DSPK1 DAP TX val=0
       aplay-6718  [000] ....   282.507963: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit val=0
       aplay-6718  [000] ....   282.507970: snd_soc_dapm_widget_power: widget=DSPK1 DAP Transmit-d3 Playback val=0
       aplay-6718  [000] ....   282.507978: snd_soc_dapm_widget_power: widget=d3 Playback val=0
       aplay-6718  [000] ....   282.507992: snd_soc_dapm_widget_power: widget=d3 OUT val=0
       aplay-6718  [000] ....   282.508002: snd_soc_dapm_widget_power: widget=d3 Headphone val=0

============================================================
and after running the aplay -D hw:tegrasndt186ref,1 sample4.wav, aplay command is terminating within 2 seconds might be due to wrong mixer setting ?

can we get some update on this to move further

Hello!

It still does not appear that you have executed all of the commands listed below. Please can you execute …

$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” None
$ amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
$ echo 0 | sudo tee /sys/kernel/debug/tracing/trace
$ echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
$ echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
$ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable
$ aplay -D hw:tegrasndt186ref,0 sample4.wav
$ aplay -D hw:tegrasndt186ref,1 sample4.wav
$ sudo cat /sys/kernel/debug/tracing/trace

Note that there are two aplay commands above.

Regards,
Jon

Hello!

Can you share the trace for this? Note that if you execute the following we should have everything in a single trace …

$ amixer -c tegrasndt186ref cset name=“I2S1 Mux” None
$ amixer -c tegrasndt186ref cset name=“DSPK1 Mux” ADMAIF1
$ echo 0 | sudo tee /sys/kernel/debug/tracing/trace
$ echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
$ echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
$ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable
$ aplay -D hw:tegrasndt186ref,0 sample4.wav
$ aplay -D hw:tegrasndt186ref,1 sample4.wav
$ sudo cat /sys/kernel/debug/tracing/trace

Jon

when we are running this command it is getting terminated within 2 sec, and i also don’t see any changes in traces after executing this command.