Chinaunix首页 | 论坛 | 博客
  • 博客访问: 347984
  • 博文数量: 69
  • 博客积分: 3077
  • 博客等级: 中校
  • 技术积分: 602
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-11 09:40
个人简介

或以为孤权重,妄相忖度

文章分类

全部博文(69)

文章存档

2012年(1)

2011年(10)

2010年(39)

2009年(19)

我的朋友

分类: 嵌入式

2010-12-03 15:13:38

软硬件平台:ARM9(S3C2410A),UDA1341, 2.6.33.1内核,arm-none-linux-gnueabi-gcc-4.3.2
ASoC:
ALSA为嵌入式系统提供的SOC级驱动,支持PCM,I2S和AC97。
详细内容可查阅:
 
(1)驱动移植
2.6.33.1已经为提供了UDA134X的ALSA驱动,只需要稍微配置即可。
在arch/arm/mach-s3c2410/mach-smdk2410.c中添加:
static struct s3c24xx_uda134x_platform_data s3c24xx_uda134x_data = {
        .l3_clk = S3C2410_GPB(4),
        .l3_data = S3C2410_GPB(3),
        .l3_mode = S3C2410_GPB(2),
        .model = UDA134X_UDA1341,
};
static struct platform_device s3c24xx_uda134x = {
        .name = "s3c24xx_uda134x",
        .dev = {
                .platform_data    = &s3c24xx_uda134x_data,
        }
};
在smdk2410_devices[]添加一项:&s3c24xx_uda134x
配置内核选项,选中ALSA支持。
 
更新内核,启动显示
usbcore: registered new interface driver usbhid                                
usbhid: USB HID core driver                                                    
usbcore: registered new interface driver snd-usb-audio                         
usbcore: registered new interface driver snd-usb-caiaq                         
No device for DAI UDA134X                                                      
No device for DAI s3c24xx-i2s                                                  
S3C24XX_UDA134X SoC Audio driver                                               
UDA134X SoC Audio Codec
                                                        
asoc: UDA134X <-> s3c24xx-i2s mapping ok                                       
usb 1-1: new full speed USB device using s3c2410-ohci and address 2            
ALSA device list:                                                              
  #0: S3C24XX_UDA134X (UDA134X)
 
驱动移植成功。可以支持板子的UDA1341,可支持我的usb声卡了。
(此处也可以直接使用alsa-driver提供驱动程序,具体我没有做)
 
(2)alsa-lib移植
版本alsa-lib-1.0.22
./configure --host=arm-linux --target=arm-linux --prefix=/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr --enable-static --enable-shared --disable-python --with-configdir=/usr/local/share --with-plugindir=/usr/local/lib/alsa_lib
编译安装,将库文件、配置文件和插件文件转移到嵌入式文件系统的对应目录上。
 
(3)alsa-utils移植
版本alsa-utils-1.0.23
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
在开机启动脚本中增加脚本使每次开机恢复设置,我增加的脚本如下:
/home/gyh/mybook/alsa-utils-prefix/sbin/alsactl restore -f /home/gyh/mybook/alsa-utils-prefix/sbin/asound.state
 
(6)mplayer移植
版本mplayer-export-2010-05-13
建立build-arm.sh文件,内容为
#!/bin/sh
./configure --cc=arm-linux-gcc \
       --host-cc=gcc \
       --enable-cross-compile \
       --target=arm-armv6-linux \
       --prefix=/home/gyh/mybook/mplayer \
       --ar=arm-linux-ar \
       --nm=arm-linux-nm \
       --ranlib=arm-linux-ranlib \
       --enable-linux-devfs \
       --disable-dvdread \
       --enable-fbdev \
       --disable-mencoder \
       --disable-liba52 \
       --enable-libavcodec_so \
       --disable-libmpeg2 \
       --disable-mp3lib \
       --enable-alsa \
       --disable-ossaudio \
       --disable-w32threads \
       --disable-win32dll \
       --disable-win32waveout \
       --disable-live 2>&1 | tee logfile
