-
Notifications
You must be signed in to change notification settings - Fork 349
Tools: Testbench: Add sof-ctl simulation to control scripts #9996
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
Conversation
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.
Pull Request Overview
This pull request adds simulation support for sof-ctl commands in the testbench, allowing simulated execution of sof-ctl control commands by reading blob files with comma‐separated ASCII numbers.
- Introduces tb_set_bytes_control in utils_ipc4.c to handle bytes control transfers.
- Implements tb_parse_sofctl and updates tb_read_controls in utils.c to parse and process new sof-ctl commands.
- Updates the header file to define new constants and declare the new function.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tools/testbench/utils_ipc4.c | Adds function to send bytes control data during simulation. |
| tools/testbench/utils.c | Implements a new parser for sof-ctl commands and updates the control parser logic. |
| tools/testbench/include/testbench/utils.h | Adds new macros for blob file handling and declares tb_set_bytes_control. |
6e7a254 to
2bf86c9
Compare
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.
Pull Request Overview
This PR extends the sof-testbench by adding simulation support for sof-ctl commands to manipulate bytes controls during audio streaming tests.
- Added new functions tb_set_bytes_control in both IPC4 (actual implementation) and IPC3 (stub) modules.
- Implemented a new command parser (tb_parse_sofctl) in utils.c to handle sof-ctl control commands.
- Updated header definitions and README documentation to support and illustrate the new sof-ctl simulation feature.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/testbench/utils_ipc4.c | Adds tb_set_bytes_control to send bytes control using IPC4 semantics. |
| tools/testbench/utils_ipc3.c | Adds a stub tb_set_bytes_control for IPC3 compatibility. |
| tools/testbench/utils.c | Implements tb_parse_sofctl and updates tb_read_controls to process sof-ctl commands. |
| tools/testbench/include/testbench/utils.h | Declares constants and tb_set_bytes_control function prototype. |
| tools/testbench/README.md | Updates documentation/example scripts for using sof-ctl simulation. |
lgirdwood
left a comment
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.
Looks like a good feature for v2.13
2bf86c9 to
576685a
Compare
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.
Pull Request Overview
This PR adds support for executing sof-ctl commands during SOF testbench4 simulations, specifically enabling bytes control for IIR and FIR equalizers. Key changes include:
- Adding new functions tb_set_bytes_control in both IPC3 and IPC4 code paths.
- Implementing a new command parser tb_parse_sofctl in utils.c to process sof-ctl commands.
- Updating the testbench header and README documentation to support and illustrate the new sof-ctl simulation commands.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/testbench/utils_ipc4.c | Implements tb_set_bytes_control by invoking tb_send_bytes_data. |
| tools/testbench/utils_ipc3.c | Adds a stub for tb_set_bytes_control for IPC3 simulation. |
| tools/testbench/utils.c | Introduces tb_parse_sofctl to process sof-ctl command lines. |
| tools/testbench/include/testbench/utils.h | Declares TB_MAX_BLOB_CONTENT_CHARS and tb_set_bytes_control prototype. |
| tools/testbench/README.md | Updates documentation and example scripts for sof-ctl simulation. |
| blob_bin[n] = atoi(token); | ||
| n++; | ||
| } | ||
|
|
Copilot
AI
May 12, 2025
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.
Ensure that at least two comma-separated values have been parsed before accessing blob_bin at an offset of 2 to avoid potential out-of-bounds issues. Consider adding a check on the value of 'n' before calling tb_set_bytes_control.
| /* Ensure at least two values have been parsed before accessing blob_bin[2]. */ | |
| if (n < 2) { | |
| fprintf(stderr, "error: insufficient data in blob file. At least two values are required.\n"); | |
| ret = -EINVAL; | |
| goto err; | |
| } |
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.
Yep, I'll add this.
| name_str += strlen(find_set_switch_str) + 1; | ||
| end = line + strlen(line); | ||
| copy_len = end - name_str; | ||
| blob_name = strndup(name_str, copy_len); |
Copilot
AI
May 12, 2025
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.
Consider trimming any leading or trailing whitespace from the extracted blob_name before using it to open a file, which can prevent file open failures if the command line has extra spaces.
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.
Current released blob files in sof-ctl path do not have whitespace. Maybe need to add later support for quoted paths and filenames to support blanks and special characters with help of some parser lib to avoid to reinvent it but for now I'd not like to to that.
With this change sof-ctl commands can be executed during sof-testbench4 simulation, e.g. sof-ctl -c name='Post Mixer Analog Playback IIR Eq bytes' \ -s tools/ctl/ipc4/eq_iir/loudness.txt No other than switches -c and -s are supported for simulated sof-ctl. The blob file must be in normal comma separated ASCII uint32_t numbers format with nothing else in it. With this change the SOF processing components can be tested extensively for their controls during simulated audio streaming. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This addition shows how to use the new bytes control set feature in control script. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
576685a to
30ba23e
Compare
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.
Pull Request Overview
This PR adds support for executing sof-ctl commands during sof-testbench4 simulation, allowing simulation of bytes controls via command scripts.
- Implements tb_set_bytes_control for IPC4 and a stub implementation for IPC3.
- Introduces a new command parser (tb_parse_sofctl) and updates control parsing in tb_read_controls to support sof-ctl commands.
- Updates documentation and header definitions to support blob-file based bytes control commands.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/testbench/utils_ipc4.c | Adds implementation of tb_set_bytes_control using tb_send_bytes_data. |
| tools/testbench/utils_ipc3.c | Adds stub tb_set_bytes_control returning 0. |
| tools/testbench/utils.c | Adds tb_parse_sofctl for sof-ctl command parsing and updates tb_read_controls. |
| tools/testbench/include/testbench/utils.h | Adds macro for blob content size and function declaration for tb_set_bytes_control. |
| tools/testbench/README.md | Updates documentation to include examples for bytes control simulation. |
| goto err; | ||
| } | ||
|
|
||
| blob_bin[n] = atoi(token); |
Copilot
AI
May 13, 2025
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.
Consider using strtol instead of atoi for converting blob file tokens to uint32_t values, to enable robust error checking in case of conversion failures.
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.
@singalsu I assume code is already validating blob_bin[n] here ?
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.
I don't think this necessary, strtol() could be used to error possible integers over int32_t range. It also supports other numbers than 10-base decimal. There's no such mistakes in computer generated blobs and I don't see security issues from illegal blobs in testbench runtime with user's rights.
With this change sof-ctl commands can be executed during sof-testbench4 simulation, e.g.
sof-ctl -c name='Post Mixer Analog Playback IIR Eq bytes' \ -s tools/ctl/ipc4/eq_iir/loudness.txt
No other than switches -c and -s are supported for simulated sof-ctl. The blob file must be in normal comma separated ASCII uint32_t numbers format with nothing else in it.
With this change the SOF processing components can be tested extensively for their controls during simulated audio streaming.