资源描述:
《linux音频alsa-uda134x驱动分析之十二(pcm)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Codec:音频芯片的控制,比如静音、打开(关闭)ADC(DAC)、设置ADC(DAC)的增益、耳机模式的检测等操作。I2S:数字音频接口,用于CPU和Codec之间的数字音频流rawdata的传输。每当有playback或record操作时,snd_soc_dai_ops.prepare()会被调用,启动I2S总线。PCM:我不知道为什么会取这个模块名,它其实是定义DMA操作的,用于将音频数据通过DMA传到I2S控制器的FIFO中。音频数据流向:RAM--(dma)-->I2SControllerFIFO--(i2s)-->Codec
2、-->Speaker/HeadsetPCM模块初始化调用snd_soc_register_platform()向ALSACore注册一个snd_soc_platform结构体。structsnd_soc_platformloon_soc_platform={.name="loon-pcm-audio",.pcm_ops=&loon_pcm_ops,.pcm_new=loon_pcm_new,.pcm_free=loon_pcm_free_dma_buffers,.suspend=loon_pcm_suspend,.resume=loon
3、_pcm_resume,};structsnd_soc_platformloon_soc_platform={.name="loon-pcm-audio",.pcm_ops=&loon_pcm_ops,.pcm_new=loon_pcm_new,.pcm_free=loon_pcm_free_dma_buffers,.suspend=loon_pcm_suspend,.resume=loon_pcm_resume,};成员pcm_new需要调用dma_alloc_writecombine()给DMA分配一块write-combining
4、的内存空间,并把这块缓冲区的相关信息保存到substream->dma_buffer中,相当于构造函数。pcm_free则相反。这些成员函数都还算简单,看看代码即可以理解其流程。snd_pcm_ops接着我们看一下snd_pcm_ops结构体,该结构体的操作集函数的实现是本模块的主体。structsnd_pcm_ops{int(*open)(structsnd_pcm_substream*substream);int(*close)(structsnd_pcm_substream*substream);int(*ioctl)(struc
5、tsnd_pcm_substream*substream,unsignedintcmd,void*arg);int(*hw_params)(structsnd_pcm_substream*substream,structsnd_pcm_hw_params*params);int(*hw_free)(structsnd_pcm_substream*substream);int(*prepare)(structsnd_pcm_substream*substream);int(*trigger)(structsnd_pcm_substream
6、*substream,intcmd);snd_pcm_uframes_t(*pointer)(structsnd_pcm_substream*substream);int(*copy)(structsnd_pcm_substream*substream,intchannel,snd_pcm_uframes_tpos,void__user*buf,snd_pcm_uframes_tcount);int(*silence)(structsnd_pcm_substream*substream,intchannel,snd_pcm_uframe
7、s_tpos,snd_pcm_uframes_tcount);structpage*(*page)(structsnd_pcm_substream*substream,unsignedlongoffset);int(*mmap)(structsnd_pcm_substream*substream,structvm_area_struct*vma);int(*ack)(structsnd_pcm_substream*substream);};structsnd_pcm_ops{int(*open)(structsnd_pcm_substr
8、eam*substream);int(*close)(structsnd_pcm_substream*substream);int(*ioctl)(structsnd_pcm_substream*subst