音频

来源:互联网 发布:淘宝修改论文靠谱吗 编辑:程序博客网 时间:2024/06/09 14:24
1.硬件:
PCM接口
IIS接口
AC97接口

DAI概述

增加AC97、I2S、PCM三种接口说明,摘自内核文档DAI.txt:


ASoC currently supports the three main Digital Audio Interfaces (DAI) found onSoC controllers and portable audio CODECs today, namely AC97, I2S and PCM.AC97====  AC97 is a five wire interface commonly found on many PC sound cards. It isnow also popular in many portable devices. This DAI has a reset line and timemultiplexes its data on its SDATA_OUT (playback) and SDATA_IN (capture) lines.The bit clock (BCLK) is always driven by the CODEC (usually 12.288MHz) and theframe (FRAME) (usually 48kHz) is always driven by the controller. Each AC97frame is 21uS long and is divided into 13 time slots.The AC97 specification can be found at :-http://www.intel.com/design/chipsets/audio/ac97_r23.pdfI2S=== I2S is a common 4 wire DAI used in HiFi, STB and portable devices. The Tx andRx lines are used for audio transmission, whilst the bit clock (BCLK) andleft/right clock (LRC) synchronise the link. I2S is flexible in that either thecontroller or CODEC can drive (master) the BCLK and LRC clock lines. Bit clockusually varies depending on the sample rate and the master system clock(SYSCLK). LRCLK is the same as the sample rate. A few devices support separateADC and DAC LRCLKs, this allows for simultaneous capture and playback atdifferent sample rates.I2S has several different operating modes:- o I2S - MSB is transmitted on the falling edge of the first BCLK after LRC         transition. o Left Justified - MSB is transmitted on transition of LRC. o Right Justified - MSB is transmitted sample size BCLKs before LRC                     transition.PCM===PCM is another 4 wire interface, very similar to I2S, which can support a moreflexible protocol. It has bit clock (BCLK) and sync (SYNC) lines that are usedto synchronise the link whilst the Tx and Rx lines are used to transmit andreceive the audio data. Bit clock usually varies depending on sample ratewhilst sync runs at the sample rate. PCM also supports Time DivisionMultiplexing (TDM) in that several devices can use the bus simultaneously (thisis sometimes referred to as network mode).Common PCM operating modes:- o Mode A - MSB is transmitted on falling edge of first BCLK after FRAME/SYNC. o Mode B - MSB is transmitted on rising edge of FRAME/SYNC.



2.ASoc音频设备驱动架构
linux2.6.35, imx535
软件架构3部分:板驱动,平台驱动,编解码驱动(codec)
板驱动 :将平台驱动和codec绑定。imx-3stack-wm8758.c
平台驱动:只关心cpu本身。imx-ssi.c
codec:只关心codec本身。wm8758.c

imx-3stack-wm8758.c

static int __init imx_3stack_init(void){int ret;ret = platform_driver_register(&imx_3stack_wm8758_audio_driver);if (ret)return -ENOMEM;imx_3stack_snd_device = platform_device_alloc("soc-audio", 2);if (!imx_3stack_snd_device)return -ENOMEM;platform_set_drvdata(imx_3stack_snd_device, &imx_3stack_snd_devdata);imx_3stack_snd_devdata.dev = &imx_3stack_snd_device->dev;ret = platform_device_add(imx_3stack_snd_device);        printk("  %s(%d)  %s  \n",__FILE__,__LINE__,__func__);if (ret)platform_device_put(imx_3stack_snd_device);if (ret)               printk("register  soc-audio failed add bypanzidong  in  imx_3stack_init \n");        printk("  %s(%d)  %s \n",__FILE__,__LINE__,__func__);return ret;}
imx_3stack_wm8758_audio_driver的probe函数中,给struct snd_soc_dai_link imx_3stack_dai 的codec_dai和cpu_dai赋值,分别:
codec_dai是struct snd_soc_dai wm8758_dai ,位于wm8758.c
cpu_dai是struct snd_soc_dai *imx_ssi_dai[5];,位于imx-ssi.c

snd_soc_device 是asoc的跟结构体,从此结构体衍生出各个东东
static struct snd_soc_device imx_3stack_snd_devdata = {.card = &snd_soc_card_imx_3stack,.codec_dev = &soc_codec_dev_wm8758,};
snd_soc_device 作为私有数据给了imx_3stack_snd_device
platform_set_drvdata(imx_3stack_snd_device, &imx_3stack_snd_devdata);

platform_device_add(imx_3stack_snd_device);之后,会匹配到snd核心已经定义好的一个platform_driver ,位于sound/soc/soc-core.c
static struct platform_driver soc_driver = {.driver= {.name= "soc-audio",.owner= THIS_MODULE,.pm= &soc_pm_ops,},.probe= soc_probe,.remove= soc_remove,};
从而触发soc_probe函数,在probe函数中接收到snd_soc_device参数,进行一系列的注册动作,并调用wm8758.c中struct snd_soc_codec_device soc_codec_dev_wm8758中的probe函数


几个数据结构
位于soc.h,soc-dai.h
/* SoC card */
struct snd_soc_card 

/* SoC Device - the audio subsystem */
struct snd_soc_device 

/*
 * Digital Audio Interface runtime data.
 *
 * Holds runtime data for a DAI.
 */
struct snd_soc_dai 

/* SoC machine DAI configuration, glues a codec and cpu DAI together */
struct snd_soc_dai_link  


/* SoC Audio Codec */
struct snd_soc_codec 

/* codec device */
struct snd_soc_codec_device 

/* SoC platform interface */
struct snd_soc_platform 


refer to
http://blog.csdn.net/azloong/article/details/6536855

0 0