Commit 0fe4b561 authored by Ravulapati Vishnu vardhan rao's avatar Ravulapati Vishnu vardhan rao Committed by Mark Brown

ASoC: amd: Passing card structure based on codec

Passing specific snd_soc_card structure depending on the ACPI ID.
In future we can add other IDs in the ACPI table and pass the structure.
Signed-off-by: default avatarRavulapati Vishnu vardhan rao <Vishnuvardhanrao.Ravulapati@amd.com>
Link: https://lore.kernel.org/r/20200728160255.31020-3-Vishnuvardhanrao.Ravulapati@amd.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9c04b5a4
...@@ -30,6 +30,7 @@ static struct snd_soc_jack pco_jack; ...@@ -30,6 +30,7 @@ static struct snd_soc_jack pco_jack;
static struct clk *rt5682_dai_wclk; static struct clk *rt5682_dai_wclk;
static struct clk *rt5682_dai_bclk; static struct clk *rt5682_dai_bclk;
static struct gpio_desc *dmic_sel; static struct gpio_desc *dmic_sel;
void *soc_is_rltk_max(struct device *dev);
static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd) static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd)
{ {
...@@ -326,18 +327,32 @@ static struct snd_soc_card acp3x_5682 = { ...@@ -326,18 +327,32 @@ static struct snd_soc_card acp3x_5682 = {
.num_controls = ARRAY_SIZE(acp3x_5682_mc_controls), .num_controls = ARRAY_SIZE(acp3x_5682_mc_controls),
}; };
void *soc_is_rltk_max(struct device *dev)
{
const struct acpi_device_id *match;
match = acpi_match_device(dev->driver->acpi_match_table, dev);
if (!match)
return NULL;
return (void *)match->driver_data;
}
static int acp3x_probe(struct platform_device *pdev) static int acp3x_probe(struct platform_device *pdev)
{ {
int ret; int ret;
struct snd_soc_card *card; struct snd_soc_card *card;
struct acp3x_platform_info *machine; struct acp3x_platform_info *machine;
struct device *dev = &pdev->dev;
card = (struct snd_soc_card *)soc_is_rltk_max(dev);
if (!card)
return -ENODEV;
machine = devm_kzalloc(&pdev->dev, sizeof(*machine), GFP_KERNEL); machine = devm_kzalloc(&pdev->dev, sizeof(*machine), GFP_KERNEL);
if (!machine) if (!machine)
return -ENOMEM; return -ENOMEM;
card = &acp3x_5682; card->dev = &pdev->dev;
acp3x_5682.dev = &pdev->dev;
platform_set_drvdata(pdev, card); platform_set_drvdata(pdev, card);
snd_soc_card_set_drvdata(card, machine); snd_soc_card_set_drvdata(card, machine);
...@@ -348,18 +363,18 @@ static int acp3x_probe(struct platform_device *pdev) ...@@ -348,18 +363,18 @@ static int acp3x_probe(struct platform_device *pdev)
return PTR_ERR(dmic_sel); return PTR_ERR(dmic_sel);
} }
ret = devm_snd_soc_register_card(&pdev->dev, &acp3x_5682); ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret) { if (ret) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"devm_snd_soc_register_card(%s) failed: %d\n", "devm_snd_soc_register_card(%s) failed: %d\n",
acp3x_5682.name, ret); card->name, ret);
return ret; return ret;
} }
return 0; return 0;
} }
static const struct acpi_device_id acp3x_audio_acpi_match[] = { static const struct acpi_device_id acp3x_audio_acpi_match[] = {
{ "AMDI5682", 0 }, { "AMDI5682", (unsigned long)&acp3x_5682},
{}, {},
}; };
MODULE_DEVICE_TABLE(acpi, acp3x_audio_acpi_match); MODULE_DEVICE_TABLE(acpi, acp3x_audio_acpi_match);
......
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