Reference http://www.alsa-project.org/main/index.php/Main_Page
I :( android_kernel)
ASOC consists of three parts
1) CODEC driver. By the kernel source code sound/soc/codecs/wm9713.c
2) platform-driven. Realize the CPU-side Dai driver by kernel source code sound/soc/codecs/s3c-ac97.c
Cpu dma driver implemented by sound/soc/codecs/s3c-pcm.c
3) the Board driver is implemented by the kernel source code sound/soc/s3c24xx/smdk_wm9713.c. It binds the first part and the second part.
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. 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. C: 902 :( snd_ctl_open_noupdate) invalid CTL androidin
E/alsalib (1767): external/ALSA-lib/src/PCM. C: 2210 :( snd_pcm_open_noupdate) unknown PCM androidplayback_speaker_normal
3. the Alsa system provides a mechanism: the application layer directly changes the Audio Codec
Register. Specifically, the snd_kcontrol_new control structure is created in the Linux driver and associated with the codec register. The asound. conf file uses the name of the control structure,
You can associate it with a register to change the value of the Register. The asound. conf file is mainly used for Android audio routing control: multiple registers can be set for different routes.
Different configuration combinations form different audio channels, so that when the route changes, the underlying codec channel changes accordingly.
Create the configuration file asound. conf in nfsdir/system/etc.
##
# 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_rjth_normal {
Type HW
Card 0
Device 0
}
PCM. androidplayback_rjth_ringtone {
Type HW
Card 0
Device 0
}
PCM. androidplayback_rjth_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 indicates the sound card number, and device indicates the device number.
View the ID number of the sound card device
# Cat/proc/asound/cards
0 [smdk]: wm9713-smdk
Smdk (wm9713)