wiki:ventana/audio

Version 1 (modified by trac, 7 years ago) ( diff )

--

Ventana Audio

The Advanced Linux Sound Architecture (ALSA) system is the current audio driver subsystem in Linux.

The hardware that is used:

  • Freescale SGTL5000 with line level input and output (standard board configuration) or (custom board configuration) headphone level output (custom board configuration) - 45mW max into 16ohme@3.3V load, and mic input
  • tda1997x (HDMI Audio in)(i.MX6)
  • imxhdmisoc (HDMI Audio out)(i.MX6)

For information regarding Audio / Video breakout adapters for Ventana see:

Note that by default, Ventana family boards that have analog audio have a default strapping of line level audio (both input and output). However, there is an option to load Headphone level output/Mic level input on request. Please contact sales@… if you would like a special built with these loadings.

Devices

The following commands are useful when dealing with multiple audio devices (These commands are done on a GW5400 which has multiple sources of audio in/out - different boards will have different devices at varied locations):

  • see a list of all audio cards:
    $ cat /proc/asound/cards
     0 [sgtl5000audio  ]: sgtl5000-audio - sgtl5000-audio
                          sgtl5000-audio
     1 [tda1997xaudio  ]: tda1997x-audio - tda1997x-audio
                          tda1997x-audio
     2 [imxhdmisoc     ]: imx-hdmi-soc - imx-hdmi-soc
                          imx-hdmi-soc
    
    • There are 3 audio cards in the system:
      • 0: sgtl5000audio (Analog Audio in/out)
      • 1: tda1997xaudio (HDMI Audio in)
      • 2: imxhdmisoc (HDMI Audio out)
        • Note that this is only available for playback if the framebuffer is not blanked
  • see a list of all playback devices:
    $ 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 2: imxhdmisoc [imx-hdmi-soc], device 0: IMX HDMI TX mxc-hdmi-soc-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    
    • the above shows 2 playback capable devices:
      • card 0: the sgtl5000audio device which has one subdevice (0) - this can be represented as 'hw:0,0'
      • card 2: the imxhdmisoc device which has one subdevice (0) - this can be represented as 'hw:2,0'
      • Note that card 1 is not listed as it is an HDMI Audio input only and not capable of playback
  • see a list of all playback device 'names'
    $ aplay -L
    null
        Discard all samples (playback) or generate zero samples (capture)
    sysdefault:CARD=sgtl5000audio
        sgtl5000-audio, 
        Default Audio Device
    sysdefault:CARD=imxhdmisoc
        imx-hdmi-soc, 
        Default Audio Device
    
    • the above shows 3 playback devices shown by name (Note that this is the name what can be used with 'aplay -D <devicename>' to specify playback device):
      • null - a null device
      • sysdefault:CARD=sgtl5000audio - Analog audio out
      • sysdefault:CARD=imxhdmisoc - HDMI audio out
  • see a list of all capture devices:
    root@ventana:~# arecord -l
    **** List of CAPTURE Hardware Devices ****
    card 0: sgtl5000audio [sgtl5000-audio], device 0: HiFi sgtl5000-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 1: tda1997xaudio [tda1997x-audio], device 0: IMX HDMI RX tda1997x-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    
    • the above shows 2 capture capable devices:
      • card 0: the sgtl5000audio device which has one subdevice (0) - this can be represented as 'hw:0,0'
      • card 1: the tda1997xaudio device which has one subdevice (0) - this can be represented as 'hw:1,0'
      • Note that card 2 is not listed as it is an HDMI Audio output only and not capable of capture
  • see a list of all record device 'names':
    $ arecord -L
    null
        Discard all samples (playback) or generate zero samples (capture)
    sysdefault:CARD=sgtl5000audio
        sgtl5000-audio, 
        Default Audio Device
    sysdefault:CARD=tda1997xaudio
        tda1997x-audio, 
        Default Audio Device
    
    • the above shows 3 capture devices shown by name (Note that this is the name what can be used with 'arecord -D <devicename>' to specify capture device):
      • 'null' - a null device
      • 'sysdefault:CARD=sgtl5000audio' - Analog audio in
      • 'sysdefault:CARD=tda1997xaudio' - HDMI audio in
  • display audio controls:
    amixer
    
    • you can use the '-c <cardno>' parameter to amixer to specify a specific card (card number for /proc/asound/cards such as 'amixer -c 0' for the first card)
    • see 'amixer -h' for details on setting/getting various controls

