Lines Matching +full:open +full:- +full:firmware

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
9 #include <linux/firmware.h>
12 #include "sof-priv.h"
19 const struct firmware *fw; in sof_test_firmware_file()
24 fw_filename = kasprintf(GFP_KERNEL, "%s/%s", profile->fw_path, in sof_test_firmware_file()
25 profile->fw_name); in sof_test_firmware_file()
27 return -ENOMEM; in sof_test_firmware_file()
31 dev_dbg(dev, "Failed to open firmware file: %s\n", fw_filename); in sof_test_firmware_file()
36 /* firmware file exists, check the magic number */ in sof_test_firmware_file()
37 magic = (const u32 *)fw->data; in sof_test_firmware_file()
46 dev_err(dev, "Invalid firmware magic: %#x\n", *magic); in sof_test_firmware_file()
47 ret = -EINVAL; in sof_test_firmware_file()
53 } else if (fw_ipc_type != profile->ipc_type) { in sof_test_firmware_file()
56 fw_filename, fw_ipc_type, profile->ipc_type); in sof_test_firmware_file()
57 ret = -EINVAL; in sof_test_firmware_file()
69 const struct firmware *fw; in sof_test_topology_file()
73 if (!profile->tplg_path || !profile->tplg_name) in sof_test_topology_file()
76 tplg_filename = kasprintf(GFP_KERNEL, "%s/%s", profile->tplg_path, in sof_test_topology_file()
77 profile->tplg_name); in sof_test_topology_file()
79 return -ENOMEM; in sof_test_topology_file()
85 dev_dbg(dev, "Failed to open topology file: %s\n", tplg_filename); in sof_test_topology_file()
94 return (sdev->pdata->desc->ops->load_firmware == snd_sof_load_firmware_raw || in sof_platform_uses_generic_loader()
95 sdev->pdata->desc->ops->load_firmware == snd_sof_load_firmware_memcpy); in sof_platform_uses_generic_loader()
105 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_file_profile_for_ipc_type()
107 struct device *dev = sdev->dev; in sof_file_profile_for_ipc_type()
111 /* firmware path */ in sof_file_profile_for_ipc_type()
112 if (base_profile->fw_path) { in sof_file_profile_for_ipc_type()
113 out_profile->fw_path = base_profile->fw_path; in sof_file_profile_for_ipc_type()
114 } else if (base_profile->fw_path_postfix) { in sof_file_profile_for_ipc_type()
115 out_profile->fw_path = devm_kasprintf(dev, GFP_KERNEL, "%s/%s", in sof_file_profile_for_ipc_type()
116 desc->default_fw_path[ipc_type], in sof_file_profile_for_ipc_type()
117 base_profile->fw_path_postfix); in sof_file_profile_for_ipc_type()
118 if (!out_profile->fw_path) in sof_file_profile_for_ipc_type()
119 return -ENOMEM; in sof_file_profile_for_ipc_type()
123 out_profile->fw_path = desc->default_fw_path[ipc_type]; in sof_file_profile_for_ipc_type()
126 /* firmware filename */ in sof_file_profile_for_ipc_type()
127 if (base_profile->fw_name) in sof_file_profile_for_ipc_type()
128 out_profile->fw_name = base_profile->fw_name; in sof_file_profile_for_ipc_type()
130 out_profile->fw_name = desc->default_fw_filename[ipc_type]; in sof_file_profile_for_ipc_type()
133 * Check the custom firmware path/filename and adjust the ipc_type to in sof_file_profile_for_ipc_type()
136 * For default path and firmware name do a verification before in sof_file_profile_for_ipc_type()
139 if ((base_profile->fw_path || base_profile->fw_name) && in sof_file_profile_for_ipc_type()
145 if (!(desc->ipc_supported_mask & BIT(ipc_type))) { in sof_file_profile_for_ipc_type()
147 ipc_type, out_profile->fw_path, in sof_file_profile_for_ipc_type()
148 out_profile->fw_name); in sof_file_profile_for_ipc_type()
149 return -EINVAL; in sof_file_profile_for_ipc_type()
153 /* firmware library path */ in sof_file_profile_for_ipc_type()
154 if (base_profile->fw_lib_path) { in sof_file_profile_for_ipc_type()
155 out_profile->fw_lib_path = base_profile->fw_lib_path; in sof_file_profile_for_ipc_type()
156 } else if (desc->default_lib_path[ipc_type]) { in sof_file_profile_for_ipc_type()
157 if (base_profile->fw_lib_path_postfix) { in sof_file_profile_for_ipc_type()
158 out_profile->fw_lib_path = devm_kasprintf(dev, in sof_file_profile_for_ipc_type()
160 desc->default_lib_path[ipc_type], in sof_file_profile_for_ipc_type()
161 base_profile->fw_lib_path_postfix); in sof_file_profile_for_ipc_type()
162 if (!out_profile->fw_lib_path) { in sof_file_profile_for_ipc_type()
163 ret = -ENOMEM; in sof_file_profile_for_ipc_type()
169 out_profile->fw_lib_path = desc->default_lib_path[ipc_type]; in sof_file_profile_for_ipc_type()
173 if (base_profile->fw_path_postfix) in sof_file_profile_for_ipc_type()
174 out_profile->fw_path_postfix = base_profile->fw_path_postfix; in sof_file_profile_for_ipc_type()
176 if (base_profile->fw_lib_path_postfix) in sof_file_profile_for_ipc_type()
177 out_profile->fw_lib_path_postfix = base_profile->fw_lib_path_postfix; in sof_file_profile_for_ipc_type()
180 if (base_profile->tplg_path) in sof_file_profile_for_ipc_type()
181 out_profile->tplg_path = base_profile->tplg_path; in sof_file_profile_for_ipc_type()
183 out_profile->tplg_path = desc->default_tplg_path[ipc_type]; in sof_file_profile_for_ipc_type()
186 out_profile->tplg_name = plat_data->tplg_filename; in sof_file_profile_for_ipc_type()
188 out_profile->ipc_type = ipc_type; in sof_file_profile_for_ipc_type()
190 /* Test only default firmware file */ in sof_file_profile_for_ipc_type()
191 if ((!base_profile->fw_path && !base_profile->fw_name) && in sof_file_profile_for_ipc_type()
202 devm_kfree(dev, out_profile->fw_path); in sof_file_profile_for_ipc_type()
204 devm_kfree(dev, out_profile->fw_lib_path); in sof_file_profile_for_ipc_type()
217 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_print_missing_firmware_info()
218 const struct sof_dev_desc *desc = plat_data->desc; in sof_print_missing_firmware_info()
219 struct device *dev = sdev->dev; in sof_print_missing_firmware_info()
223 dev_err(dev, "SOF firmware and/or topology file not found.\n"); in sof_print_missing_firmware_info()
227 ipc_type_count = SOF_IPC_TYPE_COUNT - 1; in sof_print_missing_firmware_info()
229 ipc_type_count = base_profile->ipc_type; in sof_print_missing_firmware_info()
232 if (!(desc->ipc_supported_mask & BIT(i))) in sof_print_missing_firmware_info()
240 dev_info(dev, "- ipc type %d (%s):\n", i, marker); in sof_print_missing_firmware_info()
241 if (base_profile->fw_path_postfix) in sof_print_missing_firmware_info()
242 dev_info(dev, " Firmware file: %s/%s/%s\n", in sof_print_missing_firmware_info()
243 desc->default_fw_path[i], in sof_print_missing_firmware_info()
244 base_profile->fw_path_postfix, in sof_print_missing_firmware_info()
245 desc->default_fw_filename[i]); in sof_print_missing_firmware_info()
247 dev_info(dev, " Firmware file: %s/%s\n", in sof_print_missing_firmware_info()
248 desc->default_fw_path[i], in sof_print_missing_firmware_info()
249 desc->default_fw_filename[i]); in sof_print_missing_firmware_info()
252 desc->default_tplg_path[i], in sof_print_missing_firmware_info()
253 plat_data->tplg_filename); in sof_print_missing_firmware_info()
256 if (base_profile->fw_path || base_profile->fw_name || in sof_print_missing_firmware_info()
257 base_profile->tplg_path || base_profile->tplg_name) in sof_print_missing_firmware_info()
260 dev_info(dev, "Check if you have 'sof-firmware' package installed.\n"); in sof_print_missing_firmware_info()
262 dev_info(dev, " https://github.com/thesofproject/sof-bin/\n"); in sof_print_missing_firmware_info()
269 struct device *dev = sdev->dev; in sof_print_profile_info()
271 if (ipc_type != profile->ipc_type) in sof_print_profile_info()
274 profile->ipc_type, ipc_type); in sof_print_profile_info()
276 dev_info(dev, "Firmware paths/files for ipc type %d:\n", profile->ipc_type); in sof_print_profile_info()
278 /* The firmware path is only valid when generic loader is used */ in sof_print_profile_info()
280 dev_info(dev, " Firmware file: %s/%s\n", in sof_print_profile_info()
281 profile->fw_path, profile->fw_name); in sof_print_profile_info()
283 if (profile->fw_lib_path) in sof_print_profile_info()
284 dev_info(dev, " Firmware lib path: %s\n", profile->fw_lib_path); in sof_print_profile_info()
285 dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, profile->tplg_name); in sof_print_profile_info()
292 const struct sof_dev_desc *desc = sdev->pdata->desc; in sof_create_ipc_file_profile()
297 ret = sof_file_profile_for_ipc_type(sdev, base_profile->ipc_type, desc, in sof_create_ipc_file_profile()
303 * No firmware file was found for the requested IPC type, as fallback in sof_create_ipc_file_profile()
310 ipc_fallback_start = SOF_IPC_TYPE_COUNT - 1; in sof_create_ipc_file_profile()
312 ipc_fallback_start = (int)base_profile->ipc_type - 1; in sof_create_ipc_file_profile()
314 for (i = ipc_fallback_start; i >= 0 ; i--) { in sof_create_ipc_file_profile()
315 if (i == base_profile->ipc_type || in sof_create_ipc_file_profile()
316 !(desc->ipc_supported_mask & BIT(i))) in sof_create_ipc_file_profile()
327 sof_print_missing_firmware_info(sdev, base_profile->ipc_type, in sof_create_ipc_file_profile()
330 sof_print_profile_info(sdev, base_profile->ipc_type, out_profile); in sof_create_ipc_file_profile()