概述
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,
},
};
最后
以上就是彩色发夹为你收集整理的基于imx6q-Android6.0的ASOC架构 -- Machine、Platform和Codec简介的全部内容,希望文章能够帮你解决基于imx6q-Android6.0的ASOC架构 -- Machine、Platform和Codec简介所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复