android audio arch

ALSA System on Chip(ASoC)驱动将一个audio子系统分成四个部分:
Machine driver, Platform driver, CPU driver以及Codec driver。
Machine 驱动 :
将平台,CPU以及codec驱动绑定在一块
实现在kernel/sound/soc/msm/<chipset.c>
定义前端FE和后端BE,DAI(digital audio interface) links
platform 驱动:
包括了平台相关的音频数据流的传输和路由的控制
被区分成FE和BE两个平台驱动
FE :

Audio -例化PCM播放和采集,将播放的pcm数据从用户空间传递给DSP,采集是逆过程,高通使用ASM接口,实现于kernel/sound/soc/msm-pcm-q6.c

提供了ALSA SoC framework需要的FE PCM设备信息,由平台驱动提供的ASoC framework和音频路由表可以指示PCM 播放/采集。
FE CPU DAI实现于kernel/sound/soc/msm/msm-dai-fe.c

Voice-初始化和销毁语音电话建立,实现与kernel/sound/soc/msm-pcm-voice-v2.c
VoIP-初始化和销毁MVS接口在DSP和用户空间互传数据。kernel/sound/soc/msm-pcm-voip-v2.c
Compress offload-Compress offload 播放数据传输到DSP。kernel/sound/soc/msm-compress-q6-v2.c

BE :

根据初始化的PCM播放和采集配置DSP AFE模块对应的audio 音频端口

定义了BE CPU DAI实现于kernel/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c

Routing-audio 通路选择,kernel/sound/soc/msm-pcm-routing-v2.c

CPU driver :

分为FE和BE CPU驱动

Codec 驱动 User Spcace Moudles :
Audio Hardware Abstraction Layer(AHAL)使用tinyalsa将Audioflinger调用映射到ASoC驱动
tinyalsa -kernel Asoc驱动接口,AHAL使用,提供了stream和设备管理需要的基本PCM和Mixer控制API
Audio Route-该模块从XML文件读取ALSA mixer控制器,并根据AHAL设置mixer控制器。
Multimedia framework-stagefright   1) 使用标准音频格式的播放和采集;2)和编解码库以及OpenMAX IL组件通信,实现音频编解码
Audio service  1) 运行时服务,由system server启动,server manager管理; 2) 注册intents,当接收到来自不同应用(HDMI,Bluetooth)的信息后通知Audio系统
Audio Flinger   1) 通过libaudio,蓝牙A2DP管理所有音频输入/输出设备,2) 将多个audio stream合成单一PCM,混合的output输出源被路由给输出设备 3) music stream播放的音量控制
Audio Policy Manager(APM) 1) 定义了多个音频源并发的管理策略,管理各种输入/输出设备接口mic,speaker,headphone,headset,a2dp,bluetooth sco  2) 设置场景(电话,音乐,系统音,通知) 3) 基于stream模式选择和定义合适的路由策略.定义了音频类型(语音,播放,ring)在何种设备上播放(Bluetooth ,speaker,headset). 4)管理每一个stream的音量.

Audio Output Stream and  Volume Control :

缺省的音频输出(primary output)使用AudioFlinger中的Mixer线程,音量和音效将在Flinger中使用
Lowlatency输出使用Audioflinger中的快速mixer,音量控制在Flinger中
Compress offload播放使用audio flinger中的compress offload线程,音量和音效在DSP中。

Voip播放在Audioflinger中的mixerthread,  volume 和echo cancelation 由DSP完成。

设备和流管理 :

Frontend DAI :

  • 对用户空间作为PCM设备可见
  • 可以将Audio路由到多个BE DAI
  • Routing 由用户空间mixer 控制
  • PCM由ALSA直接控制
  • 定义于 msm-dai-fe.c                      
static struct snd_soc_dai_driver msm_fe_dais[]={  
  .playback = {  
     .stream_name = "Multimedia1 Playback",  
     .aif_name = "MM_DL1",  
     .rates  
...  
  }    

}  

当front DAI使能时,AIF将会被使能。

用户空间和audio相关的代码用于调试和定制化:


sm8974 – Contains the audio Hardware Abstraction Layer (HAL)-related code  
  
<APSS_BUILD>/external/tinyalsa/ – Contains the code related to tinymix, tinyplay, and tinycap  
  
<APSS_BUILD>/hardware/qcom/audio/mm-audio – Contains the implementation of QTI OMX components for the audio encoder and decoders  
  
