Commit 41656c3d authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: Intel: boards: byt/cht: set card and driver name at run time

To avoid hard-coded variations between SOF and SST drivers, set the
card name and driver dynamically depending on the parent type. This is
the first pass required to let distributions select which drivers to
use with kernel parameters instead of build-time selection.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@linux.intel.com>
Reviewed-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Link: https://lore.kernel.org/r/20201112223825.39765-6-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 644eebdb
......@@ -205,14 +205,12 @@ static struct snd_soc_dai_link byt_cht_cx2072x_dais[] = {
},
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht cx2072x" /* card name will be 'sof-bytcht cx2072x' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht cx2072x" /* card name will be 'sof-bytcht cx2072x' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bytcht-cx2072x"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* SoC card */
static struct snd_soc_card byt_cht_cx2072x_card = {
......@@ -236,6 +234,7 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach;
struct acpi_device *adev;
int dai_index = 0;
bool sof_parent;
int i, ret;
byt_cht_cx2072x_card.dev = &pdev->dev;
......@@ -265,6 +264,17 @@ static int snd_byt_cht_cx2072x_probe(struct platform_device *pdev)
if (ret)
return ret;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
byt_cht_cx2072x_card.name = SOF_CARD_NAME;
byt_cht_cx2072x_card.driver_name = SOF_DRIVER_NAME;
} else {
byt_cht_cx2072x_card.name = CARD_NAME;
byt_cht_cx2072x_card.driver_name = DRIVER_NAME;
}
return devm_snd_soc_register_card(&pdev->dev, &byt_cht_cx2072x_card);
}
......
......@@ -205,14 +205,12 @@ static struct snd_soc_dai_link dailink[] = {
},
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht da7213" /* card name will be 'sof-bytcht da7213' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht da7213" /* card name will be 'sof-bytcht da7213' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bytcht-da7213"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* SoC card */
static struct snd_soc_card bytcht_da7213_card = {
......@@ -237,6 +235,7 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach;
const char *platform_name;
struct acpi_device *adev;
bool sof_parent;
int dai_index = 0;
int ret_val = 0;
int i;
......@@ -269,6 +268,17 @@ static int bytcht_da7213_probe(struct platform_device *pdev)
if (ret_val)
return ret_val;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
bytcht_da7213_card.name = SOF_CARD_NAME;
bytcht_da7213_card.driver_name = SOF_DRIVER_NAME;
} else {
bytcht_da7213_card.name = CARD_NAME;
bytcht_da7213_card.driver_name = DRIVER_NAME;
}
ret_val = devm_snd_soc_register_card(&pdev->dev, card);
if (ret_val) {
dev_err(&pdev->dev,
......
......@@ -406,18 +406,14 @@ static int byt_cht_es8316_resume(struct snd_soc_card *card)
return 0;
}
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht es8316" /* card name will be 'sof-bytcht es8316' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht es8316" /* card name will be 'sof-bytcht es8316' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bytcht-es8316"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
static struct snd_soc_card byt_cht_es8316_card = {
.name = CARD_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = byt_cht_es8316_dais,
.num_links = ARRAY_SIZE(byt_cht_es8316_dais),
......@@ -472,6 +468,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
const char *platform_name;
struct acpi_device *adev;
struct device *codec_dev;
bool sof_parent;
unsigned int cnt = 0;
int dai_index = 0;
int i;
......@@ -590,6 +587,17 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
byt_cht_es8316_card.long_name = long_name;
#endif
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
byt_cht_es8316_card.name = SOF_CARD_NAME;
byt_cht_es8316_card.driver_name = SOF_DRIVER_NAME;
} else {
byt_cht_es8316_card.name = CARD_NAME;
byt_cht_es8316_card.driver_name = DRIVER_NAME;
}
/* register the soc card */
snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
......
......@@ -1136,18 +1136,14 @@ static int byt_rt5640_resume(struct snd_soc_card *card)
return 0;
}
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht rt5640" /* card name will be 'sof-bytcht rt5640' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht rt5640" /* card name will be 'sof-bytcht rt5640' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bytcr-rt5640"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
static struct snd_soc_card byt_rt5640_card = {
.name = CARD_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = byt_rt5640_dais,
.num_links = ARRAY_SIZE(byt_rt5640_dais),
......@@ -1173,6 +1169,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach;
const char *platform_name;
struct acpi_device *adev;
bool sof_parent;
int ret_val = 0;
int dai_index = 0;
int i;
......@@ -1336,6 +1333,17 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
if (ret_val)
return ret_val;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
byt_rt5640_card.name = SOF_CARD_NAME;
byt_rt5640_card.driver_name = SOF_DRIVER_NAME;
} else {
byt_rt5640_card.name = CARD_NAME;
byt_rt5640_card.driver_name = DRIVER_NAME;
}
ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5640_card);
if (ret_val) {
......
......@@ -827,14 +827,12 @@ static int byt_rt5651_resume(struct snd_soc_card *card)
return 0;
}
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht rt5651" /* card name will be 'sof-bytcht rt5651' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht rt5651" /* card name will be 'sof-bytcht rt5651' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "bytcr-rt5651"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
static struct snd_soc_card byt_rt5651_card = {
.name = CARD_NAME,
......@@ -876,6 +874,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
const char *platform_name;
struct acpi_device *adev;
struct device *codec_dev;
bool sof_parent;
bool is_bytcr = false;
int ret_val = 0;
int dai_index = 0;
......@@ -1093,6 +1092,17 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
if (ret_val)
return ret_val;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
byt_rt5651_card.name = SOF_CARD_NAME;
byt_rt5651_card.driver_name = SOF_DRIVER_NAME;
} else {
byt_rt5651_card.name = CARD_NAME;
byt_rt5651_card.driver_name = DRIVER_NAME;
}
ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5651_card);
if (ret_val) {
......
......@@ -382,19 +382,15 @@ static struct snd_soc_dai_link cht_dailink[] = {
},
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht max98090" /* card name will be 'sof-bytcht max98090 */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht max98090" /* card name will be 'sof-bytcht max98090 */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "chtmax98090"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* SoC card */
static struct snd_soc_card snd_soc_card_cht = {
.name = CARD_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink),
......@@ -540,6 +536,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
const char *mclk_name;
struct snd_soc_acpi_mach *mach;
const char *platform_name;
bool sof_parent;
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
if (!drv)
......@@ -602,6 +599,17 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
}
}
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
snd_soc_card_cht.name = SOF_CARD_NAME;
snd_soc_card_cht.driver_name = SOF_DRIVER_NAME;
} else {
snd_soc_card_cht.name = CARD_NAME;
snd_soc_card_cht.driver_name = DRIVER_NAME;
}
ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
if (ret_val) {
dev_err(&pdev->dev,
......
......@@ -231,19 +231,15 @@ static struct snd_soc_dai_link cht_dailink[] = {
},
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht nau8824" /* card name will be 'sof-bytcht nau8824 */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht nau8824" /* card name will be 'sof-bytcht nau8824 */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "chtnau8824"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* SoC card */
static struct snd_soc_card snd_soc_card_cht = {
.name = CARD_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink),
......@@ -260,6 +256,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
struct cht_mc_private *drv;
struct snd_soc_acpi_mach *mach;
const char *platform_name;
bool sof_parent;
int ret_val;
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
......@@ -277,6 +274,17 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
if (ret_val)
return ret_val;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
snd_soc_card_cht.name = SOF_CARD_NAME;
snd_soc_card_cht.driver_name = SOF_DRIVER_NAME;
} else {
snd_soc_card_cht.name = CARD_NAME;
snd_soc_card_cht.driver_name = DRIVER_NAME;
}
/* register the soc card */
ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
if (ret_val) {
......
......@@ -479,21 +479,17 @@ static struct snd_soc_dai_link cht_dailink[] = {
},
};
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_RT5645_NAME "bytcht rt5645" /* card name 'sof-bytcht rt5645' */
#define CARD_RT5650_NAME "bytcht rt5650" /* card name 'sof-bytcht rt5650' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_RT5645_NAME "bytcht rt5645" /* card name 'sof-bytcht rt5645' */
#define SOF_CARD_RT5650_NAME "bytcht rt5650" /* card name 'sof-bytcht rt5650' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_RT5645_NAME "chtrt5645"
#define CARD_RT5650_NAME "chtrt5650"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* SoC card */
static struct snd_soc_card snd_soc_card_chtrt5645 = {
.name = CARD_RT5645_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink),
......@@ -506,8 +502,6 @@ static struct snd_soc_card snd_soc_card_chtrt5645 = {
};
static struct snd_soc_card snd_soc_card_chtrt5650 = {
.name = CARD_RT5650_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink),
......@@ -541,6 +535,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
const char *platform_name;
struct cht_mc_private *drv;
struct acpi_device *adev;
bool sof_parent;
bool found = false;
bool is_bytcr = false;
int dai_index = 0;
......@@ -680,6 +675,22 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
}
snd_soc_card_set_drvdata(card, drv);
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
snd_soc_card_chtrt5645.name = SOF_CARD_RT5645_NAME;
snd_soc_card_chtrt5645.driver_name = SOF_DRIVER_NAME;
snd_soc_card_chtrt5650.name = SOF_CARD_RT5650_NAME;
snd_soc_card_chtrt5650.driver_name = SOF_DRIVER_NAME;
} else {
snd_soc_card_chtrt5645.name = CARD_RT5645_NAME;
snd_soc_card_chtrt5645.driver_name = DRIVER_NAME;
snd_soc_card_chtrt5650.name = CARD_RT5650_NAME;
snd_soc_card_chtrt5650.driver_name = DRIVER_NAME;
}
ret_val = devm_snd_soc_register_card(&pdev->dev, card);
if (ret_val) {
dev_err(&pdev->dev,
......
......@@ -382,19 +382,15 @@ static int cht_resume_post(struct snd_soc_card *card)
return 0;
}
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
/* use space before codec name to simplify card ID, and simplify driver name */
#define CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
#define DRIVER_NAME "SOF"
#else
#define SOF_CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
#define SOF_DRIVER_NAME "SOF"
#define CARD_NAME "cht-bsw-rt5672"
#define DRIVER_NAME NULL /* card name will be used for driver name */
#endif
/* SoC card */
static struct snd_soc_card snd_soc_card_cht = {
.name = CARD_NAME,
.driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink),
......@@ -417,6 +413,7 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
const char *platform_name;
struct acpi_device *adev;
bool sof_parent;
int i;
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
......@@ -458,6 +455,17 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
}
snd_soc_card_set_drvdata(&snd_soc_card_cht, drv);
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
/* set card and driver name */
if (sof_parent) {
snd_soc_card_cht.name = SOF_CARD_NAME;
snd_soc_card_cht.driver_name = SOF_DRIVER_NAME;
} else {
snd_soc_card_cht.name = CARD_NAME;
snd_soc_card_cht.driver_name = DRIVER_NAME;
}
/* register the soc card */
ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht);
if (ret_val) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment