Difference between revisions of "ALSA"
m (→Test / First tries) |
(explain how to setup volume before playing sound + simplify) |
||
Line 22: | Line 22: | ||
TI TSC210x driver initializing | TI TSC210x driver initializing | ||
TSC210x detected | TSC210x detected | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
* If you want OSS support (optional): | * If you want OSS support (optional): | ||
Line 86: | Line 74: | ||
Freescale i.MX with TSC210x codec | Freescale i.MX with TSC210x codec | ||
</pre> | </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'' | ||
+ | * 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, you can unmute it by pressing the ''SPACE'' key when selected | ||
+ | |||
+ | ==First tries== | ||
* To play a test sound (connect your headset first ;-) ): | * To play a test sound (connect your headset first ;-) ): | ||
<pre class="apf"> | <pre class="apf"> | ||
Line 93: | Line 95: | ||
Note: the ''audio file Side_Left.wav'' can be copied from your Linux host (if not already on your rootfs) | Note: the ''audio file Side_Left.wav'' can be copied from your Linux host (if not already on your rootfs) | ||
− | * To record a test sound (on APF27Dev only) (connect your microphone first ;-) ): | + | * To record a test sound (on [[APF27Dev]] only) (connect your microphone first ;-) ): |
<pre class="apf"> | <pre class="apf"> | ||
# arecord /tmp/foo.wav | # arecord /tmp/foo.wav | ||
Line 102: | Line 104: | ||
# aplay /tmp/foo.wav | # aplay /tmp/foo.wav | ||
Playing WAVE '/tmp/foo.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono | Playing WAVE '/tmp/foo.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Revision as of 18:08, 29 December 2009
This page will summarize the informations to use ALSA, ie the sound capabilities (Audio In/Audio Out) of your Armadeus board.
Contents
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).
Hardware
On the i.MX family, used on the Armadeus boards, (good quality) sound can be produced that way:
- the i.MX is connected to an audio CODEC (like the TSC2102 on the APF9328 or the TSC2101 on the APF27) through one of its SSI interfaces
- the i.MX takes PCM data (ALSA format) from memory and send them (through DMA) to the SSI module
- this one converts the data to a serial stream of bits in the I2S format (or AC97). That stream is then sent to the CODEC
- the stream is converted by the CODEC's DAC to an analog sound
Sound acquisition (on TSC2101 only) 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:
# modprobe snd-imx-alsa-tsc2102 TI TSC210x driver initializing TSC210x detected
- 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.17.
# 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
Setting playback and capture volume
- For this work, you can use alsamixer "pseudo graphic" tool:
# alsamixer
- choose the Item to setup by using <- -> arrow keys
- 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, you can unmute it by pressing the SPACE key when selected
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)
- To record a test sound (on APF27Dev 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
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 ->
- http://opensource.wolfsonmicro.com/node/6
- http://www.rpsys.net/openzaurus/patches/alsa/info.html
- http://alsa-project.org/main/index.php/ASoC
But for the moment only "standard" version is functionnal.
Links
- http://www.alsa-project.org/
- http://free-electrons.com/formations/audio
- http://alsa-project.org/main/index.php/DevEmbedded
- http://alsa.opensrc.org/index.php/WritingAnAlsaDriver + http://www.alsa-project.org/~tiwai/writing-an-alsa-driver.pdf
- Introduction to Sound Programming with ALSA on Linux Journal
- PCM format on Wikipedia & I2S bus on Wikipedia