You are here: Digi Embedded Yocto > System development > Linux v3.14 Board Support Package > Devices and interfaces > Advanced Linux Sound Architecture (ALSA)

Advanced Linux Sound Architecture (ALSA)

The Advanced Linux Sound Architecture (ALSA) subsystem provides audio and MIDI capabilities to Linux systems, including a user space library to simplify application programming (alsa-lib) and support for the older Open Sound System (OSS) architecture through legacy compatibility modes. Specifically for system-on-chips, the architecture defines an ALSA system-on-chip (ASoC) layer which provides optimized support for embedded devices.

The ASoC layer divides an embedded audio system into:

The ASoC layer is described in detail at the Linux kernel documentation.

Audio interfaces

The ConnectCore 6 SBC supports the following audio interfaces:

Both audio interfaces are explained in detail in the corresponding sections. See HDMI audio and SGTL5000 audio.

Audio usage from user space

Listing the available audio devices

To list the available audio devices on the system:

root@ccimx6sbc:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sgtl5000audio [sgtl5000-audio], device 0: HiFi sgtl5000-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: imxhdmisoc [imx-hdmi-soc], device 0: i.MX HDMI Audio Tx hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Selecting the default audio device

Framebuffer-based systems

To change the default audio device on the system, modify (or create if it does not exist) the file /etc/asound.conf indicating the sound card's index or name. For instance, to set HDMI as default audio output:

/etc/asound.conf
1	defaults.pcm.card imxhdmisoc
2	defaults.ctl.card imxhdmisoc

X11-based systems

In this case, pulseaudio manages the audio sinks. You can list the available audio sinks with the following command:

# pactl list short sinks
0    alsa_output.platform-sound-hdmi.19.analog-stereo   module-alsa-card.c    s16le 2ch 44100Hz    SUSPENDED
1    alsa_output.platform-sound.18.analog-stereo        module-alsa-card.c    s16le 2ch 44100Hz    SUSPENDED

To change the default sink, you also use the pactl command using the sink index number or the sink name:

# pactl set-default-sink 1
# pactl set-default-sink alsa_output.platform-sound.18.analog-stereo

To make this configuration permanent across reboots, edit the file /etc/pulse/default.pa and add the following:

/etc/pulse/default.pa
1	set-default-sink alsa_output.platform-sound.18.analog-stereo

Playback and recording

You can access the sound driver using the ALSA API. The ALSA utilities package alsa-utils also offers user space applications:

Several predefined configuration files are stored at /var/lib/alsa/:

To enable a configuration profile, run a command like this:

root@ccimx6sbc:~# alsactl restore -f /var/lib/alsa/asound.inline.state

 

© 2017 Digi International Inc. All rights reserved.
Advanced Linux Sound Architecture (ALSA) updated on 13 April 2017 10:31:15 PM