Skip to content

Commit d4166b4

Browse files
committed
base_fw: Include sof_info and odec_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 c357597 commit d4166b4

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

src/audio/base_fw.c

Lines changed: 66 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,69 @@ __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+
/**
75+
* Encodes codec and direction information into a single 32-bit value.
76+
* @param codec Codec type (bits 0-7)
77+
* @param dir Stream direction (bits 8-11)
78+
* @return Encoded 32-bit value
79+
*/
80+
#define SET_CODEC_INFO_ITEM(codec, dir) (((codec) & 0xff) | (((dir) & 0xf) << 8))
81+
82+
static void get_codec_info(struct sof_tlv **tuple)
83+
{
84+
struct sof_ipc4_codec_info_data codec_info = { 0 };
85+
86+
#ifdef CONFIG_CADENCE_CODEC_AAC_DEC
87+
codec_info.items[codec_info.count++] =
88+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_AAC, SOF_IPC_STREAM_PLAYBACK);
89+
#endif
90+
#ifdef CONFIG_CADENCE_CODEC_MP3_DEC
91+
codec_info.items[codec_info.count++] =
92+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_PLAYBACK);
93+
#endif
94+
#ifdef CONFIG_CADENCE_CODEC_MP3_ENC
95+
codec_info.items[codec_info.count++] =
96+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_CAPTURE);
97+
#endif
98+
#ifdef CONFIG_CADENCE_CODEC_VORBIS_DEC
99+
codec_info.items[codec_info.count++] =
100+
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_VORBIS, SOF_IPC_STREAM_PLAYBACK);
101+
#endif
102+
103+
if (!codec_info.count)
104+
return;
105+
106+
tlv_value_set(*tuple, IPC4_SOF_CODEC_INFO, sizeof(codec_info.count) +
107+
sizeof(codec_info.items[0]) * codec_info.count, &codec_info);
108+
109+
*tuple = tlv_next(*tuple);
110+
}
111+
112+
#define SOF_CONFIG_MEMBER_SIZE(struct_name) (sizeof(struct sof_tlv) + \
113+
sizeof(struct struct_name))
114+
#define SOF_CONFIG_SIZE_MAX (SOF_CONFIG_MEMBER_SIZE(sof_ipc4_codec_info_data))
115+
116+
static void base_fw_sof_config(struct sof_tlv **tuple)
117+
{
118+
char sof_config_data[SOF_CONFIG_SIZE_MAX] = { 0 };
119+
struct sof_tlv *sof_config_tuple = (struct sof_tlv *)sof_config_data;
120+
uint32_t sof_config_size;
121+
122+
get_codec_info(&sof_config_tuple);
123+
sof_config_size = (uint32_t)((char *)sof_config_tuple - sof_config_data);
124+
if (sof_config_size == 0)
125+
return;
126+
127+
tlv_value_set(*tuple, IPC4_FW_SOF_INFO, sof_config_size, sof_config_data);
128+
129+
*tuple = tlv_next(*tuple);
130+
}
131+
68132
__cold static int basefw_config(uint32_t *data_offset, char *data)
69133
{
70134
uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD};
@@ -150,6 +214,8 @@ __cold static int basefw_config(uint32_t *data_offset, char *data)
150214

151215
tuple = tlv_next(tuple);
152216

217+
base_fw_sof_config(&tuple);
218+
153219
/* add platform specific tuples */
154220
basefw_vendor_fw_config(&plat_data_offset, (char *)tuple);
155221

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)