ALSA (lib and util) cross-compilation and testing

Source: Internet
Author: User
Posted on 2012-02-24 10:26 Tinz Reading (597) Comments (0) Edit Favorites

Introduction to the situation

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

sudo./configure--host=arm-none-linux-gnueabi--prefix=/home/jamie/dvsdk/alsa/alsa-lib-1.0.24.1/build-- With-alsa-devdir=/dev--enable-static--enable-shared  --disable-python  --with-configdir=/usr/local/share /alsa--with-plugindir=/usr/local/lib/alsa_lib

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. Be sure that the compiler is ready to execute directly under the shell before running this configuration command .

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.

4) (I add)--with-alsa-devdir specifies the directory of the audio device. (pcmc0d0c/pcmc0d0p/pcmc0d1p, etc.) alsa_lib default to/dev/snd to find these audio devices, but sometimes creating audio devices is not in/dev/snd, but in/dev/or other directories, which requires specifying directories, Otherwise, you will be prompted not to find PCMCXDX.

2.make

Run directly:

Make or sudo 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/jamie/dvsdk/alsa/alsa-lib-1.0.24.1/build--enable-static --enable-shared cflags= "-i/home/jamie/dvsdk/alsa/alsa-lib-1.0.24.1/build/include" LDFLAGS= "-L/home/jamie/dvsdk/ Alsa/alsa-lib-1.0.24.1/build/lib-lasound "--disable-alsamixer--disable-xmlto--with-alsa-inc-prefix=/home/jamie/ Dvsdk/alsa/alsa-lib-1.0.24.1/build/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

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

Mic

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

Turn from: http://blog.csdn.net/iamgooday/article/details/6323863

PS: I compile Util 1.0.24.2 when the make error, then found that there are version.h problems, modify the good, do not know why, version.h content will be confused.

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.