Mixer (mux/gain/volume)

The ALSA mixer controls the muxing of inputs to outputs, capture gains, and volume levels. The settings vary per card.

You can use the amixer command to get/set/list available controls per card:

  • list controls for card0:
    amixer -c0
    

sgtl5000 (analog audio)

Note that by default, Ventana family boards that have analog audio have a default strapping of line level audio (both input and output).

However, there is an option to load Headphone level output and/or Mic level input on request. Please contact sales@… if you would like a special built with these loadings.

Line Level Audio Output

common amixer settings for line level audio:

# set output level to max
amixer -c 0 -q sset "PCM" 100%
# set capture mux
amixer -c 0 -q sset "Capture Mux" LINE_IN
amixer -c 0 -q sset "Line In Function" on
# set capture gain
amixer -c 0 -q sset "Capture" 8

Headphone Level Audio Output

If you've ordered a board with HP level audio the following specifications apply:

  • sgtl5000 can drive 45mW max into a 16ohm load at 3.3V (53mA)

common amixer settings for headphone level audio:

# Set zero cross detect gain
amixer -c 0 sset Headphone Playback ZC 60%

In addition, you will also have to make a change to your device tree file in the kernel. Below is a sample patch of what you will have to do (filename depends on product you've ordered)

  • arch/arm/boot/dts/imx6qdl-gw52xx.dtsi

    diff --git a/arch/arm/boot/dts/imx6qdl-gw52xx.dtsi b/arch/arm/boot/dts/imx6qdl-gw52xx.dtsi
    index ed71beb..1c0b229 100644
    a b  
    109109               audio-codec = <&codec>;
    110110               audio-routing =
    111111                       "LINE_IN", "Line In Jack",
    112                        "Line Out Jack", "LINE_OUT";
     112                       "Headphone Jack", "HP_OUT";
    113113               mux-int-port = <1>;
    114114               mux-ext-port = <4>;
    115115       };

The defaults for the analog audio (which are found by running 'amixer' with no args) are:

  • Output Level (PCM) (0 - 192)
    • Front Left: Playback 192 [100%]
    • Front Right: Playback 192 [100%]
  • Capture Mux (MIC_IN or LINE_IN)
    • MIC_IN
  • Capture Gain (0-15):
    • Front Left: Capture 5 [33%]
    • Front Right: Capture 6 [40%]

HDMI (digital audio)

The imxhdmisoc audio (output only) device can be used to send digital audio to a connected (and unblanked) HDMI monitor that has speakers.

The tda1997xaudio audio (input only) device (on GW5400 models) can be used to capture digital audio from a connected (and unblanked) HDMI source that streams audio. Note that HDMI audio supports multiple sample-rates and the sample-rate available to capture depends on the incoming source stream. The source stream's audio sample rate can be found via sysfs /sys/bus/i2c/drivers/tda1997x/2-0048/audmode

ALSA utility (alsa-utils package) examples (arecord/aplay)

The alsa-utils package contains the arecord, aplay, amixer applications

aplay:

  • playback pre-recorded sound to analog audio device (GW54xx/GW53xx/GW52xx)
    aplay -D sysdefault:CARD=sgtl5000audio /usr/share/sounds/alsa/Front_Center.wav
    
  • playback pre-recorded sound to HDMI audio output device
    aplay -D sysdefault:CARD=imxhdmisoc /usr/share/sounds/alsa/Front_Center.wav
    

arecord:

  • record 10 seconds of CD quality audio (16bit, 44.1KHz, stereo) from analog audio device to /tmp/foo.wav
    arecord -D sysdefault:CARD=sgtl5000audio -f cd -d 10 -t wav /tmp/foo.wav
    
    • make sure you have specified the capture gain and input device (see above)

Codecs

For Codec support (Encoder / Decoder) details please see:

Gstreamer examples

For GStreamer information and examples please see:

Note: See TracWiki for help on using the wiki.