Skip to content

Commit 80aa053

Browse files
committed
base_fw: Include codec_info into the fw_config message payload
the sof_info (param id 35) contains SOF specific information in a tuple based array. The first such info block is the codec_info (sub ID: 0) to hold information about the codecs supported fro compress offload. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 26f7086 commit 80aa053

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

src/audio/base_fw.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <ipc4/pipeline.h>
1313
#include <ipc4/logging.h>
1414
#include <ipc/topology.h>
15+
#include <ipc/compress_params.h>
1516
#include <sof_versions.h>
1617
#include <sof/lib/cpu-clk-manager.h>
1718
#include <sof/lib/cpu.h>
@@ -65,6 +66,63 @@ __cold static uint32_t get_host_buffer_size(void)
6566
return periods;
6667
}
6768

69+
struct sof_ipc4_codec_info_data {
70+
uint32_t count;
71+
uint32_t items[32];
72+
} __packed __aligned(4);
73+
74+
#define SET_CODEC_INFO_ITEM(codec, dir) (((codec) & 0xff) | (((dir) & 0xff) << 16))
75+
76+
static void get_codec_info(struct sof_tlv **tuple)
77+
{
78+
struct sof_ipc4_codec_info_data codec_info = { 0 };
79+
80+
#ifdef CONFIG_CADENCE_CODEC_AAC_DEC
81+
codec_info.items[codec_info.count++] =
82+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_AAC, SOF_IPC_STREAM_PLAYBACK);
83+
#endif
84+
#ifdef CONFIG_CADENCE_CODEC_MP3_DEC
85+
codec_info.items[codec_info.count++] =
86+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_PLAYBACK);
87+
#endif
88+
#ifdef CONFIG_CADENCE_CODEC_MP3_ENC
89+
codec_info.items[codec_info.count++] =
90+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_CAPTURE);
91+
#endif
92+
#ifdef CONFIG_CADENCE_CODEC_VORBIS_DEC
93+
codec_info.items[codec_info.count++] =
94+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_VORBIS, SOF_IPC_STREAM_PLAYBACK);
95+
#endif
96+
97+
if (!codec_info.count)
98+
return;
99+
100+
tlv_value_set(*tuple, IPC4_SOF_CODEC_INFO, sizeof(codec_info.count) +
101+
sizeof(codec_info.items[0]) * codec_info.count, &codec_info);
102+
103+
*tuple = tlv_next(*tuple);
104+
}
105+
106+
#define SOF_CONFIG_MEMBER_SIZE(struct_name) (sizeof(struct sof_tlv) + \
107+
sizeof(struct struct_name))
108+
#define SOF_CONFIG_SIZE_MAX (SOF_CONFIG_MEMBER_SIZE(sof_ipc4_codec_info_data))
109+
110+
static void base_fw_sof_config(struct sof_tlv **tuple)
111+
{
112+
char sof_config_data[SOF_CONFIG_SIZE_MAX] = { 0 };
113+
struct sof_tlv *sof_config_tuple = (struct sof_tlv *)sof_config_data;
114+
uint32_t sof_config_size;
115+
116+
get_codec_info(&sof_config_tuple);
117+
sof_config_size = (uint32_t)((char *)sof_config_tuple - sof_config_data);
118+
if (sof_config_size == 0)
119+
return;
120+
121+
tlv_value_set(*tuple, IPC4_FW_SOF_INFO, sof_config_size, sof_config_data);
122+
123+
*tuple = tlv_next(*tuple);
124+
}
125+
68126
__cold static int basefw_config(uint32_t *data_offset, char *data)
69127
{
70128
uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD};
@@ -150,6 +208,8 @@ __cold static int basefw_config(uint32_t *data_offset, char *data)
150208

151209
tuple = tlv_next(tuple);
152210

211+
base_fw_sof_config(&tuple);
212+
153213
/* add platform specific tuples */
154214
basefw_vendor_fw_config(&plat_data_offset, (char *)tuple);
155215

src/include/ipc4/base_fw.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,28 @@ enum ipc4_fw_config_params {
376376
IPC4_FW_CONTEXT_SAVE = 29,
377377
/* Minimum size of host buffer in ms */
378378
IPC4_FW_MIN_HOST_BUFFER_PERIODS = 33,
379+
/* decoder/encoder codec information */
380+
IPC4_FW_SOF_INFO = 35,
379381
/* Total number of FW config parameters */
380382
IPC4_FW_CFG_PARAMS_COUNT,
381383
/* Max config parameter id */
382384
IPC4_MAX_FW_CFG_PARAM = IPC4_FW_CFG_PARAMS_COUNT - 1,
383385
};
384386

387+
/*
388+
* tuple based array for SOF specific information under IPC4_FW_SOF_INFO
389+
* tuple of fw_config
390+
*/
391+
enum ipc4_fw_sof_info_params {
392+
/* decoder/encoder codec information */
393+
IPC4_SOF_CODEC_INFO = 0,
394+
395+
/* Total number of SOF config parameters */
396+
IPC4_SOF_CFG_PARAMS_COUNT,
397+
/* Max config parameter id */
398+
IPC4_MAX_SOF_CFG_PARAM = IPC4_SOF_CFG_PARAMS_COUNT - 1,
399+
};
400+
385401
enum ipc4_hw_config_params {
386402
/* Version of cAVS implemented by FW (from ROMInfo) */
387403
IPC4_CAVS_VER_HW_CFG = 0,

0 commit comments

Comments
 (0)