i.MX8M Plus - SPDIF Protocol Implementation Example

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

i.MX8M Plus - SPDIF Protocol Implementation Example

48 Views
ramkrish
Contributor I

Hi Team,

Could someone pls suggest how to implement and validate SPDIF Protocol in i.MX8M plus?

0 Kudos
Reply
3 Replies

33 Views
yipingwang
NXP TechSupport
NXP TechSupport

Use the existing Linux ALSA Audio XCVR / S/PDIF driver on i.MX8M Plus; you normally do not implement the S/PDIF protocol from scratch. The i.MX8M Plus Audio XCVR supports eARC, ARC, and S/PDIF modes, and the Linux S/PDIF support exposes one playback device for Tx and one capture device for Rx through ALSA. 

Suggested implementation path:

Enable the kernel driver Enable:

CONFIG_SND_IMX_SPDIF

Menu path:

Copy

Device Drivers

  -> Sound card support

    -> Advanced Linux Sound Architecture

      -> ALSA for SoC audio support

        -> SoC Audio for Freescale i.MX CPUs

          -> SoC Audio support for i.MX boards with S/PDIF

The documented DT bindings are under Documentation/devicetree/bindings/sound/fsl,spdif.txt and Documentation/devicetree/bindings/sound/imx-audio-spdfif.txt . 

  • Configure the device tree For i.MX8M Plus, use the xcvr audio block and enable the sound card / DAI link. A representative configuration is:

sound-xcvr {

    compatible = "fsl,imx-audio-card";

    model = "imx-audio-xcvr";

    pri-dai-link {

        link-name = "XCVR PCM";

        cpu {

            sound-dai = <&xcvr>;

        };

    };

};

&xcvr {

    #sound-dai-cells = <0>;

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_xcvr>;

    status = "okay";

};

For Tx pin muxing, one documented example uses MX8MP_IOMUXC_SPDIF_TX__AUDIOMIX_SPDIF1_OUT . 

  • Check board routing / jumpers If using the NXP audio board, set the physical routing for the intended S/PDIF path. For i.MX8M Plus, J1500=1-2 routes the coaxial connector to i.MX8M Plus, and J1500=4-5 routes the optical connector to i.MX8M Plus.  If routing through CPLD / HDMI card, J2511=1-3 is documented as “i.MX 8M Plus to CPLD to HDMI card.” 
  • Use ALSA / IEC958 correctly The S/PDIF Tx driver supports 32, 44.1, and 48 kHz sample rates, with S16_LE and S24_LE formats; for 24-bit output, the file must use 32 bits per channel frame with only the 24 LSBs valid.  If the path expects IEC958 subframes rather than raw PCM, do the PCM-to-IEC958 conversion in user space, for example using an ALSA PCM plugin. 

Validation steps:

aplay -l

arecord -l

Use these to identify the S/PDIF playback / capture card and device IDs. The documentation shows the S/PDIF device appearing as an ALSA card such as imxspdif [imx-spdif], device 0: S/PDIF PCM . 

Tx validation:

aplay -D hw:<card_id>,<pcm_id> audio48k24S.wav

The reference validation method uses an external optical S/PDIF receiver, such as an M-Audio Transit USB sound card with WaveLab, then records the stream externally and plays it back to check correctness. 

Rx validation:

arecord -D hw:<card_id>,<pcm_id> -c 2 -d 20 -r 48000 -f S24_LE record.wav

The sample rate passed to arecord must match the incoming S/PDIF stream sample rate.  For Rx, the application flow is to open the S/PDIF Rx PCM device, wait for the internal DPLL to lock to the input bit stream, get the input sample rate, set channel / format / rate parameters, then prepare and trigger capture. 

For protocol-level checks, use:

iecset -c <card_id>

iecset is the standard utility documented for setting or dumping IEC958 status bits, and the driver also exposes channel-status handling through the ALSA control interface. 

For i.MX8M Plus EVK-style validation, NXP also documents loopback-style Linux testing using the imxaudioxcvr card, for example recording from imxaudioxcvr and playing to wm8960audio :

arecord -Dsysdefault:CARD=imxaudioxcvr -c2 -r48000 -fS32_LE -twav | \

aplay -Dsysdefault:CARD=wm8960audio

In short: enable the i.MX S/PDIF / XCVR ALSA driver, configure the xcvr device tree and board routing, then validate Tx/Rx with aplay , arecord , iecset , and an external optical/coax S/PDIF source or sink.

0 Kudos
Reply

9 Views
ramkrish
Contributor I
Hi Yipingwang,

Could you please guide me with any reference schematics to implement SPDIF in Simplest way.
0 Kudos
Reply

1 View
yipingwang
NXP TechSupport
NXP TechSupport

For the simplest i.MX 8M Plus S/PDIF implementation, use the i.MX Audio Board / MCIMX8M-AUD as the closest NXP reference hardware, not the base i.MX 8M Plus EVK alone. The audio board is documented as supporting i.MX 8M Plus and providing S/PDIF I/O with RCA and TOSLINK connectors, with TOSLINK support up to 192 kHz.

Recommended simple approach:

  • Use optical S/PDIF first if possible
    • Easiest hardware path: i.MX8MP SPDIF_OUT → optical TOSLINK transmitter module.
    • For receive: optical TOSLINK receiver module → i.MX8MP SPDIF_IN .
    • This avoids coaxial 75 Ω line-drive, transformer/coupling, and grounding concerns.
  • Use the i.MX 8M Plus S/PDIF pins through IOMUX
    • The i.MX 8M Plus audio subsystem includes SPDIF input and output .
    • The reference manual shows IOMUX options for AUDIOMIX_SPDIF1_OUT and AUDIOMIX_SPDIF1_IN on selectable pads.
    • In Linux, the corresponding IOMUX definitions include MX8MP_IOMUXC_SPDIF_TX__AUDIOMIX_SPDIF_OUT and MX8MP_IOMUXC_SPDIF_RX__AUDIOMIX_SPDIF_IN .
  • If you need coaxial RCA
    • Do not treat the SoC pin like a direct RCA line driver.
    • Add the proper 75 Ω S/PDIF coax output network / coupling per the selected transmitter/interface circuit.
    • Optical is usually the simpler and safer first implementation.
  • Reference material to look at
    • MCIMX8M-AUD / i.MX Audio Board : best NXP reference for S/PDIF I/O with RCA and TOSLINK on the i.MX 8M family.
    • i.MX 8M Plus Reference Manual : pinmux / IOMUX setup for AUDIOMIX_SPDIF1_IN and AUDIOMIX_SPDIF1_OUT .
    • i.MX 8M Plus datasheet : S/PDIF timing parameters are documented, including clock high/low timing.

For the simplest design, route AUDIOMIX_SPDIF1_OUT/IN to optical TOSLINK modules and use the MCIMX8M-AUD as the NXP reference point for S/PDIF I/O behavior.

0 Kudos
Reply