Linux ALSA sound card driver application

1. Configure the kernel to support UDA1341

1. Main catalog

linux-3.4.2\sound\soc\samsung
linux-3.4.2\sound\soc\codecs

2. The main .c file

Check the Makefile in linux-3.4.2\sound\soc\samsung and find the following configuration macros through the file

CONFIG_SND_S3C24XX_I2S  // s3c24xx-i2s.c
CONFIG_SND_SOC_SAMSUNG  // dma.c

Check the Makefile in linux-3.4.2\sound\soc\codecs and find the following configuration macros through the file

CONFIG_SND_SOC_UDA134X  // uda134x.c
CONFIG_SND_SOC_SAMSUNG_S3C24XX_UDA134X  // s3c24xx_uda134x.c

二、make menuconfig

Search for the above macros through make menuconfig and configure

Configuration

CONFIG_SND_SOC_SAMSUNG
CONFIG_SND_SOC_SAMSUNG_S3C24XX_UDA134X

After that, CONFIG_SND_S3C24XX_I2S will be automatically configured

-> Device Drivers
  -> Sound card support
    -> Advanced Linux Sound Architecture
      -> ALSA for SoC audio support
      <*>   ASoC support for Samsung                            // CONFIG_SND_SOC_SAMSUNG
      <*>   SoC I2S Audio support UDA134X wired to a S3C24XX    // CONFIG_SND_SOC_SAMSUNG_S3C24XX_UDA134X  // s3c24xx_uda134x.c     

Configure DMA

-> System Type
[*] S3C2410 DMA support

Three, add platform equipment

Modify linux-3.4.2\arch\arm\mach-s3c24xx\mach-smdk2440.c

1. Modify mach-smdk2440.c and add "s3c24xx_uda134x" platform equipment

Insert picture description here
It needs to be used in mach-smdk2440.c
Insert picture description here

2. Modify mach-smdk2440.c to add "s3c24xx-iis" platform equipment

Defined in devs.c and used directly in mach-smdk2440.c
Insert picture description here

3. Modify mach-smdk2440.c to add "samsung-audio" platform equipment

Defined in devs.c and used directly in mach-smdk2440.c
Insert picture description here

4. Modify mach-smdk2440.c and add "uda134x-codec" platform equipment

Insert picture description here

Fourth, modify the bug

sound\soc\samsung\dma.c
pos += prtd->dma_period;
改为
pos += prtd->dma_period*limit;

Five, transplant applications

Insert picture description here

1. Compile alsa-lib:

sudo mv /usr /usr_bak   //因为必须要和arm板的路径保持一致
export PATH=/usr_bak/local/sbin:/usr_bak/local/bin:/usr_bak/sbin:/usr_bak/bin:/sbin:/bin:/usr_bak/games:/usr_bak/local/arm/4.3.2/bin
./configure --host=arm-linux     //默认安装到/usr下
make
sudo mkdir /usr
sudo chown book:book /usr
make install
sudo cp -rf /usr /work/projects/alsa/
sudo rm -rf /usr
sudo mv /usr_bak /usr
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.3.2/bin

Copy the header files and libraries into the cross tool chain

cd /work/projects/alsa/usr/include
sudo cp * -rfd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include

cd /work/projects/alsa/usr/lib
sudo cp * -rfd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib

Copy the library to the lib directory of the root file system

cd /work/projects/alsa
sudo -rfd usr /work/nfs_root/fs_mini_mdev_new

2. Compile the dependencies of alsa-util

Compile the dependencies first: ncurses-5.9.tar.gz
./configure --host=arm-linux --prefix=$PWD/tmp --with-shared
make && make install
//If the installation error is reported, the
header files and libraries will be copied into Cross tool chain

cd /work/projects/alsa/ncurses-5.9/tmp/include/ncurses
sudo cp * -rfd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include
cd /work/projects/alsa/ncurses-5.9/tmp/include/
sudo cp * -rfd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include

cd /work/projects/alsa/ncurses-5.9/tmp/lib
sudo cp * -rfd /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib

Copy the library to the lib directory of the root file system

cd /work/projects/alsa/ncurses-5.9/tmp/lib
sudo cp *so* -rfd /work/nfs_root/fs_mini_mdev_new/lib

3. Compile alsa-util

./configure --host=arm-linux --prefix=$PWD/tmp --with-curses=ncurses --disable-xmlto --disable-nls
make
sudo make install
cd tmp
cp * -rfd  /work/nfs_root/fs_mini_mdev_new/usr 

Six, test

mkdir /dev/snd
cd /dev/snd/
ln -s /dev/controlC0 
ln -s /dev/pcmC0D0p 
ln -s /dev/pcmC0D0c

Play:

aplay Windows.wav

To adjust the volume:

amixer controls
amixer cget numid=1
amixer cset numid=1 30

Guess you like

Origin blog.csdn.net/qq_18077275/article/details/108878708