<APSS_BUILD>/frameworks/av/media/libstagefright/ – Contains the source code for Google’s Stagefright implementation  
  
<APSS_BUILD>/frameworks/av/media/libmediaplayerservice/nuplayer - Contains the source code for Google’s nuplayer implementation  
  
<APSS_BUILD>/frameworks/av/services/audioflinger/ – Contains the source code for AudioFlinger that manages audio streams from the user space  
  
<APSS_BUILD>/vendor/qcom/proprietary/mm-audio/ – Contains the code related to the Audio Calibration Database (ACDB) driver, parsers for DTS and AC3, surround sound, SVA, etc.  
  
<APSS_BUILD>/external/bluetooth/bluedroid/ – Contains the code related to Bluetooth® (BT) A2DP used in a QTI platform  
  
<APSS_BUILD>/external/bluetooth/bluedroid/audio_a2dp_hw/ – Contains the A2DP audio HAL implementation  
  
<APSS_BUILD>/hardware/libhardware/modules/usbaudio/ – Contains the USB HAL implementation for a USB dock use case  
  
<APSS_BUILD>/hardware/qcom/audio/hal/audio_extn/:  
  
audio_extn.c – Implements the wrapper function for audio extension features, such as FM, Dolby, Compress capture, HFP, SVA (listen), speaker protection, SSR, USB audio over headset  
  
usb.c – Contains the HAL implementation for USB playback and record over the headset  
  
compress_capture.c – Contains the HAL implementation for Compress capture  
  
dolby.c – Contains the HAL implementation for the Dolby postprocessing feature  
  
fm.c – Contains the HAL implementation for the FM playback and recording feature  
  
hfp.c – Contains the HAL implementation for the hands-free profile feature where the MSM™ chipset can be used as as a BT headset device  
  
listen.c – Contains the HAL implementation for the Snapdragon™ Voice Activation (SVA) feature  
  
spkr_protection.c – Contains the HAL implementation for the speaker protection feature  
  
ssr.c – Contains the HAL implementation for the surround sound recording feature  
  
<APSS_BUILD>/vendor/qcom/proprietary/wfd/mm/source/framework/src/ – Contains the Wi-Fi Display (WFD) frameworks-related code; WFDMMSourceAudioSource.cpp configures the RT Proxy port via ALSA APIs and gets the PCM data from the audio layer  
  
<APSS_BUILD>/system/core/include/system/ – Contains audio.h and audio_policy.h that contain enum definitions and inline functions used all over the code for audio in the user space  
  

<APSS_BUILD>/frameworks/base/media/java/android/media/ – Contains .java files for audio that expose APIs that can be called by Android™ applications written in Java  

内核空间代码 :
<APSS_BUILD>/kernel/sound/soc/msm/ – Contains the msm8994.c machine driver  
  
<APSS_BUILD>/kernel/sound/soc/msm/qdsp6v2 – Contains the source code for the platform drivers, Frontend (FE), and Backend (BE) DAI driver, QDSP drivers for AFE, ADM, and ASM, voice driver, etc.  
  
<APSS_BUILD>/kernel/sound/soc/soc-*.c – All the soc-*.c files provide information on the ALSA SOC framework  
  
<APSS_BUILD>/kernel/drivers/slimbus/ – Contains the source for the SLIMbus driver  
  
<APSS_BUILD>/kernel/arch/arm/mach-msm/qdsp6v2/ – Contains the drivers for DSP-based encoders and decoders, code for the ADSP loader, APR driver, Ion memory driver, and other utility files  
  
<APSS_BUILD>//LINUX/android/kernel/arch/arm/boot/dts – Contains msm8994-*.dtsi files that contain MSM8994-specific information;board-specific information on the MSM8994;GPIO management ; audio-related customization is available in files such as msm8994.dtsi, msm8994-mtp.dtsi, and msm8994-cdp.dtsi  
  
<APSS_BUILD>/LINUX/android//kernel/sound/soc/codecs/ – Contains the source code for the codec driver for WCD9330; codec driver-related source files are wcd9330.c, wcd9xxx-mbhc.c, wcd9xxx-resmgr.c, wcd9xxx-common.c, etc.  
  
<APSS_BUILD>//LINUX/android/kernel/drivers/mfd/ – Contains the source code for the codec driver; wcd9xxx-core.c, wcd9xxx-slimslave.c, and wcd9xxx-irq.c are the codec driver-related files  


(转自 :http://blog.csdn.net/shichaog/article/details/54862717   有改动 )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值