ASoC: Intel: broadwell: set card and driver name dynamically

Remove last hard-coded build-time dependency

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Link: https://lore.kernel.org/r/20201112223825.39765-12-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Pierre-Louis Bossart 2020-11-12 16:38:22 -06:00 committed by Mark Brown
parent 803e591337
commit 8643e85aab
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
3 changed files with 36 additions and 17 deletions

View File

@ -262,14 +262,12 @@ static struct snd_soc_dai_link bdw_rt5650_dais[] = {
},
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bdw rt5650" /* card name will be 'sof-bdw rt5650' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bdw rt5650" /* card name will be 'sof-bdw rt5650' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bdw-rt5650"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* ASoC machine driver for Broadwell DSP + RT5650 */
static struct snd_soc_card bdw_rt5650_card = {
@ -309,6 +307,15 @@ static int bdw_rt5650_probe(struct platform_device *pdev)
if (ret)
return ret;
/* set card and driver name */
if (snd_soc_acpi_sof_parent(&pdev->dev)) {
bdw_rt5650_card.name = SOF_CARD_NAME;
bdw_rt5650_card.driver_name = SOF_DRIVER_NAME;
} else {
bdw_rt5650_card.name = CARD_NAME;
bdw_rt5650_card.driver_name = DRIVER_NAME;
}
snd_soc_card_set_drvdata(&bdw_rt5650_card, bdw_rt5650);
return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5650_card);

View File

@ -387,14 +387,12 @@ static int bdw_rt5677_resume_post(struct snd_soc_card *card)
return 0;
}
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bdw rt5677" /* card name will be 'sof-bdw rt5677' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bdw rt5677" /* card name will be 'sof-bdw rt5677' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bdw-rt5677"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* ASoC machine driver for Broadwell DSP + RT5677 */
static struct snd_soc_card bdw_rt5677_card = {
@ -437,6 +435,15 @@ static int bdw_rt5677_probe(struct platform_device *pdev)
if (ret)
return ret;
/* set card and driver name */
if (snd_soc_acpi_sof_parent(&pdev->dev)) {
bdw_rt5677_card.name = SOF_CARD_NAME;
bdw_rt5677_card.driver_name = SOF_DRIVER_NAME;
} else {
bdw_rt5677_card.name = CARD_NAME;
bdw_rt5677_card.driver_name = DRIVER_NAME;
}
snd_soc_card_set_drvdata(&bdw_rt5677_card, bdw_rt5677);
return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5677_card);

View File

@ -262,19 +262,15 @@ static int broadwell_resume(struct snd_soc_card *card){
return 0;
}
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bdw rt286" /* card name will be 'sof-bdw rt286' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bdw rt286" /* card name will be 'sof-bdw rt286' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "broadwell-rt286"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* broadwell audio machine driver for WPT + RT286S */
static struct snd_soc_card broadwell_rt286 = {
.name = CARD_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = broadwell_rt286_dais,
.num_links = ARRAY_SIZE(broadwell_rt286_dais),
@ -303,6 +299,15 @@ static int broadwell_audio_probe(struct platform_device *pdev)
if (ret)
return ret;
/* set card and driver name */
if (snd_soc_acpi_sof_parent(&pdev->dev)) {
broadwell_rt286.name = SOF_CARD_NAME;
broadwell_rt286.driver_name = SOF_DRIVER_NAME;
} else {
broadwell_rt286.name = CARD_NAME;
broadwell_rt286.driver_name = DRIVER_NAME;
}
return devm_snd_soc_register_card(&pdev->dev, &broadwell_rt286);
}