-
Notifications
You must be signed in to change notification settings - Fork 318
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
Tools: Tune: Collection of patches to produce ALSA UCM friendly binary control blobs #9070
Tools: Tune: Collection of patches to produce ALSA UCM friendly binary control blobs #9070
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.
@wszypelt good to merge ? I dont think internal CI is testing these scripts yet. |
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 reviewed the changes, and they appear to be appropriate. I have a few suggestions I have added.
Thank you
SOF_CTRL_CMD_BINARY = 3; | ||
nh = 8; | ||
nb = length(blob8); | ||
ublob8 = zeros(nb + nh, 1); |
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 think it would be better. Since ublob8 is made up of 8-bit values, writing it as 'uint8' accurately reflects its contents. Ensure that input blob8 contains no unintentional 8-bit unsigned integers.
ublob8 = zeros(nb + nh, 1, 'uint8');
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 agree this would be good to do (Matlab compiler might require this). Please wait for new version for this easy improvement.
@@ -10,17 +10,19 @@ function example_fir_eq() | |||
|
|||
%% Common definitions | |||
fs = 48e3; | |||
fn.cpath3 = '../../ctl/ipc3'; | |||
fn.cpath4 = '../../ctl/ipc4'; | |||
fn.cpath3 = '../../ctl/ipc3/eq_fir'; |
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.
There is no check to see if these directories exist before writing files into them, which may lead to errors. Can you consider adding checks and possibly creating directories that do not currently exist?
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 think it's better to leave to another PR. There could be a function dir = sof_directory_create_check(dir);
fn.cpath3 = '../../ctl/ipc3'; | ||
fn.cpath4 = '../../ctl/ipc4'; | ||
fn.cpath3 = '../../ctl/ipc3/eq_fir'; | ||
fn.cpath4 = '../../ctl/ipc4/eq_fir'; |
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.
here - same as well?
@@ -10,17 +10,19 @@ function example_iir_eq() | |||
|
|||
%% Common definitions | |||
fs = 48e3; | |||
fn.cpath3 = '../../ctl/ipc3'; | |||
fn.cpath4 = '../../ctl/ipc4'; | |||
fn.cpath3 = '../../ctl/ipc3/eq_iir'; |
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.
At line 168 and 169, unnecessary semicolon is added. I hope it is OK to remove
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, maybe leave to next PR since I'm not changing these lines with this topic.
@@ -15,8 +15,10 @@ function example_spk_eq() | |||
|
|||
%% Defaults | |||
fs = 48e3; | |||
fn.cpath3 = '../../ctl/ipc3'; | |||
fn.cpath4 = '../../ctl/ipc4'; | |||
iir.cpath3 = '../../ctl/ipc3/eq_iir'; |
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.
There are few minor ;
like eq.enable_iir; and additional []
braces are there like [ bq_fir ])
at line number 137 and 154. Please consider removing them.
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.
Also better to put into other PR.
eq_tplg2_write(fullfile(iir.tpath2, iir.tplg2), bp_iir, 'eq_iir', iir.comment); | ||
end | ||
|
||
rmpath ../common |
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.
There are numerous places in the addpath where rmpath is used.
Path management in MATLAB functions is less desirable due to global effects that can result in unexpected behaviour. I would suggest using helper functions or subfunctions to handle it.
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 have clear idea how to do it. Also postpone to other PR. We need to also find a way to handle the common functions when the scripts are moved into modules (@lgirdwood).
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.
All binaries are usually installed in ${prefix}/bin
and any common module would normally end up in ${prefix}/share/sof/
- pls see how ALSA installs tools and common files, we should adopt the same approach.
@singalsu @ShriramShastry the install prefix will come from Cmake, so can matlab take a relative path to {prefix} ?
@@ -140,9 +140,9 @@ function export_multiband_drc(prm) | |||
|
|||
tplg_write(tplg1_fn, blob8, "MULTIBAND_DRC"); | |||
tplg2_write(tplg2_fn, blob8_ipc4, "multiband_drc_config", "Exported with script example_multiband_drc.m"); | |||
blob_write(blob3_fn, blob8); | |||
sof_ucm_blob_write(blob3_fn, blob8); |
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.
Adding checks to the beginning of the export_multiband_drc
function can improve the code's robustness.
if prm.sample_rate <= 0
error('Sample rate must be positive.');
end
if isempty(prm.enable_bands) || length(prm.enable_bands) < prm.num_bands
error('Enabled bands array does not match the number of bands.');
end
Also perform similar checks for band_lower_freq
and other crucial parameters
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, also into other PR. I'm not resolving these to keep these reminders for changes visible.
@lgirdwood the current CI passes correctly |
current = https://sof-ci.01.org/sof-pr-viewer/#/build/PR9070/build13904370. These references are lost on every force push, so always save them in comments (in my dreams CIs would post that comment...) |
The sof_ucm_blob_write.m is an updated copy of blob_write that exports binary blobs with header that is suitable for ALSA UCM's cset-tlv command. The UCM requires binary files so the default binary export is changed for every component setup script to this format. The ASCII decimal numbers .txt format export remains suitable for sof-ctl tool. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
There were no bytes control binary blobs for highpass filters. This patch adds export of them and adds a 100 Hz filter option. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The replacement is sof_ucm_blob_write.m. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
We have both .bin and .blob file name suffixes in use for similar byte controls initialize files. The scripts those generate files with .bin are changed to .blob. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
To remove clutter from upper level this patch changes generated files naming from e.g. "ipc4/eq_fir_loudness.blob" to "ipc4/eq_fir/loudness.blob". It helps to find the blob files from directory that has same name as the target component. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch moves blobs for crossover component into sub-directory "crossover" to clean up clutter from ctl/ipc3 and ipc4 level. The patch also adds export of blobs for IPC4 mode that was missing. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
218ed71
to
6908a5b
Compare
I updated the Matlab/Octave zeros() function to use uint8 type as @ShriramShastry suggested. I added also the missing license text comment to the new function. There are no other changes. |
@wszypelt good to merge ? I dont think Internal CI is testing matlab atm. Thanks ! |
@@ -39,7 +39,8 @@ function export_crossover(cr) | |||
endian = "little"; | |||
tpath1 = '../../topology/topology1/m4/crossover'; | |||
tpath2 = '../../topology/topology2/include/components/crossover'; | |||
ctlpath = '../../ctl/ipc3'; | |||
ctlpath3 = '../../ctl/ipc3/crossover'; | |||
ctlpath4 = '../../ctl/ipc4/crossover'; |
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 presumably an OEM or integrator will have multiple SKUs to tune. Should there be some sort of prefix for the blobs so that the storage can be specified as SKU-specific?
And while I am at it, can those tuning scripts actually be used in a script that generates blobs for multiple platforms, just taking input parameters for each SKU?
tools/tune/eq/example_fir_eq.m
Outdated
@@ -21,7 +21,7 @@ function example_fir_eq() | |||
%% ------------------- | |||
%% Example 1: Loudness | |||
%% ------------------- | |||
fn.bin = 'eq_fir_loudness.bin'; | |||
fn.bin = 'eq_fir_loudness.blob'; |
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.
Thanks, I was a bit confused by .bin
. It's much clearer now with .blob
!
:-)))
@lgirdwood I've been away for a few days, I'll try this build again. results should be available within an hour |
First commit changes the export format to needed format with additional 8 bytes header that is required UCM's cset-tlv.
The other patches clean up the binary and ASCII text blobs exports for nicer directory structure and file names.