Skip to content

Commit

Permalink
MDRC: Enhance Initialization of multiband_drc_init
Browse files Browse the repository at this point in the history
- Improved documentation for the multiband_drc_init function,
  specifying its purpose, parameters, and initialization steps.
- Clearly defined all initialization steps, including memory
  allocations and configuration checks.
- Simplified error handling with a single cleanup path, relying
  on existing functions to handle NULL pointers.
- Ensured proper initialization sequence for all components.

Signed-off-by: Shriram Shastry <[email protected]>
  • Loading branch information
ShriramShastry committed Aug 24, 2024
1 parent 9cc36e4 commit 40200c9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,21 @@ static int multiband_drc_setup(struct processing_module *mod, int16_t channels,
* End of Multiband DRC setup code. Next the standard component methods.
*/

/**
* @brief Initialize Multiband Dynamic Range Control (DRC) component.
*
* Allocates and initializes memory for the multiband DRC component data, including
* state structure, coefficient blocks, and module interface.
*
* The function checks and ensures that the provided configuration blob size is
* within expected limits. If successful, the component state is reset and multiband
* DRC processing is enabled by default.
*
* @param[in] mod Pointer to the processing module to be initialized.
*
* @return 0 on success, -EINVAL if configuration blob size is too large,
* -ENOMEM if memory allocation fails for component data.
*/
static int multiband_drc_init(struct processing_module *mod)
{
struct module_data *md = &mod->priv;
Expand Down Expand Up @@ -305,12 +320,6 @@ static int multiband_drc_init(struct processing_module *mod)
md->private = cd;
cd->multiband_drc_func = NULL;
cd->crossover_split = NULL;
/* Initialize to enabled is a workaround for IPC4 kernel version 6.6 and
* before where the processing is never enabled via switch control. New
* kernel sends the IPC4 switch control and sets this to desired state
* before prepare.
*/
multiband_drc_process_enable(&cd->process_enabled);

/* Handler for configuration data */
cd->model_handler = comp_data_blob_handler_new(dev);
Expand All @@ -328,6 +337,12 @@ static int multiband_drc_init(struct processing_module *mod)
}
multiband_drc_reset_state(&cd->state);

/* Initialize to enabled as a workaround for IPC4 kernel version 6.6
* and before where the processing is never enabled via switch
* control. The new kernel sends the IPC4 switch control and sets
* this to the desired state before prepare.
*/
multiband_drc_process_enable(&cd->process_enabled);
return 0;

cd_fail:
Expand Down

0 comments on commit 40200c9

Please sign in to comment.