Login

Why register?

  • Download software and technical materials
  • Purchase products at our on-line shop
  • Receive design news to stay up-to-date with Emcraft's new solutions

 

 

Playing audio in Linux Print


This application note describes how to add support for playing audio in Vybrid Linux. All software tests documented below were performed on the Emcraft VF6-SOM System-On-Module (SOM), plugged into the TWR-VF6-SOM-BSB development baseboard, which in turn was installed into the Freescale Tower with a Freescale TWR-DOCK2 (Rev D) card connected. The TWR-DOCK2 board provides access to audio using the SGTL5000 codeс device.

Please note that the following hardware configuration must be applied to the above hardware platform for this demo:

  • Solder R53-56 and R59, R60 0 Ohm resistors to connect the SAI2 pins to the Tower connectors.
  • Set the TWR-DOCK2 board jumpers as follows:
    • J11 installed (to enable the TWR-DOCK2 Audio Codec Subsystem);
    • J17 removed (to select the local clock generator as a clock source for the SGTL5000 codec).
  • Connect headphones to the "Headphone" jack (J14, near to primary elevator). Alternatively, connect external speakers to the "Line out" jack (J19, in the middle of 3 jacks).

Configure the kernel to add support for audio. To do so, start the kernel configuration GUI (make kmenuconfig from the project directory) and enable the following kernel options:

CONFIG_I2C=y
CONFIG_I2C_BOARDINFO=y
CONFIG_I2C_COMPAT=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_IMX=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_TIMER=y
CONFIG_SND_PCM=y
CONFIG_SND_JACK=y
CONFIG_SND_SUPPORT_OLD_API=y
CONFIG_SND_VERBOSE_PROCFS=y

CONFIG_SND_DRIVERS=y
CONFIG_SND_ARM=y
CONFIG_SND_SPI=y
CONFIG_SND_USB=y
CONFIG_SND_SOC=y

CONFIG_SND_MVF_SOC=y
CONFIG_SND_MVF_SOC_TWR=y
CONFIG_SND_SOC_MVF_SGTL5000=y
CONFIG_SND_SOC_I2C_AND_SPI=y
CONFIG_SND_SOC_SGTL5000=y

On the target, there will have to be a configuration file for the audio interface. You will need to create the config file on the host and then add it to the target root file systems. On the host, create a local/alsa.conf file (relative to the top of the project directory):

pcm.!default {
type hw
card 0
}

ctl.!default {
type hw
card 0
}

The following changes need to be applied to the project .initramfs in order to add device nodes, sound packages and the configuration file to the target file system:

dir /dev/snd 0755 0 0
nod /dev/snd/timer 0600 0 0 c 116 33
nod /dev/snd/pcmC0D0c 0600 0 0 c 116 24
nod /dev/snd/pcmC0D0p 0600 0 0 c 116 16
nod /dev/snd/controlC0 0600 0 0 c 116 0
opkg libasound2
opkg libgcc1
opkg alsa-utils-amixer
opkg alsa-utils-aplay
file /usr/share/alsa/alsa.conf ${INSTALL_ROOT}/projects/${SAMPLE}/local/alsa.conf 644 0 0

Having updated your project configuration as described above, build the bootable Linux image (<project>.uImage) by running make from the project directory. Install the newly built uImage file to the Flash on the target as described in Installing Linux Images to Flash or load it to RAM via Ethernet as described in Loading Linux Images via Ethernet and TFTP.

From the project booted on the target, configure the audio interface:

~ # amixer sset 'Headphone',0 80% unmute
Simple mixer control 'Headphone',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 127
Mono:
Front Left: Playback 102 [80%] [-0.50dB]
Front Right: Playback 102 [80%] [-0.50dB]
~ #

Now, you can play an audio file. For instance, the following command plays a .wav file from a mounted NFS share:

~ # aplay /mnt/io/sound/sample.wav