iMX8M-Plus play audio by SPDIF

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

iMX8M-Plus play audio by SPDIF

4,103 Views
kluszon
Contributor II

Is any working example for the kernel configuration and playing audio using SPDIF output on the iMX8M-Plus with Yocto Linux?

I enabled SPDIF driver in kernel config (imx8mp-var-som-symphony.dts.txt), I have some error during boot (boot_19.09.22.log), but I don't understand why? I see imxaudioxcvr sound card in the system, tried to play audio using:

aplay --device=plughw:CARD=imxaudioxcvr,DEV=0 --file-type=RAW --format=IEC958_SUBFRAME_LE example.wav

but only what I received is: 

Playing raw data '/dev/zero' : IEC-958 Little Endian, Rate 8000 Hz, Mono
aplay: set_params:1407: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  IEC958_SUBFRAME_LE
SUBFORMAT:  STD
SAMPLE_BITS: 32
FRAME_BITS: 32
CHANNELS: 1
RATE: 8000
PERIOD_TIME: 125000
PERIOD_SIZE: 1000
PERIOD_BYTES: 4000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 4000
BUFFER_BYTES: 16000
TICK_TIME: 0
 
The same situation is with /dev/random or /dev/urandom instead wav file.
0 Kudos
Reply
9 Replies

271 Views
robot1
Contributor I

Not sure if this is relevant after more than 2 years.

Anyway: this syntax solved it for me:

aplay -D iec958:CARD=imxaudioxcvr ./example.wav

Or even:

gplay-1.0 ./example.wav --audio-sink="alsasink device=iec958:CARD=imxaudioxcvr,AES3=0x01 pass-through=true"

 

This with i.MX8M Plus same devicetree setup as yours.

Flemming...

0 Kudos
Reply

4,079 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

Yes we have a unit test in our BSP, you may find more information about this in the Linux documentation:
https://www.nxp.com/webapp/Download?colCode=L5.10.72_2.2.0_LINUX_DOCS

Chapters 7.4.5 Unit Test Preparation, 7.4.5.1 Tx test step & 7.4.5.2 Rx test step

Best regards,
Aldo.

0 Kudos
Reply

4,067 Views
kluszon
Contributor II

Thank you for your reply. I tried to use command from Chapter 7.4.5.1 in i.MX_Reference_Manual: 

aplay -D hw:0,0 street.wav

and I received:

Playing WAVE 'street.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1343: Sample format non available
Available formats:
- IEC958_SUBFRAME_LE

What can I do with it? 

0 Kudos
Reply

4,050 Views
edwardtyrrell
Senior Contributor I

Hi, 

Try 'aplay -D plughw:0,0 street.wav'    If you use hw:0,0 directly then you may have issues with rates, formats etc. Adding 'plug' making 'plughw' adds an ALSA plugin to do the converting, formating of what you are trying to play to suit the limitations of the card.

hw:0,0 - raw card    // Needs the audio source to match the card

plughw:0,0 - raw card with a conversion 'plugin'  // Any audio source,format, rate etc.

Cheers.   

 

0 Kudos
Reply

4,028 Views
kluszon
Contributor II

Thank you for the answer. I check:

aplay -D plughw:0,0 street.wav

and I received exactly the same error:

Playing WAVE 'street.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1343: Sample format non available
Available formats:
- IEC958_SUBFRAME_LE

 

0 Kudos
Reply

4,025 Views
edwardtyrrell
Senior Contributor I

Hi,

What sound cards do you have ( aplay -l   )  ?

Regards IEC958_SUBFRAME_LE this is often tied up with HDMI; any other sounds cards beside your SPDIF that you're trying to use you could try?

There are a lot of "imx8mp-audio-xcvr" errors in your boot log, might be related. 

