From 639b7e90cf3535409185cf75149af17e75e9a0b9 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 26 Apr 2023 15:47:28 +0300 Subject: [PATCH 01/30] ASoC: SOF: Move sof_of_machine_select() to sof-of-dev.c from sof-audio.c Move the sof_of_machine_select() function to sof-of-dev.c file and provide an inline stub in case of non OF builds. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-audio.c | 22 ---------------------- sound/soc/sof/sof-of-dev.c | 23 +++++++++++++++++++++++ sound/soc/sof/sof-of-dev.h | 9 +++++++++ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 563fe6f7789f73..2198bb8e92c358 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -990,28 +990,6 @@ int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd) } EXPORT_SYMBOL(sof_dai_get_bclk); -static struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) -{ - struct snd_sof_pdata *sof_pdata = sdev->pdata; - const struct sof_dev_desc *desc = sof_pdata->desc; - struct snd_sof_of_mach *mach = desc->of_machines; - - if (!mach) - return NULL; - - for (; mach->compatible; mach++) { - if (of_machine_is_compatible(mach->compatible)) { - sof_pdata->tplg_filename = mach->sof_tplg_filename; - if (mach->fw_filename) - sof_pdata->fw_filename = mach->fw_filename; - - return mach; - } - } - - return NULL; -} - /* * SOF Driver enumeration. */ diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index b0e8bd06f78ae5..70930dbe1d9844 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -41,6 +41,29 @@ static void sof_of_probe_complete(struct device *dev) pm_runtime_enable(dev); } +struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_sof_of_mach *mach = desc->of_machines; + + if (!mach) + return NULL; + + for (; mach->compatible; mach++) { + if (of_machine_is_compatible(mach->compatible)) { + sof_pdata->tplg_filename = mach->sof_tplg_filename; + if (mach->fw_filename) + sof_pdata->fw_filename = mach->fw_filename; + + return mach; + } + } + + return NULL; +} +EXPORT_SYMBOL(sof_of_machine_select); + int sof_of_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; diff --git a/sound/soc/sof/sof-of-dev.h b/sound/soc/sof/sof-of-dev.h index 2948b3a0d9fef9..879ca4edb4272c 100644 --- a/sound/soc/sof/sof-of-dev.h +++ b/sound/soc/sof/sof-of-dev.h @@ -16,6 +16,15 @@ struct snd_sof_of_mach { const char *sof_tplg_filename; }; +#if IS_ENABLED(CONFIG_SND_SOC_SOF_OF_DEV) +struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev); +#else +static inline struct snd_sof_of_mach *sof_of_machine_select(struct snd_sof_dev *sdev) +{ + return NULL; +} +#endif + extern const struct dev_pm_ops sof_of_pm; int sof_of_probe(struct platform_device *pdev); From 145837c6d2d0ee92e267ad546c75e54b013a5b5b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 26 Apr 2023 15:54:01 +0300 Subject: [PATCH 02/30] ASoC: SOF: Move sof_machine_* functions from sof-audio.c to core.c Relocate the machine handling functions from sof-audio.c to core.c to maintain code separation. While doing the move, drop the redundant IS_ERR_OR_NULL(plat_data->pdev_mach) check from sof_machine_unregister() Signed-off-by: Peter Ujfalusi --- sound/soc/sof/core.c | 95 +++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-audio.c | 98 --------------------------------------- sound/soc/sof/sof-priv.h | 2 - 3 files changed, 95 insertions(+), 100 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 2d1616b81485c5..4ee7ee7217b797 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -13,6 +13,7 @@ #include #include #include "sof-priv.h" +#include "sof-of-dev.h" #include "ops.h" #define CREATE_TRACE_POINTS @@ -143,6 +144,66 @@ void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state) } EXPORT_SYMBOL(sof_set_fw_state); +/* SOF Driver enumeration */ +static 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; + + if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) { + const struct snd_sof_of_mach *of_mach; + + if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) && + sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC)) + goto nocodec; + + /* find machine */ + mach = snd_sof_machine_select(sdev); + if (mach) { + sof_pdata->machine = mach; + + if (sof_pdata->subsystem_id_set) { + mach->mach_params.subsystem_vendor = sof_pdata->subsystem_vendor; + mach->mach_params.subsystem_device = sof_pdata->subsystem_device; + mach->mach_params.subsystem_id_set = true; + } + + snd_sof_set_mach_params(mach, sdev); + return 0; + } + + of_mach = sof_of_machine_select(sdev); + if (of_mach) { + sof_pdata->of_machine = of_mach; + 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"); + } + +nocodec: + /* select nocodec mode */ + dev_warn(sdev->dev, "Using nocodec machine driver\n"); + mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); + if (!mach) + return -ENOMEM; + + mach->drv_name = "sof-nocodec"; + if (!sof_pdata->tplg_filename) + sof_pdata->tplg_filename = desc->nocodec_tplg_filename; + + sof_pdata->machine = mach; + snd_sof_set_mach_params(mach, sdev); + + return 0; +} + /* * FW Boot State Transition Diagram * @@ -512,6 +573,40 @@ int snd_sof_device_shutdown(struct device *dev) } EXPORT_SYMBOL(snd_sof_device_shutdown); +/* Machine driver registering and unregistering */ +int sof_machine_register(struct snd_sof_dev *sdev, void *pdata) +{ + struct snd_sof_pdata *plat_data = pdata; + const char *drv_name; + const void *mach; + int size; + + drv_name = plat_data->machine->drv_name; + mach = plat_data->machine; + size = sizeof(*plat_data->machine); + + /* register machine driver, pass machine info as pdata */ + plat_data->pdev_mach = + platform_device_register_data(sdev->dev, drv_name, + PLATFORM_DEVID_NONE, mach, size); + if (IS_ERR(plat_data->pdev_mach)) + return PTR_ERR(plat_data->pdev_mach); + + dev_dbg(sdev->dev, "created machine %s\n", + dev_name(&plat_data->pdev_mach->dev)); + + return 0; +} +EXPORT_SYMBOL(sof_machine_register); + +void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) +{ + struct snd_sof_pdata *plat_data = pdata; + + platform_device_unregister(plat_data->pdev_mach); +} +EXPORT_SYMBOL(sof_machine_unregister); + MODULE_AUTHOR("Liam Girdwood"); MODULE_DESCRIPTION("Sound Open Firmware (SOF) Core"); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 2198bb8e92c358..de40a5e227f4c8 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -11,7 +11,6 @@ #include #include #include "sof-audio.h" -#include "sof-of-dev.h" #include "ops.h" static bool is_virtual_widget(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget, @@ -989,100 +988,3 @@ int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd) return sof_dai_get_clk(rtd, SOF_DAI_CLK_INTEL_SSP_BCLK); } EXPORT_SYMBOL(sof_dai_get_bclk); - -/* - * SOF Driver enumeration. - */ -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; - - if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) { - const struct snd_sof_of_mach *of_mach; - - if (IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT) && - sof_debug_check_flag(SOF_DBG_FORCE_NOCODEC)) - goto nocodec; - - /* find machine */ - mach = snd_sof_machine_select(sdev); - if (mach) { - sof_pdata->machine = mach; - - if (sof_pdata->subsystem_id_set) { - mach->mach_params.subsystem_vendor = sof_pdata->subsystem_vendor; - mach->mach_params.subsystem_device = sof_pdata->subsystem_device; - mach->mach_params.subsystem_id_set = true; - } - - snd_sof_set_mach_params(mach, sdev); - return 0; - } - - of_mach = sof_of_machine_select(sdev); - if (of_mach) { - sof_pdata->of_machine = of_mach; - 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"); - } - -nocodec: - /* select nocodec mode */ - dev_warn(sdev->dev, "Using nocodec machine driver\n"); - mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); - if (!mach) - return -ENOMEM; - - mach->drv_name = "sof-nocodec"; - if (!sof_pdata->tplg_filename) - sof_pdata->tplg_filename = desc->nocodec_tplg_filename; - - sof_pdata->machine = mach; - snd_sof_set_mach_params(mach, sdev); - - return 0; -} -EXPORT_SYMBOL(sof_machine_check); - -int sof_machine_register(struct snd_sof_dev *sdev, void *pdata) -{ - struct snd_sof_pdata *plat_data = pdata; - const char *drv_name; - const void *mach; - int size; - - drv_name = plat_data->machine->drv_name; - mach = plat_data->machine; - size = sizeof(*plat_data->machine); - - /* register machine driver, pass machine info as pdata */ - plat_data->pdev_mach = - platform_device_register_data(sdev->dev, drv_name, - PLATFORM_DEVID_NONE, mach, size); - if (IS_ERR(plat_data->pdev_mach)) - return PTR_ERR(plat_data->pdev_mach); - - dev_dbg(sdev->dev, "created machine %s\n", - dev_name(&plat_data->pdev_mach->dev)); - - return 0; -} -EXPORT_SYMBOL(sof_machine_register); - -void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) -{ - struct snd_sof_pdata *plat_data = pdata; - - if (!IS_ERR_OR_NULL(plat_data->pdev_mach)) - platform_device_unregister(plat_data->pdev_mach); -} -EXPORT_SYMBOL(sof_machine_unregister); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index d4f6702e93dcb8..ec33a4794be8af 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -812,8 +812,6 @@ int sof_stream_pcm_open(struct snd_sof_dev *sdev, int sof_stream_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); -int sof_machine_check(struct snd_sof_dev *sdev); - /* SOF client support */ #if IS_ENABLED(CONFIG_SND_SOC_SOF_CLIENT) int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id, From 9c495a2200f54613c825c1c2a1b5ef4776945a03 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 16:01:06 +0300 Subject: [PATCH 03/30] ASoC: SOF: Add placeholder for platform IPC type and path overrides Add a struct sof_loadable_file_profile which can be filled by platforms (sof-acpi-dev.c, sof-of-dev.c and sof-acpi-dev.c) to be able to use common, generic code to handle path customization. Signed-off-by: Peter Ujfalusi --- include/sound/sof.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/sound/sof.h b/include/sound/sof.h index 268d0ca0f69f2b..4ef53f21f89de1 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -57,6 +57,17 @@ enum sof_ipc_type { SOF_IPC_TYPE_COUNT }; +struct sof_loadable_file_profile { + enum sof_ipc_type ipc_type; + + const char *fw_path; + const char *fw_name; + const char *fw_lib_path; + const char *fw_path_postfix; + const char *tplg_path; + const char *tplg_name; +}; + /* * SOF Platform data. */ @@ -86,6 +97,9 @@ struct snd_sof_pdata { /* descriptor */ const struct sof_dev_desc *desc; + /* platform's preferred IPC type and path overrides */ + struct sof_loadable_file_profile ipc_file_profile_base; + /* firmware and topology filenames */ const char *fw_filename_prefix; const char *fw_filename; From 3c6d4050de76bcff548ad2208c5b8162530cbde5 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 16:47:38 +0300 Subject: [PATCH 04/30] ASoC: SOF: sof-acpi-dev: Save the default IPC type and path overrides Store the default IPC type and the firmware and topology path overrides to ipc_file_profile_base Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-acpi-dev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 5c4e5ab31abff7..3852818f8998b3 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -87,6 +87,10 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc else sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3]; + sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; + sof_pdata->ipc_file_profile_base.fw_path = fw_path; + sof_pdata->ipc_file_profile_base.tplg_path = tplg_path; + /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_acpi_probe_complete; From 12b5bdb773531808d0a537f1f1fb335b31a479cd Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 16:50:17 +0300 Subject: [PATCH 05/30] ASoC: SOF: sof-of-dev: Save the default IPC type and path overrides Store the default IPC type and the firmware and topology path overrides to ipc_file_profile_base Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-of-dev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 70930dbe1d9844..58322858974a49 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -99,6 +99,10 @@ int sof_of_probe(struct platform_device *pdev) else sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3]; + sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; + sof_pdata->ipc_file_profile_base.fw_path = fw_path; + sof_pdata->ipc_file_profile_base.tplg_path = tplg_path; + /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_of_probe_complete; From 2276c6ebc982c45fe5761446ec8a9c7c38a0fabd Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 16:57:53 +0300 Subject: [PATCH 06/30] ASoC: SOF: sof-pci-dev: Save the default IPC type and path overrides Store the default IPC type and the overrides to ipc_file_profile_base Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-pci-dev.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 1d706490588e3c..1b06d6dd41406e 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -183,6 +183,7 @@ static void sof_pci_probe_complete(struct device *dev) int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { + struct sof_loadable_file_profile *path_override; struct device *dev = &pci->dev; const struct sof_dev_desc *desc = (const struct sof_dev_desc *)pci_id->driver_data; @@ -327,6 +328,18 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) sof_pdata->tplg_filename = sof_dmi_override_tplg_name; } + path_override = &sof_pdata->ipc_file_profile_base; + path_override->ipc_type = sof_pdata->ipc_type; + path_override->fw_path = fw_path; + path_override->fw_name = fw_filename; + path_override->fw_lib_path = lib_path; + path_override->tplg_path = tplg_path; + path_override->tplg_name = sof_pdata->tplg_filename; + + if (dmi_check_system(community_key_platforms) && + sof_dmi_use_community_key) + path_override->fw_path_postfix = "community"; + /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_pci_probe_complete; From f2f383eae87682c71829ad2c3ea0c6c3cbf3fda3 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 17:09:01 +0300 Subject: [PATCH 07/30] ASoC: SOF: core: Implement firmware, topology path setup in core Use the information stored in ipc_file_profile_base by platforms to construct the paths, filenames that are going to be used to load the firmware and topology files. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/Makefile | 3 +- sound/soc/sof/core.c | 70 ++++++++++++++++-- sound/soc/sof/fw-file-profile.c | 127 ++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 7 ++ 4 files changed, 200 insertions(+), 7 deletions(-) create mode 100644 sound/soc/sof/fw-file-profile.c diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index ef6fd43d0b72d1..3624124575afdf 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -1,7 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ - control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o + control.o trace.o iomem-utils.o sof-audio.o stream-ipc.o\ + fw-file-profile.o # IPC implementations ifneq ($(CONFIG_SND_SOC_SOF_IPC3),) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 4ee7ee7217b797..93fcb3b0054eb2 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -204,6 +204,67 @@ static int sof_machine_check(struct snd_sof_dev *sdev) return 0; } +static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *plat_data = sdev->pdata; + struct sof_loadable_file_profile *base_profile = &plat_data->ipc_file_profile_base; + struct sof_loadable_file_profile out_profile; + struct device *dev = sdev->dev; + int ret; + + /* check IPC support */ + if (!(BIT(base_profile->ipc_type) & plat_data->desc->ipc_supported_mask)) { + dev_err(dev, + "ipc_type %d is not supported on this platform, mask is %#x\n", + base_profile->ipc_type, plat_data->desc->ipc_supported_mask); + return -EINVAL; + } + + if (base_profile->ipc_type != plat_data->desc->ipc_default) + dev_info(dev, + "Module parameter used, overriding default IPC %d to %d\n", + plat_data->desc->ipc_default, base_profile->ipc_type); + + if (base_profile->fw_path) + dev_dbg(dev, "Module parameter used, changed fw path to %s\n", + base_profile->fw_path); + else if (base_profile->fw_path_postfix) + dev_dbg(dev, "Path postfix appended to default fw path: %s\n", + base_profile->fw_path_postfix); + + if (base_profile->fw_lib_path) + dev_dbg(dev, "Module parameter used, changed fw_lib path to %s\n", + base_profile->fw_lib_path); + else if (base_profile->fw_path_postfix) + dev_dbg(dev, "Path postfix appended to default fw_lib path: %s\n", + base_profile->fw_path_postfix); + + if (base_profile->fw_name) + dev_dbg(dev, "Module parameter used, changed fw filename to %s\n", + base_profile->fw_name); + + if (base_profile->tplg_path) + dev_dbg(dev, "Module parameter used, changed tplg path to %s\n", + base_profile->tplg_path); + + if (base_profile->tplg_name) + dev_dbg(dev, "Module parameter used, changed tplg name to %s\n", + base_profile->tplg_name); + + ret = sof_create_ipc_file_profile(sdev, base_profile, &out_profile); + if (ret) + return ret; + + plat_data->ipc_type = out_profile.ipc_type; + plat_data->fw_filename = out_profile.fw_name; + plat_data->fw_filename_prefix = out_profile.fw_path; + plat_data->fw_lib_prefix = out_profile.fw_lib_path; + plat_data->tplg_filename_prefix = out_profile.tplg_path; + plat_data->tplg_filename = out_profile.tplg_name; + + return 0; +} + /* * FW Boot State Transition Diagram * @@ -441,12 +502,9 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) } } - /* check IPC support */ - if (!(BIT(plat_data->ipc_type) & plat_data->desc->ipc_supported_mask)) { - dev_err(dev, "ipc_type %d is not supported on this platform, mask is %#x\n", - plat_data->ipc_type, plat_data->desc->ipc_supported_mask); - return -EINVAL; - } + ret = sof_select_ipc_and_paths(sdev); + if (ret) + return ret; /* init ops, if necessary */ ret = sof_ops_init(sdev); diff --git a/sound/soc/sof/fw-file-profile.c b/sound/soc/sof/fw-file-profile.c new file mode 100644 index 00000000000000..e855693c2da4fb --- /dev/null +++ b/sound/soc/sof/fw-file-profile.c @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2023 Intel Corporation. All rights reserved. +// + +#include +#include "sof-priv.h" + +static int +sof_file_profile_for_ipc_type(struct device *dev, + const struct sof_dev_desc *desc, + struct sof_loadable_file_profile *base_profile, + struct sof_loadable_file_profile *out_profile) +{ + enum sof_ipc_type ipc_type = base_profile->ipc_type; + bool fw_lib_path_allocated = false; + bool fw_path_allocated = false; + int ret = 0; + + /* firmware path */ + if (base_profile->fw_path) { + out_profile->fw_path = base_profile->fw_path; + } else if (base_profile->fw_path_postfix) { + out_profile->fw_path = devm_kasprintf(dev, GFP_KERNEL, "%s/%s", + desc->default_fw_path[ipc_type], + base_profile->fw_path_postfix); + if (!out_profile->fw_path) + return -ENOMEM; + + fw_path_allocated = true; + } else { + out_profile->fw_path = desc->default_fw_path[ipc_type]; + } + + /* firmware filename */ + if (base_profile->fw_name) + out_profile->fw_name = base_profile->fw_name; + else + out_profile->fw_name = desc->default_fw_filename[ipc_type]; + + + /* firmware library path */ + if (base_profile->fw_lib_path) { + out_profile->fw_lib_path = base_profile->fw_lib_path; + } else if (desc->default_lib_path[ipc_type]) { + if (base_profile->fw_path_postfix) { + out_profile->fw_lib_path = devm_kasprintf(dev, + GFP_KERNEL, "%s/%s", + desc->default_lib_path[ipc_type], + base_profile->fw_path_postfix); + if (!out_profile->fw_lib_path) { + ret = -ENOMEM; + goto out; + } + + fw_lib_path_allocated = true; + } else { + out_profile->fw_lib_path = desc->default_lib_path[ipc_type]; + } + } + + if (base_profile->fw_path_postfix) + out_profile->fw_path_postfix = base_profile->fw_path_postfix; + + /* topology path */ + if (base_profile->tplg_path) + out_profile->tplg_path = base_profile->tplg_path; + else + out_profile->tplg_path = desc->default_tplg_path[ipc_type]; + + /* topology name */ + if (base_profile->tplg_name) + out_profile->tplg_name = base_profile->tplg_name; + + out_profile->ipc_type = ipc_type; + +out: + if (ret) { + /* Free up path strings created with devm_kasprintf */ + if (fw_path_allocated) + devm_kfree(dev, out_profile->fw_path); + if (fw_lib_path_allocated) + devm_kfree(dev, out_profile->fw_lib_path); + + memset(out_profile, 0, sizeof(*out_profile)); + } + + return ret; +} + +static void sof_print_profile_info(struct device *dev, + struct sof_loadable_file_profile *profile) +{ + dev_info(dev, "Firmware paths/files for ipc type %d:\n", profile->ipc_type); + + dev_info(dev, " Firmware file: %s/%s\n", profile->fw_path, profile->fw_name); + if (profile->fw_lib_path) + dev_info(dev, " Firmware lib path: %s\n", profile->fw_lib_path); + if (profile->tplg_name) + dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, + profile->tplg_name); + else + dev_info(dev, " Topology path: %s\n", profile->tplg_path); +} + +int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, + struct sof_loadable_file_profile *base_profile, + struct sof_loadable_file_profile *out_profile) +{ + const struct sof_dev_desc *desc = sdev->pdata->desc; + struct device *dev = sdev->dev; + int ret; + + memset(out_profile, 0, sizeof(*out_profile)); + + ret = sof_file_profile_for_ipc_type(dev, desc, base_profile, out_profile); + if (ret) + return ret; + + sof_print_profile_info(dev, out_profile); + + return 0; +} +EXPORT_SYMBOL(sof_create_ipc_file_profile); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index ec33a4794be8af..90522be7542f53 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -693,6 +693,13 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev); */ extern struct snd_compress_ops sof_compressed_ops; +/* + * Firmware (firmware, libraries, topologies) file location + */ +int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, + struct sof_loadable_file_profile *base_profile, + struct sof_loadable_file_profile *out_profile); + /* * Firmware loading. */ From 20ce541cdab965c23080a1c0d36d17d29ff72f91 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 17:11:41 +0300 Subject: [PATCH 08/30] ASoC: SOF: sof-acpi-dev: Rely on core to create the file paths The core is now using the information from ipc_file_profile_base to create the paths for the loadable files, no need to set it in here anymore. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-acpi-dev.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 3852818f8998b3..e4b61f08202c65 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -74,18 +74,6 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->fw_filename = desc->default_fw_filename[SOF_IPC_TYPE_3]; - - /* alternate fw and tplg filenames ? */ - if (fw_path) - sof_pdata->fw_filename_prefix = fw_path; - else - sof_pdata->fw_filename_prefix = desc->default_fw_path[SOF_IPC_TYPE_3]; - - if (tplg_path) - sof_pdata->tplg_filename_prefix = tplg_path; - else - sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3]; sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; sof_pdata->ipc_file_profile_base.fw_path = fw_path; From fd827c46226053c77779f327088e7ba59d5802e3 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 17:11:54 +0300 Subject: [PATCH 09/30] ASoC: SOF: sof-of-dev: Rely on core to create the file paths The core is now using the information from ipc_file_profile_base to create the paths for the loadable files, no need to set it in here anymore. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-of-dev.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 58322858974a49..b12e810636c224 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -87,17 +87,6 @@ int sof_of_probe(struct platform_device *pdev) sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->fw_filename = desc->default_fw_filename[SOF_IPC_TYPE_3]; - - if (fw_path) - sof_pdata->fw_filename_prefix = fw_path; - else - sof_pdata->fw_filename_prefix = desc->default_fw_path[SOF_IPC_TYPE_3]; - - if (tplg_path) - sof_pdata->tplg_filename_prefix = tplg_path; - else - sof_pdata->tplg_filename_prefix = desc->default_tplg_path[SOF_IPC_TYPE_3]; sof_pdata->ipc_file_profile_base.ipc_type = desc->ipc_default; sof_pdata->ipc_file_profile_base.fw_path = fw_path; From 6932860860b3a98bb80205ccc33143e50ca19315 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 20 Apr 2023 17:12:19 +0300 Subject: [PATCH 10/30] ASoC: SOF: sof-pci-dev: Rely on core to create the file paths The core is now using the information from ipc_file_profile_base to create the paths for the loadable files, no need to set it in here anymore. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/sof-pci-dev.c | 113 +++++------------------------------- 1 file changed, 16 insertions(+), 97 deletions(-) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 1b06d6dd41406e..57c0a9291a6210 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -226,120 +226,39 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) sof_pdata->desc = desc; sof_pdata->dev = dev; - sof_pdata->ipc_type = desc->ipc_default; + path_override = &sof_pdata->ipc_file_profile_base; if (sof_pci_ipc_type < 0) { - sof_pdata->ipc_type = desc->ipc_default; - } else { - dev_info(dev, "overriding default IPC %d to requested %d\n", - desc->ipc_default, sof_pci_ipc_type); - if (sof_pci_ipc_type >= SOF_IPC_TYPE_COUNT) { - dev_err(dev, "invalid request value %d\n", sof_pci_ipc_type); - ret = -EINVAL; - goto out; - } - if (!(BIT(sof_pci_ipc_type) & desc->ipc_supported_mask)) { - dev_err(dev, "invalid request value %d, supported mask is %#x\n", - sof_pci_ipc_type, desc->ipc_supported_mask); - ret = -EINVAL; - goto out; - } - sof_pdata->ipc_type = sof_pci_ipc_type; - } - - if (fw_filename) { - sof_pdata->fw_filename = fw_filename; - - dev_dbg(dev, "Module parameter used, changed fw filename to %s\n", - sof_pdata->fw_filename); - } else { - sof_pdata->fw_filename = desc->default_fw_filename[sof_pdata->ipc_type]; - } - - /* - * for platforms using the SOF community key, change the - * default path automatically to pick the right files from the - * linux-firmware tree. This can be overridden with the - * fw_path kernel parameter, e.g. for developers. - */ - - /* alternate fw and tplg filenames ? */ - if (fw_path) { - sof_pdata->fw_filename_prefix = fw_path; - - dev_dbg(dev, - "Module parameter used, changed fw path to %s\n", - sof_pdata->fw_filename_prefix); - - } else if (dmi_check_system(community_key_platforms) && sof_dmi_use_community_key) { - sof_pdata->fw_filename_prefix = - devm_kasprintf(dev, GFP_KERNEL, "%s/%s", - sof_pdata->desc->default_fw_path[sof_pdata->ipc_type], - "community"); - - dev_dbg(dev, - "Platform uses community key, changed fw path to %s\n", - sof_pdata->fw_filename_prefix); + path_override->ipc_type = desc->ipc_default; + } else if (sof_pci_ipc_type < SOF_IPC_TYPE_COUNT) { + path_override->ipc_type = sof_pci_ipc_type; } else { - sof_pdata->fw_filename_prefix = - sof_pdata->desc->default_fw_path[sof_pdata->ipc_type]; + dev_err(dev, "Invalid IPC type requested: %d\n", sof_pci_ipc_type); + ret = -EINVAL; + goto out; } - if (lib_path) { - sof_pdata->fw_lib_prefix = lib_path; - - dev_dbg(dev, "Module parameter used, changed fw_lib path to %s\n", - sof_pdata->fw_lib_prefix); - - } else if (sof_pdata->desc->default_lib_path[sof_pdata->ipc_type]) { - if (dmi_check_system(community_key_platforms) && sof_dmi_use_community_key) { - sof_pdata->fw_lib_prefix = - devm_kasprintf(dev, GFP_KERNEL, "%s/%s", - sof_pdata->desc->default_lib_path[sof_pdata->ipc_type], - "community"); - - dev_dbg(dev, - "Platform uses community key, changed fw_lib path to %s\n", - sof_pdata->fw_lib_prefix); - } else { - sof_pdata->fw_lib_prefix = - sof_pdata->desc->default_lib_path[sof_pdata->ipc_type]; - } - } + path_override->fw_path = fw_path; + path_override->fw_name = fw_filename; + path_override->fw_lib_path = lib_path; + path_override->tplg_path = tplg_path; - if (tplg_path) - sof_pdata->tplg_filename_prefix = tplg_path; - else - sof_pdata->tplg_filename_prefix = - sof_pdata->desc->default_tplg_path[sof_pdata->ipc_type]; + if (dmi_check_system(community_key_platforms) && + sof_dmi_use_community_key) + path_override->fw_path_postfix = "community"; /* * the topology filename will be provided in the machine descriptor, unless * it is overridden by a module parameter or DMI quirk. */ if (tplg_filename) { - sof_pdata->tplg_filename = tplg_filename; - - dev_dbg(dev, "Module parameter used, changed tplg filename to %s\n", - sof_pdata->tplg_filename); + path_override->tplg_name = tplg_filename; } else { dmi_check_system(sof_tplg_table); if (sof_dmi_override_tplg_name) - sof_pdata->tplg_filename = sof_dmi_override_tplg_name; + path_override->tplg_name = sof_dmi_override_tplg_name; } - path_override = &sof_pdata->ipc_file_profile_base; - path_override->ipc_type = sof_pdata->ipc_type; - path_override->fw_path = fw_path; - path_override->fw_name = fw_filename; - path_override->fw_lib_path = lib_path; - path_override->tplg_path = tplg_path; - path_override->tplg_name = sof_pdata->tplg_filename; - - if (dmi_check_system(community_key_platforms) && - sof_dmi_use_community_key) - path_override->fw_path_postfix = "community"; - /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_pci_probe_complete; From f96ad75f1bd40606c241ee9e8592a879ba480673 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 27 Apr 2023 11:39:07 +0300 Subject: [PATCH 11/30] ASoC: SOF: core: Add helper for initialization of paths, ops Add sof_init_environment() as a helper function to contain path and ops initialization. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/core.c | 56 +++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 93fcb3b0054eb2..7a8cb0386565ea 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -265,6 +265,38 @@ static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev) return 0; } +static int sof_init_environment(struct snd_sof_dev *sdev) +{ + int ret; + + ret = sof_select_ipc_and_paths(sdev); + if (ret) + return ret; + + /* init ops, if necessary */ + ret = sof_ops_init(sdev); + if (ret < 0) + return ret; + + /* check all mandatory ops */ + if (!sof_ops(sdev) || !sof_ops(sdev)->probe) { + dev_err(sdev->dev, "missing mandatory ops\n"); + sof_ops_free(sdev); + return -EINVAL; + } + + if (!sdev->dspless_mode_selected && + (!sof_ops(sdev)->run || !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)) { + dev_err(sdev->dev, "missing mandatory DSP ops\n"); + sof_ops_free(sdev); + return -EINVAL; + } + + return 0; +} + /* * FW Boot State Transition Diagram * @@ -502,31 +534,11 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) } } - ret = sof_select_ipc_and_paths(sdev); + /* Initialize loadable file paths and check the environment validity */ + ret = sof_init_environment(sdev); if (ret) return ret; - /* init ops, if necessary */ - ret = sof_ops_init(sdev); - if (ret < 0) - return ret; - - /* check all mandatory ops */ - if (!sof_ops(sdev) || !sof_ops(sdev)->probe) { - sof_ops_free(sdev); - dev_err(dev, "missing mandatory ops\n"); - return -EINVAL; - } - - if (!sdev->dspless_mode_selected && - (!sof_ops(sdev)->run || !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_free(sdev); - dev_err(dev, "missing mandatory DSP ops\n"); - return -EINVAL; - } - INIT_LIST_HEAD(&sdev->pcm_list); INIT_LIST_HEAD(&sdev->kcontrol_list); INIT_LIST_HEAD(&sdev->widget_list); From 040635e0865fc25942cd0eb134bccecf32c82c75 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 27 Apr 2023 11:42:25 +0300 Subject: [PATCH 12/30] ASoC: SOF: core: Implement IPC version fallback if firmware files are missing If a firmware file is missing for the selected IPC type then try to switch to other supported IPC type and check if that one can be used instead. If for example a platform is changed to IPC4 as default version but the given machine does not yet have the needed topology file created then we will fall back to IPC3 which should have all the needed files. Relocate the sof_init_environment() to be done at a later phase, in sof_probe_continue(). This will only have changes in behavior if CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE is enabled (Intel HDA platforms) by not failing the module probe, but it is not going to be different case compared to for example failed firmware booting or topology loading error. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/core.c | 103 +++++++++------ sound/soc/sof/fw-file-profile.c | 213 +++++++++++++++++++++++++++++--- 2 files changed, 263 insertions(+), 53 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 7a8cb0386565ea..1de72c8717f873 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -212,14 +212,6 @@ static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev) struct device *dev = sdev->dev; int ret; - /* check IPC support */ - if (!(BIT(base_profile->ipc_type) & plat_data->desc->ipc_supported_mask)) { - dev_err(dev, - "ipc_type %d is not supported on this platform, mask is %#x\n", - base_profile->ipc_type, plat_data->desc->ipc_supported_mask); - return -EINVAL; - } - if (base_profile->ipc_type != plat_data->desc->ipc_default) dev_info(dev, "Module parameter used, overriding default IPC %d to %d\n", @@ -260,19 +252,14 @@ static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev) plat_data->fw_filename_prefix = out_profile.fw_path; plat_data->fw_lib_prefix = out_profile.fw_lib_path; plat_data->tplg_filename_prefix = out_profile.tplg_path; - plat_data->tplg_filename = out_profile.tplg_name; return 0; } -static int sof_init_environment(struct snd_sof_dev *sdev) +static int validate_sof_ops(struct snd_sof_dev *sdev) { int ret; - ret = sof_select_ipc_and_paths(sdev); - if (ret) - return ret; - /* init ops, if necessary */ ret = sof_ops_init(sdev); if (ret < 0) @@ -297,6 +284,68 @@ static int sof_init_environment(struct snd_sof_dev *sdev) return 0; } +static int sof_init_environment(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *plat_data = sdev->pdata; + struct sof_loadable_file_profile *base_profile = &plat_data->ipc_file_profile_base; + int ret; + + /* check IPC support */ + if (!(BIT(base_profile->ipc_type) & plat_data->desc->ipc_supported_mask)) { + dev_err(sdev->dev, + "ipc_type %d is not supported on this platform, mask is %#x\n", + base_profile->ipc_type, plat_data->desc->ipc_supported_mask); + return -EINVAL; + } + + /* + * Save the selected IPC type and a topology name override before + * selecting ops since platform code might need this information + */ + plat_data->ipc_type = base_profile->ipc_type; + plat_data->tplg_filename = base_profile->tplg_name; + + /* init ops, if necessary */ + ret = validate_sof_ops(sdev); + if (ret < 0) + return ret; + + /* probe the DSP hardware */ + ret = snd_sof_probe(sdev); + if (ret < 0) { + dev_err(sdev->dev, "failed to probe DSP %d\n", ret); + sof_ops_free(sdev); + return ret; + } + + /* check machine info */ + ret = sof_machine_check(sdev); + if (ret < 0) { + dev_err(sdev->dev, "failed to get machine info %d\n", ret); + goto err_machine_check; + } + + ret = sof_select_ipc_and_paths(sdev); + if (!ret && plat_data->ipc_type != base_profile->ipc_type) { + /* IPC type changed, re-initialize the ops */ + sof_ops_free(sdev); + + ret = validate_sof_ops(sdev); + if (ret < 0) { + snd_sof_remove(sdev); + return ret; + } + } + +err_machine_check: + if (ret) { + snd_sof_remove(sdev); + sof_ops_free(sdev); + } + + return ret; +} + /* * FW Boot State Transition Diagram * @@ -342,23 +391,13 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) struct snd_sof_pdata *plat_data = sdev->pdata; int ret; - /* probe the DSP hardware */ - ret = snd_sof_probe(sdev); - if (ret < 0) { - dev_err(sdev->dev, "error: failed to probe DSP %d\n", ret); - goto probe_err; - } + /* Initialize loadable file paths and check the environment validity */ + ret = sof_init_environment(sdev); + if (ret) + return ret; sof_set_fw_state(sdev, SOF_FW_BOOT_PREPARE); - /* check machine info */ - ret = sof_machine_check(sdev); - if (ret < 0) { - dev_err(sdev->dev, "error: failed to get machine info %d\n", - ret); - goto dsp_err; - } - /* set up platform component driver */ snd_sof_new_platform_drv(sdev); @@ -478,9 +517,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) ipc_err: dbg_err: snd_sof_free_debug(sdev); -dsp_err: snd_sof_remove(sdev); -probe_err: sof_ops_free(sdev); /* all resources freed, update state to match */ @@ -506,7 +543,6 @@ static void sof_probe_work(struct work_struct *work) int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) { struct snd_sof_dev *sdev; - int ret; sdev = devm_kzalloc(dev, sizeof(*sdev), GFP_KERNEL); if (!sdev) @@ -534,11 +570,6 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) } } - /* Initialize loadable file paths and check the environment validity */ - ret = sof_init_environment(sdev); - if (ret) - return ret; - INIT_LIST_HEAD(&sdev->pcm_list); INIT_LIST_HEAD(&sdev->kcontrol_list); INIT_LIST_HEAD(&sdev->widget_list); diff --git a/sound/soc/sof/fw-file-profile.c b/sound/soc/sof/fw-file-profile.c index e855693c2da4fb..fc29ee192daae4 100644 --- a/sound/soc/sof/fw-file-profile.c +++ b/sound/soc/sof/fw-file-profile.c @@ -6,17 +6,99 @@ // Copyright(c) 2023 Intel Corporation. All rights reserved. // +#include #include +#include #include "sof-priv.h" +static int sof_test_firmware_file(struct device *dev, + struct sof_loadable_file_profile *profile, + enum sof_ipc_type *ipc_type_to_adjust) +{ + enum sof_ipc_type fw_ipc_type; + const struct firmware *fw; + const char *fw_filename; + const u32 *magic; + int ret; + + fw_filename = kasprintf(GFP_KERNEL, "%s/%s", profile->fw_path, + profile->fw_name); + if (!fw_filename) + return -ENOMEM; + + ret = firmware_request_nowarn(&fw, fw_filename, dev); + if (ret < 0) { + dev_dbg(dev, "Failed to open firmware file: %s\n", fw_filename); + kfree(fw_filename); + return ret; + } + + /* firmware file exists, check the magic number */ + magic = (const u32 *)fw->data; + switch (*magic) { + case SOF_EXT_MAN_MAGIC_NUMBER: + fw_ipc_type = SOF_IPC_TYPE_3; + break; + case SOF_EXT_MAN4_MAGIC_NUMBER: + fw_ipc_type = SOF_IPC_TYPE_4; + break; + default: + dev_err(dev, "Invalid firmware magic: %#x\n", *magic); + ret = -EINVAL; + goto out; + } + + if (ipc_type_to_adjust) { + *ipc_type_to_adjust = fw_ipc_type; + } else if (fw_ipc_type != profile->ipc_type) { + dev_err(dev, + "ipc type mismatch between %s and expected: %d vs %d\n", + fw_filename, fw_ipc_type, profile->ipc_type); + ret = -EINVAL; + } +out: + release_firmware(fw); + kfree(fw_filename); + + return ret; +} + +static int sof_test_topology_file(struct device *dev, + struct sof_loadable_file_profile *profile) +{ + const struct firmware *fw; + const char *tplg_filename; + int ret; + + if (!profile->tplg_path || !profile->tplg_name) + return 0; + + tplg_filename = kasprintf(GFP_KERNEL, "%s/%s", profile->tplg_path, + profile->tplg_name); + if (!tplg_filename) + return -ENOMEM; + + ret = firmware_request_nowarn(&fw, tplg_filename, dev); + if (!ret) + release_firmware(fw); + else + dev_dbg(dev, "Failed to open topology file: %s\n", tplg_filename); + + kfree(tplg_filename); + + return ret; +} + static int -sof_file_profile_for_ipc_type(struct device *dev, +sof_file_profile_for_ipc_type(struct snd_sof_dev *sdev, + enum sof_ipc_type ipc_type, const struct sof_dev_desc *desc, struct sof_loadable_file_profile *base_profile, struct sof_loadable_file_profile *out_profile) { - enum sof_ipc_type ipc_type = base_profile->ipc_type; + struct snd_sof_pdata *plat_data = sdev->pdata; bool fw_lib_path_allocated = false; + struct device *dev = sdev->dev; bool fw_path_allocated = false; int ret = 0; @@ -41,6 +123,25 @@ sof_file_profile_for_ipc_type(struct device *dev, else out_profile->fw_name = desc->default_fw_filename[ipc_type]; + /* + * Check the custom firmware path/filename and adjust the ipc_type to + * match with the existing file for the remaining path configuration. + * + * For default path and firmware name do a verification before + * continuing further. + */ + if (base_profile->fw_path || base_profile->fw_name) { + ret = sof_test_firmware_file(dev, out_profile, &ipc_type); + if (ret) + return ret; + + if (!(desc->ipc_supported_mask & BIT(ipc_type))) { + dev_err(dev, "Unsupported IPC type %d needed by %s/%s\n", + ipc_type, out_profile->fw_path, + out_profile->fw_name); + return -EINVAL; + } + } /* firmware library path */ if (base_profile->fw_lib_path) { @@ -72,11 +173,17 @@ sof_file_profile_for_ipc_type(struct device *dev, out_profile->tplg_path = desc->default_tplg_path[ipc_type]; /* topology name */ - if (base_profile->tplg_name) - out_profile->tplg_name = base_profile->tplg_name; + out_profile->tplg_name = plat_data->tplg_filename; out_profile->ipc_type = ipc_type; + /* Test only default firmware file */ + if (!base_profile->fw_path && !base_profile->fw_name) + ret = sof_test_firmware_file(dev, out_profile, NULL); + + if (!ret) + ret = sof_test_topology_file(dev, out_profile); + out: if (ret) { /* Free up path strings created with devm_kasprintf */ @@ -91,19 +198,71 @@ sof_file_profile_for_ipc_type(struct device *dev, return ret; } -static void sof_print_profile_info(struct device *dev, +static void +sof_missing_firmware_notification(struct snd_sof_dev *sdev, + enum sof_ipc_type ipc_type, + struct sof_loadable_file_profile *base_profile) +{ + struct snd_sof_pdata *plat_data = sdev->pdata; + const struct sof_dev_desc *desc = plat_data->desc; + struct device *dev = sdev->dev; + char *marker; + int i; + + dev_err(dev, "SOF firmware and/or topology file not found.\n"); + dev_info(dev, "Supported default profiles\n"); + + for (i = 0; i < SOF_IPC_TYPE_COUNT; i++) { + if (!(desc->ipc_supported_mask & BIT(i))) + continue; + + if (i == ipc_type) + marker = "Requested"; + else + marker = "Fallback"; + + dev_info(dev, "- ipc type %d (%s):\n", i, marker); + if (base_profile->fw_path_postfix) + dev_info(dev, " Firmware file: %s/%s/%s\n", + desc->default_fw_path[i], + base_profile->fw_path_postfix, + desc->default_fw_filename[i]); + else + dev_info(dev, " Firmware file: %s/%s\n", + desc->default_fw_path[i], + desc->default_fw_filename[i]); + + dev_info(dev, " Topology file: %s/%s\n", + desc->default_tplg_path[i], + plat_data->tplg_filename); + } + + if (base_profile->fw_path || base_profile->fw_name || + base_profile->tplg_path || base_profile->tplg_name) + dev_info(dev, "Verify the path/name override module parameters.\n"); + + dev_info(dev, "Check if you have 'sof-firmware' package installed.\n"); + dev_info(dev, "Optionally it can be manually downloaded from:\n"); + dev_info(dev, " https://github.com/thesofproject/sof-bin/\n"); +} + +static void sof_print_profile_info(struct snd_sof_dev *sdev, + enum sof_ipc_type ipc_type, struct sof_loadable_file_profile *profile) { + struct device *dev = sdev->dev; + + if (ipc_type != profile->ipc_type) + dev_info(dev, + "Using fallback IPC type %d (requested type was %d)\n", + profile->ipc_type, ipc_type); + dev_info(dev, "Firmware paths/files for ipc type %d:\n", profile->ipc_type); dev_info(dev, " Firmware file: %s/%s\n", profile->fw_path, profile->fw_name); if (profile->fw_lib_path) dev_info(dev, " Firmware lib path: %s\n", profile->fw_lib_path); - if (profile->tplg_name) - dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, - profile->tplg_name); - else - dev_info(dev, " Topology path: %s\n", profile->tplg_path); + dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, profile->tplg_name); } int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, @@ -111,17 +270,37 @@ int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, struct sof_loadable_file_profile *out_profile) { const struct sof_dev_desc *desc = sdev->pdata->desc; - struct device *dev = sdev->dev; - int ret; + int ret, i; memset(out_profile, 0, sizeof(*out_profile)); - ret = sof_file_profile_for_ipc_type(dev, desc, base_profile, out_profile); - if (ret) - return ret; + ret = sof_file_profile_for_ipc_type(sdev, base_profile->ipc_type, desc, + base_profile, out_profile); + if (!ret) + goto out; - sof_print_profile_info(dev, out_profile); + /* + * No firmware file was found for the requested IPC type, check all + * IPC types as fallback + */ + for (i = 0; i < SOF_IPC_TYPE_COUNT; i++) { + if (i == base_profile->ipc_type || + !(desc->ipc_supported_mask & BIT(i))) + continue; - return 0; + ret = sof_file_profile_for_ipc_type(sdev, i, desc, base_profile, + out_profile); + if (!ret) + break; + } + +out: + if (ret) + sof_missing_firmware_notification(sdev, base_profile->ipc_type, + base_profile); + else + sof_print_profile_info(sdev, base_profile->ipc_type, out_profile); + + return ret; } EXPORT_SYMBOL(sof_create_ipc_file_profile); From b779702ac06282c9591725026cae77b2a1f560fe Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 28 Apr 2023 10:00:25 +0300 Subject: [PATCH 13/30] ASoC: SOF: Intel: Do not use resource managed allocation for ipc4_data Manage the ipc4_data allocation in code instead of devm since the ops_init might be called more than once due to IPC type fallback. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/apl.c | 2 +- sound/soc/sof/intel/cnl.c | 2 +- sound/soc/sof/intel/hda-dai.c | 3 +++ sound/soc/sof/intel/icl.c | 2 +- sound/soc/sof/intel/mtl.c | 2 +- sound/soc/sof/intel/skl.c | 2 +- sound/soc/sof/intel/tgl.c | 2 +- 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 776b66389c345b..dee6c7f73e80a6 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -55,7 +55,7 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev) if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_fw_data *ipc4_data; - sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 598cf50abadb3a..85e1e4760d0e59 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -402,7 +402,7 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev) if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_fw_data *ipc4_data; - sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 318a21c12cd005..f3649a083fb7e3 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -621,6 +621,9 @@ void hda_ops_free(struct snd_sof_dev *sdev) if (!hda_use_tplg_nhlt) intel_nhlt_free(ipc4_data->nhlt); + + kfree(sdev->private); + sdev->private = NULL; } } EXPORT_SYMBOL_NS(hda_ops_free, SND_SOC_SOF_INTEL_HDA_COMMON); diff --git a/sound/soc/sof/intel/icl.c b/sound/soc/sof/intel/icl.c index 8e29d6bb6fe82f..04069859199217 100644 --- a/sound/soc/sof/intel/icl.c +++ b/sound/soc/sof/intel/icl.c @@ -123,7 +123,7 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev) if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_fw_data *ipc4_data; - sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c index 254dbbeac1d076..030c03ba5dcc4f 100644 --- a/sound/soc/sof/intel/mtl.c +++ b/sound/soc/sof/intel/mtl.c @@ -698,7 +698,7 @@ int sof_mtl_ops_init(struct snd_sof_dev *sdev) sof_mtl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position; - sdev->private = devm_kzalloc(sdev->dev, sizeof(struct sof_ipc4_fw_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(struct sof_ipc4_fw_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; diff --git a/sound/soc/sof/intel/skl.c b/sound/soc/sof/intel/skl.c index d24e64e71b58f5..93824e6ce57307 100644 --- a/sound/soc/sof/intel/skl.c +++ b/sound/soc/sof/intel/skl.c @@ -62,7 +62,7 @@ int sof_skl_ops_init(struct snd_sof_dev *sdev) /* probe/remove/shutdown */ sof_skl_ops.shutdown = hda_dsp_shutdown; - sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; diff --git a/sound/soc/sof/intel/tgl.c b/sound/soc/sof/intel/tgl.c index f7de1f5ba06d10..d890cac6cb01bc 100644 --- a/sound/soc/sof/intel/tgl.c +++ b/sound/soc/sof/intel/tgl.c @@ -82,7 +82,7 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev) if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_fw_data *ipc4_data; - sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(*ipc4_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; From ef955968243b19760a7daa094ddab43132066ce6 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 28 Apr 2023 10:01:46 +0300 Subject: [PATCH 14/30] ASoC: SOF: Intel: lnl: Do not use resource managed allocation for ipc4_data Manage the ipc4_data allocation in code instead of devm since the ops_init might be called more than once due to IPC type fallback. This needs to be squashed for upstreaming if the ipc type fallback is sent earlier. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/lnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/lnl.c b/sound/soc/sof/intel/lnl.c index 479db350ea6da1..01466a7a823526 100644 --- a/sound/soc/sof/intel/lnl.c +++ b/sound/soc/sof/intel/lnl.c @@ -120,7 +120,7 @@ int sof_lnl_ops_init(struct snd_sof_dev *sdev) sof_lnl_ops.get_stream_position = mtl_dsp_get_stream_hda_link_position; - sdev->private = devm_kzalloc(sdev->dev, sizeof(struct sof_ipc4_fw_data), GFP_KERNEL); + sdev->private = kzalloc(sizeof(struct sof_ipc4_fw_data), GFP_KERNEL); if (!sdev->private) return -ENOMEM; From 93548f9f12ca501750ae40e82a455ea54315ebb6 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 30 Aug 2023 14:51:30 +0300 Subject: [PATCH 15/30] ASoC: SOF: Add Kconfig option to limit the IPC fallback to older versions With the SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION the IPC version fallback behavior can be modified. If it is not enabled (default) then the fallback only considers older and supported IPC version If it is enabled then all supported IPC version (even newer ones) will be tested and if conditions met, will be selected. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/Kconfig | 11 +++++++++++ sound/soc/sof/fw-file-profile.c | 25 +++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index a741ed96e78976..32ffd345e07fc4 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -126,6 +126,17 @@ config SND_SOC_SOF_STRICT_ABI_CHECKS If you are not involved in SOF releases and CI development, select "N". +config SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION + bool "SOF allow fallback to newer IPC version" + help + This option will allow the kernel to try to 'fallback' to a newer IPC + version if there are missing firmware files to satisfy the default IPC + version. + IPC version fallback to older versions is not affected by this option, + it is always available. + Say Y if you are involved in SOF development and need this option. + If not, select N. + config SND_SOC_SOF_DEBUG bool "SOF debugging features" help diff --git a/sound/soc/sof/fw-file-profile.c b/sound/soc/sof/fw-file-profile.c index fc29ee192daae4..2839505a706324 100644 --- a/sound/soc/sof/fw-file-profile.c +++ b/sound/soc/sof/fw-file-profile.c @@ -206,13 +206,18 @@ sof_missing_firmware_notification(struct snd_sof_dev *sdev, struct snd_sof_pdata *plat_data = sdev->pdata; const struct sof_dev_desc *desc = plat_data->desc; struct device *dev = sdev->dev; + int ipc_type_count, i; char *marker; - int i; dev_err(dev, "SOF firmware and/or topology file not found.\n"); dev_info(dev, "Supported default profiles\n"); - for (i = 0; i < SOF_IPC_TYPE_COUNT; i++) { + if (IS_ENABLED(CONFIG_SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION)) + ipc_type_count = SOF_IPC_TYPE_COUNT - 1; + else + ipc_type_count = base_profile->ipc_type; + + for (i = 0; i <= ipc_type_count; i++) { if (!(desc->ipc_supported_mask & BIT(i))) continue; @@ -270,7 +275,7 @@ int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, struct sof_loadable_file_profile *out_profile) { const struct sof_dev_desc *desc = sdev->pdata->desc; - int ret, i; + int ipc_fallback_start, ret, i; memset(out_profile, 0, sizeof(*out_profile)); @@ -280,10 +285,18 @@ int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, goto out; /* - * No firmware file was found for the requested IPC type, check all - * IPC types as fallback + * No firmware file was found for the requested IPC type, as fallback + * if SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION is selected, check + * all IPC versions in a backwards direction (from newer to older) + * if SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION is not selected, + * check only older IPC versions than the selected/default version */ - for (i = 0; i < SOF_IPC_TYPE_COUNT; i++) { + if (IS_ENABLED(CONFIG_SND_SOC_SOF_ALLOW_FALLBACK_TO_NEWER_IPC_VERSION)) + ipc_fallback_start = SOF_IPC_TYPE_COUNT - 1; + else + ipc_fallback_start = (int)base_profile->ipc_type - 1; + + for (i = ipc_fallback_start; i >= 0 ; i--) { if (i == base_profile->ipc_type || !(desc->ipc_supported_mask & BIT(i))) continue; From 8bf60c2f7fee70a0ff563a52133e7100907574a4 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 21 Apr 2023 12:30:57 +0300 Subject: [PATCH 16/30] -- ipc file profile in core -- From 8ac8a3a0d87adcdf46170475c40d013464e8e50c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 26 May 2023 11:23:43 +0300 Subject: [PATCH 17/30] ASoC: SOF: Intel: pci-tgl: Change the default paths and firmware names The currently used paths and firmware name reflects the reference firmware convention: default_fw_path: intel/avs/{platform_name} default_lib_path: intel/avs-lib/{platform_name} default_tplg_path: intel/avs-tplg default_fw_filename: dsp_basefw.bin The SOF supports building the firmware for cAVS2.5 platforms using IPC4 and it is the preferred IPC4 implementation to be used on these devices. Change the paths and firmware names to reflect this: default_fw_path: intel/sof-ipc4/{platform_name} default_lib_path: intel/sof-ipc4-lib/{platform_name} default_tplg_path: intel/sof-ipc4-tplg default_fw_filename: sof-{platform_name}.ri Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/pci-tgl.c | 64 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/sound/soc/sof/intel/pci-tgl.c b/sound/soc/sof/intel/pci-tgl.c index 0660d4b2ac96b6..a361ee9d1107f5 100644 --- a/sound/soc/sof/intel/pci-tgl.c +++ b/sound/soc/sof/intel/pci-tgl.c @@ -33,18 +33,18 @@ static const struct sof_dev_desc tgl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/tgl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/tgl", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/tgl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/tgl", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-tgl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-tgl.ri", }, .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -66,18 +66,18 @@ static const struct sof_dev_desc tglh_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/tgl-h", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/tgl-h", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/tgl-h", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/tgl-h", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-tgl-h.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-tgl-h.ri", }, .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -98,18 +98,18 @@ static const struct sof_dev_desc ehl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/ehl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/ehl", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/ehl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/ehl", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-ehl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-ehl.ri", }, .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -131,18 +131,18 @@ static const struct sof_dev_desc adls_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/adl-s", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl-s", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/adl-s", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/adl-s", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-adl-s.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-adl-s.ri", }, .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -164,18 +164,18 @@ static const struct sof_dev_desc adl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/adl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/adl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/adl", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-adl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-adl.ri", }, .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -197,18 +197,18 @@ static const struct sof_dev_desc adl_n_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/adl-n", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl-n", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/adl-n", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/adl-n", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-adl-n.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-adl-n.ri", }, .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -230,18 +230,18 @@ static const struct sof_dev_desc rpls_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/rpl-s", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/rpl-s", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/rpl-s", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/rpl-s", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-rpl-s.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-rpl-s.ri", }, .nocodec_tplg_filename = "sof-rpl-nocodec.tplg", .ops = &sof_tgl_ops, @@ -263,18 +263,18 @@ static const struct sof_dev_desc rpl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/rpl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4/rpl", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/rpl", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/rpl", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", + [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", }, .default_fw_filename = { [SOF_IPC_TYPE_3] = "sof-rpl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", + [SOF_IPC_TYPE_4] = "sof-rpl.ri", }, .nocodec_tplg_filename = "sof-rpl-nocodec.tplg", .ops = &sof_tgl_ops, From f8ac83b7821ee3884f7daa2c963aaf082f5b93d2 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 7 Sep 2023 14:32:06 +0300 Subject: [PATCH 18/30] -- TGL family ipc path change -- From f17d8e79acbf1eaa86ce85fffe650418e3c19f3b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 17 Apr 2023 16:01:21 +0300 Subject: [PATCH 19/30] ASoC: SOF: pci-cnl: Align the IPC4 firmware paths for cfl and cml All three platform described by pci-cnl.c (CNL, CFL and CML) uses the same firmware image (sof-cnl.ri). Packaging is handling the different file names by using symbolic links: sof-cfl.ri -> sof-cnl.ri sof-cml.ri -> sof-cnl.ri For IPC4 the firmware and lib path should be: intel/avs/cfl -> intel/avs/cnl intel/avs-lib/cfl -> intel/avs-lib/cnl Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/pci-cnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/intel/pci-cnl.c b/sound/soc/sof/intel/pci-cnl.c index 9fa0cd2eae79a3..3a1d39386ac19a 100644 --- a/sound/soc/sof/intel/pci-cnl.c +++ b/sound/soc/sof/intel/pci-cnl.c @@ -66,10 +66,10 @@ static const struct sof_dev_desc cfl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/cnl", + [SOF_IPC_TYPE_4] = "intel/avs/cfl", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/cnl", + [SOF_IPC_TYPE_4] = "intel/avs-lib/cfl", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", @@ -99,10 +99,10 @@ static const struct sof_dev_desc cml_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/cnl", + [SOF_IPC_TYPE_4] = "intel/avs/cml", }, .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/cnl", + [SOF_IPC_TYPE_4] = "intel/avs-lib/cml", }, .default_tplg_path = { [SOF_IPC_TYPE_3] = "intel/sof-tplg", From d9b46a3b6504a21532abf7890a8d422f712a5046 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 10:35:12 +0300 Subject: [PATCH 20/30] ASoC: SOF: Add vendor and platform strings to sof_dev_desc Add two identification strings to the device descriptor: name of the vendor (amd, imx, intel, mediatek), name of the platform (apl, tgl, rmb, imx8, mt8188, etc). These strings will be used to construct the paths and file names to be used for loading firmware files (DSP firmware, topologies, firmware libraries). Signed-off-by: Peter Ujfalusi --- include/sound/sof.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/sound/sof.h b/include/sound/sof.h index 4ef53f21f89de1..19a455c568a5d2 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -165,6 +165,10 @@ struct sof_dev_desc { /* default firmware name */ const char *default_fw_filename[SOF_IPC_TYPE_COUNT]; + /* strings used for the firmware layout path/filename creation */ + const char *vendor; + const char *platform; + struct snd_sof_dsp_ops *ops; int (*ops_init)(struct snd_sof_dev *sdev); void (*ops_free)(struct snd_sof_dev *sdev); From a9bf5aae97cf95476110666caec986981f440a2e Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 10:51:14 +0300 Subject: [PATCH 21/30] ASoC: SOF: amd: Add vendor and platform names for device descriptors Set the vendor and platform names in sof_dev_desc, which will be used to create the default firmware layout profile paths and firmware name. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/amd/pci-rmb.c | 2 ++ sound/soc/sof/amd/pci-rn.c | 2 ++ sound/soc/sof/amd/pci-vangogh.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sound/soc/sof/amd/pci-rmb.c b/sound/soc/sof/amd/pci-rmb.c index 72e211b5f7a489..5861e544ae822f 100644 --- a/sound/soc/sof/amd/pci-rmb.c +++ b/sound/soc/sof/amd/pci-rmb.c @@ -49,6 +49,8 @@ static const struct sof_dev_desc rembrandt_desc = { .chip_info = &rembrandt_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "amd", + .platform = "rmb", .default_fw_path = { [SOF_IPC_TYPE_3] = "amd/sof", }, diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c index a0195e9b400c89..458e61c5b88808 100644 --- a/sound/soc/sof/amd/pci-rn.c +++ b/sound/soc/sof/amd/pci-rn.c @@ -49,6 +49,8 @@ static const struct sof_dev_desc renoir_desc = { .chip_info = &renoir_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "amd", + .platform = "rn", .default_fw_path = { [SOF_IPC_TYPE_3] = "amd/sof", }, diff --git a/sound/soc/sof/amd/pci-vangogh.c b/sound/soc/sof/amd/pci-vangogh.c index 5cd3ac84752fb8..abba6c03ca44bf 100644 --- a/sound/soc/sof/amd/pci-vangogh.c +++ b/sound/soc/sof/amd/pci-vangogh.c @@ -47,6 +47,8 @@ static const struct sof_dev_desc vangogh_desc = { .chip_info = &vangogh_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "amd", + .platform = "vangogh", .default_fw_path = { [SOF_IPC_TYPE_3] = "amd/sof", }, From 5fe72da5deb00b8c7496967226618bbc521fd87c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 10:51:35 +0300 Subject: [PATCH 22/30] ASoC: SOF: imx: Add vendor and platform names for device descriptors Set the vendor and platform names in sof_dev_desc, which will be used to create the default firmware layout profile paths and firmware name. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/imx/imx8.c | 6 ++++++ sound/soc/sof/imx/imx8m.c | 2 ++ sound/soc/sof/imx/imx8ulp.c | 2 ++ 3 files changed, 10 insertions(+) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index 65a7041cbab9d7..08c04b659bc83b 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -608,9 +608,13 @@ static struct snd_sof_dsp_ops sof_imx8x_ops = { SNDRV_PCM_INFO_NO_PERIOD_WAKEUP }; +static const char vendor_string[] = "imx"; + static struct sof_dev_desc sof_of_imx8qxp_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "imx8x", .default_fw_path = { [SOF_IPC_TYPE_3] = "imx/sof", }, @@ -627,6 +631,8 @@ static struct sof_dev_desc sof_of_imx8qxp_desc = { static struct sof_dev_desc sof_of_imx8qm_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "imx8", .default_fw_path = { [SOF_IPC_TYPE_3] = "imx/sof", }, diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index 9d58dda8f079d1..65155562c38c0c 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -473,6 +473,8 @@ static struct snd_sof_dsp_ops sof_imx8m_ops = { static struct sof_dev_desc sof_of_imx8mp_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "imx", + .platform = "imx8m", .default_fw_path = { [SOF_IPC_TYPE_3] = "imx/sof", }, diff --git a/sound/soc/sof/imx/imx8ulp.c b/sound/soc/sof/imx/imx8ulp.c index 2673c1d4ddea16..5b43ebf315f61e 100644 --- a/sound/soc/sof/imx/imx8ulp.c +++ b/sound/soc/sof/imx/imx8ulp.c @@ -480,6 +480,8 @@ static struct snd_sof_dsp_ops sof_imx8ulp_ops = { static struct sof_dev_desc sof_of_imx8ulp_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "imx", + .platform = "imx8ulp", .default_fw_path = { [SOF_IPC_TYPE_3] = "imx/sof", }, From 52271256bcc7b3cf049984fdee1e2c9e2ba2b71b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 10:52:28 +0300 Subject: [PATCH 23/30] ASoC: SOF: Intel: Add vendor and platform names for device descriptors Set the vendor and platform names in sof_dev_desc, which will be used to create the default firmware layout profile paths and firmware name. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/bdw.c | 2 ++ sound/soc/sof/intel/byt.c | 8 ++++++++ sound/soc/sof/intel/pci-apl.c | 6 ++++++ sound/soc/sof/intel/pci-cnl.c | 8 ++++++++ sound/soc/sof/intel/pci-icl.c | 6 ++++++ sound/soc/sof/intel/pci-lnl.c | 2 ++ sound/soc/sof/intel/pci-mtl.c | 4 ++++ sound/soc/sof/intel/pci-skl.c | 6 ++++++ sound/soc/sof/intel/pci-tgl.c | 18 ++++++++++++++++++ sound/soc/sof/intel/pci-tng.c | 2 ++ 10 files changed, 62 insertions(+) diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 511fce8e0e198b..043cca23e98afa 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -641,6 +641,8 @@ static const struct sof_dev_desc sof_acpi_broadwell_desc = { .chip_info = &bdw_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "intel", + .platform = "bdw", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", }, diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index a976dc91d2ec69..b32629422dce6a 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -366,6 +366,8 @@ static const struct sof_intel_dsp_desc cht_chip_info = { .hw_ip_version = SOF_INTEL_BAYTRAIL, }; +static const char vendor_string[] = "intel"; + /* BYTCR uses different IRQ index */ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .machines = snd_soc_acpi_intel_baytrail_machines, @@ -376,6 +378,8 @@ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .chip_info = &byt_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "byt", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", }, @@ -398,6 +402,8 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { .chip_info = &byt_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "byt", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", }, @@ -420,6 +426,8 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { .chip_info = &cht_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "cht", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", }, diff --git a/sound/soc/sof/intel/pci-apl.c b/sound/soc/sof/intel/pci-apl.c index 4b287b5e9077cb..3d36a8e64cf121 100644 --- a/sound/soc/sof/intel/pci-apl.c +++ b/sound/soc/sof/intel/pci-apl.c @@ -19,6 +19,8 @@ /* platform specific devices */ #include "hda.h" +static const char vendor_string[] = "intel"; + static const struct sof_dev_desc bxt_desc = { .machines = snd_soc_acpi_intel_bxt_machines, .use_acpi_target_states = true, @@ -30,6 +32,8 @@ static const struct sof_dev_desc bxt_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "apl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/apl", @@ -62,6 +66,8 @@ static const struct sof_dev_desc glk_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "glk", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/glk", diff --git a/sound/soc/sof/intel/pci-cnl.c b/sound/soc/sof/intel/pci-cnl.c index 3a1d39386ac19a..0dba5d9f8fb78b 100644 --- a/sound/soc/sof/intel/pci-cnl.c +++ b/sound/soc/sof/intel/pci-cnl.c @@ -19,6 +19,8 @@ /* platform specific devices */ #include "hda.h" +static const char vendor_string[] = "intel"; + static const struct sof_dev_desc cnl_desc = { .machines = snd_soc_acpi_intel_cnl_machines, .alt_machines = snd_soc_acpi_intel_cnl_sdw_machines, @@ -31,6 +33,8 @@ static const struct sof_dev_desc cnl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "cnl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/cnl", @@ -64,6 +68,8 @@ static const struct sof_dev_desc cfl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "cfl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/cfl", @@ -97,6 +103,8 @@ static const struct sof_dev_desc cml_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "cml", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/cml", diff --git a/sound/soc/sof/intel/pci-icl.c b/sound/soc/sof/intel/pci-icl.c index b99c7c9aad7dd3..9c583af68be661 100644 --- a/sound/soc/sof/intel/pci-icl.c +++ b/sound/soc/sof/intel/pci-icl.c @@ -19,6 +19,8 @@ /* platform specific devices */ #include "hda.h" +static const char vendor_string[] = "intel"; + static const struct sof_dev_desc icl_desc = { .machines = snd_soc_acpi_intel_icl_machines, .alt_machines = snd_soc_acpi_intel_icl_sdw_machines, @@ -31,6 +33,8 @@ static const struct sof_dev_desc icl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "icl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/icl", @@ -63,6 +67,8 @@ static const struct sof_dev_desc jsl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "jsl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/avs/jsl", diff --git a/sound/soc/sof/intel/pci-lnl.c b/sound/soc/sof/intel/pci-lnl.c index 78a57eb9cbc377..2c85d682ad4031 100644 --- a/sound/soc/sof/intel/pci-lnl.c +++ b/sound/soc/sof/intel/pci-lnl.c @@ -32,6 +32,8 @@ static const struct sof_dev_desc lnl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, + .vendor = "intel", + .platform = "lnl", .default_fw_path = { [SOF_IPC_TYPE_4] = "intel/sof-ipc4/lnl", }, diff --git a/sound/soc/sof/intel/pci-mtl.c b/sound/soc/sof/intel/pci-mtl.c index 0f378f45486dec..9962a2b45b6c26 100644 --- a/sound/soc/sof/intel/pci-mtl.c +++ b/sound/soc/sof/intel/pci-mtl.c @@ -32,6 +32,8 @@ static const struct sof_dev_desc mtl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = "intel", + .platform = "mtl", .default_fw_path = { [SOF_IPC_TYPE_4] = "intel/sof-ipc4/mtl", }, @@ -62,6 +64,8 @@ static const struct sof_dev_desc arl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = "intel", + .platform = "mtl", .default_fw_path = { [SOF_IPC_TYPE_4] = "intel/sof-ipc4/arl", }, diff --git a/sound/soc/sof/intel/pci-skl.c b/sound/soc/sof/intel/pci-skl.c index 9dde439a0b0f55..ce8423092afdaa 100644 --- a/sound/soc/sof/intel/pci-skl.c +++ b/sound/soc/sof/intel/pci-skl.c @@ -17,6 +17,8 @@ /* platform specific devices */ #include "hda.h" +static const char vendor_string[] = "intel"; + static struct sof_dev_desc skl_desc = { .machines = snd_soc_acpi_intel_skl_machines, .resindex_lpe_base = 0, @@ -27,6 +29,8 @@ static struct sof_dev_desc skl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "skl", .default_fw_path = { [SOF_IPC_TYPE_4] = "intel/avs/skl", }, @@ -52,6 +56,8 @@ static struct sof_dev_desc kbl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "kbl", .default_fw_path = { [SOF_IPC_TYPE_4] = "intel/avs/kbl", }, diff --git a/sound/soc/sof/intel/pci-tgl.c b/sound/soc/sof/intel/pci-tgl.c index a361ee9d1107f5..a60902f5c40ebb 100644 --- a/sound/soc/sof/intel/pci-tgl.c +++ b/sound/soc/sof/intel/pci-tgl.c @@ -19,6 +19,8 @@ /* platform specific devices */ #include "hda.h" +static const char vendor_string[] = "intel"; + static const struct sof_dev_desc tgl_desc = { .machines = snd_soc_acpi_intel_tgl_machines, .alt_machines = snd_soc_acpi_intel_tgl_sdw_machines, @@ -31,6 +33,8 @@ static const struct sof_dev_desc tgl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "tgl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/tgl", @@ -64,6 +68,8 @@ static const struct sof_dev_desc tglh_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "tgl-h", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/tgl-h", @@ -96,6 +102,8 @@ static const struct sof_dev_desc ehl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "ehl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/ehl", @@ -129,6 +137,8 @@ static const struct sof_dev_desc adls_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "adl-s", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl-s", @@ -162,6 +172,8 @@ static const struct sof_dev_desc adl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "adl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl", @@ -195,6 +207,8 @@ static const struct sof_dev_desc adl_n_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "adl-n", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl-n", @@ -228,6 +242,8 @@ static const struct sof_dev_desc rpls_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "rpl-s", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/rpl-s", @@ -261,6 +277,8 @@ static const struct sof_dev_desc rpl_desc = { .ipc_supported_mask = BIT(SOF_IPC_TYPE_3) | BIT(SOF_IPC_TYPE_4), .ipc_default = SOF_IPC_TYPE_3, .dspless_mode_supported = true, /* Only supported for HDaudio */ + .vendor = vendor_string, + .platform = "rpl", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", [SOF_IPC_TYPE_4] = "intel/sof-ipc4/rpl", diff --git a/sound/soc/sof/intel/pci-tng.c b/sound/soc/sof/intel/pci-tng.c index c90173003c2ba8..f5659dd813b403 100644 --- a/sound/soc/sof/intel/pci-tng.c +++ b/sound/soc/sof/intel/pci-tng.c @@ -210,6 +210,8 @@ static const struct sof_dev_desc tng_desc = { .chip_info = &tng_chip_info, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "intel", + .platform = "byt", .default_fw_path = { [SOF_IPC_TYPE_3] = "intel/sof", }, From 9d932dcc8fc5c177b5b47d45674cc95cf22db269 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 10:53:05 +0300 Subject: [PATCH 24/30] ASoC: SOF: mediatek: Add vendor and platform names for device descriptors Set the vendor and platform names in sof_dev_desc, which will be used to create the default firmware layout profile paths and firmware name. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/mediatek/mt8186/mt8186.c | 6 ++++++ sound/soc/sof/mediatek/mt8195/mt8195.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 8544d65bc2cfae..132a9c8f4866b9 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -605,10 +605,14 @@ static struct snd_sof_of_mach sof_mt8186_machs[] = { {} }; +static const char vendor_string[] = "mediatek"; + static const struct sof_dev_desc sof_of_mt8186_desc = { .of_machines = sof_mt8186_machs, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "mt8186", .default_fw_path = { [SOF_IPC_TYPE_3] = "mediatek/sof", }, @@ -683,6 +687,8 @@ static const struct sof_dev_desc sof_of_mt8188_desc = { .of_machines = sof_mt8188_machs, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "mt8188", .default_fw_path = { [SOF_IPC_TYPE_3] = "mediatek/sof", }, diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index fab2d5af861007..fa20be75046d94 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -637,6 +637,8 @@ static const struct sof_dev_desc sof_of_mt8195_desc = { .of_machines = sof_mt8195_machs, .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), .ipc_default = SOF_IPC_TYPE_3, + .vendor = "mediatek", + .platform = "mt8195", .default_fw_path = { [SOF_IPC_TYPE_3] = "mediatek/sof", }, From 4b492dd7ef8a86e7d327ac4634015172be49649b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 20 Sep 2023 15:46:15 +0300 Subject: [PATCH 25/30] ASoC: SOF: fw-file-profile: Support for different layouts per IPC type The current way of setting the default paths and file names for firmware files are to have strings in the sof_dev_desc struct for the each supported IPC version and for each platform. For IPC3 we have a standard pattern among vendors and platforms: firmware path: /sof firmware name: sof-.ri topology path: /sof-tplg/ With IPC4 we have three pattern variations: SOF generic: firmware path: /sof-ipc4/ firmware name: sof-.ri firmware lib path: /sof-ipc4-lib/ topology path: /sof-ipc4-tplg/ SOF for Intel ACE platforms: firmware path: intel/sof-ipc4/ firmware name: sof-.ri firmware lib path: intel/sof-ipc4-lib/ topology path: intel/sof-ace-tplg/ Intel ACE firmware: firmware path: intel/avs/ firmware name: dsp_basefw.bin firmware lib path: intel/avs/ topology path: intel/avs-tplg/ With the 'vendor' and 'platform' string provided in sof_dev_desc we can generate any of these layouts and we can even pick the one which is available on the filesystem without a need to provide kernel parameters or modify the kernel. It can ease up moving to a new layout while providing backwards compatibility with existing sof-bin packages in case of IPC4. Moving the current Intel ACE layout to a generic IPC4 layout would be easy since the kernel will just figure out that now the files are in a differnt directory (the tplg files). Signed-off-by: Peter Ujfalusi --- sound/soc/sof/fw-file-profile.c | 359 ++++++++++++++++++++++++++------ 1 file changed, 297 insertions(+), 62 deletions(-) diff --git a/sound/soc/sof/fw-file-profile.c b/sound/soc/sof/fw-file-profile.c index 2839505a706324..154ba5e71cc9d4 100644 --- a/sound/soc/sof/fw-file-profile.c +++ b/sound/soc/sof/fw-file-profile.c @@ -11,6 +11,47 @@ #include #include "sof-priv.h" +/** + * enum sof_fw_layout_type - pre-defined file-layout for loadable fw files + * @SOF_FW_LAYOUT_IPC3_SOF: + * firmware path: /sof + * firmware name: sof-.ri + * topology path: /sof-tplg/ + * @SOF_FW_LAYOUT_IPC4_SOF: + * firmware path: /sof-ipc4/ + * firmware name: sof-.ri + * firmware lib path: /sof-ipc4-lib/ + * topology path: /sof-ipc4-tplg/ + * @SOF_FW_LAYOUT_IPC4_INTEL_ACE: + * firmware path: intel/sof-ipc4/ + * firmware name: sof-.ri + * firmware lib path: intel/sof-ipc4-lib/ + * topology path: intel/sof-ace-tplg/ + * @SOF_FW_LAYOUT_IPC4_INTEL_AVS: + * firmware path: intel/avs/ + * firmware name: dsp_basefw.bin + * firmware lib path: intel/avs/ + * topology path: intel/avs-tplg/ + */ +enum sof_fw_layout_type { + SOF_FW_LAYOUT_IPC3_SOF, + SOF_FW_LAYOUT_IPC4_SOF, + SOF_FW_LAYOUT_IPC4_INTEL_ACE, + SOF_FW_LAYOUT_IPC4_INTEL_AVS, +}; + +struct sof_fw_layout_map { + enum sof_ipc_type ipc_type; + char *layout_name; +}; + +static const struct sof_fw_layout_map fw_layouts[] = { + { .ipc_type = SOF_IPC_TYPE_3, .layout_name = "SOF IPC3", }, + { .ipc_type = SOF_IPC_TYPE_4, .layout_name = "SOF IPC4", }, + { .ipc_type = SOF_IPC_TYPE_4, .layout_name = "SOF IPC4 for Intel ACE platforms", }, + { .ipc_type = SOF_IPC_TYPE_4, .layout_name = "Intel AVS IPC4", }, +}; + static int sof_test_firmware_file(struct device *dev, struct sof_loadable_file_profile *profile, enum sof_ipc_type *ipc_type_to_adjust) @@ -90,38 +131,27 @@ static int sof_test_topology_file(struct device *dev, } static int -sof_file_profile_for_ipc_type(struct snd_sof_dev *sdev, - enum sof_ipc_type ipc_type, - const struct sof_dev_desc *desc, - struct sof_loadable_file_profile *base_profile, - struct sof_loadable_file_profile *out_profile) +sof_create_fw_profile(struct snd_sof_dev *sdev, const struct sof_dev_desc *desc, + struct sof_loadable_file_profile *default_profile, + struct sof_loadable_file_profile *base_profile, + struct sof_loadable_file_profile *out_profile) { + enum sof_ipc_type ipc_type = default_profile->ipc_type; struct snd_sof_pdata *plat_data = sdev->pdata; - bool fw_lib_path_allocated = false; struct device *dev = sdev->dev; - bool fw_path_allocated = false; int ret = 0; /* firmware path */ - if (base_profile->fw_path) { + if (base_profile->fw_path) out_profile->fw_path = base_profile->fw_path; - } else if (base_profile->fw_path_postfix) { - out_profile->fw_path = devm_kasprintf(dev, GFP_KERNEL, "%s/%s", - desc->default_fw_path[ipc_type], - base_profile->fw_path_postfix); - if (!out_profile->fw_path) - return -ENOMEM; - - fw_path_allocated = true; - } else { - out_profile->fw_path = desc->default_fw_path[ipc_type]; - } + else + out_profile->fw_path = default_profile->fw_path; /* firmware filename */ if (base_profile->fw_name) out_profile->fw_name = base_profile->fw_name; else - out_profile->fw_name = desc->default_fw_filename[ipc_type]; + out_profile->fw_name = default_profile->fw_name; /* * Check the custom firmware path/filename and adjust the ipc_type to @@ -144,24 +174,10 @@ sof_file_profile_for_ipc_type(struct snd_sof_dev *sdev, } /* firmware library path */ - if (base_profile->fw_lib_path) { + if (base_profile->fw_lib_path) out_profile->fw_lib_path = base_profile->fw_lib_path; - } else if (desc->default_lib_path[ipc_type]) { - if (base_profile->fw_path_postfix) { - out_profile->fw_lib_path = devm_kasprintf(dev, - GFP_KERNEL, "%s/%s", - desc->default_lib_path[ipc_type], - base_profile->fw_path_postfix); - if (!out_profile->fw_lib_path) { - ret = -ENOMEM; - goto out; - } - - fw_lib_path_allocated = true; - } else { - out_profile->fw_lib_path = desc->default_lib_path[ipc_type]; - } - } + else if (default_profile->fw_lib_path) + out_profile->fw_lib_path = default_profile->fw_lib_path; if (base_profile->fw_path_postfix) out_profile->fw_path_postfix = base_profile->fw_path_postfix; @@ -170,7 +186,7 @@ sof_file_profile_for_ipc_type(struct snd_sof_dev *sdev, if (base_profile->tplg_path) out_profile->tplg_path = base_profile->tplg_path; else - out_profile->tplg_path = desc->default_tplg_path[ipc_type]; + out_profile->tplg_path = default_profile->tplg_path; /* topology name */ out_profile->tplg_name = plat_data->tplg_filename; @@ -184,29 +200,243 @@ sof_file_profile_for_ipc_type(struct snd_sof_dev *sdev, if (!ret) ret = sof_test_topology_file(dev, out_profile); -out: - if (ret) { - /* Free up path strings created with devm_kasprintf */ - if (fw_path_allocated) - devm_kfree(dev, out_profile->fw_path); - if (fw_lib_path_allocated) - devm_kfree(dev, out_profile->fw_lib_path); - + if (ret) memset(out_profile, 0, sizeof(*out_profile)); + + return ret; +} + +static void sof_free_profile_strings(struct device *dev, + struct sof_loadable_file_profile *profile) +{ + devm_kfree(dev, profile->fw_path); + devm_kfree(dev, profile->fw_lib_path); + devm_kfree(dev, profile->fw_name); + devm_kfree(dev, profile->tplg_path); + + memset(profile, 0, sizeof(*profile)); +} + +static int +sof_default_fw_layout(struct device *dev, const enum sof_fw_layout_type layout_type, + const char *vendor, const char *platform, + const char *fw_path_postfix, + struct sof_loadable_file_profile *default_profile) +{ + int ret = -ENOMEM; + const char *str; + + switch (layout_type) { + case SOF_FW_LAYOUT_IPC3_SOF: + default_profile->ipc_type = SOF_IPC_TYPE_3; + /* + * firmware path: /sof + * firmware name: sof-.ri + * topology path: /sof-tplg/ + */ + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof/%s", + vendor, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof", vendor); + if (!str) + return -ENOMEM; + + default_profile->fw_path = str; + + default_profile->fw_name = devm_kasprintf(dev, GFP_KERNEL, + "sof-%s.ri", platform); + if (!default_profile->fw_name) + goto err; + + default_profile->tplg_path = devm_kasprintf(dev, GFP_KERNEL, + "%s/sof-tplg", vendor); + if (!default_profile->tplg_path) + goto err; + break; + case SOF_FW_LAYOUT_IPC4_SOF: + default_profile->ipc_type = SOF_IPC_TYPE_4; + /* + * firmware path: /sof-ipc4/ + * firmware name: sof-.ri + * firmware lib path: /sof-ipc4-lib/ + * topology path: /sof-ipc4-tplg/ + */ + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof-ipc4/%s/%s", + vendor, platform, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof-ipc4/%s", + vendor, platform); + if (!str) + return -ENOMEM; + + default_profile->fw_path = str; + + default_profile->fw_name = devm_kasprintf(dev, GFP_KERNEL, + "sof-%s.ri", platform); + if (!default_profile->fw_name) + goto err; + + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof-ipc4-lib/%s/%s", + vendor, platform, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof-ipc4-lib/%s", + vendor, platform); + if (!str) + goto err; + + default_profile->fw_lib_path = str; + + default_profile->tplg_path = devm_kasprintf(dev, GFP_KERNEL, + "%s/sof-ipc4-tplg", vendor); + if (!default_profile->tplg_path) + goto err; + break; + case SOF_FW_LAYOUT_IPC4_INTEL_ACE: + default_profile->ipc_type = SOF_IPC_TYPE_4; + /* + * firmware path: intel/sof-ipc4/ + * firmware name: sof-.ri + * firmware lib path: intel/sof-ipc4-lib/ + * topology path: intel/sof-ace-tplg/ + */ + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "intel/sof-ipc4/%s/%s", + platform, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "intel/sof-ipc4/%s", + platform); + if (!str) + return -ENOMEM; + + default_profile->fw_path = str; + + default_profile->fw_name = devm_kasprintf(dev, GFP_KERNEL, + "sof-%s.ri", platform); + if (!default_profile->fw_name) + goto err; + + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "intel/sof-ipc4-lib/%s/%s", + platform, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "intel/sof-ipc4-lib/%s", + platform); + if (!str) + goto err; + + default_profile->fw_lib_path = str; + + default_profile->tplg_path = devm_kstrdup(dev, "intel/sof-ace-tplg", + GFP_KERNEL); + if (!default_profile->tplg_path) + goto err; + break; + case SOF_FW_LAYOUT_IPC4_INTEL_AVS: + default_profile->ipc_type = SOF_IPC_TYPE_4; + /* + * firmware path: intel/avs/ + * firmware name: dsp_basefw.bin + * firmware lib path: intel/avs-lib/ + * topology path: intel/avs-tplg/ + */ + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "intel/avs/%s/%s", + platform, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "intel/avs/%s", + platform); + if (!str) + return -ENOMEM; + + default_profile->fw_path = str; + + default_profile->fw_name = devm_kstrdup(dev, "dsp_basefw.bin", + GFP_KERNEL); + if (!default_profile->fw_name) + goto err; + + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, "intel/avs/%s/%s", + platform, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "intel/avs/%s", + platform); + if (!str) + goto err; + + default_profile->fw_lib_path = str; + + default_profile->tplg_path = devm_kstrdup(dev, "intel/avs-tplg", + GFP_KERNEL); + if (!default_profile->tplg_path) + goto err; + break; + default: + dev_err(dev, "Invalid firmware layout type: %d\n", layout_type); + return -EINVAL; } + return 0; + +err: + sof_free_profile_strings(dev, default_profile); + return ret; } +static int +sof_file_profile_for_ipc_type(struct snd_sof_dev *sdev, + enum sof_ipc_type ipc_type, + const struct sof_dev_desc *desc, + struct sof_loadable_file_profile *base_profile, + struct sof_loadable_file_profile *out_profile) +{ + struct sof_loadable_file_profile default_profile = { 0 }; + bool found = false; + int i, ret; + + memset(out_profile, 0, sizeof(*out_profile)); + + for (i = 0; i < ARRAY_SIZE(fw_layouts); i++) { + if (fw_layouts[i].ipc_type != ipc_type) + continue; + + ret = sof_default_fw_layout(sdev->dev, i, desc->vendor, + desc->platform, + base_profile->fw_path_postfix, + &default_profile); + if (ret) + return ret; + + ret = sof_create_fw_profile(sdev, desc, &default_profile, + base_profile, out_profile); + if (!ret) { + found = true; + break; + } + + sof_free_profile_strings(sdev->dev, &default_profile); + } + + if (!found) + return -ENOENT; + + return 0; +} + static void sof_missing_firmware_notification(struct snd_sof_dev *sdev, enum sof_ipc_type ipc_type, struct sof_loadable_file_profile *base_profile) { + struct sof_loadable_file_profile default_profile = { 0 }; struct snd_sof_pdata *plat_data = sdev->pdata; const struct sof_dev_desc *desc = plat_data->desc; struct device *dev = sdev->dev; - int ipc_type_count, i; + int ipc_type_count, i, j, ret; char *marker; dev_err(dev, "SOF firmware and/or topology file not found.\n"); @@ -227,19 +457,26 @@ sof_missing_firmware_notification(struct snd_sof_dev *sdev, marker = "Fallback"; dev_info(dev, "- ipc type %d (%s):\n", i, marker); - if (base_profile->fw_path_postfix) - dev_info(dev, " Firmware file: %s/%s/%s\n", - desc->default_fw_path[i], - base_profile->fw_path_postfix, - desc->default_fw_filename[i]); - else - dev_info(dev, " Firmware file: %s/%s\n", - desc->default_fw_path[i], - desc->default_fw_filename[i]); - - dev_info(dev, " Topology file: %s/%s\n", - desc->default_tplg_path[i], - plat_data->tplg_filename); + for (j = 0; j < ARRAY_SIZE(fw_layouts); j++) { + if (fw_layouts[j].ipc_type != i) + continue; + + ret = sof_default_fw_layout(sdev->dev, j, desc->vendor, + desc->platform, + base_profile->fw_path_postfix, + &default_profile); + if (ret) + return; + + dev_info(dev, " Firmware layout: %s\n", + fw_layouts[j].layout_name); + dev_info(dev, " Firmware file: %s/%s\n", + default_profile.fw_path, default_profile.fw_name); + dev_info(dev, " Topology file: %s/%s\n", + default_profile.tplg_path, plat_data->tplg_filename); + + sof_free_profile_strings(sdev->dev, &default_profile); + } } if (base_profile->fw_path || base_profile->fw_name || @@ -277,8 +514,6 @@ int sof_create_ipc_file_profile(struct snd_sof_dev *sdev, const struct sof_dev_desc *desc = sdev->pdata->desc; int ipc_fallback_start, ret, i; - memset(out_profile, 0, sizeof(*out_profile)); - ret = sof_file_profile_for_ipc_type(sdev, base_profile->ipc_type, desc, base_profile, out_profile); if (!ret) From 0dd74f4f88a041a30cc2806ba7830dd39e458fc6 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 11:13:23 +0300 Subject: [PATCH 26/30] ASoC: SOF: amd: Drop default fw_path, tplg_path and fw_filename from descriptor The core no longer uses the default_fw_path, default_tplg_path and default_fw_filename. The paths and filename is created based on the vendor and platform strings. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/amd/pci-rmb.c | 9 --------- sound/soc/sof/amd/pci-rn.c | 9 --------- sound/soc/sof/amd/pci-vangogh.c | 9 --------- 3 files changed, 27 deletions(-) diff --git a/sound/soc/sof/amd/pci-rmb.c b/sound/soc/sof/amd/pci-rmb.c index 5861e544ae822f..508c6259d82fe2 100644 --- a/sound/soc/sof/amd/pci-rmb.c +++ b/sound/soc/sof/amd/pci-rmb.c @@ -51,15 +51,6 @@ static const struct sof_dev_desc rembrandt_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "amd", .platform = "rmb", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "amd/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "amd/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-rmb.ri", - }, .nocodec_tplg_filename = "sof-acp.tplg", .ops = &sof_rembrandt_ops, .ops_init = sof_rembrandt_ops_init, diff --git a/sound/soc/sof/amd/pci-rn.c b/sound/soc/sof/amd/pci-rn.c index 458e61c5b88808..90a9edae57944b 100644 --- a/sound/soc/sof/amd/pci-rn.c +++ b/sound/soc/sof/amd/pci-rn.c @@ -51,15 +51,6 @@ static const struct sof_dev_desc renoir_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "amd", .platform = "rn", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "amd/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "amd/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-rn.ri", - }, .nocodec_tplg_filename = "sof-acp.tplg", .ops = &sof_renoir_ops, .ops_init = sof_renoir_ops_init, diff --git a/sound/soc/sof/amd/pci-vangogh.c b/sound/soc/sof/amd/pci-vangogh.c index abba6c03ca44bf..a21674be337c7f 100644 --- a/sound/soc/sof/amd/pci-vangogh.c +++ b/sound/soc/sof/amd/pci-vangogh.c @@ -49,15 +49,6 @@ static const struct sof_dev_desc vangogh_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "amd", .platform = "vangogh", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "amd/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "amd/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-vangogh.ri", - }, .nocodec_tplg_filename = "sof-acp.tplg", .ops = &sof_vangogh_ops, .ops_init = sof_vangogh_ops_init, From 0d933447d4b7a7f73515c8d88d74192abd5cab2e Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 11:13:43 +0300 Subject: [PATCH 27/30] ASoC: SOF: imx: Drop default fw_path, tplg_path and fw_filename from descriptor The core no longer uses the default_fw_path, default_tplg_path and default_fw_filename. The paths and filename is created based on the vendor and platform strings. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/imx/imx8.c | 18 ------------------ sound/soc/sof/imx/imx8m.c | 9 --------- sound/soc/sof/imx/imx8ulp.c | 9 --------- 3 files changed, 36 deletions(-) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index 08c04b659bc83b..d3b667aae34dd7 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -615,15 +615,6 @@ static struct sof_dev_desc sof_of_imx8qxp_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "imx8x", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-imx8x.ri", - }, .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8x_ops, }; @@ -633,15 +624,6 @@ static struct sof_dev_desc sof_of_imx8qm_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "imx8", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-imx8.ri", - }, .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8_ops, }; diff --git a/sound/soc/sof/imx/imx8m.c b/sound/soc/sof/imx/imx8m.c index 65155562c38c0c..02d2c4fb8de379 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -475,15 +475,6 @@ static struct sof_dev_desc sof_of_imx8mp_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "imx", .platform = "imx8m", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-imx8m.ri", - }, .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8m_ops, }; diff --git a/sound/soc/sof/imx/imx8ulp.c b/sound/soc/sof/imx/imx8ulp.c index 5b43ebf315f61e..41961b91a01a40 100644 --- a/sound/soc/sof/imx/imx8ulp.c +++ b/sound/soc/sof/imx/imx8ulp.c @@ -482,15 +482,6 @@ static struct sof_dev_desc sof_of_imx8ulp_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "imx", .platform = "imx8ulp", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-imx8ulp.ri", - }, .nocodec_tplg_filename = "sof-imx8ulp-nocodec.tplg", .ops = &sof_imx8ulp_ops, }; From 30048630fe294698243027bc956ad3df5c1b02ef Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 11:14:15 +0300 Subject: [PATCH 28/30] ASoC: SOF: Intel: Drop default fw_path, tplg_path and fw_filename from descriptor The core no longer uses the default_fw_path, default_tplg_path and default_fw_filename. The paths and filename is created based on the vendor and platform strings. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/bdw.c | 9 --- sound/soc/sof/intel/byt.c | 27 -------- sound/soc/sof/intel/pci-apl.c | 30 --------- sound/soc/sof/intel/pci-cnl.c | 45 ------------- sound/soc/sof/intel/pci-icl.c | 30 --------- sound/soc/sof/intel/pci-lnl.c | 9 --- sound/soc/sof/intel/pci-mtl.c | 24 ------- sound/soc/sof/intel/pci-skl.c | 18 ----- sound/soc/sof/intel/pci-tgl.c | 120 ---------------------------------- sound/soc/sof/intel/pci-tng.c | 9 --- 10 files changed, 321 deletions(-) diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 043cca23e98afa..84fda61b95aa41 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -643,15 +643,6 @@ static const struct sof_dev_desc sof_acpi_broadwell_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "intel", .platform = "bdw", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-bdw.ri", - }, .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", .ops = &sof_bdw_ops, }; diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index b32629422dce6a..e1c7d694aabb8a 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -380,15 +380,6 @@ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "byt", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-byt.ri", - }, .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, }; @@ -404,15 +395,6 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "byt", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-byt.ri", - }, .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, }; @@ -428,15 +410,6 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "cht", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-cht.ri", - }, .nocodec_tplg_filename = "sof-cht-nocodec.tplg", .ops = &sof_cht_ops, }; diff --git a/sound/soc/sof/intel/pci-apl.c b/sound/soc/sof/intel/pci-apl.c index 3d36a8e64cf121..f1a800058ae680 100644 --- a/sound/soc/sof/intel/pci-apl.c +++ b/sound/soc/sof/intel/pci-apl.c @@ -34,21 +34,6 @@ static const struct sof_dev_desc bxt_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "apl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/apl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/apl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-apl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-apl-nocodec.tplg", .ops = &sof_apl_ops, .ops_init = sof_apl_ops_init, @@ -68,21 +53,6 @@ static const struct sof_dev_desc glk_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "glk", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/glk", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/glk", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-glk.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-glk-nocodec.tplg", .ops = &sof_apl_ops, .ops_init = sof_apl_ops_init, diff --git a/sound/soc/sof/intel/pci-cnl.c b/sound/soc/sof/intel/pci-cnl.c index 0dba5d9f8fb78b..a408ec22740f8f 100644 --- a/sound/soc/sof/intel/pci-cnl.c +++ b/sound/soc/sof/intel/pci-cnl.c @@ -35,21 +35,6 @@ static const struct sof_dev_desc cnl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "cnl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/cnl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/cnl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-cnl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .ops_init = sof_cnl_ops_init, @@ -70,21 +55,6 @@ static const struct sof_dev_desc cfl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "cfl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/cfl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/cfl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-cfl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .ops_init = sof_cnl_ops_init, @@ -105,21 +75,6 @@ static const struct sof_dev_desc cml_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "cml", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/cml", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/cml", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-cml.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .ops_init = sof_cnl_ops_init, diff --git a/sound/soc/sof/intel/pci-icl.c b/sound/soc/sof/intel/pci-icl.c index 9c583af68be661..421df56c83e041 100644 --- a/sound/soc/sof/intel/pci-icl.c +++ b/sound/soc/sof/intel/pci-icl.c @@ -35,21 +35,6 @@ static const struct sof_dev_desc icl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "icl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/icl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/icl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-icl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-icl-nocodec.tplg", .ops = &sof_icl_ops, .ops_init = sof_icl_ops_init, @@ -69,21 +54,6 @@ static const struct sof_dev_desc jsl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "jsl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/avs/jsl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/avs-lib/jsl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-jsl.ri", - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-jsl-nocodec.tplg", .ops = &sof_cnl_ops, .ops_init = sof_cnl_ops_init, diff --git a/sound/soc/sof/intel/pci-lnl.c b/sound/soc/sof/intel/pci-lnl.c index 2c85d682ad4031..3d971b195c6e48 100644 --- a/sound/soc/sof/intel/pci-lnl.c +++ b/sound/soc/sof/intel/pci-lnl.c @@ -34,15 +34,6 @@ static const struct sof_dev_desc lnl_desc = { .dspless_mode_supported = true, .vendor = "intel", .platform = "lnl", - .default_fw_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/lnl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ace-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_4] = "sof-lnl.ri", - }, .nocodec_tplg_filename = "sof-lnl-nocodec.tplg", .ops = &sof_lnl_ops, .ops_init = sof_lnl_ops_init, diff --git a/sound/soc/sof/intel/pci-mtl.c b/sound/soc/sof/intel/pci-mtl.c index 9962a2b45b6c26..bb320d0178aedb 100644 --- a/sound/soc/sof/intel/pci-mtl.c +++ b/sound/soc/sof/intel/pci-mtl.c @@ -34,18 +34,6 @@ static const struct sof_dev_desc mtl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = "intel", .platform = "mtl", - .default_fw_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/mtl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/mtl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ace-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_4] = "sof-mtl.ri", - }, .nocodec_tplg_filename = "sof-mtl-nocodec.tplg", .ops = &sof_mtl_ops, .ops_init = sof_mtl_ops_init, @@ -66,18 +54,6 @@ static const struct sof_dev_desc arl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = "intel", .platform = "mtl", - .default_fw_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/arl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/arl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ace-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_4] = "sof-arl.ri", - }, .nocodec_tplg_filename = "sof-arl-nocodec.tplg", .ops = &sof_mtl_ops, .ops_init = sof_mtl_ops_init, diff --git a/sound/soc/sof/intel/pci-skl.c b/sound/soc/sof/intel/pci-skl.c index ce8423092afdaa..b6d87f2663d21d 100644 --- a/sound/soc/sof/intel/pci-skl.c +++ b/sound/soc/sof/intel/pci-skl.c @@ -31,15 +31,6 @@ static struct sof_dev_desc skl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "skl", - .default_fw_path = { - [SOF_IPC_TYPE_4] = "intel/avs/skl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-skl-nocodec.tplg", .ops = &sof_skl_ops, .ops_init = sof_skl_ops_init, @@ -58,15 +49,6 @@ static struct sof_dev_desc kbl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "kbl", - .default_fw_path = { - [SOF_IPC_TYPE_4] = "intel/avs/kbl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_4] = "dsp_basefw.bin", - }, .nocodec_tplg_filename = "sof-kbl-nocodec.tplg", .ops = &sof_skl_ops, .ops_init = sof_skl_ops_init, diff --git a/sound/soc/sof/intel/pci-tgl.c b/sound/soc/sof/intel/pci-tgl.c index a60902f5c40ebb..311bc84bf92ef8 100644 --- a/sound/soc/sof/intel/pci-tgl.c +++ b/sound/soc/sof/intel/pci-tgl.c @@ -35,21 +35,6 @@ static const struct sof_dev_desc tgl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "tgl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/tgl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/tgl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-tgl.ri", - [SOF_IPC_TYPE_4] = "sof-tgl.ri", - }, .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -70,21 +55,6 @@ static const struct sof_dev_desc tglh_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "tgl-h", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/tgl-h", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/tgl-h", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-tgl-h.ri", - [SOF_IPC_TYPE_4] = "sof-tgl-h.ri", - }, .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -104,21 +74,6 @@ static const struct sof_dev_desc ehl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "ehl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/ehl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/ehl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-ehl.ri", - [SOF_IPC_TYPE_4] = "sof-ehl.ri", - }, .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -139,21 +94,6 @@ static const struct sof_dev_desc adls_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "adl-s", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl-s", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/adl-s", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-adl-s.ri", - [SOF_IPC_TYPE_4] = "sof-adl-s.ri", - }, .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -174,21 +114,6 @@ static const struct sof_dev_desc adl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "adl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/adl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-adl.ri", - [SOF_IPC_TYPE_4] = "sof-adl.ri", - }, .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -209,21 +134,6 @@ static const struct sof_dev_desc adl_n_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "adl-n", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/adl-n", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/adl-n", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-adl-n.ri", - [SOF_IPC_TYPE_4] = "sof-adl-n.ri", - }, .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -244,21 +154,6 @@ static const struct sof_dev_desc rpls_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "rpl-s", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/rpl-s", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/rpl-s", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-rpl-s.ri", - [SOF_IPC_TYPE_4] = "sof-rpl-s.ri", - }, .nocodec_tplg_filename = "sof-rpl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -279,21 +174,6 @@ static const struct sof_dev_desc rpl_desc = { .dspless_mode_supported = true, /* Only supported for HDaudio */ .vendor = vendor_string, .platform = "rpl", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4/rpl", - }, - .default_lib_path = { - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-lib/rpl", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - [SOF_IPC_TYPE_4] = "intel/sof-ipc4-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-rpl.ri", - [SOF_IPC_TYPE_4] = "sof-rpl.ri", - }, .nocodec_tplg_filename = "sof-rpl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, diff --git a/sound/soc/sof/intel/pci-tng.c b/sound/soc/sof/intel/pci-tng.c index f5659dd813b403..73af0d6ad9e84a 100644 --- a/sound/soc/sof/intel/pci-tng.c +++ b/sound/soc/sof/intel/pci-tng.c @@ -212,15 +212,6 @@ static const struct sof_dev_desc tng_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "intel", .platform = "byt", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-byt.ri", - }, .nocodec_tplg_filename = "sof-byt.tplg", .ops = &sof_tng_ops, }; From 54150df03d55a7f1bb5f28bb0cbd0e0109eeed5d Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 11:14:42 +0300 Subject: [PATCH 29/30] ASoC: SOF: mediatek: Drop default fw_path, tplg_path and fw_filename from descriptor The core no longer uses the default_fw_path, default_tplg_path and default_fw_filename. The paths and filename is created based on the vendor and platform strings. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/mediatek/mt8186/mt8186.c | 18 ------------------ sound/soc/sof/mediatek/mt8195/mt8195.c | 9 --------- 2 files changed, 27 deletions(-) diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 132a9c8f4866b9..536c222f1decfb 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -613,15 +613,6 @@ static const struct sof_dev_desc sof_of_mt8186_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "mt8186", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "mediatek/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "mediatek/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-mt8186.ri", - }, .nocodec_tplg_filename = "sof-mt8186-nocodec.tplg", .ops = &sof_mt8186_ops, }; @@ -689,15 +680,6 @@ static const struct sof_dev_desc sof_of_mt8188_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = vendor_string, .platform = "mt8188", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "mediatek/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "mediatek/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-mt8188.ri", - }, .nocodec_tplg_filename = "sof-mt8188-nocodec.tplg", .ops = &sof_mt8188_ops, .ops_init = sof_mt8188_ops_init, diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index fa20be75046d94..33d18b7935d259 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -639,15 +639,6 @@ static const struct sof_dev_desc sof_of_mt8195_desc = { .ipc_default = SOF_IPC_TYPE_3, .vendor = "mediatek", .platform = "mt8195", - .default_fw_path = { - [SOF_IPC_TYPE_3] = "mediatek/sof", - }, - .default_tplg_path = { - [SOF_IPC_TYPE_3] = "mediatek/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC_TYPE_3] = "sof-mt8195.ri", - }, .nocodec_tplg_filename = "sof-mt8195-nocodec.tplg", .ops = &sof_mt8195_ops, .ipc_timeout = 1000, From b6904192884ff079eb7e39085f374f89966213c4 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Apr 2023 11:16:33 +0300 Subject: [PATCH 30/30] ASoC: SOF: Remove the string arrays used for default paths and firmware name The default_fw_path, default_tplg_path, default_lib_path and default_fw_filename are no longer used, they can be removed from sof_dev_desc. Signed-off-by: Peter Ujfalusi --- include/sound/sof.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/sound/sof.h b/include/sound/sof.h index 19a455c568a5d2..ecb43e76100190 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -157,14 +157,6 @@ struct sof_dev_desc { /* The platform supports DSPless mode */ bool dspless_mode_supported; - /* defaults paths for firmware, library and topology files */ - const char *default_fw_path[SOF_IPC_TYPE_COUNT]; - const char *default_lib_path[SOF_IPC_TYPE_COUNT]; - const char *default_tplg_path[SOF_IPC_TYPE_COUNT]; - - /* default firmware name */ - const char *default_fw_filename[SOF_IPC_TYPE_COUNT]; - /* strings used for the firmware layout path/filename creation */ const char *vendor; const char *platform;