Skip to content

Conversation

@ranj063
Copy link
Collaborator

@ranj063 ranj063 commented Jan 21, 2026

This PR is part 1 of the compressed offload support which includes splitting up the cadence implementation for IPC3 and IPC4 along with the required patches for setting a DP module's ring buffer size based on what the input buffer size requirements for the codec are and the init data required for module init. The topology patches showing the compressed path will be included in the next part

Add a global ID for module specific init data in the extended init data
section and update the decode function to save the data in the module's
init_data.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
When a modules advertises the input and output buffer requirements for
processing, use that to determine the size of the secondary buffer when
attaching them to buffers interfacing with DP modules.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Split the implementation for IPC3 for the cadence decoder and add a new
implementation for IPC4. The IPC4 implementation assumes that the codec
info is passed to the firmware during the module init IPC as module
specific data. The implementation includes support for MP3 decoder, MP3
encoder and AAC decoder for the time being.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds compressed offload support for IPC4 by refactoring the Cadence codec implementation. It splits the existing implementation into IPC3 and IPC4-specific variants while keeping common functionality shared.

Changes:

  • Split Cadence codec implementation into IPC3 (cadence_ipc3.c) and IPC4 (cadence_ipc4.c) specific files
  • Modified ring buffer creation to account for module-specific buffer size requirements
  • Added support for module initialization data in IPC4

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ipc/ipc4/helper.c Updated ring buffer size calculation to use MAX of default sizes and module-specific buffer requirements
src/include/sof/audio/module_adapter/module/cadence.h Exposed common Cadence codec functions, added IPC4-specific structures, moved API ID enum from .c file
src/include/sof/audio/cadence/mp3_enc/xa_mp3_enc_api.h Added new MP3 encoder API header with configuration parameters and error codes
src/include/ipc4/module.h Added MODULE_DATA initialization data type to support codec-specific init data
src/audio/module_adapter/module_adapter_ipc4.c Added handling for MODULE_DATA initialization data type
src/audio/module_adapter/module/cadence_ipc4.c New IPC4-specific Cadence codec implementation with DP-aware processing
src/audio/module_adapter/module/cadence_ipc3.c Extracted IPC3-specific Cadence codec implementation
src/audio/module_adapter/module/cadence.c Refactored to contain only common codec functionality shared between IPC3/IPC4
src/audio/module_adapter/CMakeLists.txt Updated build configuration to compile IPC-specific implementations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +258 to +259
cd->direction = *((uint32_t *)codec->cfg.init_data +
sizeof(struct snd_codec) / sizeof(uint32_t));
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Pointer arithmetic error: adding the result of sizeof(struct snd_codec) / sizeof(uint32_t) to a uint32_t* pointer will skip that many uint32_t elements (multiplying by sizeof(uint32_t) again). This should be cast to uint8_t* first, then offset by sizeof(struct snd_codec), then cast back to uint32_t* and dereferenced.

Suggested change
cd->direction = *((uint32_t *)codec->cfg.init_data +
sizeof(struct snd_codec) / sizeof(uint32_t));
uint8_t *init_bytes = (uint8_t *)codec->cfg.init_data;
cd->direction = *(uint32_t *)(init_bytes + sizeof(struct snd_codec));

Copilot uses AI. Check for mistakes.
{
struct cadence_codec_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
int word_size = 16;
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The hardcoded word size value 16 is used here but then validated against audio_fmt.depth in the switch statement below. Consider using a constant definition or deriving the value from the configuration to make the relationship clearer.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant