reference http://www.alsa-project.org/main/index.php/Main_Page
I:(android_kernel)
ASoC由三部份组成
1)Codec驱动。由内核源代码sound/soc/codecs/wm9713.c
2)平台驱动。由内核源码sound/soc/codecs/s3c-ac97.c实现S3C6410 CPU端的DAI驱动
由sound/soc/codecs/s3c-pcm.c实现CPU端的DMA驱动
3)板驱动由内核源代码sound/soc/s3c24xx/smdk_wm9713.c实现,它将第一部分和第二部分进行绑定
II:android filesystem
1.download alsa code
cd Android/external
git clone git://Android.git.kernel.org/platform/external/alsa-lib.git
git clone git://Android.git.kernel.org/platform/external/alsa-utils.git
cd ../hardware
git clone git://Android.git.kernel.org/platform/hardware/alsa_sound.git
2.modif /home/android/device/wolf/smdk6410/BoardConfig.mk
BOARD_USES_ALSA_AUDIO := true
#BOARD_USES_GENERIC_AUDIO := true
2.build the android
W/AudioHardwareInterface( 1767): Using stubbed audio hardware. No sound will be produced.
make clean
make -j4
logcat
W/AudioHardwareALSA( 1767): Unable to attach mixer to device AndroidOut: No such file or directory
E/ALSALib ( 1767): external/alsa-lib/src/control/control.c:902:(snd_ctl_open_noupdate) Invalid CTL AndroidOut
W/AudioHardwareALSA( 1767): Unable to attach mixer to device AndroidIn: No such file or directory
E/ALSALib ( 1767): external/alsa-lib/src/control/control.c:902:(snd_ctl_open_noupdate) Invalid CTL AndroidIn
E/ALSALib ( 1767): external/alsa-lib/src/pcm/pcm.c:2210:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker_normal
3.alsa体系提供了这样一种机制:应用层直接改变音频codec的
寄存器,具体而言:linux驱动中创建snd_kcontrol_new控制结构,并关联到codec寄存器,asound.conf文件通过控制结构名字,
就能关联到寄存器,从而改变寄存器的值。asound.conf文件主要用来做Android音频的路由控制:不同路由可以设置多个寄存器
的不同配置组合,形成不同的音频通道,从而当路由改变时,底层codec通道随之改变
在nfsdir/system/etc下新建配置文件asound.conf
# #
# # Mixer devices
# #
ctl.AndroidPlayback {
type hw
card 0 # Can replace with drivers name from /proc/asound/cards
}
ctl.AndroidCapture {
type hw
card 0
}
# #
# # Playback devices
# #
pcm.AndroidPlayback {
type hw
card 0
device 0
# #
# # Hook example
# #
# type hooks
# slave.pcm {
# type hw
# card 0
# device 0
# }
# hooks.0 {
# type ctl_elems
# hook_args [
# { name 'DAC Gain' value [ 39 39 ] }
# { name 'Mic Bias Voltage' value '1.5' }
# { name 'In Mixer Right MIC_R Switch' value false }
# { name 'Out Mixer Left DAC_L Switch' value true }
# ]
# }
}
pcm.AndroidPlayback_Earpiece {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Earpiece_normal {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Earpiece_ringtone {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Earpiece_incall {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Speaker {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Speaker_normal {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Speaker_ringtone {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Speaker_incall {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth_normal {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth_ringtone {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth_incall {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Headset {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Headset_normal {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Headset_ringtone {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Headset_incall {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth-A2DP {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth-A2DP_normal {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth-A2DP_ringtone {
type hw
card 0
device 0
}
pcm.AndroidPlayback_Bluetooth-A2DP_incall {
type hw
card 0
device 0
}
# #
# # Reference only
# #
pcm.AndroidPlayback_FM {
type hw
card 0
device 0
}
# #
# # Capture devices
# #
pcm.AndroidCapture {
type hw
card 0
device 0
}
---------------------------------------------------
card代表声卡号, device代表设备号
查看声卡设备对应的ID号
# cat /proc/asound/cards
0 [SMDK ]: WM9713 - SMDK
SMDK (WM9713)