Difference between revisions of "ALSA"

From ArmadeusWiki
Jump to: navigation, search
(Installation)
m (Hardware)
 
(68 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page will summarize the informations to use ALSA on your Armadeus boards.
+
This page will summarize the informations to use ALSA, ie the sound capabilities (Audio In/Audio Out) of your Armadeus board.
  
 
==Introduction==
 
==Introduction==
ALSA stands for ''Advanced Linux Sound Architecture'' and provides audio and MIDI functionality to the Linux operating system. Everyone wanting to write portable & state of the art Linux applications dealing with sound should consider using ALSA.
+
ALSA stands for ''Advanced Linux Sound Architecture'' and provides audio and MIDI functionality to the Linux operating system. Everyone wanting to write portable & state of the art Linux applications dealing with sound should consider using ALSA.<br>
 +
ALSA is composed of a low level part (target specific Linux drivers) and a userspace library (''libasound'') with a lot of tools (''aplay, arecord, alsamixer, speaker-test'').
  
==ALSA Soc==
+
==Hardware==
 
+
On the i.MX family, used on the Armadeus boards, (good quality) sound can be produced that way:
On the APF boards we are going to use Embedded version of ALSA: ALSA Soc ->
+
# the i.MX is connected to an audio CODEC (like the [[TSC2102]] on the [[APF9328DevFull]], the [[TSC2101]] on the [[APF27Dev]], the WM8960 on the [[APF51Dev]] or the SGTL5000 on the [[APF6Dev]]) through one of its SSI interfaces
* http://opensource.wolfsonmicro.com/node/6
+
# the i.MX takes PCM data (ALSA format) from memory and send them (through DMA) to the SSI module
* http://www.rpsys.net/openzaurus/patches/alsa/info.html
+
# this one converts the data to a serial bitstream in [http://en.wikipedia.org/wiki/I%C2%B2S the I2S format] (or AC97). That stream is then sent to the CODEC
* http://alsa-project.org/main/index.php/ASoC
+
# the stream is converted by the CODEC's DAC to an analog sound
 
+
Sound acquisition (on [[TSC2101]], WM8960 and SGTL5000) is done in the reverse way.
== nodes creation ==
+
 
+
in /dev/snd
+
 
+
mknod controlC0 c 116 0
+
mknod pcmC0D0c c 116 24
+
mknod pcmC0D0p c 116 16
+
  
 
==Installation==
 
==Installation==
* On your Host select ALSA compilation in Linux configuration:
+
'''ALSA is by default installed on the standard Armadeus rootfs.''' If you want to change the default configuration, you can consult [[ALSA_Installation|this wiki page.]]
[armadeus]$ make linux-menuconfig
+
+
Device Drivers  ---> Sound  ---> <M> Sound card support
+
Device Drivers  ---> Sound  ---> Advanced Linux Sound Architecture  ---> <M> Advanced Linux Sound Architecture
+
Device Drivers  ---> Sound  ---> Advanced Linux Sound Architecture  --->    ALSA ARM devices  ---> <M> IMX TSC2102 alsa driver
+
  
<M> Advanced Linux Sound Architecture
+
==Usage==
< >  Sequencer support (NEW)
+
* Load the ALSA drivers:
<M>  OSS Mixer API
+
{| cellspacing="20"
<M>   OSS PCM (digital audio) API
+
||
  [*]    OSS PCM (digital audio) API - Include plugin system (NEW)
+
* On APF9328/APF27:
  [ ]  Dynamic device file minor numbers (NEW)
+
<pre class="apf">
  [*]  Support old ALSA API (NEW)
+
  # modprobe snd-imx-alsa-tsc2102
[ ]  Verbose procfs contents (NEW)
+
  TI TSC210x driver initializing
[ ]  Verbose printk
+
  TSC210x detected
[ ]  Debug
+
</pre>
[ ]    Debug detection
+
||
[ ]    Enable PCM ring buffer overrun/underrun debugging (NEW)
+
* On APF51:
      Generic devices  --->
+
<pre class="apf">
    ALSA ARM devices  --->
+
# modprobe snd-soc-imx-fiq
    USB devices  --->
+
# modprobe snd-soc-wm8960
    System on Chip audio support  --->
+
# modprobe snd-soc-apf51dev-wm8960
 +
</pre>
 +
||
 +
* Other boards:
 +
not needed
  
* in Buildroot configuration, select the user space packages for ALSA:
 
[armadeus]$ make menuconfig
 
Package Selection for the target-> Audio libraries:
 
  
--- Audio libraries and applications
 
[*]  alsa-lib
 
[*]    alsa-utils
 
        ALSA utils selection  --->
 
[ ]  asterisk
 
[*]  aumix
 
[ ]  libmad
 
....
 
  
in ALSA utils selection  --->
+
|}
[*] alsaconf
+
[*] alsactl
+
[*] alsamixer
+
[ ] amidi
+
[*] amixer
+
[*] aplay
+
[ ] arecord
+
[ ] iecset
+
[ ] aconnect
+
[ ] aplaymidi
+
[ ] arecordmidi
+
[ ] aseqdump
+
[ ] aseqnet
+
[*] speaker-test
+
  
* save your configuration and rebuild your rootfs:
+
* If you want OSS support (optional):
[armadeus]$ make
+
<pre class="apf">
 
+
* after reflashing your rootfs on your board, you can load ALSA drivers:
+
modprobe soundcore
+
modprobe snd
+
modprobe snd-timer
+
modprobe snd-page-alloc
+
modprobe snd-pcm
+
 
  modprobe snd-pcm-oss
 
  modprobe snd-pcm-oss
 
  modprobe snd-mixer-oss
 
  modprobe snd-mixer-oss
Only if MIDI sequencer used:
+
</pre>
 +
* If you want MIDI sequencer support (optional):
 +
<pre class="apf">
 
  modprobe snd-seq
 
  modprobe snd-seq
 
  modprobe snd-seq-device
 
  modprobe snd-seq-device
Specific to DevFull:
+
</pre>
modprobe spi_imx
+
modprobe snd-imx-alsa-tsc2102
+
  
* http://alsa-project.org/main/index.php/DevEmbedded
+
===Loading script===
 +
If you want the drivers to be loaded automatically during each boot, you can add a script in ''/etc/init.d/''. For example:
 +
<pre class="apf">
 +
# vi /etc/init.d/S60alsa
 +
</pre>
 +
<source lang="bash">
 +
#!/bin/sh
 +
 
 +
modprobe snd-imx-alsa-tsc2102
 +
</source>
 +
<pre class="apf">
 +
# chmod a+x /etc/init.d/S60alsa
 +
</pre>
  
==Test==
+
==First checks (optionnal)==
# aplay -lL
+
* Check if ALSA is running:
  # aplay -vDhw:0,0 /usr/share/sounds/alsa/Side_Left.wav
+
<pre class="apf">
 +
  # cat /proc/asound/version
 +
Advanced Linux Sound Architecture Driver Version 1.0.18a.
 +
</pre>
  
Note: the audio file Side_Left.wav can be copied from your host PC
+
* To check if the CODEC was detected as a sound chip:
 +
 
 +
{| border="1" cellpadding="10" cellspacing="0" summary="DFS check depending on kernel version" class="wikitable"
 +
|- style="background:#efefef;" align="center"
 +
! APF9328 / APF27 || APF28 || APF51 || APF6
 +
|---
 +
|<pre class="apf">
 +
# aplay -lL
 +
default:CARD=IMX-ALSA
 +
    i.MX+TSC210x audio, i.MX SSI
 +
    Default Audio Device
 +
null
 +
    Discard all samples (playback) or generate zero samples (capture)
 +
**** List of PLAYBACK Hardware Devices ****
 +
card 0: IMX-ALSA [i.MX+TSC210x audio], device 0: i.MX SSI [i.MX SSI]
 +
  Subdevices: 1/1
 +
  Subdevice #0: subdevice #0
 +
 
 +
or
 +
 
 +
# cat /proc/asound/cards
 +
0 [IMX-ALSA      ]: i.MX - i.MX+TSC210x audio
 +
                      Freescale i.MX with TSC210x codec
 +
</pre>
 +
|
 +
|
 +
|<pre class="apf"># aplay -lL
 +
null
 +
    Discard all samples (playback) or generate zero samples (capture)
 +
default:CARD=imx6armadeussgt
 +
    imx6-armadeus-sgtl5000,
 +
    Default Audio Device
 +
sysdefault:CARD=imx6armadeussgt
 +
    imx6-armadeus-sgtl5000,
 +
    Default Audio Device
 +
default:CARD=imxspdif
 +
    imx-spdif,
 +
    Default Audio Device
 +
sysdefault:CARD=imxspdif
 +
    imx-spdif,
 +
    Default Audio Device
 +
default:CARD=imxhdmisoc
 +
    imx-hdmi-soc,
 +
    Default Audio Device
 +
sysdefault:CARD=imxhdmisoc
 +
    imx-hdmi-soc,
 +
    Default Audio Device
 +
**** List of PLAYBACK Hardware Devices ****
 +
card 0: imx6armadeussgt [imx6-armadeus-sgtl5000], device 0: HiFi sgtl5000-0 []
 +
  Subdevices: 1/1
 +
  Subdevice #0: subdevice #0
 +
card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 []
 +
  Subdevices: 1/1
 +
  Subdevice #0: subdevice #0
 +
card 2: imxhdmisoc [imx-hdmi-soc], device 0: i.MX HDMI Audio Tx hdmi-hifi-0 []
 +
  Subdevices: 1/1
 +
  Subdevice #0: subdevice #0
 +
 
 +
or
 +
 
 +
# cat /proc/asound/cards
 +
0 [imx6armadeussgt]: imx6-armadeus-s - imx6-armadeus-sgtl5000
 +
                      imx6-armadeus-sgtl5000
 +
1 [imxspdif      ]: imx-spdif - imx-spdif
 +
                      imx-spdif
 +
2 [imxhdmisoc    ]: imx-hdmi-soc - imx-hdmi-soc
 +
                      imx-hdmi-soc
 +
 
 +
</pre>
 +
|}
 +
 
 +
==Setting playback and capture volume==
 +
* For this work, you can use ''alsamixer'' "pseudo graphic" tool:
 +
<pre class="apf">
 +
# alsamixer
 +
</pre>
 +
[[Image:alsamixer.png]]
 +
 
 +
* choose the ''Item'' to setup by using ''<- -> arrow keys'' (here Master Playback volume is selected)
 +
* modify its value with ''up/down arrow keys''
 +
* you can switch ''View'' between Playback and Capture settings with ''TAB'' key
 +
* Capture ''Handset'' input is by default muted (''MM''), you can unmute it by pressing the ''SPACE'' key when selected
 +
* when stereo channels are used you can modify individual channel volume with:
 +
** 'q': left up, 'z': left down
 +
** 'e': right up, 'c': right down
 +
* if ''alsamixer'' changed your terminal layout after exiting you can get it back with:
 +
<pre class="apf">
 +
# reset
 +
</pre>
 +
 
 +
==First tries==
 +
* To play a test sound (connect your headset first ;-) ):
 +
