ASoC: amd: acp: Add callback for machine driver on ACP

Add method to select and register machine driver for acp platform
based on ACPI ID.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
Link: https://lore.kernel.org/r/20211019070938.5076-4-AjitKumar.Pandey@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Ajit Kumar Pandey 2021-10-19 12:39:33 +05:30 committed by Mark Brown
parent 58c8c8438d
commit e646b51f5d
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
3 changed files with 32 additions and 0 deletions

View File

@ -67,6 +67,27 @@ static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
.periods_max = CAPTURE_MAX_NUM_PERIODS,
};
int acp_machine_select(struct acp_dev_data *adata)
{
struct snd_soc_acpi_mach *mach;
int size;
size = sizeof(*adata->machines);
mach = snd_soc_acpi_find_machine(adata->machines);
if (!mach) {
dev_err(adata->dev, "warning: No matching ASoC machine driver found\n");
return -EINVAL;
}
adata->mach_dev = platform_device_register_data(adata->dev, mach->drv_name,
PLATFORM_DEVID_NONE, mach, size);
if (!adata->mach_dev)
dev_warn(adata->dev, "Unable to register Machine device\n");
return 0;
}
EXPORT_SYMBOL_NS_GPL(acp_machine_select, SND_SOC_ACP_COMMON);
static irqreturn_t i2s_irq_handler(int irq, void *data)
{
struct acp_dev_data *adata = data;
@ -283,6 +304,8 @@ int acp_platform_unregister(struct device *dev)
{
struct acp_dev_data *adata = dev_get_drvdata(dev);
if (adata->mach_dev)
platform_device_unregister(adata->mach_dev);
return 0;
}
EXPORT_SYMBOL_NS_GPL(acp_platform_unregister, SND_SOC_ACP_COMMON);

View File

@ -111,6 +111,9 @@ static int renoir_audio_probe(struct platform_device *pdev)
adata->dai_driver = acp_renoir_dai;
adata->num_dai = ARRAY_SIZE(acp_renoir_dai);
adata->machines = snd_soc_acpi_amd_acp_machines;
acp_machine_select(adata);
dev_set_drvdata(dev, adata);
acp_platform_register(dev);

View File

@ -90,6 +90,9 @@ struct acp_dev_data {
int num_dai;
struct acp_stream *stream[ACP_MAX_STREAM];
struct snd_soc_acpi_mach *machines;
struct platform_device *mach_dev;
};
extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops;
@ -98,6 +101,9 @@ int asoc_acp_i2s_probe(struct snd_soc_dai *dai);
int acp_platform_register(struct device *dev);
int acp_platform_unregister(struct device *dev);
int acp_machine_select(struct acp_dev_data *adata);
extern struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[];
static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int direction)
{
u64 byte_count, low = 0, high = 0;