Lines Matching +full:uuid +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0-only
3 * skl-sst-utils.c - SKL sst utils functions
10 #include <linux/uuid.h>
11 #include "../common/sst-dsp.h"
12 #include "../common/sst-dsp-priv.h"
53 u8 uuid[16]; member
94 for (pvt_id = 0; pvt_id < module->max_instance; pvt_id++) { in skl_get_pvtid_map()
95 if (module->instance_id[pvt_id] == instance_id) in skl_get_pvtid_map()
98 return -EINVAL; in skl_get_pvtid_map()
106 list_for_each_entry(module, &skl->uuid_list, list) { in skl_get_pvt_instance_id_map()
107 if (module->id == module_id) in skl_get_pvt_instance_id_map()
111 return -EINVAL; in skl_get_pvt_instance_id_map()
121 max_inst = module->max_instance; in skl_getid_32()
127 if (pvt_id <= (max_inst - 1)) { in skl_getid_32()
133 return -EINVAL; in skl_getid_32()
144 pvt_id = skl_getid_32(module, &module->pvt_id[j], in skl_pvtid_128()
150 if ((word1_mask + word2_mask) >= module->max_instance) in skl_pvtid_128()
151 return -EINVAL; in skl_pvtid_128()
155 if (word2_mask >= module->max_instance) in skl_pvtid_128()
156 return -EINVAL; in skl_pvtid_128()
159 return -EINVAL; in skl_pvtid_128()
166 * @uuid_mod: module's uuid
177 list_for_each_entry(module, &skl->uuid_list, list) { in skl_get_pvt_id()
178 if (guid_equal(uuid_mod, &module->uuid)) { in skl_get_pvt_id()
182 module->instance_id[pvt_id] = instance_id; in skl_get_pvt_id()
189 return -EINVAL; in skl_get_pvt_id()
197 * @uuid_mod: module's uuid
207 list_for_each_entry(module, &skl->uuid_list, list) { in skl_put_pvt_id()
208 if (guid_equal(uuid_mod, &module->uuid)) { in skl_put_pvt_id()
215 module->pvt_id[i] &= ~(1 << (*pvt_id)); in skl_put_pvt_id()
216 *pvt_id = -1; in skl_put_pvt_id()
221 return -EINVAL; in skl_put_pvt_id()
226 * Parse the firmware binary to get the UUID, module id
236 struct skl_dev *skl = ctx->thread_context; in snd_skl_parse_uuids()
243 stripped_fw.data = fw->data; in snd_skl_parse_uuids()
244 stripped_fw.size = fw->size; in snd_skl_parse_uuids()
253 dev_err(ctx->dev, "Small fw file size, No space for hdr\n"); in snd_skl_parse_uuids()
254 return -EINVAL; in snd_skl_parse_uuids()
260 safe_file += adsp_hdr->len + sizeof(*mod_entry); in snd_skl_parse_uuids()
262 dev_err(ctx->dev, "Small fw file size, No module entry\n"); in snd_skl_parse_uuids()
263 return -EINVAL; in snd_skl_parse_uuids()
266 mod_entry = (struct adsp_module_entry *)(buf + offset + adsp_hdr->len); in snd_skl_parse_uuids()
268 num_entry = adsp_hdr->num_modules; in snd_skl_parse_uuids()
273 dev_err(ctx->dev, "Small fw file size, No modules\n"); in snd_skl_parse_uuids()
274 return -EINVAL; in snd_skl_parse_uuids()
279 * Read the UUID(GUID) from FW Manifest. in snd_skl_parse_uuids()
281 * The 16 byte UUID format is: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX in snd_skl_parse_uuids()
282 * Populate the UUID table to store module_id and loadable flags in snd_skl_parse_uuids()
289 ret = -ENOMEM; in snd_skl_parse_uuids()
293 import_guid(&module->uuid, mod_entry->uuid); in snd_skl_parse_uuids()
295 module->id = (i | (index << 12)); in snd_skl_parse_uuids()
296 module->is_loadable = mod_entry->type.load_type; in snd_skl_parse_uuids()
297 module->max_instance = mod_entry->instance_max_count; in snd_skl_parse_uuids()
298 size = sizeof(int) * mod_entry->instance_max_count; in snd_skl_parse_uuids()
299 module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL); in snd_skl_parse_uuids()
300 if (!module->instance_id) { in snd_skl_parse_uuids()
301 ret = -ENOMEM; in snd_skl_parse_uuids()
306 list_add_tail(&module->list, &skl->uuid_list); in snd_skl_parse_uuids()
308 dev_dbg(ctx->dev, in snd_skl_parse_uuids()
309 "Adding uuid :%pUL mod id: %d Loadable: %d\n", in snd_skl_parse_uuids()
310 &module->uuid, module->id, module->is_loadable); in snd_skl_parse_uuids()
322 struct uuid_module *uuid, *_uuid; in skl_freeup_uuid_list() local
324 list_for_each_entry_safe(uuid, _uuid, &skl->uuid_list, list) { in skl_freeup_uuid_list()
325 list_del(&uuid->list); in skl_freeup_uuid_list()
326 kfree(uuid); in skl_freeup_uuid_list()
335 * the table for the UUID for the module
342 if (fw->size < sizeof(hdr)) { in skl_dsp_strip_extended_manifest()
344 return -EINVAL; in skl_dsp_strip_extended_manifest()
347 hdr = (struct skl_ext_manifest_hdr *)fw->data; in skl_dsp_strip_extended_manifest()
349 if (hdr->id == SKL_EXT_MANIFEST_HEADER_MAGIC) { in skl_dsp_strip_extended_manifest()
350 fw->size -= hdr->len; in skl_dsp_strip_extended_manifest()
351 fw->data += hdr->len; in skl_dsp_strip_extended_manifest()
357 int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name, in skl_sst_ctx_init() argument
364 skl->dev = dev; in skl_sst_ctx_init()
365 skl_dev->thread_context = skl; in skl_sst_ctx_init()
366 INIT_LIST_HEAD(&skl->uuid_list); in skl_sst_ctx_init()
367 skl->dsp = skl_dsp_ctx_init(dev, skl_dev, irq); in skl_sst_ctx_init()
368 if (!skl->dsp) { in skl_sst_ctx_init()
369 dev_err(skl->dev, "%s: no device\n", __func__); in skl_sst_ctx_init()
370 return -ENODEV; in skl_sst_ctx_init()
373 sst = skl->dsp; in skl_sst_ctx_init()
374 sst->fw_name = fw_name; in skl_sst_ctx_init()
375 sst->dsp_ops = dsp_ops; in skl_sst_ctx_init()
376 init_waitqueue_head(&skl->mod_load_wait); in skl_sst_ctx_init()
377 INIT_LIST_HEAD(&sst->module_list); in skl_sst_ctx_init()
379 skl->is_first_boot = true; in skl_sst_ctx_init()
389 struct sst_dsp *dsp = skl->dsp; in skl_prepare_lib_load()
391 if (linfo->fw == NULL) { in skl_prepare_lib_load()
392 ret = request_firmware(&linfo->fw, linfo->name, in skl_prepare_lib_load()
393 skl->dev); in skl_prepare_lib_load()
395 dev_err(skl->dev, "Request lib %s failed:%d\n", in skl_prepare_lib_load()
396 linfo->name, ret); in skl_prepare_lib_load()
401 if (skl->is_first_boot) { in skl_prepare_lib_load()
402 ret = snd_skl_parse_uuids(dsp, linfo->fw, hdr_offset, index); in skl_prepare_lib_load()
407 stripped_fw->data = linfo->fw->data; in skl_prepare_lib_load()
408 stripped_fw->size = linfo->fw->size; in skl_prepare_lib_load()