Skip to content

Commit 756a0ba

Browse files
committed
ASoC: SOF: ipc4/ipc4-loader: Add SOF_INFO and CODEC_INFO to fw_config_params
SOF_INFO (id == 35) tuple holds tuple structured information about SOF features. The first entry in SOF_INFO is the SOF_CODEC_INFO (id == 0) which contains information about the supported codecs for decode/encode in the booted firmware. If present in the fw_config payload, make a copy of it and store it sof_ipc4_fw_data->codec_info to be used by the compressed code. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 1adc1f7 commit 756a0ba

3 files changed

Lines changed: 67 additions & 6 deletions

File tree

include/sound/sof/ipc4/header.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,10 @@ enum sof_ipc4_fw_config_params {
437437
SOF_IPC4_FW_CFG_RESERVED,
438438
SOF_IPC4_FW_CFG_POWER_GATING_POLICY,
439439
SOF_IPC4_FW_CFG_ASSERT_MODE,
440-
SOF_IPC4_FW_RESERVED1,
441-
SOF_IPC4_FW_RESERVED2,
442-
SOF_IPC4_FW_RESERVED3,
443-
SOF_IPC4_FW_RESERVED4,
444-
SOF_IPC4_FW_RESERVED5,
445-
SOF_IPC4_FW_CONTEXT_SAVE
440+
/* Reserved: 24 - 28 */
441+
SOF_IPC4_FW_CONTEXT_SAVE = 29,
442+
/* Reserved: 30 - 34 */
443+
SOF_IPC4_FW_CFG_SOF_INFO = 35,
446444
};
447445

448446
struct sof_ipc4_fw_version {
@@ -452,6 +450,14 @@ struct sof_ipc4_fw_version {
452450
uint16_t build;
453451
} __packed;
454452

453+
/*
454+
* tuple based array for SOF specific information under SOF_IPC4_FW_CFG_SOF_INFO
455+
* tuple of fw_config
456+
*/
457+
enum ipc4_fw_sof_info_params {
458+
SOF_IPC4_SOF_CODEC_INFO,
459+
};
460+
455461
/* Payload data for SOF_IPC4_MOD_SET_DX */
456462
struct sof_ipc4_dx_state_info {
457463
/* core(s) to apply the change */

sound/soc/sof/ipc4-loader.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,52 @@ static int sof_ipc4_validate_firmware(struct snd_sof_dev *sdev)
417417
return 0;
418418
}
419419

420+
static int sof_ipc4_query_sof_info(struct snd_sof_dev *sdev,
421+
void *sof_info_data, u32 sof_info_size)
422+
{
423+
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
424+
struct sof_ipc4_tuple *tuple;
425+
size_t tuple_size;
426+
size_t offset = 0;
427+
int ret = 0;
428+
429+
while (offset < sof_info_size) {
430+
if (sof_info_size - offset < sizeof(*tuple)) {
431+
dev_err(sdev->dev, "Invalid SOF info tuple header at offset %zu\n", offset);
432+
ret = -EINVAL;
433+
goto out;
434+
}
435+
436+
tuple = (struct sof_ipc4_tuple *)((u8 *)sof_info_data + offset);
437+
tuple_size = sizeof(*tuple) + tuple->size;
438+
if (tuple_size < sizeof(*tuple) || tuple_size > sof_info_size - offset) {
439+
dev_err(sdev->dev,
440+
"Invalid SOF info tuple size %u at offset %zu\n",
441+
tuple->size, offset);
442+
ret = -EINVAL;
443+
goto out;
444+
}
445+
446+
switch (tuple->type) {
447+
case SOF_IPC4_SOF_CODEC_INFO:
448+
ipc4_data->codec_info = devm_kmemdup(sdev->dev, tuple->value,
449+
tuple->size, GFP_KERNEL);
450+
if (!ipc4_data->codec_info) {
451+
ret = -ENOMEM;
452+
goto out;
453+
}
454+
break;
455+
default:
456+
break;
457+
}
458+
459+
offset += tuple_size;
460+
}
461+
462+
out:
463+
return ret;
464+
}
465+
420466
int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
421467
{
422468
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
@@ -492,6 +538,11 @@ int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
492538
*/
493539
ipc4_data->libraries_restored = ipc4_data->fw_context_save;
494540
break;
541+
case SOF_IPC4_FW_CFG_SOF_INFO:
542+
ret = sof_ipc4_query_sof_info(sdev, tuple->value, tuple->size);
543+
if (ret)
544+
goto out;
545+
break;
495546
default:
496547
break;
497548
}

sound/soc/sof/ipc4-priv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ struct snd_ipc4_nhlt {
8181
* @libraries_restored: The libraries have been retained during firmware boot
8282
* @nhlt_list: The NHLT tables from the BIOS and the topology manifest
8383
*
84+
* @codec_info: Information about the available codecs in booted firmware. The
85+
* data is to be used by the code for compressed support.
8486
* @load_library: Callback function for platform dependent library loading
8587
* @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
8688
*/
@@ -97,6 +99,8 @@ struct sof_ipc4_fw_data {
9799
bool libraries_restored;
98100
struct list_head nhlt_list;
99101

102+
void *codec_info;
103+
100104
int (*load_library)(struct snd_sof_dev *sdev,
101105
struct sof_ipc4_fw_library *fw_lib, bool reload);
102106
void (*intel_configure_mic_privacy)(struct snd_sof_dev *sdev,

0 commit comments

Comments
 (0)