当前位置:网站首页>Transplant alsa sound card to xunwei-4418 development board

Transplant alsa sound card to xunwei-4418 development board

2020-12-08 11:12:58 Book white

senior Linux  Sound system (Advanced Linux Sound Architecture, Abbreviation for ALSA) yes Linux The kernel , Driver for sound card , In place of the original OSS( Open sound system ). Part of the purpose is to support automatic configuration of sound cards , And the perfect processing system of multiple sound devices . This article introduces how to transplant ALSA To iTOP-4418 Development board , For the smallest Linux Systems and qt System .

Check the content of the compressed package provided this time , They are guidance documents , Test music and source code , stay binary There are compiled binaries in the folder , For users to use directly , As shown in the figure below .

 

Copy the two compressed packages provided to Ubunut Working directory of “/root/ALSA” in , If there is no such directory, you need to create , After the copy is completed, it is shown in the figure below .

 

First compile alsa-lib-1.1.5.tar.bz2 , Enter the command in the current directory “tar -xvf alsa-lib-1.1.5.tar.bz2” decompression , And then by command “cd alsa-lib-1.1.5 ”, Enter the folder you just unzipped , As shown in the figure below .

 

In this catalog , Enter the following command to cross compile the source code .

CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --prefix=/root/ALSA/install/

After completion, as shown in the figure below .

 

Then type the command in turn “make”,“make install” Generate library file to directory “/root/ALSA/install/” in . The two commands were executed successfully , You can see it in the superior directory install The folder has been generated . As shown in the red box below .

 

Next compile alsa-utils-1.1.5.tar.bz2, Enter the command in the current directory “tar -xvf alsa-utils-1.1.5.tar.bz2 ” decompression , And then by command “cd a alsa-utils-1.1.5 ”, Enter the folder you just unzipped , As shown in the figure below .

 

In this catalog , Enter the following command to cross compile the source code .

CC=arm-none-linux-gnueabi-gcc ./configure --prefix=/root/ALSA/install/ --host=arm-linux --withalsa-inc-prefix=/root/ALSA/install/include --with-alsa-prefix=/root/ALSA/install/lib --disable-alsamixer

 

--disable-xmlto --disable-nls

After completion, as shown in the figure below .

 

Then type the command in turn “make” Generate binary files to the corresponding folder in the current directory , These files are in the folder selected by the red box in the figure below , Files with no extension and the same name as the folder are generated ELF file .

 

Here we use aplay Folder as an example , Use “cd aplay” Enter folder , use ls The command can see the generated aplay Executable file , As shown in the figure below .

 

Users need to copy all the executable files in the selected folder to U disc , Pass in to the development board , This is the end of the compilation .

If the user doesn't want to compile ,binary There are compiled executable files in the folder , Copy directly to U You can do the next step on the disk .

The next command line operation is performed in the serial console . take U Disk inserted to run qt System development board , Use command “mount /dev/sda1 /mnt/disk” mount U disc . Use command “cp /mnt/disk/ALSA/* /bin” take ALSA Copy all executable files to “/bin” Under the table of contents .

Plug in the headphones , Use command “speaker-test -c 2 &” Detect headphones , Pink noise coming out of the headphones . The execution result is shown in the figure below .

Use command ps, see speaker-test Of pid, As shown in the figure below .
In this case speaker-test Of pid yes 553, Use command kill 553 Stop it . When it's done, the headphones stop outputting pink noise .
At this time ALSA Not completely , If you pass apaly If you play audio directly, you will find that you can't control the volume , Next, create a configuration file to refine it . Enter the command in the serial console “cd /etc” Get into /etc Catalog , Enter the command in this directory “vi asound.conf” create profile , Type the following code into the file .
pcm.!default "plug:primary"
pcm.primary {
type softvol
slave.pcm "plughw:0"
control.name "master"
control.card 0
}
After completion, as shown in the figure below
The configuration file creates a file called ‘pcm’ The slave device of , It belongs to the volume control plug-in primary, adopt !default Option to set the plug-in to default PCM Output devices , Then restart the development board . Then you can use aplay Play the audio , The author's audio file is placed in /root Directory As shown in the figure below .
The configuration file creates a file called ‘pcm’ The slave device of , It belongs to the volume control plug-in primary, adopt !default Option to set the plug-in to default PCM Output devices , Then restart the development board . Then you can use aplay Play the audio , The author's audio file is placed in /root Directory As shown in the figure below .
Use command “amixer set 'master' 100” Set the volume to 100, The volume value is acceptable 0-255, The operation is shown in the figure below .
You can hear the headphones turn down . The recording test passed the command “arecord filename &” To execute ,filename The user specifies ,& Do not omit . The recording process is shown in the figure below .
The way to end the recording is the same as the way to end the playback , That is, through ps Check the process pid, use kill Command to terminate it , I won't repeat it here . After recording, you can see it in the current directory test.wav file , This document can be used aplay Playback test .

版权声明
本文为[Book white]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201208111211398m.html