ALSA Cross Compilation and testing

Source: Internet
Author: User

Normal 0 7.8 pt 0 2 false false MicrosoftInternetExplorer4 Brief introduction

ALSA is a large number of audio device libraries used in Linux system, which can separate drive and application development through ALSA architecture. Alsa provides the API for the upper layer, also provides the interface for the lower layer, when the kernel is configured to specify "Support Alsa" can get kernel support, specific location:

Menuconfig-> Device Drivers-> Sound card support-> Advanced Linux Sound Architecture, the audio devices added by the driver layer should also appear here.

Since our kernel already contains the driver of the corresponding audio device, it is not done in depth.

With the Alsa kernel drive, we also need support from Alsa Lib and Alsa Util, the 3 relationships shown in the following illustration:

Alsa Util

-------------

Alsa Lib

-------------

Alsa Driver


Alsa Util is a pure application layer of software, the equivalent of ALSA device testing procedures, Alsa Lib is the support of the application API middle-tier program. The sequence of transplant Alsa programs is to transplant driver,lib,util successively.

Alsa Lib Transplantation

Lib porting does not need to modify a tiny source code, only need to recompile LIB to support its own platform. Its source code can be downloaded from the official website. The compilation process is as follows:

1. Configure

./configure--host=arm-none-linux-gnueabi--prefix=/home/jeff/downloads/alsa-lib/out/arm-linux/--enable-static-- Enable-shared–-with-configdir=/usr/local/share

The configuration is checked for configuration items in this command before the configuration is implemented. It should be noted that if the configuration error, not necessarily error, but will take the default configuration options. Several important configuration items:

1)--host Specifies the compiler, which is specified here as a cross compiler. Note Before running this configuration command, it is important to ensure that the compiler can already Shell under the direct execution .

2)--prefix Specifies the installation path of the compiled file, and subsequent installation commands create LIB and include two directories in the directory

3--with-configdir Specifies the installation directory of the Conf file, which is the most useful alsa.conf in the directory, and this file will be ported directly to your target system.

2. Make

Run directly:

Make

3. Make install

Running install has 2 points to note

1 Install may install some files in some non-user directories, so root permissions are required

2 Install also performs some compile commands, so remember to ensure that the cross compiler under root permissions is also available.

Alsa Util Transplantation

Util generates application files for playing, recording, and configuring audio, which is useful for testing. The compilation process is as follows:

1. Configure

./configure--host=arm-none-linux-gnueabi--prefix=/home/jeff/downloads/alsa-lib/out/arm-linux/--enable-static-- Enable-shared cflags= "-i$pwd/. /out/arm-linux/include "ldflags="-l$pwd/. /out/arm-linux/lib-lasound "--disable-alsamixer--disable-xmlto--with-alsa-inc-prefix=/home/jeff/downloads/ Alsa-lib/out/arm-linux/include

Several of these important configuration items:

1--host Specifies the compiler, the same configuration options as Lib

2)--prefix Specifies the installation path for the compiled file, the same as the configuration options for Lib

3) Cflags is used for compilation options specified at compile time, where the Lib compiled header file is used, so the header file is specified as the directory

4) Ldflags is used to specify the connection library file at compile time, as in the case of Cflags, the library file generated by Lib compilation is specified.

5--with-alsa-inc-prefix Specifies the header file directory, which is similar to 3, but must be specified because the Configure program will go to the directory to check the version. If not specified, it will go directly to the default directory ( that is, the host's corresponding alsalib directory, so there may be errors )

2. Make

Run directly:

Make

Success must be compiled.

There's a way to teach you 1. Make clean 2) Configure 3 The Make install this method does not error, but actually installs the precompiled executable program, which is based on the x86 system and cannot be used in the embedded platform.

3. Make install

lib and util installed to embedded platform

On the target board, the following files must be copied to the corresponding location:

1 Lib library file, placed in the/lib/

2 conf file, should be placed in/usr/local/share, the same as the directory specified at compile time

3 application file, util can produce Aplay,amixer,arecord executable program, these files can be placed in/usr/sbin

4 must be guaranteed to have/dev/snd/directory, this directory should contain the following several device files (drive),

ControlC0, pcmc0d0c, pcmc0d0p, timer.

If these files are already under/dev/, they can be copied to the SND directory.

Run the test program

On our current board there are 4 audio links, respectively: MIC, line in, line out, headphone out. All 4 links need to be tested.

For the play link (line out, headphone out), the corresponding playback command is:

Aplay Mysound.wav

For recording links (Mic, line in), the corresponding recording command is:

Arecord Myvoice.wav–fdat–d 5

Where-fdat specifies to record the CD quality, the-D represents 5 seconds after recording and exits.

Command amixer can be used to control link-breaking and corresponding configuration. For each system, there will be a different link name, with Amixer to understand the name and status of all the links on the current system.

Command Amixer Scontrols can view the simple control link in the system, corresponding to the full version of the control link (amixer controls), according to the author's experience, this simple control link is sufficient.

Command Amixer scontent can view all simple links to the system in extremely current state.


In my current system, for example, in order for a different link to work, we have to set it through the command.

Headphone out

Amixer–c 0 sset ' PCM ', 0 100%,100% unmute Playback

Line Out

Amixer–c 0 sset ' line ', 0 100%,100% unmute Playback

Line in

Amixer–c 0 sset ' right PGA Mixer line1l ', 0 100%,100% unmute Cap

Note that the line recording should be determined that the input device itself is an active device, the passive microphone can not be used to connect the line input.

Mic

Amixer–c 0 sset ' right PGA Mixer mic3l ', 0 100%,100% unmute Cap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.