<pre class="apf">
 +
# aplay /usr/share/sounds/alsa/Side_Left.wav
 +
Playing WAVE '/usr/share/sounds/alsa/Side_Left.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
 +
</pre>
 +
 
 +
'''Note:''' the audio file ''Side_Left.wav'' can be copied from your Linux host (if not already on your rootfs)
 +
 
 +
If you have several sound cards, sound is played on the first one in [[ALSA#First_checks_.28optionnal.29|previous list]]. To choose a given sound card, do:
 +
<pre class="apf">
 +
# aplay -D "default:CARD=name_of_card" /usr/share/sounds/alsa/Side_Left.wav
 +
</pre>
 +
* To record a test sound (on APF with Mic Input only) (connect your microphone first ;-) ):
 +
<pre class="apf">
 +
# arecord /tmp/foo.wav
 +
Recording WAVE '/tmp/foo.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
 +
</pre>
 +
* and to replay it after:
 +
<pre class="apf">
 +
# aplay /tmp/foo.wav
 +
Playing WAVE '/tmp/foo.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
 +
</pre>
 +
* for a faster and "wider" sampling:
 +
<pre class="apf">
 +
# arecord -f S16_LE -r 16000 /tmp/toto.wav
 +
Recording WAVE '/tmp/toto.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
 +
</pre>
 +
 
 +
==Automate ALSA settings at boot==
 +
* ''alsamixer'' is quite cool to setup ALSA parameters in live but in some cases you may want to set them up at a default value at system startup. Here is the way to do.
 +
===APF9328 / APF27===
 +
* use ''amixer'' tool. Display all the possible controls and identify the one of interest (here we'll take ''Handset Capture Switch''):
 +
<pre class="apf">
 +
# amixer contents
 +
...
 +
numid=7,iface=MIXER,name='Handset Capture Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=off
 +
...
 +
</pre>
 +
* ''Handset Capture Switch'' control here is of boolean type, off by default and control the Audio In On/Off.
 +
* Check you can get individually access to the control:
 +
<pre class="apf">
 +
# amixer cget numid=7
 +
numid=7,iface=MIXER,name='Handset Capture Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=off
 +
</pre>
 +
* And then modify its value:
 +
<pre class="apf">
 +
# amixer cset numid=7 on
 +
numid=7,iface=MIXER,name='Handset Capture Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=on
 +
</pre>
 +
* Now we can do the same for the ''Handset Capture Volume'':
 +
<pre class="apf">
 +
# amixer cget numid=6
 +
numid=6,iface=MIXER,name='Handset Capture Volume'
 +
  ; type=INTEGER,access=rw------,values=1,min=0,max=100,step=0
 +
  : values=50
 +
 
 +
# amixer cset numid=6 30
 +
numid=6,iface=MIXER,name='Handset Capture Volume'
 +
  ; type=INTEGER,access=rw------,values=1,min=0,max=100,step=0
 +
  : values=30
 +
</pre>
 +
* Now you know the way to do it, you can add these commands to the S60alsa script we built in the previous chapter:
 +
<pre class="apf">
 +
# vi /etc/init.d/S60alsa
 +
</pre>
 +
<source lang="bash">
 +
#!/bin/sh
 +
 
 +
modprobe snd-imx-alsa-tsc2102
 +
# default values for Audio In:
 +
amixer cset numid=7 on
 +
amixer cset numid=6 30
 +
</source>
 +
 
 +
===APF51===
 +
* Parameters to activate audio out:
 +
<pre class="apf">
 +
# amixer cset numid=40 on
 +
numid=40,iface=MIXER,name='Left Output Mixer PCM Playback Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=on
 +
# amixer cset numid=37 on
 +
numid=37,iface=MIXER,name='Right Output Mixer PCM Playback Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=on
 +
# amixer cset numid=6 on,on
 +
numid=6,iface=MIXER,name='Headphone Playback ZC Switch'
 +
  ; type=BOOLEAN,access=rw------,values=2
 +
  : values=on,on
 +
# amixer cset numid=5 116,116
 +
numid=5,iface=MIXER,name='Headphone Playback Volume'
 +
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
 +
  : values=116,116
 +
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
 +
</pre>
 +
* Parameters to activate audio in:
 +
<pre class="apf">
 +
# amixer cset numid=1 48,0
 +
numid=1,iface=MIXER,name='Capture Volume'
 +
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=63,step=0
 +
  : values=48,0
 +
  | dBscale-min=-97.00dB,step=0.50dB,mute=0
 +
# amixer cset numid=44 on
 +
numid=44,iface=MIXER,name='Left Input Mixer Boost Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=on
 +
# amixer cset numid=50 on
 +
numid=50,iface=MIXER,name='Left Boost Mixer LINPUT1 Switch'
 +
  ; type=BOOLEAN,access=rw------,values=1
 +
  : values=on
 +
# amixer cset numid=3 on,on
 +
numid=3,iface=MIXER,name='Capture Switch'
 +
  ; type=BOOLEAN,access=rw------,values=2
 +
  : values=on,on
 +
</pre>
 +
* Now you know the way to do it, you can add these commands to the S60alsa script we built in the previous chapter:
 +
<pre class="apf">
 +
# vi /etc/init.d/S60alsa
 +
</pre>
 +
<source lang="bash">
 +
#!/bin/sh
 +
 
 +
modprobe snd-soc-imx-fiq
 +
modprobe snd-soc-wm8960
 +
modprobe snd-soc-apf51dev-wm8960
 +
# default values for Audio out:
 +
amixer cset numid=40 on
 +
amixer cset numid=37 on
 +
amixer cset numid=6 on,on
 +
amixer cset numid=5 116,116
 +
# default values for Audio capture:
 +
amixer cset numid=1 48,0
 +
amixer cset numid=44 on
 +
amixer cset numid=50 on
 +
amixer cset numid=3 on,on
 +
 
 +
</source>
 +
 
 +
==Going further==
 +
Now that ALSA is working, you can switch to serious things ;-) ->
 +
* [[PrBoom]]
 +
* [[madplay]]
 +
 
 +
==ALSA Soc==
 +
 
 +
On the APF boards we are going to use Embedded version of ALSA: ALSA Soc ->
 +
* http://opensource.wolfsonmicro.com/node/6
 +
* http://www.rpsys.net/openzaurus/patches/alsa/info.html
 +
* http://alsa-project.org/main/index.php/ASoC
 +
 
 +
APF51/APF28 are already using it but for the moment only the "standard" version is functionnal on APF9328/APF27.
  
 
==Links==
 
==Links==
 
* http://www.alsa-project.org/
 
* http://www.alsa-project.org/
* http://alsa.opensrc.org/index.php/WritingAnAlsaDriver + http://www.alsa-project.org/~tiwai/writing-an-alsa-driver.pdf
+
* http://free-electrons.com/formations/audio
* http://www.linuxjournal.com/article/6735
+
* http://alsa-project.org/main/index.php/DevEmbedded
* http://en.wikipedia.org/wiki/PCM
+
* http://alsa.opensrc.org/index.php/WritingAnAlsaDriver + http://www.alsa-project.org/~tiwai/writing-an-alsa-driver.pdf or http://www.alsa-project.org/~tiwai/writing-an-alsa-driver/index.html
* [http://www.busybox.net/lists/buildroot/2008-February/007061.html Buildroot bug (aplay: set_params:1012: unable to install sw params:)]
+
* [http://www.linuxjournal.com/article/6735 Introduction to Sound Programming with ALSA on Linux Journal]
 +
* [http://en.wikipedia.org/wiki/PCM PCM format on Wikipedia] & [http://en.wikipedia.org/wiki/I%C2%B2S I2S bus on Wikipedia]
 +
 
 +
[[Category:Audio]]

Latest revision as of 17:09, 30 July 2018

This page will summarize the informations to use ALSA, ie the sound capabilities (Audio In/Audio Out) of your Armadeus board.

Introduction

ALSA stands for Advanced Linux Sound Architecture and provides audio and MIDI functionality to the Linux operating system. Everyone wanting to write portable & state of the art Linux applications dealing with sound should consider using ALSA.
ALSA is composed of a low level part (target specific Linux drivers) and a userspace library (libasound) with a lot of tools (aplay, arecord, alsamixer, speaker-test).

Hardware

On the i.MX family, used on the Armadeus boards, (good quality) sound can be produced that way:

  1. the i.MX is connected to an audio CODEC (like the TSC2102 on the APF9328DevFull, the TSC2101 on the APF27Dev, the WM8960 on the APF51Dev or the SGTL5000 on the APF6Dev) through one of its SSI interfaces
  2. the i.MX takes PCM data (ALSA format) from memory and send them (through DMA) to the SSI module
  3. this one converts the data to a serial bitstream in the I2S format (or AC97). That stream is then sent to the CODEC
  4. the stream is converted by the CODEC's DAC to an analog sound

Sound acquisition (on TSC2101, WM8960 and SGTL5000) is done in the reverse way.

Installation

ALSA is by default installed on the standard Armadeus rootfs. If you want to change the default configuration, you can consult this wiki page.

Usage

  • Load the ALSA drivers:
  • On APF9328/APF27:
 # modprobe snd-imx-alsa-tsc2102
 TI TSC210x driver initializing
 TSC210x detected
  • On APF51:
# modprobe snd-soc-imx-fiq
# modprobe snd-soc-wm8960
# modprobe snd-soc-apf51dev-wm8960
  • Other boards:

not needed


  • If you want OSS support (optional):
 modprobe snd-pcm-oss
 modprobe snd-mixer-oss
  • If you want MIDI sequencer support (optional):
 modprobe snd-seq
 modprobe snd-seq-device

Loading script

If you want the drivers to be loaded automatically during each boot, you can add a script in /etc/init.d/. For example:

 # vi /etc/init.d/S60alsa
#!/bin/sh
  
modprobe snd-imx-alsa-tsc2102
 # chmod a+x /etc/init.d/S60alsa

First checks (optionnal)

  • Check if ALSA is running:
 # cat /proc/asound/version
 Advanced Linux Sound Architecture Driver Version 1.0.18a.
  • To check if the CODEC was detected as a sound chip:
APF9328 / APF27 APF28 APF51 APF6
# aplay -lL
default:CARD=IMX-ALSA
    i.MX+TSC210x audio, i.MX SSI
    Default Audio Device
null
    Discard all samples (playback) or generate zero samples (capture)
**** List of PLAYBACK Hardware Devices ****
card 0: IMX-ALSA [i.MX+TSC210x audio], device 0: i.MX SSI [i.MX SSI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

or

 # cat /proc/asound/cards
 0 [IMX-ALSA       ]: i.MX - i.MX+TSC210x audio
                      Freescale i.MX with TSC210x codec
# aplay -lL
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=imx6armadeussgt
    imx6-armadeus-sgtl5000, 
    Default Audio Device
sysdefault:CARD=imx6armadeussgt
    imx6-armadeus-sgtl5000, 
    Default Audio Device
default:CARD=imxspdif
    imx-spdif, 
    Default Audio Device
sysdefault:CARD=imxspdif
    imx-spdif, 
    Default Audio Device
default:CARD=imxhdmisoc
    imx-hdmi-soc, 
    Default Audio Device
sysdefault:CARD=imxhdmisoc
    imx-hdmi-soc, 
    Default Audio Device
**** List of PLAYBACK Hardware Devices ****
card 0: imx6armadeussgt [imx6-armadeus-sgtl5000], device 0: HiFi sgtl5000-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: imxhdmisoc [imx-hdmi-soc], device 0: i.MX HDMI Audio Tx hdmi-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

or

# cat /proc/asound/cards
 0 [imx6armadeussgt]: imx6-armadeus-s - imx6-armadeus-sgtl5000
                      imx6-armadeus-sgtl5000
 1 [imxspdif       ]: imx-spdif - imx-spdif
                      imx-spdif
 2 [imxhdmisoc     ]: imx-hdmi-soc - imx-hdmi-soc
                      imx-hdmi-soc

Setting playback and capture volume

  • For this work, you can use alsamixer "pseudo graphic" tool:
# alsamixer

Alsamixer.png

  • choose the Item to setup by using <- -> arrow keys (here Master Playback volume is selected)
  • modify its value with up/down arrow keys
  • you can switch View between Playback and Capture settings with TAB key
  • Capture Handset input is by default muted (MM), you can unmute it by pressing the SPACE key when selected
  • when stereo channels are used you can modify individual channel volume with:
    • 'q': left up, 'z': left down
    • 'e': right up, 'c': right down
  • if alsamixer changed your terminal layout after exiting you can get it back with:
# reset

First tries

  • To play a test sound (connect your headset first ;-) ):
 # aplay /usr/share/sounds/alsa/Side_Left.wav
 Playing WAVE '/usr/share/sounds/alsa/Side_Left.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

Note: the audio file Side_Left.wav can be copied from your Linux host (if not already on your rootfs)

If you have several sound cards, sound is played on the first one in previous list. To choose a given sound card, do:

# aplay -D "default:CARD=name_of_card" /usr/share/sounds/alsa/Side_Left.wav
  • To record a test sound (on APF with Mic Input only) (connect your microphone first ;-) ):
# arecord /tmp/foo.wav
Recording WAVE '/tmp/foo.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
  • and to replay it after:
# aplay /tmp/foo.wav
Playing WAVE '/tmp/foo.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
  • for a faster and "wider" sampling:
# arecord -f S16_LE -r 16000 /tmp/toto.wav
Recording WAVE '/tmp/toto.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono

Automate ALSA settings at boot

  • alsamixer is quite cool to setup ALSA parameters in live but in some cases you may want to set them up at a default value at system startup. Here is the way to do.

APF9328 / APF27

  • use amixer tool. Display all the possible controls and identify the one of interest (here we'll take Handset Capture Switch):
# amixer contents
...
numid=7,iface=MIXER,name='Handset Capture Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
...
  • Handset Capture Switch control here is of boolean type, off by default and control the Audio In On/Off.
  • Check you can get individually access to the control:
# amixer cget numid=7
numid=7,iface=MIXER,name='Handset Capture Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
  • And then modify its value:
# amixer cset numid=7 on
numid=7,iface=MIXER,name='Handset Capture Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
  • Now we can do the same for the Handset Capture Volume:
# amixer cget numid=6
numid=6,iface=MIXER,name='Handset Capture Volume'
  ; type=INTEGER,access=rw------,values=1,min=0,max=100,step=0
  : values=50

# amixer cset numid=6 30
numid=6,iface=MIXER,name='Handset Capture Volume'
  ; type=INTEGER,access=rw------,values=1,min=0,max=100,step=0
  : values=30
  • Now you know the way to do it, you can add these commands to the S60alsa script we built in the previous chapter:
 # vi /etc/init.d/S60alsa
#!/bin/sh
  
modprobe snd-imx-alsa-tsc2102
# default values for Audio In:
amixer cset numid=7 on
amixer cset numid=6 30

APF51

  • Parameters to activate audio out:
# amixer cset numid=40 on
numid=40,iface=MIXER,name='Left Output Mixer PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
# amixer cset numid=37 on
numid=37,iface=MIXER,name='Right Output Mixer PCM Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
# amixer cset numid=6 on,on
numid=6,iface=MIXER,name='Headphone Playback ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
# amixer cset numid=5 116,116
numid=5,iface=MIXER,name='Headphone Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=116,116
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
  • Parameters to activate audio in:
# amixer cset numid=1 48,0
numid=1,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=63,step=0
  : values=48,0
  | dBscale-min=-97.00dB,step=0.50dB,mute=0
# amixer cset numid=44 on
numid=44,iface=MIXER,name='Left Input Mixer Boost Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
# amixer cset numid=50 on
numid=50,iface=MIXER,name='Left Boost Mixer LINPUT1 Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
# amixer cset numid=3 on,on
numid=3,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
  • Now you know the way to do it, you can add these commands to the S60alsa script we built in the previous chapter:
 # vi /etc/init.d/S60alsa
#!/bin/sh

modprobe snd-soc-imx-fiq
modprobe snd-soc-wm8960
modprobe snd-soc-apf51dev-wm8960
# default values for Audio out:
amixer cset numid=40 on
amixer cset numid=37 on
amixer cset numid=6 on,on
amixer cset numid=5 116,116
# default values for Audio capture:
amixer cset numid=1 48,0
amixer cset numid=44 on
amixer cset numid=50 on
amixer cset numid=3 on,on

Going further

Now that ALSA is working, you can switch to serious things ;-) ->

ALSA Soc

On the APF boards we are going to use Embedded version of ALSA: ALSA Soc ->

APF51/APF28 are already using it but for the moment only the "standard" version is functionnal on APF9328/APF27.

Links