diff --git a/include/sound/soc.h b/include/sound/soc.h index 71a745fa8131d4..a120583a82d96f 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -856,6 +856,14 @@ struct snd_soc_component_driver { unsigned int use_pmdown_time:1; /* care pmdown_time at stop */ unsigned int endianness:1; unsigned int non_legacy_dai_naming:1; + + /* this component uses topology and ignore machine driver FEs */ + const char *ignore_machine; + const char *topology_name_prefix; + int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params); + bool use_dai_pcm_id; /* use the DAI link PCM ID as PCM device number */ + int be_pcm_base; /* base device ID for all BE PCMs */ }; struct snd_soc_component { @@ -1017,14 +1025,6 @@ struct snd_soc_platform_driver { /* platform stream compress ops */ const struct snd_compr_ops *compr_ops; - - /* this platform uses topology and ignore machine driver FEs */ - const char *ignore_machine; - const char *topology_name_prefix; - int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params); - bool use_dai_pcm_id; /* use the DAI link PCM ID as PCM device number */ - int be_pcm_base; /* base device ID for all BE PCMs */ }; struct snd_soc_dai_link_component { @@ -1183,6 +1183,7 @@ struct snd_soc_card { struct mutex dapm_mutex; bool instantiated; + bool topology_shortname_created; int (*probe)(struct snd_soc_card *card); int (*late_probe)(struct snd_soc_card *card); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 97e1796c09d8a8..ff05be98ffe730 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1675,6 +1675,8 @@ static int soc_probe_link_dais(struct snd_soc_card *card, { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; int i, ret, num; dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", @@ -1721,18 +1723,23 @@ static int soc_probe_link_dais(struct snd_soc_card *card, soc_dpcm_debugfs_add(rtd); #endif + num = rtd->num; + /* * most drivers will register their PCMs using DAI link ordering but * topology based drivers can use the DAI link id field to set PCM * device number and then use rtd + a base offset of the BEs. */ - if (rtd->platform->driver->use_dai_pcm_id) { + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + if (!component->driver->use_dai_pcm_id) + continue; + if (rtd->dai_link->no_pcm) - num = rtd->platform->driver->be_pcm_base + rtd->num; + num += component->driver->be_pcm_base; else num = rtd->dai_link->id; - } else { - num = rtd->num; } if (cpu_dai->driver->compress_new) { @@ -2095,21 +2102,22 @@ EXPORT_SYMBOL_GPL(snd_soc_set_dmi_name); static void soc_check_tplg_fes(struct snd_soc_card *card) { - struct snd_soc_platform *platform; + struct snd_soc_component *component; + const struct snd_soc_component_driver *comp_drv; struct snd_soc_dai_link *dai_link; int i; - list_for_each_entry(platform, &platform_list, list) { + list_for_each_entry(component, &component_list, list) { - /* does this platform override FEs ? */ - if (!platform->driver->ignore_machine) + /* does this component override FEs ? */ + if (!component->driver->ignore_machine) continue; /* for this machine ? */ - if (!strcmp(platform->driver->ignore_machine, + if (!strcmp(component->driver->ignore_machine, card->dev->driver->name)) goto match; - if (strcmp(platform->driver->ignore_machine, + if (strcmp(component->driver->ignore_machine, dev_name(card->dev))) continue; match: @@ -2127,15 +2135,15 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) dev_info(card->dev, "info: override FE DAI link %s\n", card->dai_link[i].name); - /* override platform */ - dai_link->platform_name = platform->component.name; + /* override platform component */ + dai_link->platform_name = component->name; /* convert non BE into BE */ dai_link->no_pcm = 1; /* override any BE fixups */ dai_link->be_hw_params_fixup = - platform->driver->be_hw_params_fixup; + component->driver->be_hw_params_fixup; /* most BE links don't set stream name, so set it to * dai link name if it's NULL to help bind widgets. @@ -2145,10 +2153,19 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) } /* Inform userspace we are using alternate topology */ - if (platform->driver->topology_name_prefix) { - snprintf(card->topology_shortname, 32, "%s-%s", - platform->driver->topology_name_prefix, - card->name); + if (component->driver->topology_name_prefix) { + + /* topology shortname created ? */ + if (!card->topology_shortname_created) { + comp_drv = component->driver; + + snprintf(card->topology_shortname, 32, "%s-%s", + comp_drv->topology_name_prefix, + card->name); + card->topology_shortname_created = true; + } + + /* use topology shortname */ card->name = card->topology_shortname; } } diff --git a/sound/soc/sof/compressed.c b/sound/soc/sof/compressed.c index 64b35fb0e6e5ed..ca830c216db0a7 100644 --- a/sound/soc/sof/compressed.c +++ b/sound/soc/sof/compressed.c @@ -20,11 +20,15 @@ #include #include "sof-priv.h" +#define DRV_NAME "sof-audio" + static int sof_compressed_open(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; mutex_lock(&spcm->mutex); @@ -36,8 +40,10 @@ static int sof_compressed_open(struct snd_compr_stream *cstream) static int sof_compressed_free(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; mutex_lock(&spcm->mutex); @@ -62,8 +68,10 @@ static int sof_compressed_set_params(struct snd_compr_stream *cstream, struct snd_compr_params *params) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); switch (params->codec.id) { case SND_AUDIOCODEC_VORBIS: @@ -80,8 +88,10 @@ static int sof_compressed_set_params(struct snd_compr_stream *cstream, static int sof_compressed_trigger(struct snd_compr_stream *cstream, int cmd) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; struct sof_ipc_stream stream; struct sof_ipc_reply reply; @@ -118,8 +128,10 @@ static int sof_compressed_pointer(struct snd_compr_stream *cstream, struct snd_compr_tstamp *tstamp) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct sof_ipc_stream_posn posn; struct snd_sof_pcm *spcm = rtd->sof; diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 924220c55b3c6c..e6e40d4e7f3017 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -257,7 +257,6 @@ static int sof_probe(struct platform_device *pdev) /* set up platform component driver */ snd_sof_new_platform_drv(sdev); - snd_sof_new_dai_drv(sdev); /* set default timeouts if none provided */ if (plat_data->desc->ipc_timeout == 0) @@ -307,17 +306,10 @@ static int sof_probe(struct platform_device *pdev) goto fw_run_err; } - /* now register audio DSP platform driver */ - ret = snd_soc_register_platform(&pdev->dev, &sdev->plat_drv); - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to register DSP platform driver %d\n", - ret); - goto fw_run_err; - } - - ret = snd_soc_register_component(&pdev->dev, sdev->cmpnt_drv, - sdev->ops->drv, sdev->ops->num_drv); + /* now register audio DSP platform driver and dai */ + ret = snd_soc_register_component(&pdev->dev, &sdev->plat_drv, + sdev->ops->drv, + sdev->ops->num_drv); if (ret < 0) { dev_err(sdev->dev, "error: failed to register DSP DAI driver %d\n", ret); @@ -361,7 +353,6 @@ static int sof_remove(struct platform_device *pdev) { struct snd_sof_dev *sdev = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_component(&pdev->dev); snd_sof_fw_unload(sdev); snd_sof_ipc_free(sdev); diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index a4a14acaa442c0..4f9be5f8f4cf95 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -29,13 +29,17 @@ #include "sof-priv.h" #include "ops.h" +#define DRV_NAME "sof-audio" + /* Create DMA buffer page table for DSP */ static int create_page_table(struct snd_pcm_substream *substream, unsigned char *dma_area, size_t size) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream); int stream = substream->stream; @@ -50,8 +54,10 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; struct sof_ipc_pcm_params pcm; struct sof_ipc_pcm_params_reply ipc_params_reply; @@ -167,8 +173,10 @@ static int sof_pcm_hw_params(struct snd_pcm_substream *substream, static int sof_pcm_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; struct sof_ipc_stream stream; struct sof_ipc_reply reply; @@ -223,8 +231,10 @@ static int sof_restore_hw_params(struct snd_pcm_substream *substream, static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; struct sof_ipc_stream stream; struct sof_ipc_reply reply; @@ -321,8 +331,10 @@ static int sof_pcm_trigger(struct snd_pcm_substream *substream, int cmd) static snd_pcm_uframes_t sof_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; snd_pcm_uframes_t host = 0, dai = 0; @@ -346,8 +358,10 @@ static int sof_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; struct snd_soc_tplg_stream_caps *caps = &spcm->pcm.caps[substream->stream]; @@ -410,8 +424,10 @@ static int sof_pcm_open(struct snd_pcm_substream *substream) static int sof_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm = rtd->sof; /* nothing todo for BE */ @@ -443,8 +459,10 @@ static struct snd_pcm_ops sof_pcm_ops = { static int sof_pcm_new(struct snd_soc_pcm_runtime *rtd) { + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm; struct snd_pcm *pcm = rtd->pcm; struct snd_soc_tplg_stream_caps *caps; @@ -535,8 +553,10 @@ static void sof_pcm_free(struct snd_pcm *pcm) { struct snd_sof_pcm *spcm; struct snd_soc_pcm_runtime *rtd = pcm->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); spcm = snd_sof_find_spcm_dai(sdev, rtd); if (!spcm) { @@ -563,8 +583,10 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); struct snd_sof_dai *dai = snd_sof_find_dai(sdev, (char *)rtd->dai_link->name); @@ -640,15 +662,15 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } -static int sof_pcm_probe(struct snd_soc_platform *platform) +static int sof_pcm_probe(struct snd_soc_component *component) { struct snd_sof_dev *sdev = - snd_soc_platform_get_drvdata(platform); - struct snd_sof_pdata *plat_data = dev_get_platdata(platform->dev); + snd_soc_component_get_drvdata(component); + struct snd_sof_pdata *plat_data = dev_get_platdata(component->dev); int ret; /* load the default topology */ - sdev->component = &platform->component; + sdev->component = component; ret = snd_sof_load_topology(sdev, plat_data->machine->sof_tplg_filename); if (ret < 0) { @@ -658,30 +680,30 @@ static int sof_pcm_probe(struct snd_soc_platform *platform) } /* enable runtime PM with auto suspend */ - pm_runtime_set_autosuspend_delay(platform->dev, + pm_runtime_set_autosuspend_delay(component->dev, SND_SOF_SUSPEND_DELAY); - pm_runtime_use_autosuspend(platform->dev); - pm_runtime_enable(platform->dev); - pm_runtime_idle(platform->dev); + pm_runtime_use_autosuspend(component->dev); + pm_runtime_enable(component->dev); + pm_runtime_idle(component->dev); + err: return ret; } -static int sof_pcm_remove(struct snd_soc_platform *platform) +static void sof_pcm_remove(struct snd_soc_component *component) { - pm_runtime_disable(platform->dev); - - return 0; + pm_runtime_disable(component->dev); } void snd_sof_new_platform_drv(struct snd_sof_dev *sdev) { - struct snd_soc_platform_driver *pd = &sdev->plat_drv; + struct snd_soc_component_driver *pd = &sdev->plat_drv; struct snd_sof_pdata *plat_data = sdev->pdata; dev_dbg(sdev->dev, "using platform alias %s\n", plat_data->machine->asoc_plat_name); + pd->name = "sof-audio"; pd->probe = sof_pcm_probe; pd->remove = sof_pcm_remove; pd->ops = &sof_pcm_ops; @@ -695,12 +717,3 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev) pd->topology_name_prefix = "sof"; } -static const struct snd_soc_component_driver sof_dai_component = { - .name = "sof-dai", -}; - -void snd_sof_new_dai_drv(struct snd_sof_dev *sdev) -{ - sdev->cmpnt_drv = &sof_dai_component; -} - diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index cb81e4aab9acc9..d9d62461c06d22 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -294,8 +294,7 @@ struct snd_sof_dev { struct pci_dev *pci; /* ASoC components */ - struct snd_soc_platform_driver plat_drv; - const struct snd_soc_component_driver *cmpnt_drv; + struct snd_soc_component_driver plat_drv; /* DSP firmware boot */ wait_queue_head_t boot_wait; @@ -383,7 +382,6 @@ int snd_sof_suspend(struct device *dev); int snd_sof_suspend_late(struct device *dev); void snd_sof_new_platform_drv(struct snd_sof_dev *sdev); -void snd_sof_new_dai_drv(struct snd_sof_dev *sdev); int snd_sof_create_page_table(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,