Skip to content

Commit 0fe4b56

Browse files
Ravulapati Vishnu vardhan raobroonie
authored andcommitted
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: Ravulapati Vishnu vardhan rao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9c04b5a commit 0fe4b56

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

sound/soc/amd/acp3x-rt5682-max9836.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static struct snd_soc_jack pco_jack;
3030
static struct clk *rt5682_dai_wclk;
3131
static struct clk *rt5682_dai_bclk;
3232
static struct gpio_desc *dmic_sel;
33+
void *soc_is_rltk_max(struct device *dev);
3334

3435
static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd)
3536
{
@@ -326,18 +327,32 @@ static struct snd_soc_card acp3x_5682 = {
326327
.num_controls = ARRAY_SIZE(acp3x_5682_mc_controls),
327328
};
328329

330+
void *soc_is_rltk_max(struct device *dev)
331+
{
332+
const struct acpi_device_id *match;
333+
334+
match = acpi_match_device(dev->driver->acpi_match_table, dev);
335+
if (!match)
336+
return NULL;
337+
return (void *)match->driver_data;
338+
}
339+
329340
static int acp3x_probe(struct platform_device *pdev)
330341
{
331342
int ret;
332343
struct snd_soc_card *card;
333344
struct acp3x_platform_info *machine;
345+
struct device *dev = &pdev->dev;
346+
347+
card = (struct snd_soc_card *)soc_is_rltk_max(dev);
348+
if (!card)
349+
return -ENODEV;
334350

335351
machine = devm_kzalloc(&pdev->dev, sizeof(*machine), GFP_KERNEL);
336352
if (!machine)
337353
return -ENOMEM;
338354

339-
card = &acp3x_5682;
340-
acp3x_5682.dev = &pdev->dev;
355+
card->dev = &pdev->dev;
341356
platform_set_drvdata(pdev, card);
342357
snd_soc_card_set_drvdata(card, machine);
343358

@@ -348,18 +363,18 @@ static int acp3x_probe(struct platform_device *pdev)
348363
return PTR_ERR(dmic_sel);
349364
}
350365

351-
ret = devm_snd_soc_register_card(&pdev->dev, &acp3x_5682);
366+
ret = devm_snd_soc_register_card(&pdev->dev, card);
352367
if (ret) {
353368
dev_err(&pdev->dev,
354369
"devm_snd_soc_register_card(%s) failed: %d\n",
355-
acp3x_5682.name, ret);
370+
card->name, ret);
356371
return ret;
357372
}
358373
return 0;
359374
}
360375

361376
static const struct acpi_device_id acp3x_audio_acpi_match[] = {
362-
{ "AMDI5682", 0 },
377+
{ "AMDI5682", (unsigned long)&acp3x_5682},
363378
{},
364379
};
365380
MODULE_DEVICE_TABLE(acpi, acp3x_audio_acpi_match);

0 commit comments

Comments
 (0)