Audio (i.MX31)

From BlueWiki

Revision as of 15:20, 27 February 2010 by Thomas.linder (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

1 Kernel configuration

Audio is supported starting at BSP rel. 109. To enable Audio, perform the following changes in the kernel configuration:

Device Driver -> Sound Support -> Y
Device Driver -> Sound Support -> Advanced Linux Sound Architecture -> Y
Device Driver -> Sound Support -> Advanced Linux Sound Architecture -> OSS Mixer API -> Y
Device Driver -> Sound Support -> Advanced Linux Sound Architecture -> OSS PCM (digital audio) API -> Y
Device Driver -> Sound Support -> Advanced Linux Sound Architecture -> Alsa ARM Devices -> MXC PMIC sound System -> Y
Device Driver -> Sound Support -> Advanced Linux Sound Architecture -> Alsa ARM Devices -> Playback stream mixing -> N (!!!)

2 Getting test soundfiles

Run the command

./ltib -m prep -p mxc-misc

This will unpack the misc package which you can find in ~/ltib5/rpm/BUILD/misc. If you search for *.wav files you will find a directory containing about 15 different wave files named audio%SampleFrequency%%BitsPerSample%%Mono/Stereo%.wav. Copy these to the directory ~/ltib5/rootfs/tmp so they will be available on the target.

3 Playing Audio

Two different sources for audio exist. You can either play audio on the stereo dsp, which can handle sample frequencies up to 96kHz, stereo. Or you can play audio on the voice codec, which can play audio files sampled at 8kHz or 16kHz, mono only. To play an audio file on the voice codec try the command:

aplay -N -M -D hw:0,1 audio16k16M.wav
or
aplay -N -M -D hw:0,1 audio8k16M.wav

Note that you cannot play files with a higher sample rate than 16kHz or with more than one channel.

To play an audio file on the stereo dsp, run the command:

aplay -N -M -D hw:0,0 audio44k16M.wav
or
aplay -N -M audio16k16S.wav

Note that you can play audio files up to 96kHz in stereo.

4 Recording Audio

Recording is only possible through the use of the voice codec. To record audio in maximum quality run the command

 arecord -r 16000 -c 1 -f S16_LE -N -M -d 10 recording.wav  // This will record 10 seconds of audio with 16bit/mono/16kHz on the voice codec

To play the recorded file use the command

aplay -N -M -D hw:0,1 recording.wav
or 
aplay -N -M -D hw:0,0 recording.wav

depending on the device you want to use.


5 Playing an mp3 file

To play an mp3 file simply run the command

madplay file.mp3

Make sure the madplay package was selected in the system configuration.


6 Switch to Line - In

To switch to line in, start a recording and then run the following command:

atlas-regs -s 0x26=0x00422000

If you need this change to last, you might have to correct the part of the mxc sound driver which is called after a recording is started.

Personal tools