snd_soc_card和snd_soc_component_driver都是ALSA ASoC驱动程序中的重要组成部分。他们的区别在于:
static struct snd_soc_card mycard = {
.name = "mycard-name",
.owner = THIS_MODULE,
.dai_link = mycard_dai_link,
.num_links = ARRAY_SIZE(mycard_dai_link),
.probe = mycard_probe,
.remove = mycard_remove,
.dapm_widgets = mycard_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(mycard_dapm_widgets),
.dapm_routes = mycard_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(mycard_dapm_routes),
.controls = mycard_snd_controls,
.num_controls = ARRAY_SIZE(mycard_snd_controls),
};
struct snd_soc_component_driver mycomponent = {
.name = "mycomponent-name",
.probe = mycomponent_probe,
.remove = mycomponent_remove,
.read = mycomponent_read,
.write = mycomponent_write
};
因此,在ALSA ASoC驱动程序的开发中,可以根据实际需要选择使用snd_soc_card或snd_soc_component_driver来管理音频设备和组件。