diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-04-26 16:59:21 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-04-26 16:59:21 +0200 |
commit | 0301201b7181a927b59421097a01ee98683aa67c (patch) | |
tree | 74b525a64009c7f2770438e01e87d0111c354b86 /sound/soc/sof | |
parent | 1c98f574403dbcf2eb832d5535a10d967333ef2d (diff) | |
parent | ffc9841d5200a484ea0ecc645157b4d7b873f3a6 (diff) | |
download | linux-0301201b7181a927b59421097a01ee98683aa67c.tar.bz2 |
Merge tag 'asoc-v5.13' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v5.13
A lot of changes here for quite a quiet release in subsystem terms -
there's been a lot of fixes and cleanups all over the subsystem both
from generic work and from people working on specific drivers.
- More cleanup and consolidation work in the core and the generic card
drivers from Morimoto-san.
- Lots of cppcheck fixes for Pierre-Louis Brossart.
- New drivers for Freescale i.MX DMA over rpmsg, Mediatek MT6358
accessory detection, and Realtek RT1019, RT1316, RT711 and RT715.
Diffstat (limited to 'sound/soc/sof')
-rw-r--r-- | sound/soc/sof/Kconfig | 11 | ||||
-rw-r--r-- | sound/soc/sof/core.c | 14 | ||||
-rw-r--r-- | sound/soc/sof/debug.c | 21 | ||||
-rw-r--r-- | sound/soc/sof/intel/Kconfig | 2 | ||||
-rw-r--r-- | sound/soc/sof/intel/bdw.c | 8 | ||||
-rw-r--r-- | sound/soc/sof/intel/byt.c | 22 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda-dai.c | 44 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda-dsp.c | 11 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda.c | 10 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda.h | 2 | ||||
-rw-r--r-- | sound/soc/sof/intel/pci-tgl.c | 20 | ||||
-rw-r--r-- | sound/soc/sof/intel/tgl.c | 2 | ||||
-rw-r--r-- | sound/soc/sof/nocodec.c | 39 | ||||
-rw-r--r-- | sound/soc/sof/ops.h | 6 | ||||
-rw-r--r-- | sound/soc/sof/pcm.c | 38 | ||||
-rw-r--r-- | sound/soc/sof/sof-acpi-dev.c | 18 | ||||
-rw-r--r-- | sound/soc/sof/sof-audio.c | 63 | ||||
-rw-r--r-- | sound/soc/sof/sof-audio.h | 2 | ||||
-rw-r--r-- | sound/soc/sof/sof-of-dev.c | 18 | ||||
-rw-r--r-- | sound/soc/sof/sof-pci-dev.c | 20 | ||||
-rw-r--r-- | sound/soc/sof/sof-priv.h | 2 | ||||
-rw-r--r-- | sound/soc/sof/topology.c | 250 |
22 files changed, 349 insertions, 274 deletions
diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 8dfc165c3690..cd659493b5df 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -68,6 +68,17 @@ config SND_SOC_SOF_DEVELOPER_SUPPORT if SND_SOC_SOF_DEVELOPER_SUPPORT +config SND_SOC_SOF_FORCE_PROBE_WORKQUEUE + bool "SOF force probe workqueue" + select SND_SOC_SOF_PROBE_WORK_QUEUE + help + This option forces the use of a probe workqueue, which is only used + when HDaudio is enabled due to module dependencies. Forcing this + option is intended for debug only, but this should not add any + functional issues in nominal cases. + Say Y if you are involved in SOF development and need this option. + If not, select N. + config SND_SOC_SOF_NOCODEC tristate diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 4a3d522f612b..3e4dd4a86363 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -154,7 +154,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) if (ret < 0) { dev_err(sdev->dev, "error: failed to get machine info %d\n", ret); - goto dbg_err; + goto dsp_err; } /* set up platform component driver */ @@ -232,8 +232,11 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) } ret = snd_sof_machine_register(sdev, plat_data); - if (ret < 0) + if (ret < 0) { + dev_err(sdev->dev, + "error: failed to register machine driver %d\n", ret); goto fw_trace_err; + } /* * Some platforms in SOF, ex: BYT, may not have their platform PM @@ -257,8 +260,9 @@ fw_run_err: fw_load_err: snd_sof_ipc_free(sdev); ipc_err: - snd_sof_free_debug(sdev); dbg_err: + snd_sof_free_debug(sdev); +dsp_err: snd_sof_remove(sdev); /* all resources freed, update state to match */ @@ -308,8 +312,10 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) !sof_ops(sdev)->block_read || !sof_ops(sdev)->block_write || !sof_ops(sdev)->send_msg || !sof_ops(sdev)->load_firmware || !sof_ops(sdev)->ipc_msg_data || !sof_ops(sdev)->ipc_pcm_params || - !sof_ops(sdev)->fw_ready) + !sof_ops(sdev)->fw_ready) { + dev_err(dev, "error: missing mandatory ops\n"); return -EINVAL; + } INIT_LIST_HEAD(&sdev->pcm_list); INIT_LIST_HEAD(&sdev->kcontrol_list); diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c index 715a374b33cf..a51a928ea40a 100644 --- a/sound/soc/sof/debug.c +++ b/sound/soc/sof/debug.c @@ -451,8 +451,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, dentry = file->f_path.dentry; if ((!strcmp(dentry->d_name.name, "ipc_flood_count") || - !strcmp(dentry->d_name.name, "ipc_flood_duration_ms")) && - dfse->cache_buf) { + !strcmp(dentry->d_name.name, "ipc_flood_duration_ms"))) { if (*ppos) return 0; @@ -609,14 +608,16 @@ int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev, dfse->sdev = sdev; #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST) - /* - * cache_buf is unused for SOF_DFSENTRY_TYPE_BUF debugfs entries. - * So, use it to save the results of the last IPC flood test. - */ - dfse->cache_buf = devm_kzalloc(sdev->dev, IPC_FLOOD_TEST_RESULT_LEN, - GFP_KERNEL); - if (!dfse->cache_buf) - return -ENOMEM; + if (!strncmp(name, "ipc_flood", strlen("ipc_flood"))) { + /* + * cache_buf is unused for SOF_DFSENTRY_TYPE_BUF debugfs entries. + * So, use it to save the results of the last IPC flood test. + */ + dfse->cache_buf = devm_kzalloc(sdev->dev, IPC_FLOOD_TEST_RESULT_LEN, + GFP_KERNEL); + if (!dfse->cache_buf) + return -ENOMEM; + } #endif debugfs_create_file(name, mode, sdev->debugfs_root, dfse, diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig index da1c396f529d..4bce89b5ea40 100644 --- a/sound/soc/sof/intel/Kconfig +++ b/sound/soc/sof/intel/Kconfig @@ -293,6 +293,6 @@ config SND_SOC_SOF_INTEL_SOUNDWIRE Say Y if you want to enable SoundWire links with SOF. If unsure select "N". -endif ## SND_SOC_SOF_INTEL_PCI +endif ## SND_SOC_SOF_PCI endif ## SND_SOC_SOF_INTEL_TOPLEVEL diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index fd5ae628732d..89a6c1f04a55 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -559,12 +559,16 @@ static void bdw_machine_select(struct snd_sof_dev *sdev) } static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach, - struct device *dev) + struct snd_sof_dev *sdev) { + struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_dev_desc *desc = pdata->desc; struct snd_soc_acpi_mach_params *mach_params; mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; - mach_params->platform = dev_name(dev); + mach_params->platform = dev_name(sdev->dev); + mach_params->num_dai_drivers = desc->ops->num_drv; + mach_params->dai_drivers = desc->ops->drv; } /* Broadwell DAIs */ diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index 2846fdec9d95..d9803e2ba67f 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -427,15 +427,6 @@ static void byt_machine_select(struct snd_sof_dev *sdev) sof_pdata->machine = mach; } -static void byt_set_mach_params(const struct snd_soc_acpi_mach *mach, - struct device *dev) -{ - struct snd_soc_acpi_mach_params *mach_params; - - mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; - mach_params->platform = dev_name(dev); -} - /* Baytrail DAIs */ static struct snd_soc_dai_driver byt_dai[] = { { @@ -506,6 +497,19 @@ static struct snd_soc_dai_driver byt_dai[] = { }, }; +static void byt_set_mach_params(const struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_dev_desc *desc = pdata->desc; + struct snd_soc_acpi_mach_params *mach_params; + + mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; + mach_params->platform = dev_name(sdev->dev); + mach_params->num_dai_drivers = desc->ops->num_drv; + mach_params->dai_drivers = desc->ops->drv; +} + /* * Probe and remove. */ diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index c6cb8c212eca..8d7bab433fb3 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -414,6 +414,44 @@ static struct snd_soc_cdai_ops sof_probe_compr_ops = { #endif #endif +static int ssp_dai_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); + struct sof_ipc_dai_config *config; + struct snd_sof_dai *sof_dai; + struct sof_ipc_reply reply; + int ret; + + list_for_each_entry(sof_dai, &sdev->dai_list, list) { + if (!sof_dai->cpu_dai_name || !sof_dai->dai_config) + continue; + + if (!strcmp(dai->name, sof_dai->cpu_dai_name) && + substream->stream == sof_dai->comp_dai.direction) { + config = &sof_dai->dai_config[sof_dai->current_config]; + + /* send IPC */ + ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, + config->hdr.size, &reply, sizeof(reply)); + + if (ret < 0) + dev_err(sdev->dev, "error: failed to set DAI config for %s\n", + sof_dai->name); + return ret; + } + } + + return 0; +} + +static const struct snd_soc_dai_ops ssp_dai_ops = { + .hw_params = ssp_dai_hw_params, +}; + /* * common dai driver for skl+ platforms. * some products who use this DAI array only physically have a subset of @@ -422,6 +460,7 @@ static struct snd_soc_cdai_ops sof_probe_compr_ops = { struct snd_soc_dai_driver skl_dai[] = { { .name = "SSP0 Pin", + .ops = &ssp_dai_ops, .playback = { .channels_min = 1, .channels_max = 8, @@ -433,6 +472,7 @@ struct snd_soc_dai_driver skl_dai[] = { }, { .name = "SSP1 Pin", + .ops = &ssp_dai_ops, .playback = { .channels_min = 1, .channels_max = 8, @@ -444,6 +484,7 @@ struct snd_soc_dai_driver skl_dai[] = { }, { .name = "SSP2 Pin", + .ops = &ssp_dai_ops, .playback = { .channels_min = 1, .channels_max = 8, @@ -455,6 +496,7 @@ struct snd_soc_dai_driver skl_dai[] = { }, { .name = "SSP3 Pin", + .ops = &ssp_dai_ops, .playback = { .channels_min = 1, .channels_max = 8, @@ -466,6 +508,7 @@ struct snd_soc_dai_driver skl_dai[] = { }, { .name = "SSP4 Pin", + .ops = &ssp_dai_ops, .playback = { .channels_min = 1, .channels_max = 8, @@ -477,6 +520,7 @@ struct snd_soc_dai_driver skl_dai[] = { }, { .name = "SSP5 Pin", + .ops = &ssp_dai_ops, .playback = { .channels_min = 1, .channels_max = 8, diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index 736a54beca23..623cf291e207 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -685,7 +685,7 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) if (ret < 0) { dev_err(sdev->dev, "error: failed to start controller after resume\n"); - return ret; + goto cleanup; } #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) @@ -711,6 +711,10 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) hda_dsp_ctrl_ppcap_enable(sdev, true); hda_dsp_ctrl_ppcap_int_enable(sdev, true); +cleanup: + /* display codec can powered off after controller init */ + hda_codec_i915_display_power(sdev, false); + return 0; } @@ -730,8 +734,6 @@ int hda_dsp_resume(struct snd_sof_dev *sdev) /* resume from D0I3 */ if (sdev->dsp_power_state.state == SOF_DSP_PM_D0) { - hda_codec_i915_display_power(sdev, true); - #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) /* power up links that were active before suspend */ list_for_each_entry(hlink, &bus->hlink_list, list) { @@ -842,9 +844,6 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) cancel_delayed_work_sync(&hda->d0i3_work); if (target_state == SOF_DSP_PM_D0) { - /* we can't keep a wakeref to display driver at suspend */ - hda_codec_i915_display_power(sdev, false); - /* Set DSP power state */ ret = snd_sof_dsp_set_power_state(sdev, &target_dsp_state); if (ret < 0) { diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 0c096db07322..b00e8fcb2312 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -616,8 +616,6 @@ static int hda_init_caps(struct snd_sof_dev *sdev) u32 link_mask; int ret = 0; - device_disable_async_suspend(bus->dev); - /* check if dsp is there */ if (bus->ppcap) dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); @@ -1215,12 +1213,16 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev) #endif void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, - struct device *dev) + struct snd_sof_dev *sdev) { + struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_dev_desc *desc = pdata->desc; struct snd_soc_acpi_mach_params *mach_params; mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; - mach_params->platform = dev_name(dev); + mach_params->platform = dev_name(sdev->dev); + mach_params->num_dai_drivers = desc->ops->num_drv; + mach_params->dai_drivers = desc->ops->drv; } void hda_machine_select(struct snd_sof_dev *sdev) diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index ae80725b0e33..4d44f8910393 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -763,7 +763,7 @@ extern const struct sof_intel_dsp_desc adls_chip_info; /* machine driver select */ void hda_machine_select(struct snd_sof_dev *sdev); void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, - struct device *dev); + struct snd_sof_dev *sdev); /* PCI driver selection and probe */ int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id); diff --git a/sound/soc/sof/intel/pci-tgl.c b/sound/soc/sof/intel/pci-tgl.c index 38bc353f7313..88c3bf404dd7 100644 --- a/sound/soc/sof/intel/pci-tgl.c +++ b/sound/soc/sof/intel/pci-tgl.c @@ -39,6 +39,7 @@ static const struct sof_dev_desc tgl_desc = { static const struct sof_dev_desc tglh_desc = { .machines = snd_soc_acpi_intel_tgl_machines, .alt_machines = snd_soc_acpi_intel_tgl_sdw_machines, + .use_acpi_target_states = true, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, @@ -71,6 +72,7 @@ static const struct sof_dev_desc ehl_desc = { static const struct sof_dev_desc adls_desc = { .machines = snd_soc_acpi_intel_adl_machines, .alt_machines = snd_soc_acpi_intel_adl_sdw_machines, + .use_acpi_target_states = true, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, @@ -84,6 +86,22 @@ static const struct sof_dev_desc adls_desc = { .ops = &sof_tgl_ops, }; +static const struct sof_dev_desc adl_desc = { + .machines = snd_soc_acpi_intel_adl_machines, + .alt_machines = snd_soc_acpi_intel_adl_sdw_machines, + .resindex_lpe_base = 0, + .resindex_pcicfg_base = -1, + .resindex_imr_base = -1, + .irqindex_host_ipc = -1, + .resindex_dma_base = -1, + .chip_info = &tgl_chip_info, + .default_fw_path = "intel/sof", + .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-adl.ri", + .nocodec_tplg_filename = "sof-adl-nocodec.tplg", + .ops = &sof_tgl_ops, +}; + /* PCI IDs */ static const struct pci_device_id sof_pci_ids[] = { { PCI_DEVICE(0x8086, 0xa0c8), /* TGL-LP */ @@ -97,7 +115,7 @@ static const struct pci_device_id sof_pci_ids[] = { { PCI_DEVICE(0x8086, 0x7ad0), /* ADL-S */ .driver_data = (unsigned long)&adls_desc}, { PCI_DEVICE(0x8086, 0x51c8), /* ADL-P */ - .driver_data = (unsigned long)&tgl_desc}, + .driver_data = (unsigned long)&adl_desc}, { 0, } }; MODULE_DEVICE_TABLE(pci, sof_pci_ids); diff --git a/sound/soc/sof/intel/tgl.c b/sound/soc/sof/intel/tgl.c index 54ba1b88ba86..2ed788304414 100644 --- a/sound/soc/sof/intel/tgl.c +++ b/sound/soc/sof/intel/tgl.c @@ -125,7 +125,7 @@ const struct snd_sof_dsp_ops sof_tgl_ops = { EXPORT_SYMBOL_NS(sof_tgl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc tgl_chip_info = { - /* Tigerlake */ + /* Tigerlake , Alderlake */ .cores_num = 4, .init_core_mask = 1, .host_managed_cores_mask = BIT(0), diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c index 3b9bb2e83a86..356497fe4f4c 100644 --- a/sound/soc/sof/nocodec.c +++ b/sound/soc/sof/nocodec.c @@ -20,16 +20,14 @@ static struct snd_soc_card sof_nocodec_card = { }; static int sof_nocodec_bes_setup(struct device *dev, - const struct snd_sof_dsp_ops *ops, + struct snd_soc_dai_driver *drv, struct snd_soc_dai_link *links, - int link_num, struct snd_soc_card *card, - int (*pcm_dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params)) + int link_num, struct snd_soc_card *card) { struct snd_soc_dai_link_component *dlc; int i; - if (!ops || !links || !card) + if (!drv || !links || !card) return -EINVAL; /* set up BE dai_links */ @@ -55,16 +53,16 @@ static int sof_nocodec_bes_setup(struct device *dev, links[i].id = i; links[i].no_pcm = 1; - links[i].cpus->dai_name = ops->drv[i].name; - links[i].platforms->name = dev_name(dev); + links[i].cpus->dai_name = drv[i].name; + links[i].platforms->name = dev_name(dev->parent); links[i].codecs->dai_name = "snd-soc-dummy-dai"; links[i].codecs->name = "snd-soc-dummy"; - if (ops->drv[i].playback.channels_min) + if (drv[i].playback.channels_min) links[i].dpcm_playback = 1; - if (ops->drv[i].capture.channels_min) + if (drv[i].capture.channels_min) links[i].dpcm_capture = 1; - links[i].be_hw_params_fixup = pcm_dai_link_fixup; + links[i].be_hw_params_fixup = sof_pcm_dai_link_fixup; } card->dai_link = links; @@ -73,29 +71,34 @@ static int sof_nocodec_bes_setup(struct device *dev, return 0; } -int sof_nocodec_setup(struct device *dev, const struct snd_sof_dsp_ops *ops, - int (*pcm_dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params)) +static int sof_nocodec_setup(struct device *dev, + u32 num_dai_drivers, + struct snd_soc_dai_driver *dai_drivers) { struct snd_soc_dai_link *links; /* create dummy BE dai_links */ - links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * - ops->num_drv, GFP_KERNEL); + links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * num_dai_drivers, GFP_KERNEL); if (!links) return -ENOMEM; - return sof_nocodec_bes_setup(dev, ops, links, ops->num_drv, - &sof_nocodec_card, pcm_dai_link_fixup); + return sof_nocodec_bes_setup(dev, dai_drivers, links, num_dai_drivers, &sof_nocodec_card); } -EXPORT_SYMBOL(sof_nocodec_setup); static int sof_nocodec_probe(struct platform_device *pdev) { struct snd_soc_card *card = &sof_nocodec_card; + struct snd_soc_acpi_mach *mach; + int ret; card->dev = &pdev->dev; card->topology_shortname_created = true; + mach = pdev->dev.platform_data; + + ret = sof_nocodec_setup(card->dev, mach->mach_params.num_dai_drivers, + mach->mach_params.dai_drivers); + if (ret < 0) + return ret; return devm_snd_soc_register_card(&pdev->dev, card); } diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index 5099ad03df72..323a0b3f561b 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -497,12 +497,10 @@ snd_sof_machine_select(struct snd_sof_dev *sdev) static inline void snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach, - struct device *dev) + struct snd_sof_dev *sdev) { - struct snd_sof_dev *sdev = dev_get_drvdata(dev); - if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params) - sof_ops(sdev)->set_mach_params(mach, dev); + sof_ops(sdev)->set_mach_params(mach, sdev); } static inline const struct snd_sof_dsp_ops diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 61c3fe17342d..9893b182da43 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -619,6 +619,31 @@ capture: return 0; } +static void ssp_dai_config_pcm_params_match(struct snd_sof_dev *sdev, const char *link_name, + struct snd_pcm_hw_params *params) +{ + struct sof_ipc_dai_config *config; + struct snd_sof_dai *dai; + int i; + + /* + * Search for all matching DAIs as we can have both playback and capture DAI + * associated with the same link. + */ + list_for_each_entry(dai, &sdev->dai_list, list) { + if (!dai->name || strcmp(link_name, dai->name)) + continue; + for (i = 0; i < dai->number_configs; i++) { + config = &dai->dai_config[i]; + if (config->ssp.fsync_rate == params_rate(params)) { + dev_dbg(sdev->dev, "DAI config %d matches pcm hw params\n", i); + dai->current_config = i; + break; + } + } + } +} + /* fixup the BE DAI link to match any values from topology */ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -631,6 +656,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); struct snd_sof_dai *dai = snd_sof_find_dai(component, (char *)rtd->dai_link->name); + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_soc_dpcm *dpcm; /* no topology exists for this BE, try a common configuration */ @@ -673,10 +699,13 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa /* read rate and channels from topology */ switch (dai->dai_config->type) { case SOF_DAI_INTEL_SSP: - rate->min = dai->dai_config->ssp.fsync_rate; - rate->max = dai->dai_config->ssp.fsync_rate; - channels->min = dai->dai_config->ssp.tdm_slots; - channels->max = dai->dai_config->ssp.tdm_slots; + /* search for config to pcm params match, if not found use default */ + ssp_dai_config_pcm_params_match(sdev, (char *)rtd->dai_link->name, params); + + rate->min = dai->dai_config[dai->current_config].ssp.fsync_rate; + rate->max = dai->dai_config[dai->current_config].ssp.fsync_rate; + channels->min = dai->dai_config[dai->current_config].ssp.tdm_slots; + channels->max = dai->dai_config[dai->current_config].ssp.tdm_slots; dev_dbg(component->dev, "rate_min: %d rate_max: %d\n", rate->min, rate->max); @@ -746,6 +775,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa return 0; } +EXPORT_SYMBOL(sof_pcm_dai_link_fixup); static int sof_pcm_probe(struct snd_soc_component *component) { diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 1fec0420f662..7fbf09f9f17e 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -61,7 +61,6 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc struct device *dev = &pdev->dev; struct snd_sof_pdata *sof_pdata; const struct snd_sof_dsp_ops *ops; - int ret; dev_dbg(dev, "ACPI DSP detected"); @@ -93,22 +92,11 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc sof_pdata->tplg_filename_prefix = sof_pdata->desc->default_tplg_path; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) - /* set callback to enable runtime_pm */ + /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_acpi_probe_complete; -#endif - /* call sof helper for DSP hardware probe */ - ret = snd_sof_device_probe(dev, sof_pdata); - if (ret) { - dev_err(dev, "error: failed to probe DSP hardware!\n"); - return ret; - } -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) - sof_acpi_probe_complete(dev); -#endif - - return ret; + /* call sof helper for DSP hardware probe */ + return snd_sof_device_probe(dev, sof_pdata); } EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_ACPI_DEV); diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 3277489fee5e..510883cd9107 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -267,7 +267,7 @@ int sof_restore_pipelines(struct device *dev) /* restore dai links */ list_for_each_entry_reverse(dai, &sdev->dai_list, list) { struct sof_ipc_reply reply; - struct sof_ipc_dai_config *config = dai->dai_config; + struct sof_ipc_dai_config *config = &dai->dai_config[dai->current_config]; if (!config) { dev_err(dev, "error: no config for DAI %s\n", @@ -434,6 +434,33 @@ struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp, } /* + * Helper to get SSP MCLK from a pcm_runtime. + * Return 0 if not exist. + */ +int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); + struct snd_sof_dai *dai = + snd_sof_find_dai(component, (char *)rtd->dai_link->name); + + /* use the tplg configured mclk if existed */ + if (!dai || !dai->dai_config) + return 0; + + switch (dai->dai_config->type) { + case SOF_DAI_INTEL_SSP: + return dai->dai_config->ssp.mclk_rate; + default: + /* not yet implemented for platforms other than the above */ + dev_err(rtd->dev, "mclk for dai_config->type %d not supported yet!\n", + dai->dai_config->type); + return -EINVAL; + } +} +EXPORT_SYMBOL(sof_dai_get_mclk); + +/* * SOF Driver enumeration. */ int sof_machine_check(struct snd_sof_dev *sdev) @@ -441,24 +468,24 @@ int sof_machine_check(struct snd_sof_dev *sdev) struct snd_sof_pdata *sof_pdata = sdev->pdata; const struct sof_dev_desc *desc = sof_pdata->desc; struct snd_soc_acpi_mach *mach; - int ret; -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) + if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) { - /* find machine */ - snd_sof_machine_select(sdev); - if (sof_pdata->machine) { - snd_sof_set_mach_params(sof_pdata->machine, sdev->dev); - return 0; + /* find machine */ + snd_sof_machine_select(sdev); + if (sof_pdata->machine) { + snd_sof_set_mach_params(sof_pdata->machine, sdev); + return 0; + } + + if (!IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)) { + dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); + return -ENODEV; + } + } else { + dev_warn(sdev->dev, "Force to use nocodec mode\n"); } -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) - dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); - return -ENODEV; -#endif -#else - dev_warn(sdev->dev, "Force to use nocodec mode\n"); -#endif /* select nocodec mode */ dev_warn(sdev->dev, "Using nocodec machine driver\n"); mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); @@ -468,12 +495,8 @@ int sof_machine_check(struct snd_sof_dev *sdev) mach->drv_name = "sof-nocodec"; sof_pdata->tplg_filename = desc->nocodec_tplg_filename; - ret = sof_nocodec_setup(sdev->dev, desc->ops, sof_pcm_dai_link_fixup); - if (ret < 0) - return ret; - sof_pdata->machine = mach; - snd_sof_set_mach_params(sof_pdata->machine, sdev->dev); + snd_sof_set_mach_params(sof_pdata->machine, sdev); return 0; } diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index dc930fc2f4b5..dc274e63ed9a 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -112,6 +112,8 @@ struct snd_sof_dai { const char *cpu_dai_name; struct sof_ipc_comp_dai comp_dai; + int number_configs; + int current_config; struct sof_ipc_dai_config *dai_config; struct list_head list; /* list in sdev dai list */ }; diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 85ff0db88eb7..c9c70645b377 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -71,7 +71,6 @@ static int sof_of_probe(struct platform_device *pdev) const struct sof_dev_desc *desc; struct snd_sof_pdata *sof_pdata; const struct snd_sof_dsp_ops *ops; - int ret; dev_info(&pdev->dev, "DT DSP detected"); @@ -98,22 +97,11 @@ static int sof_of_probe(struct platform_device *pdev) sof_pdata->fw_filename_prefix = sof_pdata->desc->default_fw_path; sof_pdata->tplg_filename_prefix = sof_pdata->desc->default_tplg_path; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) - /* set callback to enable runtime_pm */ + /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_of_probe_complete; -#endif - /* call sof helper for DSP hardware probe */ - ret = snd_sof_device_probe(dev, sof_pdata); - if (ret) { - dev_err(dev, "error: failed to probe DSP hardware\n"); - return ret; - } - -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) - sof_of_probe_complete(dev); -#endif - return ret; + /* call sof helper for DSP hardware probe */ + return snd_sof_device_probe(dev, sof_pdata); } static int sof_of_remove(struct platform_device *pdev) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index b842a414e1df..3489dc1b48f6 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -184,25 +184,13 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) if (sof_override_tplg_name) sof_pdata->tplg_filename = sof_override_tplg_name; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) - /* set callback to enable runtime_pm */ + /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_pci_probe_complete; -#endif + /* call sof helper for DSP hardware probe */ ret = snd_sof_device_probe(dev, sof_pdata); - if (ret) { - dev_err(dev, "error: failed to probe DSP hardware!\n"); - goto release_regions; - } - -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) - sof_pci_probe_complete(dev); -#endif - - return ret; - -release_regions: - pci_release_regions(pci); + if (ret) + pci_release_regions(pci); return ret; } diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index ad0d7ba2708c..fd8423172d8f 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -259,7 +259,7 @@ struct snd_sof_dsp_ops { void *pdata); /* optional */ void (*machine_select)(struct snd_sof_dev *sdev); /* optional */ void (*set_mach_params)(const struct snd_soc_acpi_mach *mach, - struct device *dev); /* optional */ + struct snd_sof_dev *sdev); /* optional */ /* DAI ops */ struct snd_soc_dai_driver *drv; diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 10f99620eb31..59abcfc9bd55 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2811,12 +2811,14 @@ static void sof_dai_set_format(struct snd_soc_tplg_hw_config *hw_config, * name. Note that the function can only be used for the case that all DAIs * have a common DAI config for now. */ -static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, - struct snd_soc_dai_link *link, - struct sof_ipc_dai_config *config) +static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size, + struct snd_soc_dai_link *link, + struct sof_ipc_dai_config *config, + int num_conf, int curr_conf) { struct snd_sof_dai *dai; int found = 0; + int i; list_for_each_entry(dai, &sdev->dai_list, list) { if (!dai->name) @@ -2832,19 +2834,27 @@ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, * dai config's dai_index match to the component's * dai_index. */ - config->dai_index = dai->comp_dai.dai_index; + for (i = 0; i < num_conf; i++) + config[i].dai_index = dai->comp_dai.dai_index; + dev_dbg(sdev->dev, "set DAI config for %s index %d\n", + dai->name, config[curr_conf].dai_index); /* send message to DSP */ ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, size, + config[curr_conf].hdr.cmd, + &config[curr_conf], size, &reply, sizeof(reply)); if (ret < 0) { - dev_err(sdev->dev, "error: failed to set DAI config for %s index %d\n", - dai->name, config->dai_index); + dev_err(sdev->dev, + "error: failed to set DAI config for %s index %d\n", + dai->name, config[curr_conf].dai_index); return ret; } - dai->dai_config = kmemdup(config, size, GFP_KERNEL); + + dai->number_configs = num_conf; + dai->current_config = curr_conf; + dai->dai_config = kmemdup(config, size * num_conf, GFP_KERNEL); if (!dai->dai_config) return -ENOMEM; @@ -2868,64 +2878,81 @@ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, return 0; } +static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, + struct snd_soc_dai_link *link, + struct sof_ipc_dai_config *config) +{ + return sof_set_dai_config_multi(sdev, size, link, config, 1, 0); +} + static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg, struct snd_soc_tplg_hw_config *hw_config, - struct sof_ipc_dai_config *config) + struct sof_ipc_dai_config *config, int curr_conf) { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; + int num_conf = le32_to_cpu(cfg->num_hw_configs); u32 size = sizeof(*config); int ret; + int i; - /* handle master/slave and inverted clocks */ - sof_dai_set_format(hw_config, config); - - /* init IPC */ - memset(&config->ssp, 0, sizeof(struct sof_ipc_dai_ssp_params)); - config->hdr.size = size; + /* + * Parse common data, we should have 1 common data per hw_config. + */ + ret = sof_parse_token_sets(scomp, &config->ssp, ssp_tokens, + ARRAY_SIZE(ssp_tokens), private->array, + le32_to_cpu(private->size), + num_conf, size); - ret = sof_parse_tokens(scomp, &config->ssp, ssp_tokens, - ARRAY_SIZE(ssp_tokens), private->array, - le32_to_cpu(private->size)); if (ret != 0) { dev_err(scomp->dev, "error: parse ssp tokens failed %d\n", le32_to_cpu(private->size)); return ret; } - config->ssp.mclk_rate = le32_to_cpu(hw_config->mclk_rate); - config->ssp.bclk_rate = le32_to_cpu(hw_config->bclk_rate); - config->ssp.fsync_rate = le32_to_cpu(hw_config->fsync_rate); - config->ssp.tdm_slots = le32_to_cpu(hw_config->tdm_slots); - config->ssp.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width); - config->ssp.mclk_direction = hw_config->mclk_direction; - config->ssp.rx_slots = le32_to_cpu(hw_config->rx_slots); - config->ssp.tx_slots = le32_to_cpu(hw_config->tx_slots); + /* process all possible hw configs */ + for (i = 0; i < num_conf; i++) { - dev_dbg(scomp->dev, "tplg: config SSP%d fmt 0x%x mclk %d bclk %d fclk %d width (%d)%d slots %d mclk id %d quirks %d\n", - config->dai_index, config->format, - config->ssp.mclk_rate, config->ssp.bclk_rate, - config->ssp.fsync_rate, config->ssp.sample_valid_bits, - config->ssp.tdm_slot_width, config->ssp.tdm_slots, - config->ssp.mclk_id, config->ssp.quirks); - - /* validate SSP fsync rate and channel count */ - if (config->ssp.fsync_rate < 8000 || config->ssp.fsync_rate > 192000) { - dev_err(scomp->dev, "error: invalid fsync rate for SSP%d\n", - config->dai_index); - return -EINVAL; - } + /* handle master/slave and inverted clocks */ + sof_dai_set_format(&hw_config[i], &config[i]); - if (config->ssp.tdm_slots < 1 || config->ssp.tdm_slots > 8) { - dev_err(scomp->dev, "error: invalid channel count for SSP%d\n", - config->dai_index); - return -EINVAL; + config[i].hdr.size = size; + + /* copy differentiating hw configs to ipc structs */ + config[i].ssp.mclk_rate = le32_to_cpu(hw_config[i].mclk_rate); + config[i].ssp.bclk_rate = le32_to_cpu(hw_config[i].bclk_rate); + config[i].ssp.fsync_rate = le32_to_cpu(hw_config[i].fsync_rate); + config[i].ssp.tdm_slots = le32_to_cpu(hw_config[i].tdm_slots); + config[i].ssp.tdm_slot_width = le32_to_cpu(hw_config[i].tdm_slot_width); + config[i].ssp.mclk_direction = hw_config[i].mclk_direction; + config[i].ssp.rx_slots = le32_to_cpu(hw_config[i].rx_slots); + config[i].ssp.tx_slots = le32_to_cpu(hw_config[i].tx_slots); + + dev_dbg(scomp->dev, "tplg: config SSP%d fmt 0x%x mclk %d bclk %d fclk %d width (%d)%d slots %d mclk id %d quirks %d\n", + config[i].dai_index, config[i].format, + config[i].ssp.mclk_rate, config[i].ssp.bclk_rate, + config[i].ssp.fsync_rate, config[i].ssp.sample_valid_bits, + config[i].ssp.tdm_slot_width, config[i].ssp.tdm_slots, + config[i].ssp.mclk_id, config[i].ssp.quirks); + + /* validate SSP fsync rate and channel count */ + if (config[i].ssp.fsync_rate < 8000 || config[i].ssp.fsync_rate > 192000) { + dev_err(scomp->dev, "error: invalid fsync rate for SSP%d\n", + config[i].dai_index); + return -EINVAL; + } + + if (config[i].ssp.tdm_slots < 1 || config[i].ssp.tdm_slots > 8) { + dev_err(scomp->dev, "error: invalid channel count for SSP%d\n", + config[i].dai_index); + return -EINVAL; + } } /* set config for all DAI's with name matching the link name */ - ret = sof_set_dai_config(sdev, size, link, config); + ret = sof_set_dai_config_multi(sdev, size, link, config, num_conf, curr_conf); if (ret < 0) dev_err(scomp->dev, "error: failed to save DAI config for SSP%d\n", config->dai_index); @@ -3216,11 +3243,13 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_soc_tplg_link_config *cfg) { struct snd_soc_tplg_private *private = &cfg->priv; - struct sof_ipc_dai_config config; struct snd_soc_tplg_hw_config *hw_config; - int num_hw_configs; + struct sof_ipc_dai_config common_config; + struct sof_ipc_dai_config *config; + int curr_conf; + int num_conf; int ret; - int i = 0; + int i; if (!link->platforms) { dev_err(scomp->dev, "error: no platforms\n"); @@ -3257,13 +3286,11 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, return -EINVAL; } - /* Send BE DAI link configurations to DSP */ - memset(&config, 0, sizeof(config)); + memset(&common_config, 0, sizeof(common_config)); /* get any common DAI tokens */ - ret = sof_parse_tokens(scomp, &config, dai_link_tokens, - ARRAY_SIZE(dai_link_tokens), private->array, - le32_to_cpu(private->size)); + ret = sof_parse_tokens(scomp, &common_config, dai_link_tokens, ARRAY_SIZE(dai_link_tokens), + private->array, le32_to_cpu(private->size)); if (ret != 0) { dev_err(scomp->dev, "error: parse link tokens failed %d\n", le32_to_cpu(private->size)); @@ -3274,132 +3301,72 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, * DAI links are expected to have at least 1 hw_config. * But some older topologies might have no hw_config for HDA dai links. */ - num_hw_configs = le32_to_cpu(cfg->num_hw_configs); - if (!num_hw_configs) { - if (config.type != SOF_DAI_INTEL_HDA) { + hw_config = cfg->hw_config; + num_conf = le32_to_cpu(cfg->num_hw_configs); + if (!num_conf) { + if (common_config.type != SOF_DAI_INTEL_HDA) { dev_err(scomp->dev, "error: unexpected DAI config count %d!\n", le32_to_cpu(cfg->num_hw_configs)); return -EINVAL; } + num_conf = 1; + curr_conf = 0; } else { dev_dbg(scomp->dev, "tplg: %d hw_configs found, default id: %d!\n", cfg->num_hw_configs, le32_to_cpu(cfg->default_hw_config_id)); - for (i = 0; i < num_hw_configs; i++) { - if (cfg->hw_config[i].id == cfg->default_hw_config_id) + for (curr_conf = 0; curr_conf < num_conf; curr_conf++) { + if (hw_config[curr_conf].id == cfg->default_hw_config_id) break; } - if (i == num_hw_configs) { + if (curr_conf == num_conf) { dev_err(scomp->dev, "error: default hw_config id: %d not found!\n", le32_to_cpu(cfg->default_hw_config_id)); return -EINVAL; } } - /* configure dai IPC message */ - hw_config = &cfg->hw_config[i]; + /* Reserve memory for all hw configs, eventually freed by widget */ + config = kcalloc(num_conf, sizeof(*config), GFP_KERNEL); + if (!config) + return -ENOMEM; - config.hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG; - config.format = le32_to_cpu(hw_config->fmt); + /* Copy common data to all config ipc structs */ + for (i = 0; i < num_conf; i++) { + config[i].hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG; + config[i].format = hw_config[i].fmt; + config[i].type = common_config.type; + config[i].dai_index = common_config.dai_index; + } /* now load DAI specific data and send IPC - type comes from token */ - switch (config.type) { + switch (common_config.type) { case SOF_DAI_INTEL_SSP: - ret = sof_link_ssp_load(scomp, index, link, cfg, hw_config, - &config); + ret = sof_link_ssp_load(scomp, index, link, cfg, hw_config, config, curr_conf); break; case SOF_DAI_INTEL_DMIC: - ret = sof_link_dmic_load(scomp, index, link, cfg, hw_config, - &config); + ret = sof_link_dmic_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; case SOF_DAI_INTEL_HDA: - ret = sof_link_hda_load(scomp, index, link, cfg, hw_config, - &config); + ret = sof_link_hda_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; case SOF_DAI_INTEL_ALH: - ret = sof_link_alh_load(scomp, index, link, cfg, hw_config, - &config); + ret = sof_link_alh_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; case SOF_DAI_IMX_SAI: - ret = sof_link_sai_load(scomp, index, link, cfg, hw_config, - &config); + ret = sof_link_sai_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; case SOF_DAI_IMX_ESAI: - ret = sof_link_esai_load(scomp, index, link, cfg, hw_config, - &config); + ret = sof_link_esai_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; default: - dev_err(scomp->dev, "error: invalid DAI type %d\n", - config.type); + dev_err(scomp->dev, "error: invalid DAI type %d\n", common_config.type); ret = -EINVAL; break; } - if (ret < 0) - return ret; - - return 0; -} - -static int sof_link_hda_unload(struct snd_sof_dev *sdev, - struct snd_soc_dai_link *link) -{ - struct snd_soc_dai *dai; - - dai = snd_soc_find_dai(link->cpus); - if (!dai) { - dev_err(sdev->dev, "error: failed to find dai %s in %s", - link->cpus->dai_name, __func__); - return -EINVAL; - } - - return 0; -} - -static int sof_link_unload(struct snd_soc_component *scomp, - struct snd_soc_dobj *dobj) -{ - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); - struct snd_soc_dai_link *link = - container_of(dobj, struct snd_soc_dai_link, dobj); - - struct snd_sof_dai *sof_dai; - int ret = 0; - - /* only BE link is loaded by sof */ - if (!link->no_pcm) - return 0; - list_for_each_entry(sof_dai, &sdev->dai_list, list) { - if (!sof_dai->name) - continue; - - if (strcmp(link->name, sof_dai->name) == 0) - goto found; - } - - dev_err(scomp->dev, "error: failed to find dai %s in %s", - link->name, __func__); - return -EINVAL; -found: - - switch (sof_dai->dai_config->type) { - case SOF_DAI_INTEL_SSP: - case SOF_DAI_INTEL_DMIC: - case SOF_DAI_INTEL_ALH: - case SOF_DAI_IMX_SAI: - case SOF_DAI_IMX_ESAI: - /* no resource needs to be released for all cases above */ - break; - case SOF_DAI_INTEL_HDA: - ret = sof_link_hda_unload(sdev, link); - break; - default: - dev_err(scomp->dev, "error: invalid DAI type %d\n", - sof_dai->dai_config->type); - ret = -EINVAL; - break; - } + kfree(config); return ret; } @@ -3704,7 +3671,6 @@ static struct snd_soc_tplg_ops sof_tplg_ops = { /* DAI link - used for any driver specific init */ .link_load = sof_link_load, - .link_unload = sof_link_unload, /* completion - called at completion of firmware loading */ .complete = sof_complete, |