-
Notifications
You must be signed in to change notification settings - Fork 350
Part 2 of compressed offload support for IPC4 (no topology changes) #10534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f80699d
eec1547
7e2086d
ac37487
27b24d5
25961a8
ededd70
2984da4
dfac8f3
c28c64c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # the cadence_libs directory should be in one level up from the sof | ||
| # project dir: sof/../cadence_libs/ | ||
| # which is zephyr/../cadence_libs/ | ||
|
|
||
| CONFIG_CADENCE_CODEC=y | ||
| CONFIG_CADENCE_CODEC_MP3_DEC=y | ||
| CONFIG_CADENCE_CODEC_MP3_DEC_LIB="../cadence_libs/xa_mp3_dec.a" | ||
| CONFIG_CADENCE_CODEC_MP3_ENC=y | ||
| CONFIG_CADENCE_CODEC_MP3_ENC_LIB="../cadence_libs/xa_mp3_enc.a" | ||
| CONFIG_CADENCE_CODEC_AAC_DEC=y | ||
| CONFIG_CADENCE_CODEC_AAC_DEC_LIB="../cadence_libs/xa_aac_dec.a" | ||
| CONFIG_CADENCE_CODEC_VORBIS_DEC=y | ||
| CONFIG_CADENCE_CODEC_VORBIS_DEC_LIB="../cadence_libs/xa_vorbis_dec.a" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
|
|
@@ -65,6 +66,63 @@ __cold static uint32_t get_host_buffer_size(void) | |
| return periods; | ||
| } | ||
|
|
||
| struct sof_ipc4_codec_info_data { | ||
| uint32_t count; | ||
| uint32_t items[32]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
| #define SET_CODEC_INFO_ITEM(codec, dir) (((codec) & 0xff) | (((dir) & 0xff) << 16)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internally 16 bits would be enough, I presume 32 bits are used for compatibility with external standards?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The codec ID (lower 16bit) is actually defined in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason we are trying to save here, why not just go for 31bits ID and 1 bit direction to start with ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that would make more sense I guess, need ot align the kernel PR as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. compress direction have 3 values: enum snd_compr_direction {
SND_COMPRESS_PLAYBACK = 0,
SND_COMPRESS_CAPTURE,
SND_COMPRESS_ACCEL
};I guess we could use bit 30-31, that would allow one more value for future proofing. |
||
|
|
||
| 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; | ||
|
|
||
| get_codec_info(&sof_config_tuple); | ||
| sof_config_size = (uint32_t)((char *)sof_config_tuple - sof_config_data); | ||
| if (sof_config_size == 0) | ||
| 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}; | ||
|
|
@@ -150,6 +208,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); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,10 @@ | |
| #include <sof/audio/cadence/mp3_dec/xa_mp3_dec_api.h> | ||
| #include <sof/audio/cadence/mp3_enc/xa_mp3_enc_api.h> | ||
| #include <sof/audio/cadence/aac_dec/xa_aac_dec_api.h> | ||
| #include <sof/ipc/msg.h> | ||
| #include <sof/schedule/ll_schedule_domain.h> | ||
| #include <ipc/compress_params.h> | ||
| #include <ipc4/notification.h> | ||
| #include <rtos/init.h> | ||
|
|
||
| SOF_DEFINE_REG_UUID(cadence_codec); | ||
|
|
@@ -204,6 +206,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; | ||
| } | ||
|
|
@@ -465,6 +470,36 @@ static int cadence_codec_process(struct processing_module *mod, struct sof_sourc | |
| return ret; | ||
| } | ||
|
|
||
| if (codec->mpd.eos_reached && !codec->mpd.eos_notification_sent) { | ||
| struct ipc_msg msg_proto; | ||
| struct comp_ipc_config *ipc_config = &dev->ipc_config; | ||
| union ipc4_notification_header *primary = | ||
| (union ipc4_notification_header *)&msg_proto.header; | ||
| struct sof_ipc4_notify_module_data *msg_module_data; | ||
| struct ipc_msg *msg; | ||
|
|
||
| memset_s(&msg_proto, sizeof(msg_proto), 0, sizeof(msg_proto)); | ||
| primary->r.notif_type = SOF_IPC4_MODULE_NOTIFICATION; | ||
| primary->r.type = SOF_IPC4_GLB_NOTIFICATION; | ||
| primary->r.rsp = SOF_IPC4_MESSAGE_DIR_MSG_REQUEST; | ||
| primary->r.msg_tgt = SOF_IPC4_MESSAGE_TARGET_FW_GEN_MSG; | ||
| msg = ipc_msg_w_ext_init(msg_proto.header, msg_proto.extension, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a good place to use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would a followup patch do? |
||
| sizeof(*msg_module_data)); | ||
| if (msg) { | ||
| msg_module_data = (struct sof_ipc4_notify_module_data *)msg->tx_data; | ||
| msg_module_data->instance_id = IPC4_INST_ID(ipc_config->id); | ||
| msg_module_data->module_id = IPC4_MOD_ID(ipc_config->id); | ||
| msg_module_data->event_id = SOF_IPC4_NOTIFY_MODULE_EVENTID_COMPR_MAGIC_VAL; | ||
| msg_module_data->event_data_size = 0; | ||
|
|
||
| ipc_msg_send(msg, NULL, false); | ||
| codec->mpd.eos_notification_sent = true; | ||
| } | ||
|
|
||
| /* Set EOS for the sink as we are not going to produce more data */ | ||
| audio_buffer_set_eos(sof_audio_buffer_from_sink(sinks[0])); | ||
| } | ||
|
|
||
| /* do not proceed if not enough free space left */ | ||
| if (out_space < codec->mpd.produced) { | ||
| source_release_data(sources[0], 0); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this ID is good than we need to reserve it...
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 35 seems free. We need to reserve it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, can we initiate the reservation process? |
||
| /* 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, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,6 +177,7 @@ struct ipc4_message_reply { | |
| #define SOF_IPC4_ENUM_CONTROL_PARAM_ID 201 | ||
| #define SOF_IPC4_BYTES_CONTROL_PARAM_ID 202 | ||
| #define SOF_IPC4_NOTIFY_MODULE_EVENTID_ALSA_MAGIC_VAL ((uint32_t)(0xA15A << 16)) | ||
| #define SOF_IPC4_NOTIFY_MODULE_EVENTID_COMPR_MAGIC_VAL ((uint32_t)(0xC0C0 << 16)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this magic value?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fine by me. |
||
|
|
||
| /** | ||
| * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overlay relies on relative library paths (e.g.,
../cadence_libs/...) but doesn’t document the expected directory layout or where the paths are resolved from during builds. Add brief comments at the top of the file explaining the expected location ofcadence_libs/relative to the build/app directory, and how users should adjust these paths for their environment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'll add a comment to the compr_overlay.conf file as well.