1,編譯編譯環境:arm-linux-gcc v4.4.3
2,開發板:FL2440,256M nand flash。
3,u-boot版本:u-boot-2011.09
4,linux 版本:linux-3.0
1】在初始化文件中加入UDA1341 , samsung_asoc_dma結構。(紅色爲添加內容)
#include <linux/dm9000.h>
//添加SD 卡設備結構所需的頭文件
#include <linux/mmc/host.h>
#include <plat/mci.h>
//添加聲卡頭文件
#include <sound/s3c24xx_uda134x.h>
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,
}
};
static struct platform_device uda1340_codec = {
.name = "uda134x-codec",
.id = -1,
};
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_ohci,
&s3c_device_lcd,
&s3c_device_rtc,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_adc,
&s3c_device_ts,
&s3c_device_adcdev,
&s3c_device_iis,
&s3c_device_dm9000,
&uda1340_codec,
&s3c24xx_uda134x,
&samsung_asoc_dma,
};
這樣,我們基本就添加好了 UDA1341 音頻設備的驅動。
【2】在內核中配置UDA1341 設備驅動
在終端中進入到內核源碼根目錄下執行make menuconfig
Device Drivers --->
<*> Sound card support --->
[*] Preclaim OSS device numbers
<*> Advanced Linux Sound Architecture --->
< > Sequencer support
<*> OSS Mixer API
<*> OSS PCM (digital audio) API
[*] OSS PCM (digital audio) API - Include plugin system
[*] Dynamic device file minor numbers
[ ] Support old ALSA API
[*] Verbose procfs contents
<*> ALSA for SoC audio support --->
-*- SoC I2S Audio support UDA134X wired to a S3C24XX
【3】重新編譯內核並測試
燒到fl2440板子上啓動內核打印如何下說明UDA1341音頻驅動添加成功了:
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (928 buckets, 3712 max)
執行如下命令顯示:
->cat /proc/devices
Character devices:
... ...
10 misc
13 input
14 sound
29 fb
3]madplay 移植播放mp3音樂
所需源碼包:madplay-0.15.2b.tar.gz,libmad-0.15.1b.tar.gz,libid3tag-0.15.1b.tar.gz
和 zlib-1.1.4.tar.gz
1新建目錄並上傳源碼包到madplay 目錄並解壓:
[liuchengdeng@centos6 ~]$ mkdir madplay
[liuchengdeng@centos6 ~]$ mkdir madplay/mad
[liuchengdeng@centos6 madplay]$ ls
mad [liuchengdeng@centos6 madplay]$ ls
mad madplay-0.15.2b.tar.gz,libmad-0.15.1b.tar.gz,libid3tag-0.15.1b.tar.gz
和 zlib-1.1.4.tar.gz
修改以下三項:
CC=gcc 修改爲CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
AR=ar rc 修改爲AR=a/opt/buildroot-2012.08/arm920t/usr/bin/rm-linux-ar rc
RANLIB=ranlib 修改爲RANLIB=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-ranlib
(3)編譯make
(4)安裝make install
3: 編譯libid3tag-0.15.1b
進入到libid3tag-0.15.1b
1)運行以下命令
./configure CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc AR=arm-linux-ar RANLIB=arm-linux-ranlib --host=arm-linux --prefix=/home/liuchengdeng/madplay/mad --disable-shared CPPFLAGS=-I/home/liuchengdeng/madplay/mad/include/ LDFLAGS=-L/home/liuchengdeng/madplay/mad/lib
2)編譯:make
3)安裝:make install
4: 編譯libmad-0.15.1b
進入到libmad-0.15.1b 路徑:
1)運行以下命令
./configure CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
AR=arm-linux-ar RANLIB=arm-linux-ranlib --host=arm-linux --prefix=/home/liuchengdeng/madplay/mad --disable-shared CPPFLAGS=-I/home/liuchengdeng/madplay/mad/include/ LDFLAGS=-L/home/liuchengdeng/madplay/mad/lib
2)編譯:make
3)安裝:make install
5。編譯madplay:進入madplay-0.15.2b
1)執行如下命令:
/configure
CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
AR=arm-linux-ar RANLIB=arm-linux-ranlib --host=arm-linux --prefix=/home/liuchengdeng/madplay/mad --disable-shared --enable-static --disable-nls CPPFLAGS=-I/home/liuchengdeng/madplay/mad/include/ LDFLAGS=-L/home/zhao/madplay/mad/lib
2)編譯:make
3)安裝:make install
如此就會看到當前目錄有個madplay,這樣生成的madplay最終是動態編譯的.
注意了:爲了靜態編譯,make之後輸出的最後的編譯命令複製一下,最後加上-static,執行如下命令:
/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc -Wall -g -O2 -o madplay madplay.o getopt.o getopt1.o version.o resample.o filter.o tag.o crc.o rgain.o player.o audio.o audio_aiff.o audio_cdda.o audio_hex.o audio_null.o audio_raw.o
audio_snd.o audio_wave.o audio_oss.o -L/home/liuchengdeng/madplay/mad/lib /home/liuchengdeng/madplay/mad/lib/libmad.a /madplay/mad/lib/libid3tag.a -lz -lm -static
(如果此命令不能編譯成功,就把madplay下載到開發板上,然後在把所有需要的動態庫下載到文件系統的lib目錄下 。arm-linux-readelf -d madplay可以查看madplay需要哪些動態庫)
在將當前目錄下的madplay通過TFTP下載到開發板上,然後下載一個mp3格式的音頻文件到開發板,執行:
./madplay xxx.mp3