How to Activate S/PDIF Output on Colibri T20 Computer Module

Monday, June 23, 2014
Icon for Colibri

 

Icon for ColibriColibri T20 module is based on NVIDIA's Tegra 2 ARM Cortex A9 Dual Core processor, and is ideal for systems that require high CPU performance at low power consumption. Along with the many other state of the art features, Colibri T20 Computer on Module comes with a built-in S/PDIF(Sony/Philips Digital Interface) engine that can be used to output digital audio data instead of the analog audio out.

 

How to activate the S/PDIF Unit?

If you have the HDMI screen connected you can pull the HOTPLUG_DET pin high to activate the S/PDIF, else if you dont have a HDMI screen connected then use the following code to activate S/PDIF:

// MixerSetOutputDevice.cpp : Defines the entry point for the console application.
 
#include <windows.h>
#include <winioctl.h>
 
//=============================================================================
// definitions for the MIX_MESSAGE IoControl
#define IOCTL_MIX_MESSAGE \ CTL_CODE((ULONG)0x8000, 0x0040, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
 
// Definitions for the Nvidia SET_OUTPUT_DEVICE feature
#define MXDM_SET_OUTPUT_DEVICE (112)
#define WaveOutDevice_HDMI (4)
 
typedef struct {
    UINT uDeviceId;
    UINT uMsg;          // set to MXDM_SET_OUTPUT_DEVICE
    DWORD dwUser;
    DWORD dwParam1;     // set to WaveOutDevice_HDMI
    DWORD dwParam2;
} MMDRV_MESSAGE_PARAMS;
 
//=============================================================================
 
int _tmain(int argc, _TCHAR* argv[])
{
    HANDLE                  hWAV        = INVALID_HANDLE_VALUE; 
    DWORD                   ret; 
    MMDRV_MESSAGE_PARAMS    mixerParams = {0, MXDM_SET_OUTPUT_DEVICE, 0, WaveOutDevice_HDMI, 0};
    DWORD                   outBuf;
    DWORD                   outSize;
 
    hWAV = CreateFile(L"WAV1:", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 
    ret = DeviceIoControl(hWAV, IOCTL_MIX_MESSAGE, &mixerParams, sizeof(mixerParams), &outBuf , sizeof(outBuf), &outSize, NULL );
    if (!ret)
        printf("error in DeviceIoControl: %d, LastError=%d\r\n", ret, GetLastError());
 
    CloseHandle(hWAV);
    return 0;
}

How to configure the SPDIF_OUT Pin?

The SPDIF_OUT function is available on the following pins of the Colibri T20:
GPIO
AltFn#
SODIMM Pin
 C3
 1
 19
 D4
 0 
 92
 K5
 0
 137
You can choose any of these pins as the S/PDIF_OUT pin.
Please note that SPDIF_OUT feature is not compatible with other Colibri modules. The pins mentioned in the table above are all used for other features in the compatible Colibri default configuration. In order to change the alternate function to SPDIF_OUT temporarily, you can use our GPIOConfig Tool. To change it each time the system starts, we recommend to put the respective code into your application, e.g. use the SetPinAltFn() API of our GPIOLib.
Have a Question?