ALSA可以分爲ALSA driver、ALSA lib、ALSA application三個層次。
soc可以分爲4個域:
- Codec domain ;
- Platform/Machine domain;
- Path domain -alsamixer, amixer;
- sound/soc/codecs目錄Stream domain - DACs and ADCs. aplay, arecord。
對codec內部的硬件構件抽象的部件包括:
Mixer - Mixes several analog signals into a single analog signal.混合多個模擬信號到單個模擬信號Mux - An analog switch that outputs only one of many inputs.多路模擬信號的選擇開關PGA - A programmable gain amplifier or attenuation widget.ADC - Analog to Digital ConverterDAC - Digital to Analog ConverterSwitch - An analog switchInput - A codec input pinOutput - A codec output pinHeadphone - Headphone (and optional Jack)Mic - Mic (and optional Jack)Line - Line Input/Output (and optional Jack)Speaker - SpeakerPre - Special PRE widget (exec before all others)Post - Special POST widget (exec after all others)
path的頭尾端點就是用SND_SOC_DAPM_INPUT或者SND_SOC_DAPM_OUTPUT定義這個部件。
Audio Codec中有許多部件,並且可以是任意的名字,ALSA怎麼可能知道該如何操作這些部件來切換到你想要的路徑,即時ALSA lib也不會關心這部分內容,這些細微的切換又ALSA application以上來完成,ALSA lib也最多提供各種操作mixer或者Mux的函數,如何切換是你應用的事情。
對部件的操作函數是snd_mixer_selem_set_enum_item(),alsamixer也是通過這個函數達到切換的目的
amixer-用戶層
->snd_ctl_ioctl-系統調用
->snd_ctl_elem_write_user-內核鉤子函數
->snd_ctl_elem_wirte
->snd_ctl_find_id-遍歷kcontrol鏈表找到name字段匹配的kctl
->kctl->put()-調用kctl的成員函數put()
->snd_soc_put_volsw_2r