imx8mp - wm8962 codec audio

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

imx8mp - wm8962 codec audio

1,870 Views
robertZ
Contributor II

I have a problem with the audio codec - WM8962.
I work on my own platform, modeled on imx8mp-devkit.


Diagram:

 

Zrzut ekranu z 2023-06-07 15-03-58.png

 

 

Added device to devicetree:

 
reg_audio_pwr: regulator-audio-pwr {
compatible = "regulator-fixed";
regulator-name = "audio-pwr";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
gpio = <&gpio4 29 GPIO_ACTIVE_HIGH>;
enable-active-high;
regulator-always-on;
};
 
 
sound-wm8962 {
 
compatible = "simple-audio-card";
simple-audio-card,name = "wm8962";
simple-audio-card,format = "i2s";
simple-audio-card,widgets = 
"Headphone", "Headphones",
"Microphone", "Headset Mic",
"Speaker", "Speaker";
simple-audio-card,routing = 
"Headphones", "HPOUTL",
    "Headphones", "HPOUTR",
    "Speaker", "SPKOUTL",
    "Speaker", "SPKOUTR",
    "Headset Mic", "MICBIAS",
    "IN3R", "Headset Mic";
simple-audio-card,hp-det-gpio = <&gpio4 28 0>;
 
simple-audio-card,cpu {
sound-dai = <&sai3>;
};
simple-audio-card,codec {
sound-dai = <&codec>;
frame-master;
bitclock-master;
};
 
 
};
 
&sai3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>;
assigned-clocks = <&clk IMX8MP_CLK_SAI3>;
assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
assigned-clock-rates = <6144000>;
fsl,sai-mclk-direction-output;
#sound-dai-cells = <0>;
status = "okay";
};
 
pinctrl_sai3: sai3grp {
fsl,pins = <
MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_SAI3_TX_SYNC 0xd6
MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_SAI3_TX_BCLK 0xd6
MX8MP_IOMUXC_SAI3_RXD__AUDIOMIX_SAI3_RX_DATA00 0xd6
MX8MP_IOMUXC_SAI3_TXD__AUDIOMIX_SAI3_TX_DATA00 0xd6
MX8MP_IOMUXC_SAI3_MCLK__AUDIOMIX_SAI3_MCLK 0xd6
>;
};
 
The codec is visible in the system and does not issue any errors:
 
[ 6.596032] wm8962 2-001a: customer id 0 revision F
[ 6.854604] input: wm8962 Headphones as /devices/platform/sound-wm8962/sound/card2/input1
List of all devices:
 
