Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/audio/base_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <ipc4/pipeline.h>
#include <ipc4/logging.h>
#include <ipc/topology.h>
#include <ipc/compress_params.h>
#include <sof_versions.h>
#include <sof/lib/cpu-clk-manager.h>
#include <sof/lib/cpu.h>
Expand Down Expand Up @@ -65,6 +66,69 @@ __cold static uint32_t get_host_buffer_size(void)
return periods;
}

struct sof_ipc4_codec_info_data {
uint32_t count;
uint32_t items[32];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 32? Future-proofing or aligning to some existing spec/convention?

} __packed __aligned(4);

/**
* Encodes codec and direction information into a single 32-bit value.
* @param codec Codec type (bits 0-7)
* @param dir Stream direction (bits 8-11)
* @return Encoded 32-bit value
*/
#define SET_CODEC_INFO_ITEM(codec, dir) (((codec) & 0xff) | (((dir) & 0xf) << 8))

static void get_codec_info(struct sof_tlv **tuple)
{
struct sof_ipc4_codec_info_data codec_info = { 0 };

#ifdef CONFIG_CADENCE_CODEC_AAC_DEC
codec_info.items[codec_info.count++] =
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_AAC, SOF_IPC_STREAM_PLAYBACK);
#endif
#ifdef CONFIG_CADENCE_CODEC_MP3_DEC
codec_info.items[codec_info.count++] =
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_PLAYBACK);
#endif
#ifdef CONFIG_CADENCE_CODEC_MP3_ENC
codec_info.items[codec_info.count++] =
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_MP3, SOF_IPC_STREAM_CAPTURE);
#endif
#ifdef CONFIG_CADENCE_CODEC_VORBIS_DEC
codec_info.items[codec_info.count++] =
SET_CODEC_INFO_ITEM(SND_AUDIOCODEC_VORBIS, SOF_IPC_STREAM_PLAYBACK);
#endif

if (!codec_info.count)
return;

tlv_value_set(*tuple, IPC4_SOF_CODEC_INFO, sizeof(codec_info.count) +
sizeof(codec_info.items[0]) * codec_info.count, &codec_info);

*tuple = tlv_next(*tuple);
}

#define SOF_CONFIG_MEMBER_SIZE(struct_name) (sizeof(struct sof_tlv) + \
sizeof(struct struct_name))
#define SOF_CONFIG_SIZE_MAX (SOF_CONFIG_MEMBER_SIZE(sof_ipc4_codec_info_data))

static void base_fw_sof_config(struct sof_tlv **tuple)
{
char sof_config_data[SOF_CONFIG_SIZE_MAX] = { 0 };
struct sof_tlv *sof_config_tuple = (struct sof_tlv *)sof_config_data;
uint32_t sof_config_size;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t resp. ssize_t?


get_codec_info(&sof_config_tuple);
sof_config_size = (uint32_t)((char *)sof_config_tuple - sof_config_data);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just type-cast sof_config_tuple to uintptr_t to avoid double-casting

if (sof_config_size == 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it turn negative?

return;

tlv_value_set(*tuple, IPC4_FW_SOF_INFO, sof_config_size, sof_config_data);

*tuple = tlv_next(*tuple);
}

__cold static int basefw_config(uint32_t *data_offset, char *data)
{
uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD};
Expand Down Expand Up @@ -150,6 +214,8 @@ __cold static int basefw_config(uint32_t *data_offset, char *data)

tuple = tlv_next(tuple);

base_fw_sof_config(&tuple);

/* add platform specific tuples */
basefw_vendor_fw_config(&plat_data_offset, (char *)tuple);

Expand Down
4 changes: 4 additions & 0 deletions src/audio/module_adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ endif()
zephyr_library_import(xa_aac_dec ${CONFIG_CADENCE_CODEC_AAC_DEC_LIB})
endif()

if (CONFIG_CADENCE_CODEC_VORBIS_DEC)
zephyr_library_import(xa_vorbis_dec ${CONFIG_CADENCE_CODEC_VORBIS_DEC_LIB})
endif()

if (CONFIG_CADENCE_CODEC_MP3_DEC)
zephyr_library_import(xa_mp3_dec ${CONFIG_CADENCE_CODEC_MP3_DEC_LIB})
endif()
Expand Down
8 changes: 6 additions & 2 deletions src/audio/module_adapter/module/cadence_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ static int cadence_configure_codec_params(struct processing_module *mod)
return cadence_configure_mp3_enc_params(mod);
case CADENCE_CODEC_AAC_DEC_ID:
return cadence_configure_aac_dec_params(mod);
case CADENCE_CODEC_VORBIS_DEC_ID:
/* No configuration needed for Vorbis */
return 0;
default:
break;
}
Expand All @@ -217,8 +220,8 @@ static int cadence_codec_init(struct processing_module *mod)
struct module_data *codec = &mod->priv;
struct module_config *cfg = &codec->cfg;
struct module_ext_init_data *ext_data = cfg->ext_data;
struct module_config *setup_cfg = NULL;
struct cadence_codec_data *cd;
struct module_config *setup_cfg;
struct comp_dev *dev = mod->dev;
int mem_tabs_size;
int ret;
Expand Down Expand Up @@ -308,7 +311,8 @@ static int cadence_codec_init(struct processing_module *mod)
free:
mod_free(mod, cd->mem_tabs);
free_cfg:
mod_free(mod, setup_cfg->data);
if (setup_cfg)
mod_free(mod, setup_cfg->data);
free_cd:
mod_free(mod, cd);

Expand Down
16 changes: 16 additions & 0 deletions src/include/ipc4/base_fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,28 @@ enum ipc4_fw_config_params {
IPC4_FW_CONTEXT_SAVE = 29,
/* Minimum size of host buffer in ms */
IPC4_FW_MIN_HOST_BUFFER_PERIODS = 33,
/* decoder/encoder codec information */
IPC4_FW_SOF_INFO = 35,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this ID is good than we need to reserve it...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

35 seems free. We need to reserve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, can we initiate the reservation process?
This will reduce the collision surface for future in both ways.

/* Total number of FW config parameters */
IPC4_FW_CFG_PARAMS_COUNT,
/* Max config parameter id */
IPC4_MAX_FW_CFG_PARAM = IPC4_FW_CFG_PARAMS_COUNT - 1,
};

/*
* tuple based array for SOF specific information under IPC4_FW_SOF_INFO
* tuple of fw_config
*/
enum ipc4_fw_sof_info_params {
/* decoder/encoder codec information */
IPC4_SOF_CODEC_INFO = 0,

/* Total number of SOF config parameters */
IPC4_SOF_CFG_PARAMS_COUNT,
/* Max config parameter id */
IPC4_MAX_SOF_CFG_PARAM = IPC4_SOF_CFG_PARAMS_COUNT - 1,
};

enum ipc4_hw_config_params {
/* Version of cAVS implemented by FW (from ROMInfo) */
IPC4_CAVS_VER_HW_CFG = 0,
Expand Down