Skip to content

Commit 27deecf

Browse files
committed
ASoC: SOF: ipc4-loader/topology: Query the CPC value from manifest
The manifest's firmware module configuration section contains the measured CPC values along with a matching IBS/OBS values. The CPC can be looked up by looking for a matching IBS/OBS entry. In case of multiple matches we will use the highest CPC value and if there is no direct match, we will use the highest CPC value we have encountered. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 477dc0a commit 27deecf

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

sound/soc/sof/ipc4-loader.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,65 @@ int sof_ipc4_reload_fw_libraries(struct snd_sof_dev *sdev)
423423
return ret;
424424
}
425425

426+
/**
427+
* sof_ipc4_update_cpc_from_manifest - Update the cpc in base config from manifest
428+
* @sdev: SOF device
429+
* @fw_module: pointer struct sof_ipc4_fw_module to parse
430+
* @basecfg: Pointer to the base_config to update
431+
*/
432+
void sof_ipc4_update_cpc_from_manifest(struct snd_sof_dev *sdev,
433+
struct sof_ipc4_fw_module *fw_module,
434+
struct sof_ipc4_base_module_cfg *basecfg)
435+
{
436+
const struct sof_man4_module_config *fw_mod_cfg;
437+
u32 cpc_pick = 0;
438+
u32 max_cpc = 0;
439+
int i;
440+
441+
if (!fw_module || !fw_module->fw_mod_cfg)
442+
return;
443+
444+
/*
445+
* Find the best matching (highest) CPC value based on the module's
446+
* external configuration (IBS/OBS).
447+
* The CPC value in each module config entry has been measured and
448+
* recorded as a IBS/OBS/CPC triplet.
449+
*
450+
* In case of multiple IBS/OBS matches, use the highest CPC number.
451+
*/
452+
fw_mod_cfg = fw_module->fw_mod_cfg;
453+
for (i = 0; i < fw_module->man4_module_entry.cfg_count; i++) {
454+
if (basecfg->obs == fw_mod_cfg[i].obs &&
455+
basecfg->ibs == fw_mod_cfg[i].ibs &&
456+
cpc_pick < fw_mod_cfg[i].cpc)
457+
cpc_pick = fw_mod_cfg[i].cpc;
458+
459+
if (max_cpc < fw_mod_cfg[i].cpc)
460+
max_cpc = fw_mod_cfg[i].cpc;
461+
}
462+
463+
basecfg->cpc = cpc_pick;
464+
465+
/*
466+
* No matching IBS/OBS found, use the maximum CPC value we have
467+
* encountered while parsing the module config entries
468+
*/
469+
if (!basecfg->cpc)
470+
basecfg->cpc = max_cpc;
471+
472+
if (!basecfg->cpc)
473+
dev_warn(sdev->dev,
474+
"%s (UUID: %pUL): No CPC value available\n",
475+
fw_module->man4_module_entry.name,
476+
&fw_module->man4_module_entry.uuid);
477+
else if (!cpc_pick)
478+
dev_info(sdev->dev,
479+
"%s (UUID: %pUL): No CPC match for ibs/obs: %u/%u\n",
480+
fw_module->man4_module_entry.name,
481+
&fw_module->man4_module_entry.uuid, basecfg->ibs,
482+
basecfg->obs);
483+
}
484+
426485
const struct sof_ipc_fw_loader_ops ipc4_loader_ops = {
427486
.validate = sof_ipc4_validate_firmware,
428487
.parse_ext_manifest = sof_ipc4_fw_parse_basefw_ext_man,

sound/soc/sof/ipc4-priv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,10 @@ int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev);
114114
int sof_ipc4_reload_fw_libraries(struct snd_sof_dev *sdev);
115115
struct sof_ipc4_fw_module *sof_ipc4_find_module_by_uuid(struct snd_sof_dev *sdev,
116116
const guid_t *uuid);
117+
118+
struct sof_ipc4_base_module_cfg;
119+
void sof_ipc4_update_cpc_from_manifest(struct snd_sof_dev *sdev,
120+
struct sof_ipc4_fw_module *fw_module,
121+
struct sof_ipc4_base_module_cfg *basecfg);
122+
117123
#endif

sound/soc/sof/ipc4-topology.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,14 @@ sof_ipc4_update_resource_usage(struct snd_sof_dev *sdev, struct snd_sof_widget *
966966
pipe_widget = swidget->spipe->pipe_widget;
967967
pipeline = pipe_widget->private;
968968
pipeline->mem_usage += total;
969+
970+
/* Update base_config->cpc from the module manifest */
971+
sof_ipc4_update_cpc_from_manifest(sdev, swidget->module_info, base_config);
972+
973+
dev_dbg(sdev->dev, "%s: ibs / obs / cpc: %u / %u / %u\n",
974+
swidget->widget->name, base_config->ibs, base_config->obs,
975+
base_config->cpc);
976+
969977
}
970978

971979
static int sof_ipc4_widget_assign_instance_id(struct snd_sof_dev *sdev,

0 commit comments

Comments
 (0)