瑞芯微Rockchip开发者社区
直播中

陈勇

7年用户 1260经验值
私信 关注
[经验]

RK3288 Android6.0 Audio的ASOC驱动及数据结构分析

Platform: Rockchip

OS: Android 6.0

Kernel: 3.10.92

系统使用ASOC来处理Audio部分,可分为三大部分: Machine, Codec以及Platform.

其中Codec分codec driver以及codec dai driver,Platform分platform driver以及CPU dai driver.

rk_rt5631.c:

Machine driver,和板子相关,所以不同的板子都需要作修改。

rt5631.c:

Codec driver以及Codec dai driver,和平台无关。相关的部分被放在Machine以及Platform驱动中处理。

rk_i2s.c:

Platform下的cpu dai driver,不包含和板子相关的控制,只和平台相关,因为I2S控制器是一定的。

rk_pcm.c:

Platform driver,dma相关控制,用来输出数据到i2s。

注册及重要的数据结构:

Machine driver注册:

rockchip_rt5631_audio_probe -> rk_rt5631.c

snd_soc_register_card

snd_soc_card:

static struct snd_soc_card rockchip_rt5631_snd_card = {

.name = "RK_RT5631",

.dai_link = &rk29_dai,

.num_links = 1,

};

snd_soc_dai_link:

static struct snd_soc_dai_link rk29_dai = {

.name = "rt5631",

.stream_name = "rt5631 PCM",

.codec_dai_name = "rt5631-hifi",

.init = rk29_rt5631_init,

.ops = &rk29_ops,

};

Codec以及codec dai driver注册:

rt5631_i2c_probe -> rt5631.c

snd_soc_register_codec

snd_soc_codec_driver:

static struct snd_soc_codec_driver soc_codec_dev_rt5631 = {

.probe = rt5631_probe,

.remove = rt5631_remove,

.suspend = rt5631_suspend,

.resume = rt5631_resume,

.set_bias_level = rt5631_set_bias_level,

.reg_cache_size = ARRAY_SIZE(rt5631_reg),

.reg_word_size = sizeof(u16),

.reg_cache_default = rt5631_reg,

.reg_cache_step = 1,

};

snd_soc_dai_driver:

static struct snd_soc_dai_driver rt5631_dai[] = {

{

.name = "rt5631-hifi",

.playback = {

.stream_name = "HIFI Playback",

.channels_min = 1,

.channels_max = 2,

.rates = RT5631_STEREO_RATES,

.formats = RT5631_FORMAT,

},

.capture = {

.stream_name = "HIFI Capture",

.channels_min = 1,

.channels_max = 2,

.rates = RT5631_STEREO_RATES,

.formats = RT5631_FORMAT,

},

.ops = &rt5631_ops,

},

};

Platform driver注册:

rockchip_i2s_probe -> rk_i2s.c

rockchip_pcm_platform_register ->

snd_dmaengine_pcm_register ->

snd_soc_add_platform

snd_soc_platform_driver:

static const struct snd_soc_platform_driver dmaengine_no_residue_pcm_platform = {

.ops = &dmaengine_no_residue_pcm_ops,

.pcm_new = dmaengine_pcm_new,

.pcm_free = dmaengine_pcm_free,

.probe_order = SND_SOC_COMP_ORDER_LATE,

};

CPU dai driver注册:

rockchip_i2s_probe -> rk_i2s.c

snd_soc_register_component

snd_soc_dai_driver:

static struct snd_soc_dai_driver rockchip_i2s_dai = {

.probe = rockchip_i2s_dai_probe,

.playback = {

.stream_name = "Playback",

.channels_min = 2,

.channels_max = 8,

.rates = ROCKCHIP_I2S_RATES,

.formats = ROCKCHIP_I2S_FORMATS,

},

.capture = {

.stream_name = "Capture",

.channels_min = 2,

.channels_max = 8,

.rates = ROCKCHIP_I2S_RATES,

.formats = ROCKCHIP_I2S_FORMATS,

},

.ops = &rockchip_i2s_dai_ops,

.symmetric_rates = 1,

};

原作者:KrisFei

更多回帖

发帖
×
20
完善资料,
赚取积分