diff --git a/include/sound/sof.h b/include/sound/sof.h index d3c41f87ac3191..30fe18ac0be2c3 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -50,13 +50,59 @@ enum sof_dsp_power_states { SOF_DSP_PM_D3, }; +/** + * enum sof_fw_layout_type - pre-defined file-layout for loadable fw files + * @SOF_FW_LAYOUT_VENDOR_IPC3: + * firmware path: /sof + * firmware name: sof-.ri + * topology path: /sof-tplg/ + * @SOF_FW_LAYOUT_VENDOR_IPC4_SOF: + * firmware path: /sof-ipc4/ + * firmware name: sof-.ri + * firmware lib path: /sof-ipc4-lib/ + * topology path: /sof-ipc4-tplg/ + * @SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_AVS: + * firmware path: intel/avs/ + * firmware name: dsp_basefw.bin + * firmware lib path: intel/avs-lib/ + * topology path: intel/avs-tplg/ + * @SOF_FW_LAYOUT_VENDOR_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/ + */ +enum sof_fw_layout_type { + SOF_FW_LAYOUT_VENDOR_IPC3, + SOF_FW_LAYOUT_VENDOR_IPC4_SOF, + SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_AVS, + SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_ACE, + SOF_FW_LAYOUT_COUNT, +}; + /* Definitions for multiple IPCs */ enum sof_ipc_type { - SOF_IPC, - SOF_INTEL_IPC4, + SOF_IPC_TYPE_3, + SOF_IPC_TYPE_4, SOF_IPC_TYPE_COUNT }; +/** + * struct sof_fw_layout_profile - Description of a firmware layout and type + * @ipc_type: IPC type of the profile + * @fw_path: Path where the @fw_filename resides + * @fw_lib_path: Path where the external libraries can be found (IPC4 only) + * @fw_name: Name of the frmware file + * @tplg_path: Path where to look for the topology files + */ +struct sof_fw_layout_profile { + enum sof_ipc_type ipc_type; + const char *fw_path; + const char *fw_lib_path; + const char *fw_name; + const char *tplg_path; +}; + /* * SOF Platform data. */ @@ -79,6 +125,8 @@ struct snd_sof_pdata { const struct sof_dev_desc *desc; /* firmware and topology filenames */ + struct sof_fw_layout_profile default_fw_profile; + const char *fw_filename_prefix; const char *fw_filename; const char *tplg_filename_prefix; @@ -135,13 +183,9 @@ 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; struct snd_sof_dsp_ops *ops; int (*ops_init)(struct snd_sof_dev *sdev); diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index a2725188f4ce48..ae101e7fd199a0 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -272,7 +272,7 @@ config SND_SOC_SOF_PROBE_WORK_QUEUE config SND_SOC_SOF_IPC3 bool -config SND_SOC_SOF_INTEL_IPC4 +config SND_SOC_SOF_IPC4 bool source "sound/soc/sof/amd/Kconfig" diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index 308d8763991636..a2069add19a784 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -1,14 +1,15 @@ # 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-layout.o # IPC implementations ifneq ($(CONFIG_SND_SOC_SOF_IPC3),) snd-sof-objs += ipc3.o ipc3-loader.o ipc3-topology.o ipc3-control.o ipc3-pcm.o\ ipc3-dtrace.o endif -ifneq ($(CONFIG_SND_SOC_SOF_INTEL_IPC4),) +ifneq ($(CONFIG_SND_SOC_SOF_IPC4),) snd-sof-objs += ipc4.o ipc4-loader.o ipc4-topology.o ipc4-control.o ipc4-pcm.o\ ipc4-mtrace.o endif @@ -30,7 +31,7 @@ snd-sof-probes-objs := sof-client-probes.o ifneq ($(CONFIG_SND_SOC_SOF_IPC3),) snd-sof-probes-objs += sof-client-probes-ipc3.o endif -ifneq ($(CONFIG_SND_SOC_SOF_INTEL_IPC4),) +ifneq ($(CONFIG_SND_SOC_SOF_IPC4),) snd-sof-probes-objs += sof-client-probes-ipc4.o endif diff --git a/sound/soc/sof/amd/pci-rmb.c b/sound/soc/sof/amd/pci-rmb.c index eaf70ea6e556e9..a64e135b0420d7 100644 --- a/sound/soc/sof/amd/pci-rmb.c +++ b/sound/soc/sof/amd/pci-rmb.c @@ -45,17 +45,10 @@ static const struct sof_dev_desc rembrandt_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &rembrandt_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "amd/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "amd/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-rmb.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "amd", + .platform = "rmb", .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 4809cb644152b1..2a1210910e521d 100644 --- a/sound/soc/sof/amd/pci-rn.c +++ b/sound/soc/sof/amd/pci-rn.c @@ -45,17 +45,10 @@ static const struct sof_dev_desc renoir_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &renoir_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "amd/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "amd/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-rn.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "amd", + .platform = "rn", .nocodec_tplg_filename = "sof-acp.tplg", .ops = &sof_renoir_ops, .ops_init = sof_renoir_ops_init, diff --git a/sound/soc/sof/fw-file-layout.c b/sound/soc/sof/fw-file-layout.c new file mode 100644 index 00000000000000..72606c9507cbba --- /dev/null +++ b/sound/soc/sof/fw-file-layout.c @@ -0,0 +1,355 @@ +// 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 +#include +#include "sof-priv.h" + +struct sof_profile_ipc_type_table { + enum sof_fw_layout_type layout_type; + enum sof_ipc_type ipc_type; +}; + +static const enum sof_ipc_type layout_to_ipc_type_map[] = { + [SOF_FW_LAYOUT_VENDOR_IPC3] = SOF_IPC_TYPE_3, + [SOF_FW_LAYOUT_VENDOR_IPC4_SOF] = SOF_IPC_TYPE_4, + [SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_AVS] = SOF_IPC_TYPE_4, + [SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_ACE] = SOF_IPC_TYPE_4, +}; + +static void sof_free_profile_strings(struct device *dev, + struct sof_fw_layout_profile *fw_layout) +{ + devm_kfree(dev, fw_layout->fw_path); + devm_kfree(dev, fw_layout->fw_lib_path); + devm_kfree(dev, fw_layout->fw_name); + devm_kfree(dev, fw_layout->tplg_path); + + fw_layout->fw_path = NULL; + fw_layout->fw_lib_path = NULL; + fw_layout->fw_name = NULL; + fw_layout->tplg_path = NULL; +} + +static int +setup_fw_layout_profile(struct device *dev, + const enum sof_fw_layout_type layout_type, + const char *vendor_name, const char *platform_name, + const char *fw_path_postfix, + struct sof_fw_layout_profile *out_layout) +{ + int ret = -ENOMEM; + const char *str; + + switch (layout_type) { + case SOF_FW_LAYOUT_VENDOR_IPC3: + out_layout->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_name, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof", + vendor_name); + if (!str) + return -ENOMEM; + + out_layout->fw_path = str; + + out_layout->fw_name = devm_kasprintf(dev, GFP_KERNEL, + "sof-%s.ri", + platform_name); + if (!out_layout->fw_name) + goto err; + + out_layout->tplg_path = devm_kasprintf(dev, GFP_KERNEL, + "%s/sof-tplg", + vendor_name); + if (!out_layout->tplg_path) + goto err; + break; + case SOF_FW_LAYOUT_VENDOR_IPC4_SOF: + out_layout->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_name, platform_name, + fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "%s/sof-ipc4/%s", + vendor_name, platform_name); + if (!str) + return -ENOMEM; + + out_layout->fw_path = str; + + out_layout->fw_name = devm_kasprintf(dev, GFP_KERNEL, + "sof-%s.ri", + platform_name); + if (!out_layout->fw_name) + goto err; + + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, + "%s/sof-ipc4-lib/%s/%s", + vendor_name, platform_name, + fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, + "%s/sof-ipc4-lib/%s", + vendor_name, platform_name); + if (!str) + goto err; + + out_layout->fw_lib_path = str; + + out_layout->tplg_path = devm_kasprintf(dev, GFP_KERNEL, + "%s/sof-ace-tplg", + vendor_name); + if (!out_layout->tplg_path) + goto err; + break; + case SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_AVS: + out_layout->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_name, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, "intel/avs/%s", + platform_name); + if (!str) + return -ENOMEM; + + out_layout->fw_path = str; + + out_layout->fw_name = devm_kstrdup(dev, "dsp_basefw.bin", + GFP_KERNEL); + if (!out_layout->fw_name) + goto err; + + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, + "intel/avs-lib/%s/%s", + platform_name, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, + "intel/avs-lib/%s", + platform_name); + if (!str) + goto err; + + out_layout->fw_lib_path = str; + + out_layout->tplg_path = devm_kstrdup(dev, "intel/avs-tplg", + GFP_KERNEL); + if (!out_layout->tplg_path) + goto err; + break; + case SOF_FW_LAYOUT_VENDOR_IPC4_INTEL_ACE: + out_layout->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_name, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, + "intel/sof-ipc4/%s", + platform_name); + if (!str) + return -ENOMEM; + + out_layout->fw_path = str; + + out_layout->fw_name = devm_kasprintf(dev, GFP_KERNEL, + "sof-%s.ri", + platform_name); + if (!out_layout->fw_name) + goto err; + + if (fw_path_postfix) + str = devm_kasprintf(dev, GFP_KERNEL, + "intel/sof-ipc4-lib/%s/%s", + platform_name, fw_path_postfix); + else + str = devm_kasprintf(dev, GFP_KERNEL, + "intel/sof-ipc4-lib/%s", + platform_name); + if (!str) + goto err; + + out_layout->fw_lib_path = str; + + out_layout->tplg_path = devm_kstrdup(dev, "intel/sof-ace-tplg", + GFP_KERNEL); + if (!out_layout->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, out_layout); + + return ret; +} + +static int sof_test_fw_layout(struct device *dev, + struct sof_fw_layout_profile *fw_layout) +{ + 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", fw_layout->fw_path, + fw_layout->fw_name); + if (!fw_filename) + return -ENOMEM; + + ret = firmware_request_nowarn(&fw, fw_filename, dev); + if (ret < 0) + 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 (fw_ipc_type != fw_layout->ipc_type) { + dev_err(dev, + "ipc type mismatch between file and profile: %d vs %d\n", + fw_ipc_type, fw_layout->ipc_type); + ret = -EINVAL; + } +out: + release_firmware(fw); + + return ret; +} + +static int fw_layout_for_ipc_type(struct device *dev, + const enum sof_ipc_type ipc_type, + const struct sof_dev_desc *desc, + const char *fw_path_postfix, + struct sof_fw_layout_profile *out_layout) +{ + bool found = false; + int i, ret; + + memset(out_layout, 0, sizeof(*out_layout)); + + for (i = 0; i < ARRAY_SIZE(layout_to_ipc_type_map); i++) { + if (layout_to_ipc_type_map[i] != ipc_type) + continue; + + ret = setup_fw_layout_profile(dev, i, desc->vendor, + desc->platform, fw_path_postfix, + out_layout); + if (ret) + return ret; + + ret = sof_test_fw_layout(dev, out_layout); + if (!ret) { + found = true; + break; + } + + sof_free_profile_strings(dev, out_layout); + } + + if (!found) + return -ENOENT; + + dev_dbg(dev, "Default profile type for IPC type %d: %d\n", ipc_type, i); + + return 0; +} + +int sof_create_default_fw_layout_profile(struct device *dev, + const enum sof_ipc_type ipc_type, + const struct sof_dev_desc *desc, + const char *fw_path_postfix, + struct sof_fw_layout_profile *out_layout) +{ + int ret = -ENOENT; + int i; + + memset(out_layout, 0, sizeof(*out_layout)); + + ret = fw_layout_for_ipc_type(dev, ipc_type, desc, fw_path_postfix, + out_layout); + if (!ret) + return 0; + + dev_warn(dev, "No default profile found for requested IPC type %d\n", + ipc_type); + + /* + * 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 == ipc_type || !(desc->ipc_supported_mask & BIT(i))) + continue; + + ret = fw_layout_for_ipc_type(dev, i, desc, fw_path_postfix, + out_layout); + if (!ret) + break; + + dev_info(dev, "No default profile found for fallback IPC type%d\n", + ipc_type); + } + + if (ret) { + dev_err(dev, "No sof firmware file was found, you might need to\n"); + dev_err(dev, + " download it from https://github.com/thesofproject/sof-bin/\n"); + } + + return ret; +} +EXPORT_SYMBOL(sof_create_default_fw_layout_profile); diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index 2844d9a8040ad9..d3b667aae34dd7 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -608,34 +608,22 @@ 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), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-imx8x.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "imx8x", .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8x_ops, }; static struct sof_dev_desc sof_of_imx8qm_desc = { - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-imx8.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "imx8", .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 1243f8a6141eaa..02d2c4fb8de379 100644 --- a/sound/soc/sof/imx/imx8m.c +++ b/sound/soc/sof/imx/imx8m.c @@ -471,17 +471,10 @@ static struct snd_sof_dsp_ops sof_imx8m_ops = { }; static struct sof_dev_desc sof_of_imx8mp_desc = { - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-imx8m.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "imx", + .platform = "imx8m", .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 4a562c9856e93c..41961b91a01a40 100644 --- a/sound/soc/sof/imx/imx8ulp.c +++ b/sound/soc/sof/imx/imx8ulp.c @@ -478,17 +478,10 @@ static struct snd_sof_dsp_ops sof_imx8ulp_ops = { }; static struct sof_dev_desc sof_of_imx8ulp_desc = { - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "imx/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "imx/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-imx8ulp.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "imx", + .platform = "imx8ulp", .nocodec_tplg_filename = "sof-imx8ulp-nocodec.tplg", .ops = &sof_imx8ulp_ops, }; diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig index ff45e28712d783..16704359593ac7 100644 --- a/sound/soc/sof/intel/Kconfig +++ b/sound/soc/sof/intel/Kconfig @@ -98,7 +98,7 @@ config SND_SOC_SOF_MERRIFIELD config SND_SOC_SOF_INTEL_SKL tristate select SND_SOC_SOF_HDA_COMMON - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_SKYLAKE tristate "SOF support for SkyLake" @@ -124,7 +124,7 @@ config SND_SOC_SOF_INTEL_APL tristate select SND_SOC_SOF_HDA_COMMON select SND_SOC_SOF_IPC3 - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_APOLLOLAKE tristate "SOF support for Apollolake" @@ -151,7 +151,7 @@ config SND_SOC_SOF_INTEL_CNL select SND_SOC_SOF_HDA_COMMON select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE select SND_SOC_SOF_IPC3 - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_CANNONLAKE tristate "SOF support for Cannonlake" @@ -187,7 +187,7 @@ config SND_SOC_SOF_INTEL_ICL select SND_SOC_SOF_HDA_COMMON select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE select SND_SOC_SOF_IPC3 - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_ICELAKE tristate "SOF support for Icelake" @@ -214,7 +214,7 @@ config SND_SOC_SOF_INTEL_TGL select SND_SOC_SOF_HDA_COMMON select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE select SND_SOC_SOF_IPC3 - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_TIGERLAKE tristate "SOF support for Tigerlake" @@ -250,7 +250,7 @@ config SND_SOC_SOF_INTEL_MTL tristate select SND_SOC_SOF_HDA_COMMON select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_METEORLAKE tristate "SOF support for Meteorlake" @@ -266,7 +266,7 @@ config SND_SOC_SOF_INTEL_LNL tristate select SND_SOC_SOF_HDA_COMMON select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE - select SND_SOC_SOF_INTEL_IPC4 + select SND_SOC_SOF_IPC4 config SND_SOC_SOF_LUNARLAKE tristate "SOF support for Lunarlake" diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index e1f25a8f0c3262..776b66389c345b 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -39,7 +39,7 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev) /* probe/remove/shutdown */ sof_apl_ops.shutdown = hda_dsp_shutdown; - if (sdev->pdata->ipc_type == SOF_IPC) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { /* doorbell */ sof_apl_ops.irq_thread = hda_dsp_ipc_irq_thread; @@ -52,7 +52,7 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev) sof_apl_ops.set_power_state = hda_dsp_set_power_state_ipc3; } - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + 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); diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 812a49b1d3f496..84fda61b95aa41 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -639,17 +639,10 @@ static const struct sof_dev_desc sof_acpi_broadwell_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = 0, .chip_info = &bdw_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-bdw.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "intel", + .platform = "bdw", .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 faf223b383605b..e1c7d694aabb8a 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, @@ -374,17 +376,10 @@ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .resindex_imr_base = 2, .irqindex_host_ipc = 0, .chip_info = &byt_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-byt.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "byt", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, }; @@ -396,17 +391,10 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { .resindex_imr_base = 2, .irqindex_host_ipc = 5, .chip_info = &byt_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-byt.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "byt", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, }; @@ -418,17 +406,10 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { .resindex_imr_base = 2, .irqindex_host_ipc = 5, .chip_info = &cht_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-cht.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "cht", .nocodec_tplg_filename = "sof-cht-nocodec.tplg", .ops = &sof_cht_ops, }; diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index a95222e53ecf30..bb1a3aa78da44a 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -386,7 +386,7 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev) sof_cnl_ops.shutdown = hda_dsp_shutdown; /* ipc */ - if (sdev->pdata->ipc_type == SOF_IPC) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { /* doorbell */ sof_cnl_ops.irq_thread = cnl_ipc_irq_thread; @@ -399,7 +399,7 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev) sof_cnl_ops.set_power_state = hda_dsp_set_power_state_ipc3; } - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + 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); diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 24325c22c1ea2d..b8cef34e1601bf 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -448,7 +448,7 @@ hda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidg sdai = swidget->private; switch (sdev->pdata->ipc_type) { - case SOF_IPC: + case SOF_IPC_TYPE_3: { struct sof_dai_private_data *private = sdai->private; @@ -456,7 +456,7 @@ hda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidg return &hda_ipc3_dma_ops; break; } - case SOF_INTEL_IPC4: + case SOF_IPC_TYPE_4: { struct sof_ipc4_copier *ipc4_copier = sdai->private; diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index f4c8d8d28d1d65..67a43b33699599 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -378,7 +378,7 @@ void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops) #endif } - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4 && !hda_use_tplg_nhlt) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4 && !hda_use_tplg_nhlt) { struct sof_ipc4_fw_data *ipc4_data = sdev->private; ipc4_data->nhlt = intel_nhlt_init(sdev->dev); @@ -387,7 +387,7 @@ void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops) void hda_ops_free(struct snd_sof_dev *sdev) { - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_fw_data *ipc4_data = sdev->private; if (!hda_use_tplg_nhlt) diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c index 50ce6b190002e2..769697bdc3951a 100644 --- a/sound/soc/sof/intel/hda-loader.c +++ b/sound/soc/sof/intel/hda-loader.c @@ -605,7 +605,7 @@ int hda_dsp_post_fw_run(struct snd_sof_dev *sdev) /* Check if IMR boot is usable */ if (!sof_debug_check_flag(SOF_DBG_IGNORE_D3_PERSISTENT) && (sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT || - sdev->pdata->ipc_type == SOF_INTEL_IPC4)) + sdev->pdata->ipc_type == SOF_IPC_TYPE_4)) hdev->imrboot_supported = true; } diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index e92acfd4e2f936..cec30947f9ab69 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -676,7 +676,7 @@ void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags) hda_dsp_get_state(sdev, level); /* The firmware register dump only available with IPC3 */ - if (flags & SOF_DBG_DUMP_REGS && sdev->pdata->ipc_type == SOF_IPC) { + if (flags & SOF_DBG_DUMP_REGS && sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { u32 status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_STATUS); u32 panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_TRACEP); diff --git a/sound/soc/sof/intel/icl.c b/sound/soc/sof/intel/icl.c index 0f249efc6a5a28..996efe4da8c752 100644 --- a/sound/soc/sof/intel/icl.c +++ b/sound/soc/sof/intel/icl.c @@ -107,7 +107,7 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev) /* probe/remove/shutdown */ sof_icl_ops.shutdown = hda_dsp_shutdown; - if (sdev->pdata->ipc_type == SOF_IPC) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { /* doorbell */ sof_icl_ops.irq_thread = cnl_ipc_irq_thread; @@ -120,7 +120,7 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev) sof_icl_ops.set_power_state = hda_dsp_set_power_state_ipc3; } - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + 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); diff --git a/sound/soc/sof/intel/pci-apl.c b/sound/soc/sof/intel/pci-apl.c index 69cad5a6bc724e..a6cf777a2967d0 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, @@ -27,24 +29,11 @@ static const struct sof_dev_desc bxt_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &apl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/apl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/apl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-apl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "apl", .nocodec_tplg_filename = "sof-apl-nocodec.tplg", .ops = &sof_apl_ops, .ops_init = sof_apl_ops_init, @@ -59,24 +48,11 @@ static const struct sof_dev_desc glk_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &apl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/glk", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/glk", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-glk.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "glk", .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 8895508a0be6d7..21e3b9affe851e 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, @@ -28,24 +30,11 @@ static const struct sof_dev_desc cnl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &cnl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/cnl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/cnl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-cnl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "cnl", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .ops_init = sof_cnl_ops_init, @@ -61,24 +50,11 @@ static const struct sof_dev_desc cfl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &cnl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/cnl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/cnl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-cfl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "cfl", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .ops_init = sof_cnl_ops_init, @@ -94,24 +70,11 @@ static const struct sof_dev_desc cml_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &cnl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/cnl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/cnl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-cml.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "cml", .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 5fb5a820693e4a..f41bfd8a85b8fd 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, @@ -28,24 +30,11 @@ static const struct sof_dev_desc icl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &icl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/icl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/icl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-icl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "icl", .nocodec_tplg_filename = "sof-icl-nocodec.tplg", .ops = &sof_icl_ops, .ops_init = sof_icl_ops_init, @@ -60,24 +49,11 @@ static const struct sof_dev_desc jsl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &jsl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/jsl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/jsl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-jsl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "jsl", .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 2b6756f45e801b..be7f28131fd843 100644 --- a/sound/soc/sof/intel/pci-lnl.c +++ b/sound/soc/sof/intel/pci-lnl.c @@ -29,18 +29,11 @@ static const struct sof_dev_desc lnl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &lnl_chip_info, - .ipc_supported_mask = BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_INTEL_IPC4, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), + .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, - .default_fw_path = { - [SOF_INTEL_IPC4] = "intel/sof-ipc4/lnl", - }, - .default_tplg_path = { - [SOF_INTEL_IPC4] = "intel/sof-ace-tplg", - }, - .default_fw_filename = { - [SOF_INTEL_IPC4] = "sof-lnl.ri", - }, + .vendor = "intel", + .platform = "lnl", .nocodec_tplg_filename = "sof-lnl-nocodec.tplg", /* the MTL ops are still used for now */ .ops = &sof_mtl_ops, diff --git a/sound/soc/sof/intel/pci-mtl.c b/sound/soc/sof/intel/pci-mtl.c index e276e1e37fed8e..16438290d6c66a 100644 --- a/sound/soc/sof/intel/pci-mtl.c +++ b/sound/soc/sof/intel/pci-mtl.c @@ -29,21 +29,11 @@ static const struct sof_dev_desc mtl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &mtl_chip_info, - .ipc_supported_mask = BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_INTEL_IPC4, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), + .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ - .default_fw_path = { - [SOF_INTEL_IPC4] = "intel/sof-ipc4/mtl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/sof-ipc4-lib/mtl", - }, - .default_tplg_path = { - [SOF_INTEL_IPC4] = "intel/sof-ace-tplg", - }, - .default_fw_filename = { - [SOF_INTEL_IPC4] = "sof-mtl.ri", - }, + .vendor = "intel", + .platform = "mtl", .nocodec_tplg_filename = "sof-mtl-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 5e69af6eed344b..c779f1d1966ba7 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, @@ -24,18 +26,11 @@ static struct sof_dev_desc skl_desc = { .resindex_imr_base = -1, .chip_info = &skl_chip_info, .irqindex_host_ipc = -1, - .ipc_supported_mask = BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_INTEL_IPC4, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), + .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ - .default_fw_path = { - [SOF_INTEL_IPC4] = "intel/avs/skl", - }, - .default_tplg_path = { - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "skl", .nocodec_tplg_filename = "sof-skl-nocodec.tplg", .ops = &sof_skl_ops, .ops_init = sof_skl_ops_init, @@ -49,18 +44,11 @@ static struct sof_dev_desc kbl_desc = { .resindex_imr_base = -1, .chip_info = &skl_chip_info, .irqindex_host_ipc = -1, - .ipc_supported_mask = BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_INTEL_IPC4, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_4), + .ipc_default = SOF_IPC_TYPE_4, .dspless_mode_supported = true, /* Only supported for HDaudio */ - .default_fw_path = { - [SOF_INTEL_IPC4] = "intel/avs/kbl", - }, - .default_tplg_path = { - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "kbl", .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 ca37ff1bbd2ae5..d9c2d6868ed6bd 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, @@ -28,24 +30,11 @@ static const struct sof_dev_desc tgl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &tgl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/tgl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/tgl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-tgl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "tgl", .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -61,24 +50,11 @@ static const struct sof_dev_desc tglh_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &tglh_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/tgl-h", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/tgl-h", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-tgl-h.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "tgl-h", .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -93,24 +69,11 @@ static const struct sof_dev_desc ehl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &ehl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/ehl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/ehl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-ehl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "ehl", .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -126,24 +89,11 @@ static const struct sof_dev_desc adls_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &adls_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/adl-s", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/adl-s", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-adl-s.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "adl-s", .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -159,24 +109,11 @@ static const struct sof_dev_desc adl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &tgl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/adl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/adl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-adl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "adl", .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -192,24 +129,11 @@ static const struct sof_dev_desc adl_n_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &tgl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/adl-n", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/adl-n", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-adl-n.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "adl-n", .nocodec_tplg_filename = "sof-adl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -225,24 +149,11 @@ static const struct sof_dev_desc rpls_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &adls_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/rpl-s", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/rpl-s", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-rpl-s.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "rpl-s", .nocodec_tplg_filename = "sof-rpl-nocodec.tplg", .ops = &sof_tgl_ops, .ops_init = sof_tgl_ops_init, @@ -258,24 +169,11 @@ static const struct sof_dev_desc rpl_desc = { .resindex_imr_base = -1, .irqindex_host_ipc = -1, .chip_info = &tgl_chip_info, - .ipc_supported_mask = BIT(SOF_IPC) | BIT(SOF_INTEL_IPC4), - .ipc_default = SOF_IPC, + .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 */ - .default_fw_path = { - [SOF_IPC] = "intel/sof", - [SOF_INTEL_IPC4] = "intel/avs/rpl", - }, - .default_lib_path = { - [SOF_INTEL_IPC4] = "intel/avs-lib/rpl", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - [SOF_INTEL_IPC4] = "intel/avs-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-rpl.ri", - [SOF_INTEL_IPC4] = "dsp_basefw.bin", - }, + .vendor = vendor_string, + .platform = "rpl", .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 8c22a00266c06a..82bda665b5aa57 100644 --- a/sound/soc/sof/intel/pci-tng.c +++ b/sound/soc/sof/intel/pci-tng.c @@ -208,17 +208,10 @@ static const struct sof_dev_desc tng_desc = { .resindex_imr_base = 0, .irqindex_host_ipc = -1, .chip_info = &tng_chip_info, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "intel/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "intel/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-byt.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "intel", + .platform = "byt", .nocodec_tplg_filename = "sof-byt.tplg", .ops = &sof_tng_ops, }; diff --git a/sound/soc/sof/intel/tgl.c b/sound/soc/sof/intel/tgl.c index 8e2b07e1612b76..c6627deab708d2 100644 --- a/sound/soc/sof/intel/tgl.c +++ b/sound/soc/sof/intel/tgl.c @@ -66,7 +66,7 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev) /* probe/remove/shutdown */ sof_tgl_ops.shutdown = hda_dsp_shutdown_dma_flush; - if (sdev->pdata->ipc_type == SOF_IPC) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { /* doorbell */ sof_tgl_ops.irq_thread = cnl_ipc_irq_thread; @@ -79,7 +79,7 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev) sof_tgl_ops.set_power_state = hda_dsp_set_power_state_ipc3; } - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + 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); diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index b53abc92302669..febe372f9aa876 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -165,12 +165,12 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev) switch (sdev->pdata->ipc_type) { #if defined(CONFIG_SND_SOC_SOF_IPC3) - case SOF_IPC: + case SOF_IPC_TYPE_3: ops = &ipc3_ops; break; #endif -#if defined(CONFIG_SND_SOC_SOF_INTEL_IPC4) - case SOF_INTEL_IPC4: +#if defined(CONFIG_SND_SOC_SOF_IPC4) + case SOF_IPC_TYPE_4: ops = &ipc4_ops; break; #endif diff --git a/sound/soc/sof/ipc3-dtrace.c b/sound/soc/sof/ipc3-dtrace.c index 1d3bca2d28dd61..7f240c1ba319e4 100644 --- a/sound/soc/sof/ipc3-dtrace.c +++ b/sound/soc/sof/ipc3-dtrace.c @@ -501,7 +501,7 @@ static int ipc3_dtrace_init(struct snd_sof_dev *sdev) int ret; /* dtrace is only supported with SOF_IPC */ - if (sdev->pdata->ipc_type != SOF_IPC) + if (sdev->pdata->ipc_type != SOF_IPC_TYPE_3) return -EOPNOTSUPP; if (sdev->fw_trace_data) { diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 597cb4476acb41..2ab66dd70b5eb8 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -611,35 +611,23 @@ 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), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "mediatek/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "mediatek/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-mt8186.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "mt8186", .nocodec_tplg_filename = "sof-mt8186-nocodec.tplg", .ops = &sof_mt8186_ops, }; static const struct sof_dev_desc sof_of_mt8188_desc = { - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "mediatek/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "mediatek/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-mt8188.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = vendor_string, + .platform = "mt8188", .nocodec_tplg_filename = "sof-mt8188-nocodec.tplg", .ops = &sof_mt8186_ops, }; diff --git a/sound/soc/sof/mediatek/mt8195/mt8195.c b/sound/soc/sof/mediatek/mt8195/mt8195.c index 42bae574c87ab2..57deacc989defb 100644 --- a/sound/soc/sof/mediatek/mt8195/mt8195.c +++ b/sound/soc/sof/mediatek/mt8195/mt8195.c @@ -669,17 +669,10 @@ static struct snd_sof_of_mach sof_mt8195_machs[] = { static const struct sof_dev_desc sof_of_mt8195_desc = { .of_machines = sof_mt8195_machs, - .ipc_supported_mask = BIT(SOF_IPC), - .ipc_default = SOF_IPC, - .default_fw_path = { - [SOF_IPC] = "mediatek/sof", - }, - .default_tplg_path = { - [SOF_IPC] = "mediatek/sof-tplg", - }, - .default_fw_filename = { - [SOF_IPC] = "sof-mt8195.ri", - }, + .ipc_supported_mask = BIT(SOF_IPC_TYPE_3), + .ipc_default = SOF_IPC_TYPE_3, + .vendor = "mediatek", + .platform = "mt8195", .nocodec_tplg_filename = "sof-mt8195-nocodec.tplg", .ops = &sof_mt8195_ops, .ipc_timeout = 1000, diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 1b04dcb332935f..f3563eac943aec 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -58,8 +58,10 @@ static void sof_acpi_probe_complete(struct device *dev) int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc) { + struct sof_fw_layout_profile *fw_profile; struct device *dev = &pdev->dev; struct snd_sof_pdata *sof_pdata; + int ret; dev_dbg(dev, "ACPI DSP detected"); @@ -74,20 +76,26 @@ 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]; + sof_pdata->ipc_type = desc->ipc_default; + + fw_profile = &sof_pdata->default_fw_profile; + ret = sof_create_default_fw_layout_profile(dev, sof_pdata->ipc_type, + desc, NULL, fw_profile); + if (ret) + return ret; + + sof_pdata->fw_filename = fw_profile->fw_name; /* alternate fw and tplg filenames ? */ if (fw_path) sof_pdata->fw_filename_prefix = fw_path; else - sof_pdata->fw_filename_prefix = - sof_pdata->desc->default_fw_path[SOF_IPC]; + sof_pdata->fw_filename_prefix = fw_profile->fw_path; if (tplg_path) sof_pdata->tplg_filename_prefix = tplg_path; else - sof_pdata->tplg_filename_prefix = - sof_pdata->desc->default_tplg_path[SOF_IPC]; + sof_pdata->tplg_filename_prefix = fw_profile->tplg_path; /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_acpi_probe_complete; diff --git a/sound/soc/sof/sof-client-ipc-msg-injector.c b/sound/soc/sof/sof-client-ipc-msg-injector.c index 752d5320680f14..e249d3a9afb59d 100644 --- a/sound/soc/sof/sof-client-ipc-msg-injector.c +++ b/sound/soc/sof/sof-client-ipc-msg-injector.c @@ -267,7 +267,7 @@ static int sof_msg_inject_probe(struct auxiliary_device *auxdev, priv->max_msg_size = sof_client_get_ipc_max_payload_size(cdev); alloc_size = priv->max_msg_size; - if (priv->ipc_type == SOF_INTEL_IPC4) + if (priv->ipc_type == SOF_IPC_TYPE_4) alloc_size += sizeof(struct sof_ipc4_msg); priv->tx_buffer = devm_kmalloc(dev, alloc_size, GFP_KERNEL); @@ -275,7 +275,7 @@ static int sof_msg_inject_probe(struct auxiliary_device *auxdev, if (!priv->tx_buffer || !priv->rx_buffer) return -ENOMEM; - if (priv->ipc_type == SOF_INTEL_IPC4) { + if (priv->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_msg *ipc4_msg; ipc4_msg = priv->tx_buffer; diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c index 8d9e9d5f40e45b..1744760af664cf 100644 --- a/sound/soc/sof/sof-client-probes.c +++ b/sound/soc/sof/sof-client-probes.c @@ -419,13 +419,13 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev, priv->host_ops = ops; switch (sof_client_get_ipc_type(cdev)) { -#ifdef CONFIG_SND_SOC_SOF_INTEL_IPC4 - case SOF_INTEL_IPC4: +#ifdef CONFIG_SND_SOC_SOF_IPC4 + case SOF_IPC_TYPE_4: priv->ipc_ops = &ipc4_probe_ops; break; #endif #ifdef CONFIG_SND_SOC_SOF_IPC3 - case SOF_IPC: + case SOF_IPC_TYPE_3: priv->ipc_ops = &ipc3_probe_ops; break; #endif diff --git a/sound/soc/sof/sof-client.c b/sound/soc/sof/sof-client.c index d6b7caa0cf0317..f5cbdf93a383b3 100644 --- a/sound/soc/sof/sof-client.c +++ b/sound/soc/sof/sof-client.c @@ -74,7 +74,7 @@ static int sof_register_ipc_flood_test(struct snd_sof_dev *sdev) int ret = 0; int i; - if (sdev->pdata->ipc_type != SOF_IPC) + if (sdev->pdata->ipc_type != SOF_IPC_TYPE_3) return 0; for (i = 0; i < CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST_NUM; i++) { @@ -253,12 +253,12 @@ EXPORT_SYMBOL_NS_GPL(sof_client_dev_unregister, SND_SOC_SOF_CLIENT); int sof_client_ipc_tx_message(struct sof_client_dev *cdev, void *ipc_msg, void *reply_data, size_t reply_bytes) { - if (cdev->sdev->pdata->ipc_type == SOF_IPC) { + if (cdev->sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { struct sof_ipc_cmd_hdr *hdr = ipc_msg; return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, hdr->size, reply_data, reply_bytes); - } else if (cdev->sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + } else if (cdev->sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_msg *msg = ipc_msg; return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, msg->data_size, @@ -272,12 +272,12 @@ EXPORT_SYMBOL_NS_GPL(sof_client_ipc_tx_message, SND_SOC_SOF_CLIENT); int sof_client_ipc_set_get_data(struct sof_client_dev *cdev, void *ipc_msg, bool set) { - if (cdev->sdev->pdata->ipc_type == SOF_IPC) { + if (cdev->sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { struct sof_ipc_cmd_hdr *hdr = ipc_msg; return sof_ipc_set_get_data(cdev->sdev->ipc, ipc_msg, hdr->size, set); - } else if (cdev->sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + } else if (cdev->sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_msg *msg = ipc_msg; return sof_ipc_set_get_data(cdev->sdev->ipc, ipc_msg, @@ -288,12 +288,12 @@ int sof_client_ipc_set_get_data(struct sof_client_dev *cdev, void *ipc_msg, } EXPORT_SYMBOL_NS_GPL(sof_client_ipc_set_get_data, SND_SOC_SOF_CLIENT); -#ifdef CONFIG_SND_SOC_SOF_INTEL_IPC4 +#ifdef CONFIG_SND_SOC_SOF_IPC4 struct sof_ipc4_fw_module *sof_client_ipc4_find_module(struct sof_client_dev *c, const guid_t *uuid) { struct snd_sof_dev *sdev = c->sdev; - if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) return sof_ipc4_find_module_by_uuid(sdev, uuid); dev_err(sdev->dev, "Only supported with IPC4\n"); @@ -411,11 +411,11 @@ void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf) struct sof_ipc_event_entry *event; u32 msg_type; - if (sdev->pdata->ipc_type == SOF_IPC) { + if (sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { struct sof_ipc_cmd_hdr *hdr = msg_buf; msg_type = hdr->cmd & SOF_GLB_TYPE_MASK; - } else if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + } else if (sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { struct sof_ipc4_msg *msg = msg_buf; msg_type = SOF_IPC4_NOTIFICATION_TYPE_GET(msg->primary); @@ -445,10 +445,10 @@ int sof_client_register_ipc_rx_handler(struct sof_client_dev *cdev, if (!callback) return -EINVAL; - if (cdev->sdev->pdata->ipc_type == SOF_IPC) { + if (cdev->sdev->pdata->ipc_type == SOF_IPC_TYPE_3) { if (!(ipc_msg_type & SOF_GLB_TYPE_MASK)) return -EINVAL; - } else if (cdev->sdev->pdata->ipc_type == SOF_INTEL_IPC4) { + } else if (cdev->sdev->pdata->ipc_type == SOF_IPC_TYPE_4) { if (!(ipc_msg_type & SOF_IPC4_NOTIFICATION_TYPE_MASK)) return -EINVAL; } else { diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 53faeccedd4f0d..2ca70e7dd4330c 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -43,9 +43,11 @@ static void sof_of_probe_complete(struct device *dev) int sof_of_probe(struct platform_device *pdev) { + struct sof_fw_layout_profile *fw_profile; struct device *dev = &pdev->dev; const struct sof_dev_desc *desc; struct snd_sof_pdata *sof_pdata; + int ret; dev_info(&pdev->dev, "DT DSP detected"); @@ -64,17 +66,26 @@ 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]; + sof_pdata->ipc_type = desc->ipc_default; + fw_profile = &sof_pdata->default_fw_profile; + ret = sof_create_default_fw_layout_profile(dev, sof_pdata->ipc_type, + desc, NULL, fw_profile); + if (ret) + return ret; + + sof_pdata->fw_filename = fw_profile->fw_name; + + /* alternate fw and tplg filenames ? */ if (fw_path) sof_pdata->fw_filename_prefix = fw_path; else - sof_pdata->fw_filename_prefix = sof_pdata->desc->default_fw_path[SOF_IPC]; + sof_pdata->fw_filename_prefix = fw_profile->fw_path; if (tplg_path) sof_pdata->tplg_filename_prefix = tplg_path; else - sof_pdata->tplg_filename_prefix = sof_pdata->desc->default_tplg_path[SOF_IPC]; + sof_pdata->tplg_filename_prefix = fw_profile->tplg_path; /* set callback to be called on successful device probe to enable runtime_pm */ sof_pdata->sof_probe_complete = sof_of_probe_complete; diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index f5ece43d0ec247..498efe410bc7e5 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -46,7 +46,7 @@ MODULE_PARM_DESC(sof_pci_debug, "SOF PCI debug options (0x0 all off)"); static int sof_pci_ipc_type = -1; module_param_named(ipc_type, sof_pci_ipc_type, int, 0444); -MODULE_PARM_DESC(ipc_type, "SOF IPC type (0): SOF, (1) Intel CAVS"); +MODULE_PARM_DESC(ipc_type, "Force SOF IPC type. 0 - IPC3, 1 - IPC4"); static const char *sof_dmi_override_tplg_name; static bool sof_dmi_use_community_key; @@ -183,10 +183,12 @@ 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_fw_layout_profile *fw_profile; struct device *dev = &pci->dev; const struct sof_dev_desc *desc = (const struct sof_dev_desc *)pci_id->driver_data; struct snd_sof_pdata *sof_pdata; + char *fw_path_postfix = NULL; int ret; dev_dbg(&pci->dev, "PCI DSP detected"); @@ -217,8 +219,6 @@ 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; - if (sof_pci_ipc_type < 0) { sof_pdata->ipc_type = desc->ipc_default; } else { @@ -238,13 +238,41 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) sof_pdata->ipc_type = sof_pci_ipc_type; } + if (dmi_check_system(community_key_platforms) && sof_dmi_use_community_key) { + fw_path_postfix = "community"; + dev_dbg(dev, + "Platform uses community key, changing paths accordingly\n"); + } + + fw_profile = &sof_pdata->default_fw_profile; + ret = sof_create_default_fw_layout_profile(dev, sof_pdata->ipc_type, + desc, fw_path_postfix, + fw_profile); + if (!ret) { + if (sof_pdata->ipc_type != fw_profile->ipc_type) { + dev_info(dev, + "IPC type %d is not supported, using IPC type %d\n", + sof_pdata->ipc_type, fw_profile->ipc_type); + sof_pdata->ipc_type = fw_profile->ipc_type; + } + dev_dbg(dev, "Default firmware paths, filename:\n"); + dev_dbg(dev, "firmware path:\t\t%s\n", fw_profile->fw_path); + if (fw_profile->fw_lib_path) + dev_dbg(dev, "firmware library path:\t%s\n", + fw_profile->fw_lib_path); + dev_dbg(dev, "topology path:\t\t%s\n", fw_profile->tplg_path); + dev_dbg(dev, "firmware name:\t\t%s\n", fw_profile->fw_name); + } else { + goto out; + } + 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]; + sof_pdata->fw_filename = fw_profile->fw_name; } /* @@ -261,19 +289,8 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 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); } else { - sof_pdata->fw_filename_prefix = - sof_pdata->desc->default_fw_path[sof_pdata->ipc_type]; + sof_pdata->fw_filename_prefix = fw_profile->fw_path; } if (lib_path) { @@ -282,27 +299,14 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 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]; - } + } else { + sof_pdata->fw_lib_prefix = fw_profile->fw_lib_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]; + sof_pdata->tplg_filename_prefix = fw_profile->tplg_path; /* * the topology filename will be provided in the machine descriptor, unless diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index cd4f6ac126eca7..2982b82e514eae 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -690,6 +690,15 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev); */ extern struct snd_compress_ops sof_compressed_ops; +/* + * Firmware layout profile handling + */ +int sof_create_default_fw_layout_profile(struct device *dev, + const enum sof_ipc_type ipc_type, + const struct sof_dev_desc *desc, + const char *fw_path_postfix, + struct sof_fw_layout_profile *out_layout); + /* * Firmware loading. */