执行./build-arm.sh
make
复制mplayer至嵌入式文件系统内
执行:./mplayer /home/gyh/Documents/Legend.mp3
显示如下:
MPlayer SVN-r31170-snapshot-4.3.2 (C) 2000-2010 MPlayer Team
Playing /home/gyh/Documents/Legend.mp3.                                               
Audio only file format detected.                                                      
Clip info:                                                                            
 Title: Legend                                                                        
 Artist: wangfei                                                                      
 Album:                                                                               
 Year:                                                                                
 Comment: wangfei                                                                     
 Genre: Other                                                                         
==========================================================================            
Requested audio codec family [mp3] (afm=mp3lib) not available.                        
Enable it at compilation.                                                             
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders                      
AUDIO: 48000 Hz, 2 ch, s16le, 320.0 kbit/20.83% (ratio: 40000->192000)                
Selected audio codec: [ffmp3] afm: ffmpeg (FFmpeg MPEG layer-3 audio)                 
==========================================================================            
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)                                     
Video: no video                                                                       
Starting playback...
 
听到这首悦耳的《传奇》,心情真好,嘿嘿
 
(7)Qt-extended-4.4.3的alsa移植
export PKG_CONFIG_PATH=/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib/pkgconfig/
 
../qt-extended-4.4.3/configure -release -xplatform linux-arm-g++ -arch arm -displaysizes 240x320 -build-qt -extra-qt-embedded-config "-xplatform qws/linux-arm-g++ -embedded arm -qconfig qpe -shared -little-endian -webkit -qt-kbd-usb -qt-libpng -qt-libjpeg -qt-gif -depths 16 -qt-mouse-tslib -I/home/gyh/backup/tslib1.4/include -L/home/gyh/backup/tslib1.4/lib" -verbose -mediaengines cruxus -dbus -ssl -sound-system alsa
 
bin/qbuild && bin/qbuild image
 
复制到我的SD卡上,能播放wav格式的音乐了,不过声音短短续续的,还望各位前辈指教。
 
添加libmad以支持mp3,试验用,先不考虑版权了,呵呵
 
可以播放mp3了,不过仍然断断续续的,几经研究未果,有人说是内核版本问题,换到低版本问题依旧,看来不是,aplay和mplayer都正常,初步判断是qt-extended的BUG,还望各位大师指教啊。
 
=======================================================================================
 
PS1:我的三星I6410 M1 CPU用的是S3C6410.编译MPlayer时注意target应该为arm-armv6-linux,切记,编译ALSA-LIB的时候,--prefix路径为所对应编译器的的目录,如这里选择的是:
--prefix=/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr
否则的话,在配置mplayer的过程会出现:Checking for ALSA audio ... no
的提示,估计出现这个提示的人不多,因为网上找到关于这个提示的非常少,我也是偶然的机会悟出来的,开头我一直纳闷,怎么让编译器找得到alsa-lib呢,因为这个lib三星的SDK已经提供了,所以并不需要重新编译一次,只需找到头文件和库放到响应的位置就行了!不过,手机上那个终端是别人搞的,貌似有点问题,不管了,抽空搞个GTK 的GUI 应该就没有问题了。总之困扰多时的mplayer alsa 问题终于解决了,心情舒畅了不少,mplayer -ao help,终于看到盼望已久的alsa啦。
 
PS2:建议使用4.2.2-eabi-LiMo-0.1.tar.gz交叉工具链,为啥呢,因为这个编译器它里面包含了几乎所有的库,个人觉得应该不是三星官方发布的,应当也是爱好者发布的好东西。编译mplayer,那简直就是不费吹灰之力,设定环境变量,configure一下,make,make install 就完事了。具体下载地址GOOGLE搜索吧。
阅读(3240) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~