分类: LINUX
2010-01-14 14:52:42
一,前言:WM8960是一个音频CODEC,与CPU通过I2S进行数据传输,CPU通过I
Kernel:linux-
二,实现I
#include
#include
#include
#include
#define WM8960_SLAVE_ADDR 0x
static unsigned short probe_i
static unsigned short dummy[] = {I
static struct i
.normal_i
.probe = probe_i
.ignore = dummy,
};
static struct i
struct i
EXPORT_SYMBOL(wm8960_i
static int wm8960_i
{
struct i
i
if (!i
return -ENOMEM;
strcpy(i
i
i
i
i
wm8960_i
return i
}
static int wm8960_i
{
i
kfree(wm8960_i
return 0;
}
static int wm8960_i
{
return i
}
static struct i
.driver = {
.name = "WM8960",
.owner = THIS_MODULE,
},
.id = -1,
.attach_adapter = wm8960_i
.detach_client = wm8960_i
};
static int __init wm8960_i
{
return i
}
static void __exit wm8960_i
{
i
}
module_init(wm8960_i
module_exit(wm8960_i
MODULE_AUTHOR("Telechips Inc. SYS4-3 linux@telechips.com");
MODULE_DESCRIPTION("WM8960 I
MODULE_LICENSE("GPL");
这个i
三,参照sound/soc/codecs目录下的wm8731.c写出一个wm8960.c。
四,修改一下sound/soc/tcc/tcc_board.c,主要是与wm8960有联系的地方改一下。关于声卡驱动的架构以后有空再写一篇分析出来。
五,修改一下相应目录下的Kconfig和Makefile。
六,测试结果如下:
/nand2/mplayer # ./mplayer-y justonelastdance.mp3
MPlayer SVN-r4-
Playing justonelastdance.mp3.
Audio only file format detected.
Clip info:
Title: Just One Last Dance
Artist: Sarah Connor
Album: Key To My Soul
Year: 2003
Comment:
Track: 3
Genre: Pop
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such device or address
alsa-init: requested format: 44100 Hz, 2 channels, 9
alsa-init: using ALS
soc_pcm_open
[AO] device [default], mode [0], return [0]
== alsa-debug ==
totsize=0x10000 period=0x4000 period num=4
== alsa-debug == set_dma_outbuffer, addr[0x41040000], len[65536], period[16384]
== alsa-debug == [set_dma_outbuffer] HwTxDaParam [0xFFF00004]
== alsa-debug == [set_dma_outbuffer] HwTxDaTCnt [1023]
======================================
set [2] channels
======================================
AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 8.3 (08.2) of 268.0 (04:28.0) 10.4%
MPlayer interrupted by signal
A: 8.4 (08.4) of 268.0 (04:28.0) 10.4%
动人的声音就出来了。
|