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)