ALSA在ARM(S3C6410)中的移植(2)

PKG_CONFIG_PATH="/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib/pkgconfig" LDFLAGS="-L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib -lpthread -lc -lgcc" CFLAGS="-I/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/include" ./configure --host=arm-linux --target=arm-linux --prefix=/home/gyh/mybook/alsa-utils-prefix --disable-alsamixer --with-alsa-prefix=/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib/ --with-alsa-inc-prefix=/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include/

将/home/gyh/mybook/alsa-utils-prefix目录拷贝到嵌入式文件系统的对应目录上。

 

(4)alsa配置

在启动脚本中添加:(可能您的不需要)

/bin/mkdir /dev/snd
/bin/ln -s /dev/pcmC0D0c /dev/snd/pcmC0D0c
/bin/ln -s /dev/pcmC0D0p /dev/snd/pcmC0D0p
/bin/ln -s /dev/controlC0 /dev/snd/controlC0
/bin/ln -s /dev/pcmC1D0c /dev/snd/pcmC1D0c
/bin/ln -s /dev/pcmC1D0p /dev/snd/pcmC1D0p
/bin/ln -s /dev/controlC1 /dev/snd/controlC1
/bin/ln -s /dev/seq /dev/snd/seq
/bin/ln -s /dev/timer /dev/snd/timer

 

modprobe.conf文件内容为

#for ALSA
alias char-major-116 snd

options snd cards_limit=2
alias snd-card-0 snd-soc-uda134x #换成您自己的
alias snd-card-1 snd-usb-audio

#for OSS
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0

#OSS Emulation by ALSA
alias sound-service-0-0  snd-mixer-oss
alias sound-service-0-1  snd-seq-oss
alias sound-service-0-3  snd-pcm-oss
alias sound-service-0-8  snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

alias sound-slot-1 snd-card-1

alias sound-service-1-0  snd-mixer-oss
alias sound-service-1-1  snd-seq-oss
alias sound-service-1-3  snd-pcm-oss
alias sound-service-1-8  snd-seq-oss
alias sound-service-1-12 snd-pcm-oss

options snd-soc-uda134x index=0
options snd-usb-audio index=1

 

asound.conf里内容为

# asoc:uda134x                                                                 
                                                                               
pcm.!dmix {                                                                    
        type dmix                                                              
        ipc_key 5678293                                                        
        ipc_key_add_uid yes                                                    
        slave {                                                                
                pcm "hw:0,0"                                                   
                period_time 0                                                  
                period_size 2048                                               
                buffer_size 16384                                              
                format S16_LE                                                  
                rate 48000                                                     
        }                                                                      
}                                                                              
                                                                               
pcm.!dsnoop {                                                                  
        type dsnoop                                                            
        ipc_key 5778293                                                        
        ipc_key_add_uid yes                                                    
        slave {                                                                
                pcm "hw:0,0"                                                   
                period_time 0                                                  
                period_size 2048                                               
                buffer_size 16384                                              
                format S16_LE                                                  
                rate 48000                                                     
        }                                                                      
}                                                                              
                                                                               
pcm.asymed {                                                                   
        type asym                                                              
        playback.pcm "dmix"                                                    
        capture.pcm "dsnoop"                                                   
}                                                                              
                                                                               
pcm.!default {                                                                 
        type plug                                                              
        slave.pcm "asymed"                                                     
}                                                                              
                                                                               
pcm.dsp0 {                                                                     
        type plug                                                              
        slave.pcm "asymed"                                                     
}                                                                              
                                                                               
ctl.mixer0 {                                                                   
        type hw                                                                
        card 0                                                                 
}

 

(5)测试放音和录音

./aplay try.wav &

显示Playing WAVE 'try.wav' : Signed 16 bit Little .....

听到音乐了。

 

./arecord -t wav -f dat myrecord.wav

显示mapped channel 9 to 1

Recording WAVE 'myrecord.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Steo
对着麦克风说话,ctrl+C停止

./aplay myrecord.wav听到刚才说的话。

 

设置音量

./amixer set Master 50%

./amixer set Capture 50%

./alsactl store -f asound.state

在开机启动脚本中增加脚本使每次开机恢复设置,我增加的脚本如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wysygz.html