基于imx6q-Android6.0的ASOC架构 -- Machine、Platform和Codec简介

arm平台:IMX6Q
内核:Linux4.1.15
系统:Android6.0
codec:wm8960
主要内容为Machine、Platform和Codec三大部分之间的关系和实现。文章中的举例和代码均为imx6q-Android6.0源码和文件。
文章中如有错误和不严谨内容,欢迎指正。

ASOC下的Machine、Platform和Codec

1、codec:编解码芯片驱动

kernel_imx/sound/soc/codecs/wm8960.c

作用:实现控制命令的的具体操作。编解码芯片寄存器的读写等功能。
主要的两个结构体:
struct snd_soc_codec_driver 控制接口(i2c)
struct snd_soc_dai_driver 音频传输接口(ssi或i2s)
函数:
snd_soc_register_codec

snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8960, &wm8960_dai, 1);

struct snd_soc_codec_driver soc_codec_dev_wm8960 = {
        .probe =        wm8960_probe,
        .set_bias_level = wm8960_set_bias_level,
        .suspend_bias_off = true,
};

static const struct snd_soc_dai_ops wm8960_dai_ops = {
        .hw_params = wm8960_hw_params,
        .hw_free = wm8960_hw_free,
        .digital_mute = wm8960_mute,
        .set_fmt = wm8960_set_dai_fmt,
        .set_clkdiv = wm8960_set_dai_clkdiv,
        .set_pll = wm8960_set_dai_pll,
        .set_sysclk = wm8960_set_dai_sysclk,
};

static struct snd_soc_dai_driver wm8960_dai = {
        .name = "wm8960-hifi",
        .playback = {
                .stream_name = "Playback",
                .channels_min = 1,
                .channels_max = 2,
                .rates = WM8960_RATES,
                .formats = WM8960_FORMATS,},
        .capture = {
                .stream_name = "Capture",
                .channels_min = 1,
                .channels_max = 2,
                .rates = WM8960_RATES,
                .formats = WM8960_FORMATS,},
        .ops = &wm8960_dai_ops,
        .symmetric_rates = 1,
};

2、Platform :CPU接口驱动

kernel_imx/sound/soc/fsl/fsl_ssi.c

作用:注册CPU接口驱动和实现。
主要结构体:
struct snd_soc_dai_driver
函数:
snd_soc_register_component

static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
        .bus_control = true,
        .playback = {
                .stream_name = "AC97 Playback",
                .channels_min = 2,
                .channels_max = 2,
                .rates = SNDRV_PCM_RATE_8000_48000,
                .formats = SNDRV_PCM_FMTBIT_S16_LE,
        },
        .capture = {
                .stream_name = "AC97 Capture",
                .channels_min = 2,
                .channels_max = 2,
                .rates = SNDRV_PCM_RATE_48000,
                .formats = SNDRV_PCM_FMTBIT_S16_LE,
        },
        .ops = &fsl_ssi_dai_ops,
};

3、Machine:连接platform和codec

kernel_imx/sound/soc/fsl/imx-wm8960.c

主要结构体:
struct snd_soc_card
struct snd_soc_dai_link

函数:snd_soc_register_card

static struct snd_soc_dai_link imx_wm8960_dai[] = {
        {
                .name = "HiFi",
                .stream_name = "HiFi",
                .codec_dai_name = "wm8960-hifi",
                .ops = &imx_hifi_ops,
        },
        {
                .name = "HiFi-ASRC-FE",
                .stream_name = "HiFi-ASRC-FE",
                .codec_name = "snd-soc-dummy",
                .codec_dai_name = "snd-soc-dummy-dai",
                .dynamic = 1,
                .ignore_pmdown_time = 1,
                .dpcm_playback = 1,
                .dpcm_capture = 1,
        },
        {
                .name = "HiFi-ASRC-BE",
                .stream_name = "HiFi-ASRC-BE",
                .codec_dai_name = "wm8960-hifi",
                .platform_name = "snd-soc-dummy",
                .no_pcm = 1,
                .ignore_pmdown_time = 1,
                .dpcm_playback = 1,
                .dpcm_capture = 1,
                .ops = &imx_hifi_ops,
                .be_hw_params_fixup = be_hw_params_fixup,
        },
};

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值