root@imx8mp-lpddr4-evk:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: imxaudioxcvr [imx-audio-xcvr], device 0: XCVR PCM snd-soc-dummy-dai-0 [XCVR PCM snd-soc-dummy-dai-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: btscoaudio [bt-sco-audio], device 0: 30c20000.sai-bt-sco-pcm-wb bt-sco-pcm-wb-0 [30c20000.sai-bt-sco-pcm-wb bt-sco-pcm-wb-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: wm8962 [wm8962], device 0: 30c30000.sai-wm8962 wm8962-0 [30c30000.sai-wm8962 wm8962-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
 
however when i try to play some track nothing happens:
 
 
root@imx8mp-lpddr4-evk:~# gst-launch-1.0 playbin uri=file:///unit_tests/Audio/sample_22_frames.mp3 audio-sink="alsasink device=hw:2,0"
[   27.363409] audit: type=1701 audit(1667923787.928:18): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=682 comm="vsidaemon" exe="/usr/bin/vsidaemon" sig=6 res=1
[   37.603724] audit: type=1701 audit(1667923798.168:19): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=725 comm="vsidaemon" exe="/usr/bin/vsidaemon" sig=6 res=1
[   38.876656] audit: type=1334 audit(1667923799.444:20): prog-id=0 op=UNLOAD
[   38.883569] audit: type=1334 audit(1667923799.444:21): prog-id=0 op=UNLOAD
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
 
====== BEEP: 4.7.3 build on Feb  3 2023 05:14:46. ======
Core: DSP decoder Wrapper  build on Dec 20 2022 13:03:58
 file: /usr/lib/imx-mm/audio-codec/wrap/lib_dsp_wrap_arm_elinux.so
 
====== BEEP: 4.7.3 build on Feb  3 2023 05:14:46. ======
Core: MP3 decoder Wrapper  build on Jan 11 2018 10:20:25
 file: /usr/lib/imx-mm/audio-codec/wrap/lib_mp3d_wrap_arm_elinux.so.3
CODEC: BLN_MAD-MMCODECS_MP3D_ARM_02.13.01_ARMV8  build on Sep 16 2022 13:30:45.
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstAudioSinkClock
Chandling interrupt. (0.0 %)
 
 
Do you have any ideas what I might be doing wrong? Or where is the error?
0 Kudos
Reply
9 Replies

1,843 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

I hope you are doing well.

Are you able to hear something when you play audio using ALSA aplay command on hw 2.0?

Best regards.

Jorge.

0 Kudos
Reply

1,809 Views
robertZ
Contributor II

Yes, I checked the "aplay" function:

aplay -D sysdefault:CARD=wm8962 /unit_tests/Audio/sample_22_frames.mp3

And there was no improvement.

 

I made a modification in "devicetree":

 

sound-wm8962 {
 
compatible = "simple-audio-card";
simple-audio-card,name = "wm8962";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-inversion;
simple-audio-card,frame-master = <&wmcpu>;
simple-audio-card,bitclock-master = <&wmcpu>;
simple-audio-card,widgets = 
"Headphone", "Headphones",
"Microphone", "Headset Mic",
"Speaker", "Speaker";
simple-audio-card,routing = 
"Headphones", "HPOUTL",
    "Headphones", "HPOUTR",
    "Speaker", "SPKOUTL",
    "Speaker", "SPKOUTR",
    "Headset Mic", "MICBIAS",
    "IN3R", "Headset Mic";
simple-audio-card,hp-det-gpio = <&gpio4 28 0>;
 
 
wmcpu: simple-audio-card,cpu {
sound-dai = <&sai3>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <8>;
};
simple-audio-card,codec {
sound-dai = <&codec 0>;
};
 
 
};
 
Now I have signals on the BCLK, LRCLK and DAC, ADC lines, but I have no sound at the output, on the speakers.
 
Zrzut ekranu z 2023-06-12 09-38-33.png
 
0 Kudos
Reply

1,754 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Got it, once the sound card is detected on Linux it should be correctly configured and ready to be used.

On the path with an audio test .wav file please try with the next command:

aplay -Dplughw:2,0 <your_audio_test >.wav

Where :

-D: selects the device.

In the case of gstreamer I suggest you use the example on i.MX8 Gstreamer User's Guide that is on the chapter 7.

Best regards.

0 Kudos
Reply

1,718 Views
robertZ
Contributor II

thank you for the hint.
I also used aplay and gst.

 

root@imx8mp-lpddr4-evk:/home# aplay -D plughw:2,0 audiocheck.net_hdsweep_1Hz_48000Hz_-3dBFS_30s.wav
Playing WAVE 'audiocheck.net_hdsweep_1Hz_48000Hz_-3dBFS_30s.wav' : Signed 16 bit Little Endian, Rate 96000 Hz, Mono

 

 

root@imx8mp-lpddr4-evk:/home# gst-launch-1.0 filesrc location=acdc_44000.mp3 ! mpegaudioparse ! mpg123audiodec ! audioconvert ! alsasink device=plughw:2
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
Redistribute latency...
New clock: GstAudioSinkClock
^Chandling interrupt. (9.4 %)
Interrupt: Stopping pipeline ...
Execution ended after 0:00:19.513247750

 

I checked the signal lines in both cases.

Zrzut ekranu z 2023-06-14 10-00-01.png

 

Everything looks correct, but the codec does not output any signals to the speakers.

It looks like a configuration problem but I have no idea what could be wrong.

 

0 Kudos
Reply

1,689 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

I am a little confused, your image shows data on ADCDAT line. This is an output from the codec. When you are playing audio from the MPU you should see data on DACDAT line.

Jorge7u7_0-1686941412476.png

I think that the image is not showing all the data transfer. Could you confirm it?

Best regards.

Jorge.

0 Kudos
Reply

1,643 Views
robertZ
Contributor II

Hi,

yes you are right adcdat is the output of the codec. I got the signals wrong and it should be the other way around.

I checked again to make sure and it's just a naming error.
I'm sending the corrected image of the signals again.

Yes, the image does not show the entire data transfer.

signal.png

1,626 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Is it happening in all your boards?

It seems that it should work as expected, it is possible to check the analog output on speaker and headphone output?

Best regards.

Jorge.

0 Kudos
Reply

1,598 Views
robertZ
Contributor II

Sorry for not replying for so long but I've been busy with other things.

That's how I checked the signals at the output (speaker output, headphone output) with an oscilloscope but no signal.

0 Kudos
Reply

1,581 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Got it, do not worry.

Is this happening in all your boards?

Just to discard a faulty component.

Best regards.

0 Kudos
Reply