-
Notifications
You must be signed in to change notification settings - Fork 140
Sanity check available_fmt->input_pin_fmts and available_fmt->output_pin_fmts before using them #4190
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
Sanity check available_fmt->input_pin_fmts and available_fmt->output_pin_fmts before using them #4190
Changes from all commits
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 |
|---|---|---|
|
|
@@ -1050,16 +1050,21 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, | |
| return -EINVAL; | ||
| } | ||
|
|
||
| /* copy input format */ | ||
| memcpy(&base_config->audio_fmt, &available_fmt->input_pin_fmts[i].audio_fmt, | ||
| sizeof(struct sof_ipc4_audio_format)); | ||
|
|
||
| /* set base_cfg ibs/obs */ | ||
| base_config->ibs = available_fmt->input_pin_fmts[i].buffer_size; | ||
| base_config->obs = available_fmt->output_pin_fmts[i].buffer_size; | ||
| /* copy input format and set base_cfg ibs*/ | ||
| if (available_fmt->input_pin_fmts) { | ||
| memcpy(&base_config->audio_fmt, &available_fmt->input_pin_fmts[i].audio_fmt, | ||
| sizeof(struct sof_ipc4_audio_format)); | ||
| base_config->ibs = available_fmt->input_pin_fmts[i].buffer_size; | ||
|
|
||
| dev_dbg(sdev->dev, "init input audio formats for %s\n", swidget->widget->name); | ||
| sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->input_pin_fmts[i], 1); | ||
|
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 not group all the |
||
| } else { | ||
| dev_dbg(sdev->dev, "No init input audio formats for %s\n", swidget->widget->name); | ||
|
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. this is printed when no input pin is defined, sure it means that there is no input format, but...
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. I add this printed info in case some one will check the input audio formats. So he can easily use |
||
| } | ||
|
|
||
| dev_dbg(sdev->dev, "Init input audio formats for %s\n", swidget->widget->name); | ||
| sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->input_pin_fmts[i], 1); | ||
| /* set base_cfg obs */ | ||
| if (available_fmt->output_pin_fmts) | ||
| base_config->obs = available_fmt->output_pin_fmts[i].buffer_size; | ||
|
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. Non existent |
||
|
|
||
| /* Return the index of the matched format */ | ||
| return i; | ||
|
|
@@ -1735,8 +1740,9 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget, | |
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| memcpy(&process->output_format, &available_fmt->output_pin_fmts[ret].audio_fmt, | ||
| sizeof(struct sof_ipc4_audio_format)); | ||
| if (available_fmt->output_pin_fmts) | ||
| memcpy(&process->output_format, &available_fmt->output_pin_fmts[ret].audio_fmt, | ||
| sizeof(struct sof_ipc4_audio_format)); | ||
|
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. let's say you got a match with the 2nd input format in
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, I mentioned a similar question in #4163 (comment). The output is not 1:1 mapping to input. Sometimes input number may be larger than output number. This may cause issue. What I understand is we will limit it in tplg based on @ranj063 's comments?
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. As @ujfalusi raise this issue, I still want to recommend that we can add an index in the format structure. Let say: When there is output format mapped to an input format, they have the same format_index. So we don't use |
||
|
|
||
| /* update pipeline memory usage */ | ||
| sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &process->base_config); | ||
|
|
||
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.
@libinyang, the commit subject and message is not too verbose...