|
发表于 2012-5-15 19:12:44
|
显示全部楼层
SOC_CARD层:
一、静态定义一个snd_soc_card实例xxx_soc_card:
struct snd_soc_card xxx_soc_card = {
.name = “xxx”,
.dai_link = &xxx_dai_link[0],
.num_links = ARRAY_SIZE(xxx_dai_link),
};
二、定义一个snd_soc_dai_link实例xxx_dai_link:
struct snd_soc_dai_link xxx_dai_link[] = {
{
.name = “Codec Name”,
.stream_name = “Stream Name”,
.cpu_dai_name = “Cpu DAI Name”,
.platform_name = “Platform Name”,
.codec_dai_name = “Codec DAI Name”,
.codec_name = “Codec Name”,
.ops = &xxx_dai_link_ops,
.init = xxx_dai_init, //init(struct snd_soc_pcm_runtime rtd)
},
{
... ...
},
};
三、定义platform/machine kcontrol/widget/route 以及 xxx_dai_init()函数:
1、根据需要,静态地定义kcontrol/widget/route等;
2、定义xxx_dai_init():
static int xxx_dai_init(struct snd_soc_pcm_runtime * rtd)
{
// TODO :从rtd得到codec,从codec得到dapm context,
将上面定义的kcontrol/widget/route,关联到codec 的dapm context
return 0;
}
四、定义xxx_dai_link_ops:
struct snd_soc_ops xxx_dai_link_ops = {
.startup =
.shutdown =
.prepare =
.trigger =
.hw_free =
.hw_params = xxx_hw_params,
};
五、实现xxx_hw_params():
static int xxx_hw_params(struct snc_pcm_substream * substream ,
struct snd_pcm_hw_params *params)
{
//TODO :根据substream得到rtd,由rtd得到cpu_dai和codec_dai,设置两个dai的格式、时钟等
return 0;
} |
|