ASoC: SOF: IPC4: Add helper for looking up module by UUID
Add a simple helper to walk the loaded libraries and their modules to make the ipc4-topology not aware of the underlying infrastructure and simplify the code. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Chao Song <chao.song@intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20221020121238.18339-11-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
5a932cfce4
commit
c73f8b4708
|
@ -160,6 +160,27 @@ static size_t sof_ipc4_fw_parse_basefw_ext_man(struct snd_sof_dev *sdev)
|
|||
return payload_offset;
|
||||
}
|
||||
|
||||
struct sof_ipc4_fw_module *sof_ipc4_find_module_by_uuid(struct snd_sof_dev *sdev,
|
||||
const guid_t *uuid)
|
||||
{
|
||||
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
|
||||
struct sof_ipc4_fw_library *fw_lib;
|
||||
unsigned long lib_id;
|
||||
int i;
|
||||
|
||||
if (guid_is_null(uuid))
|
||||
return NULL;
|
||||
|
||||
xa_for_each(&ipc4_data->fw_lib_xa, lib_id, fw_lib) {
|
||||
for (i = 0; i < fw_lib->num_modules; i++) {
|
||||
if (guid_equal(uuid, &fw_lib->modules[i].man4_module_entry.uuid))
|
||||
return &fw_lib->modules[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int sof_ipc4_validate_firmware(struct snd_sof_dev *sdev)
|
||||
{
|
||||
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
|
||||
|
|
|
@ -84,4 +84,7 @@ extern const struct sof_ipc_fw_tracing_ops ipc4_mtrace_ops;
|
|||
|
||||
int sof_ipc4_set_pipeline_state(struct snd_sof_dev *sdev, u32 id, u32 state);
|
||||
int sof_ipc4_mtrace_update_pos(struct snd_sof_dev *sdev, int core);
|
||||
|
||||
struct sof_ipc4_fw_module *sof_ipc4_find_module_by_uuid(struct snd_sof_dev *sdev,
|
||||
const guid_t *uuid);
|
||||
#endif
|
||||
|
|
|
@ -289,22 +289,11 @@ static int sof_ipc4_widget_set_module_info(struct snd_sof_widget *swidget)
|
|||
{
|
||||
struct snd_soc_component *scomp = swidget->scomp;
|
||||
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
|
||||
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
|
||||
struct sof_ipc4_fw_library *fw_lib;
|
||||
unsigned long lib_id;
|
||||
int i;
|
||||
|
||||
xa_for_each(&ipc4_data->fw_lib_xa, lib_id, fw_lib) {
|
||||
/* set module info */
|
||||
for (i = 0; i < fw_lib->num_modules; i++) {
|
||||
struct sof_ipc4_fw_module *module = &fw_lib->modules[i];
|
||||
swidget->module_info = sof_ipc4_find_module_by_uuid(sdev, &swidget->uuid);
|
||||
|
||||
if (guid_equal(&swidget->uuid, &module->man4_module_entry.uuid)) {
|
||||
swidget->module_info = module;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (swidget->module_info)
|
||||
return 0;
|
||||
|
||||
dev_err(sdev->dev, "failed to find module info for widget %s with UUID %pUL\n",
|
||||
swidget->widget->name, &swidget->uuid);
|
||||
|
|
Loading…
Reference in New Issue