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()
99 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_file_profile_for_ipc_type()
101 struct device *dev = sdev->dev; in sof_file_profile_for_ipc_type()
105 /* firmware path */ in sof_file_profile_for_ipc_type()
106 if (base_profile->fw_path) { in sof_file_profile_for_ipc_type()
107 out_profile->fw_path = base_profile->fw_path; in sof_file_profile_for_ipc_type()
108 } else if (base_profile->fw_path_postfix) { in sof_file_profile_for_ipc_type()
109 out_profile->fw_path = devm_kasprintf(dev, GFP_KERNEL, "%s/%s", in sof_file_profile_for_ipc_type()
110 desc->default_fw_path[ipc_type], in sof_file_profile_for_ipc_type()
111 base_profile->fw_path_postfix); in sof_file_profile_for_ipc_type()
112 if (!out_profile->fw_path) in sof_file_profile_for_ipc_type()
113 return -ENOMEM; in sof_file_profile_for_ipc_type()
117 out_profile->fw_path = desc->default_fw_path[ipc_type]; in sof_file_profile_for_ipc_type()
120 /* firmware filename */ in sof_file_profile_for_ipc_type()
121 if (base_profile->fw_name) in sof_file_profile_for_ipc_type()
122 out_profile->fw_name = base_profile->fw_name; in sof_file_profile_for_ipc_type()
124 out_profile->fw_name = desc->default_fw_filename[ipc_type]; in sof_file_profile_for_ipc_type()
127 * Check the custom firmware path/filename and adjust the ipc_type to in sof_file_profile_for_ipc_type()
130 * For default path and firmware name do a verification before in sof_file_profile_for_ipc_type()
133 if (base_profile->fw_path || base_profile->fw_name) { in sof_file_profile_for_ipc_type()
138 if (!(desc->ipc_supported_mask & BIT(ipc_type))) { in sof_file_profile_for_ipc_type()
140 ipc_type, out_profile->fw_path, in sof_file_profile_for_ipc_type()
141 out_profile->fw_name); in sof_file_profile_for_ipc_type()
142 return -EINVAL; in sof_file_profile_for_ipc_type()
146 /* firmware library path */ in sof_file_profile_for_ipc_type()
147 if (base_profile->fw_lib_path) { in sof_file_profile_for_ipc_type()
148 out_profile->fw_lib_path = base_profile->fw_lib_path; in sof_file_profile_for_ipc_type()
149 } else if (desc->default_lib_path[ipc_type]) { in sof_file_profile_for_ipc_type()
150 if (base_profile->fw_lib_path_postfix) { in sof_file_profile_for_ipc_type()
151 out_profile->fw_lib_path = devm_kasprintf(dev, in sof_file_profile_for_ipc_type()
153 desc->default_lib_path[ipc_type], in sof_file_profile_for_ipc_type()
154 base_profile->fw_lib_path_postfix); in sof_file_profile_for_ipc_type()
155 if (!out_profile->fw_lib_path) { in sof_file_profile_for_ipc_type()
156 ret = -ENOMEM; in sof_file_profile_for_ipc_type()
162 out_profile->fw_lib_path = desc->default_lib_path[ipc_type]; in sof_file_profile_for_ipc_type()
166 if (base_profile->fw_path_postfix) in sof_file_profile_for_ipc_type()
167 out_profile->fw_path_postfix = base_profile->fw_path_postfix; in sof_file_profile_for_ipc_type()
169 if (base_profile->fw_lib_path_postfix) in sof_file_profile_for_ipc_type()
170 out_profile->fw_lib_path_postfix = base_profile->fw_lib_path_postfix; in sof_file_profile_for_ipc_type()
173 if (base_profile->tplg_path) in sof_file_profile_for_ipc_type()
174 out_profile->tplg_path = base_profile->tplg_path; in sof_file_profile_for_ipc_type()
176 out_profile->tplg_path = desc->default_tplg_path[ipc_type]; in sof_file_profile_for_ipc_type()
179 out_profile->tplg_name = plat_data->tplg_filename; in sof_file_profile_for_ipc_type()
181 out_profile->ipc_type = ipc_type; in sof_file_profile_for_ipc_type()
183 /* Test only default firmware file */ in sof_file_profile_for_ipc_type()
184 if (!base_profile->fw_path && !base_profile->fw_name) in sof_file_profile_for_ipc_type()
194 devm_kfree(dev, out_profile->fw_path); in sof_file_profile_for_ipc_type()
196 devm_kfree(dev, out_profile->fw_lib_path); in sof_file_profile_for_ipc_type()
209 struct snd_sof_pdata *plat_data = sdev->pdata; in sof_print_missing_firmware_info()
210 const struct sof_dev_desc *desc = plat_data->desc; in sof_print_missing_firmware_info()
211 struct device *dev = sdev->dev; in sof_print_missing_firmware_info()
215 dev_err(dev, "SOF firmware and/or topology file not found.\n"); in sof_print_missing_firmware_info()
219 ipc_type_count = SOF_IPC_TYPE_COUNT - 1; in sof_print_missing_firmware_info()
221 ipc_type_count = base_profile->ipc_type; in sof_print_missing_firmware_info()
224 if (!(desc->ipc_supported_mask & BIT(i))) in sof_print_missing_firmware_info()
232 dev_info(dev, "- ipc type %d (%s):\n", i, marker); in sof_print_missing_firmware_info()
233 if (base_profile->fw_path_postfix) in sof_print_missing_firmware_info()
234 dev_info(dev, " Firmware file: %s/%s/%s\n", in sof_print_missing_firmware_info()
235 desc->default_fw_path[i], in sof_print_missing_firmware_info()
236 base_profile->fw_path_postfix, in sof_print_missing_firmware_info()
237 desc->default_fw_filename[i]); in sof_print_missing_firmware_info()
239 dev_info(dev, " Firmware file: %s/%s\n", in sof_print_missing_firmware_info()
240 desc->default_fw_path[i], in sof_print_missing_firmware_info()
241 desc->default_fw_filename[i]); in sof_print_missing_firmware_info()
244 desc->default_tplg_path[i], in sof_print_missing_firmware_info()
245 plat_data->tplg_filename); in sof_print_missing_firmware_info()
248 if (base_profile->fw_path || base_profile->fw_name || in sof_print_missing_firmware_info()
249 base_profile->tplg_path || base_profile->tplg_name) in sof_print_missing_firmware_info()
252 dev_info(dev, "Check if you have 'sof-firmware' package installed.\n"); in sof_print_missing_firmware_info()
254 dev_info(dev, " https://github.com/thesofproject/sof-bin/\n"); in sof_print_missing_firmware_info()
261 struct device *dev = sdev->dev; in sof_print_profile_info()
263 if (ipc_type != profile->ipc_type) in sof_print_profile_info()
266 profile->ipc_type, ipc_type); in sof_print_profile_info()
268 dev_info(dev, "Firmware paths/files for ipc type %d:\n", profile->ipc_type); in sof_print_profile_info()
270 dev_info(dev, " Firmware file: %s/%s\n", profile->fw_path, profile->fw_name); in sof_print_profile_info()
271 if (profile->fw_lib_path) in sof_print_profile_info()
272 dev_info(dev, " Firmware lib path: %s\n", profile->fw_lib_path); in sof_print_profile_info()
273 dev_info(dev, " Topology file: %s/%s\n", profile->tplg_path, profile->tplg_name); in sof_print_profile_info()
280 const struct sof_dev_desc *desc = sdev->pdata->desc; in sof_create_ipc_file_profile()
285 ret = sof_file_profile_for_ipc_type(sdev, base_profile->ipc_type, desc, in sof_create_ipc_file_profile()
291 * No firmware file was found for the requested IPC type, as fallback in sof_create_ipc_file_profile()
298 ipc_fallback_start = SOF_IPC_TYPE_COUNT - 1; in sof_create_ipc_file_profile()
300 ipc_fallback_start = (int)base_profile->ipc_type - 1; in sof_create_ipc_file_profile()
302 for (i = ipc_fallback_start; i >= 0 ; i--) { in sof_create_ipc_file_profile()
303 if (i == base_profile->ipc_type || in sof_create_ipc_file_profile()
304 !(desc->ipc_supported_mask & BIT(i))) in sof_create_ipc_file_profile()
315 sof_print_missing_firmware_info(sdev, base_profile->ipc_type, in sof_create_ipc_file_profile()
318 sof_print_profile_info(sdev, base_profile->ipc_type, out_profile); in sof_create_ipc_file_profile()