mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-19 04:22:35 -05:00
ASoC: Intel: avs: probe: Refactor dai_link creation
To allow for multiple instances of the card, move away from static dai_link declaration. While at it, simplify the code as the name of the platform component matches the name of the card's platform_device: - drop mach->mach_params.platform usage - drop snd_soc_fixup_dai_links_platform_name() usage Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Message-ID: <20250902094853.1231842-11-cezary.rojewski@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
ba36843282
commit
a46b3da24c
@@ -9,45 +9,54 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-acpi.h>
|
||||
|
||||
SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
|
||||
SND_SOC_DAILINK_DEF(probe_cp, DAILINK_COMP_ARRAY(COMP_CPU("Probe Extraction CPU DAI")));
|
||||
SND_SOC_DAILINK_DEF(platform, DAILINK_COMP_ARRAY(COMP_PLATFORM("probe-platform")));
|
||||
static int avs_create_dai_links(struct device *dev, struct snd_soc_dai_link **links, int *num_links)
|
||||
{
|
||||
struct snd_soc_dai_link *dl;
|
||||
|
||||
static struct snd_soc_dai_link probe_mb_dai_links[] = {
|
||||
{
|
||||
.name = "Compress Probe Capture",
|
||||
.nonatomic = 1,
|
||||
SND_SOC_DAILINK_REG(probe_cp, dummy, platform),
|
||||
},
|
||||
};
|
||||
dl = devm_kzalloc(dev, sizeof(*dl), GFP_KERNEL);
|
||||
if (!dl)
|
||||
return -ENOMEM;
|
||||
|
||||
dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
|
||||
dl->platforms = devm_kzalloc(dev, sizeof(*dl->platforms), GFP_KERNEL);
|
||||
if (!dl->cpus || !dl->platforms)
|
||||
return -ENOMEM;
|
||||
|
||||
dl->name = "Compress Probe Capture";
|
||||
dl->cpus->dai_name = "Probe Extraction CPU DAI";
|
||||
dl->num_cpus = 1;
|
||||
dl->codecs = &snd_soc_dummy_dlc;
|
||||
dl->num_codecs = 1;
|
||||
dl->platforms->name = dev_name(dev);
|
||||
dl->num_platforms = 1;
|
||||
dl->nonatomic = 1;
|
||||
|
||||
*links = dl;
|
||||
*num_links = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int avs_probe_mb_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct snd_soc_acpi_mach *mach;
|
||||
struct snd_soc_card *card;
|
||||
int ret;
|
||||
|
||||
mach = dev_get_platdata(dev);
|
||||
|
||||
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
|
||||
if (!card)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = avs_create_dai_links(dev, &card->dai_link, &card->num_links);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
card->driver_name = "avs_probe_mb";
|
||||
card->long_name = card->name = "AVS PROBE";
|
||||
card->dev = dev;
|
||||
card->owner = THIS_MODULE;
|
||||
card->dai_link = probe_mb_dai_links;
|
||||
card->num_links = ARRAY_SIZE(probe_mb_dai_links);
|
||||
card->fully_routed = true;
|
||||
|
||||
ret = snd_soc_fixup_dai_links_platform_name(card, mach->mach_params.platform);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return devm_snd_soc_register_deferrable_card(dev, card);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user