[ 8.590774] systemd[1]: Starting Load Kernel Modules...
Starting Load Kernel Modules...
[ 8.612281] systemd[1]: Starting Remount Root and Kernel File Systems...
Starting Remount Root and Kernel File Systems...
[ 8.640078] systemd[1]: Starting Coldplug All udev Devices...
Starting Coldpl[ 8.646179] galcore: loading out-of-tree module taints kernel.
ug All udev Devices...
[ 8.661390] module built by at Fri Sep 16 11:48:27 UTC 2022
[ 8.663955] fsl,imx8mp-audio-xcvr 30cc0000.xcvr: Unbalanced pm_runtime_enable!
[ 8.669693] fsl,imx8mp-audio-xcvr 30cc0000.xcvr: failed to pcm register
[ 8.693829] imx-xcvr sound-xcvr: snd_soc_register_card failed: -517
[ OK ] Mounted 8.811451] fsl,imx8mp-audio-xcvr 30cc0000.xcvr: Unbalanced pm_runtime_enable!
[ 8.821348] fsl,imx8mp-audio-xcvr 30cc0000.xcvr: failed to pcm register
[ 8.831449] imx-xcvr sound-xcvr: snd_soc_register_card failed: -517

 

Check out this link, same issue you're seeing:  https://archlinuxarm.org/forum/viewtopic.php?f=65&t=15231&p=66234#p66234 

Then,

https://archlinuxarm.org/forum/viewtopic.php?f=65&t=15231&p=66234#p66234 

Might help.. Might not.

 

0 Kudos
Reply

4,020 Views
kluszon
Contributor II

"aplay -l" give me:

**** 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: audiohdmi [audio-hdmi], device 0: imx8 hdmi i2s-hifi-0 [imx8 hdmi i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: wm8904audio [wm8904-audio], device 0: 30c30000.sai-wm8904-hifi wm8904-hifi-0 [30c30000.sai-wm8904-hifi wm8904-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

I can play audio on HDMI (card 1) and jack (card 2) without any error.

 

@edwardtyrrell Both links are the same. I can't apply it, because it's a solution for Raspberry Pi OS, but I'm using Yocto.

I know about errors during boot, but I don't understand it...

0 Kudos
Reply

4,014 Views
edwardtyrrell
Senior Contributor I

Yea, I only use Yocto but sometimes the RPi boys experience very similar issues and it's that little bit of information that really helps not the code. For example, a link off the link I sent you, there's this bit of info..

PulseAudio on the desktop seems to work fine. aplay at the console
fails:

aplay -v ~/LRMonoPhase4.wav
Playing WAVE '/home/anholt/LRMonoPhase4.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
aplay: set_params:1297: Sample format non available
Available formats:
- IEC958_SUBFRAME_LE

but if you specify iec958 it works:

aplay -v -D iec958 ~/LRMonoPhase4.wav
Playing WAVE '/home/anholt/LRMonoPhase4.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
IEC958 subframe conversion PCM (IEC958_SUBFRAME_LE)
Its setup is:
stream : PLAYBACK
and:

And I'm afraid that dmix won't work with IEC958 subframe type. dmix
can deal with the direct hw access, and it's limited with the normal
linear PCM types. In theory, we can apply the dmix-style plugin onto
iec958 subframes, but the current code doesn't do it.

That said, the default should be rather passing iec958 or hdmi without
the mixing. If the stream mixing is required, you need to use some
sound server instead.

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

Regarding your boot errors, they might need looking in too. You are trying to use card 0:0 and according to your aplay -l that card has the basically the same name as the driver that's failing in your boot log. What is also interesting is just before probing the imx8mp-audio-xcvr driver the boot log states it's loading 'out-of-tree modules'; was this compiled out of the Yocto environment and some important config def or other build related specifics could be missing?  

 

0 Kudos
Reply

4,001 Views
kluszon
Contributor II

Specify iec958 for aplay doesn't change anything in my case, I've got the same error.

Regarding your boot errors, they might need looking in too. You are trying to use card 0:0 and according to your aplay -l that card has the basically the same name as the driver that's failing in your boot log. What is also interesting is just before probing the imx8mp-audio-xcvr driver the boot log states it's loading 'out-of-tree modules'; was this compiled out of the Yocto environment and some important config def or other build related specifics could be missing?

I know that the boot error is with xcvr sound card, but it doesn't talk nothing to me... The only thing I did was kernel configuration for it. I can't find any official documentation or example from NXP on how should it be configurated (The first answer in the thread doesn't help).

0 Kudos
Reply