-
Notifications
You must be signed in to change notification settings - Fork 361
audio: eq_iir: register IPC-time blob validator #10942
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
Draft
singalsu
wants to merge
2
commits into
thesofproject:main
Choose a base branch
from
singalsu:model_handler_validator_eqiir
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,59 +239,111 @@ static int eq_iir_init_response(struct comp_dev *dev, int idx, | |
| return 0; | ||
| } | ||
|
|
||
| static int eq_iir_init_coef(struct processing_module *mod, int nch) | ||
| /* Validate the config blob layout and, if lookup is non-NULL, populate it | ||
| * with pointers to each response header. Pass lookup = NULL to validate only. | ||
| */ | ||
| static int eq_iir_walk_config(struct comp_dev *dev, | ||
| struct sof_eq_iir_config *config, | ||
| size_t config_size, | ||
| struct sof_eq_iir_header **lookup) | ||
| { | ||
| struct comp_data *cd = module_get_private_data(mod); | ||
| struct sof_eq_iir_config *config = cd->config; | ||
| struct iir_state_df1 *iir = cd->iir; | ||
| struct sof_eq_iir_header *lookup[SOF_EQ_IIR_MAX_RESPONSES]; | ||
| struct sof_eq_iir_header *eq; | ||
| uint32_t coef_words_max; | ||
| int32_t *assign_response; | ||
| int32_t *coef_data; | ||
| int size_sum = 0; | ||
| int resp = 0; | ||
| int ret; | ||
| int i; | ||
| uint32_t j; | ||
| int s; | ||
| int ret; | ||
|
|
||
| comp_info(mod->dev, "%u responses, %u channels, stream %d channels", | ||
| config->number_of_responses, config->channels_in_config, nch); | ||
|
|
||
| /* Sanity checks */ | ||
| if (nch > PLATFORM_MAX_CHANNELS || | ||
| config->channels_in_config > PLATFORM_MAX_CHANNELS || | ||
| if (config->channels_in_config > PLATFORM_MAX_CHANNELS || | ||
| !config->channels_in_config) { | ||
| comp_err(mod->dev, "invalid channels count"); | ||
| comp_err(dev, "invalid channels_in_config %u", config->channels_in_config); | ||
| return -EINVAL; | ||
| } | ||
| if (config->number_of_responses > SOF_EQ_IIR_MAX_RESPONSES) { | ||
| comp_err(mod->dev, "# of resp exceeds max"); | ||
| comp_err(dev, "# of resp %u exceeds max", config->number_of_responses); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| ret = eq_iir_blob_words_max(mod->dev, config, cd->config_size, &coef_words_max); | ||
| ret = eq_iir_blob_words_max(dev, config, config_size, &coef_words_max); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| /* Collect index of response start positions in all_coefficients[] */ | ||
| j = 0; | ||
| assign_response = ASSUME_ALIGNED(&config->data[0], 4); | ||
| coef_data = ASSUME_ALIGNED(&config->data[config->channels_in_config], 4); | ||
| for (i = 0; i < SOF_EQ_IIR_MAX_RESPONSES; i++) { | ||
| if (i < config->number_of_responses) { | ||
| ret = eq_iir_init_response(mod->dev, i, coef_data, | ||
| coef_words_max, &j, &eq); | ||
| if (ret < 0) | ||
| return ret; | ||
| for (i = 0; i < config->number_of_responses; i++) { | ||
| ret = eq_iir_init_response(dev, i, coef_data, coef_words_max, &j, &eq); | ||
| if (ret < 0) | ||
| return ret; | ||
| if (lookup) | ||
| lookup[i] = eq; | ||
| } else { | ||
| } | ||
| if (lookup) { | ||
| for (; i < SOF_EQ_IIR_MAX_RESPONSES; i++) | ||
| lookup[i] = NULL; | ||
|
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.
|
||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| int eq_iir_validate_config(struct comp_dev *dev, | ||
| struct sof_eq_iir_config *config, | ||
| size_t config_size) | ||
| { | ||
| int32_t *assign_response; | ||
| int32_t resp; | ||
| int ret; | ||
| int i; | ||
|
|
||
| ret = eq_iir_walk_config(dev, config, config_size, NULL); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| /* Validate every assign_response[] entry that the per-channel loop in | ||
| * eq_iir_init_coef() could pick up. Entries beyond channels_in_config | ||
| * reuse the last assigned value, so checking [0, channels_in_config) | ||
| * covers all reachable nch. | ||
| */ | ||
| assign_response = ASSUME_ALIGNED(&config->data[0], 4); | ||
| for (i = 0; i < config->channels_in_config; i++) { | ||
| resp = assign_response[i]; | ||
| if (resp >= 0 && resp >= config->number_of_responses) { | ||
| comp_err(dev, "assign_response[%d] = %d exceeds %u", | ||
| i, resp, config->number_of_responses); | ||
| return -EINVAL; | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int eq_iir_init_coef(struct processing_module *mod, int nch) | ||
| { | ||
| struct comp_data *cd = module_get_private_data(mod); | ||
| struct sof_eq_iir_config *config = cd->config; | ||
| struct iir_state_df1 *iir = cd->iir; | ||
| struct sof_eq_iir_header *lookup[SOF_EQ_IIR_MAX_RESPONSES]; | ||
| struct sof_eq_iir_header *eq; | ||
| int32_t *assign_response; | ||
| int size_sum = 0; | ||
| int resp = 0; | ||
| int i; | ||
| int s; | ||
| int ret; | ||
|
|
||
| comp_info(mod->dev, "%u responses, %u channels, stream %d channels", | ||
| config->number_of_responses, config->channels_in_config, nch); | ||
|
|
||
| if (nch > PLATFORM_MAX_CHANNELS) { | ||
| comp_err(mod->dev, "invalid stream channels %d", nch); | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| ret = eq_iir_walk_config(mod->dev, config, cd->config_size, lookup); | ||
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| /* Initialize 1st phase */ | ||
| assign_response = ASSUME_ALIGNED(&config->data[0], 4); | ||
| for (i = 0; i < nch; i++) { | ||
| /* Check for not reading past blob response to channel assign | ||
| * map. The previous channel response is assigned for any | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you never propagate this function's returned error code and always use it as a condition in
ifclauses. How about making it boolean