Skip to content
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: sof-ctl: Use same blob format as UCM2/cset-tlv #9760

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion scripts/sof-rebuild-processing-comp-blobs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ if [ -z "${SOF_WORKSPACE}" ]; then
fi

if ! command -v octave &> /dev/null; then
echo "Error: this scrip needs GNU Octave, see https://octave.org/"
echo "Error: this script needs GNU Octave, see https://octave.org/"
exit 1
fi

"$SOF_WORKSPACE"/sof/scripts/build-tools.sh -c

if ! command -v sof-ctl &> /dev/null; then
echo "Error: The sof-ctl utility is not found from path for executables. It is needed"
echo " to retrieve SOF ABI header It can be added with e.g. symlink to user's binaries:"
echo " ln -s $SOF_WORKSPACE/sof/tools/build_tools/ctl/sof-ctl $HOME/bin/sof-ctl"
exit 1
fi

cmp --quiet "$(which sof-ctl)" "$SOF_WORKSPACE"/sof/tools/build_tools/ctl/sof-ctl || {
echo "Error: The sof-ctl in user's path is not the same as sof-ctl build from tools."
exit 1
}

OCTAVE="octave --quiet --no-window-system"
cd "$SOF_WORKSPACE"/sof/src/audio/aria/tune; $OCTAVE sof_aria_blobs.m
cd "$SOF_WORKSPACE"/sof/src/audio/crossover/tune; $OCTAVE sof_example_crossover.m
Expand Down
16 changes: 8 additions & 8 deletions src/audio/aria/tune/sof_aria_blobs.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ function sof_aria_blobs()

blob8 = sof_aria_build_blob(0);
tplg2_fn = sprintf("%s/passthrough.conf", sof_tplg_aria);
check_create_dir(tplg2_fn);
tplg2_write(tplg2_fn, blob8, "aria_config", ...
"Exported with script sof_aria_blobs.m" , ...
"cd tools/tune/aria; octave sof_aria_blobs.m");
sof_check_create_dir(tplg2_fn);
sof_tplg2_write(tplg2_fn, blob8, "aria_config", ...
"Exported with script sof_aria_blobs.m" , ...
"cd tools/tune/aria; octave sof_aria_blobs.m");

for param = 1:3
blob8 = sof_aria_build_blob(param);
tplg2_fn = sprintf("%s/param_%d.conf", sof_tplg_aria, param);
tplg2_write(tplg2_fn, blob8, "aria_config", ...
"Exported with script sof_aria_blobs.m" , ...
"cd tools/tune/aria; octave sof_aria_blobs.m");
sof_tplg2_write(tplg2_fn, blob8, "aria_config", ...
"Exported with script sof_aria_blobs.m" , ...
"cd tools/tune/aria; octave sof_aria_blobs.m");
end

sof_aria_paths(false);
Expand All @@ -53,7 +53,7 @@ function sof_aria_paths(enable)
data_length = length(param_values);
data_size = 4 * data_length;
ipc_ver = 4;
[abi_bytes, abi_size] = get_abi(data_size, ipc_ver, blob_type, blob_param_id);
[abi_bytes, abi_size] = sof_get_abi(data_size, ipc_ver, blob_type, blob_param_id);
blob_size = data_size + abi_size;
blob8 = uint8(zeros(1, blob_size));
blob8(1:abi_size) = abi_bytes;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/crossover/tune/sof_crossover_build_blob.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function blob8 = crossover_build_blob(blob_struct, endian, ipc_ver)
function blob8 = sof_crossover_build_blob(blob_struct, endian, ipc_ver)

if nargin < 2
endian = 'little';
Expand All @@ -21,7 +21,7 @@
%% Build Blob
% refer to sof/src/include/user/crossover.h for the config struct.
data_size = 4 * (2 + 4 + 4 + numel(blob_struct.all_coef));
[abi_bytes, abi_size] = get_abi(data_size, ipc_ver);
[abi_bytes, abi_size] = sof_get_abi(data_size, ipc_ver);

blob_size = data_size + abi_size;
blob8 = uint8(zeros(1, blob_size));
Expand Down
25 changes: 6 additions & 19 deletions src/audio/crossover/tune/sof_example_crossover.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ function export_crossover(cr)
tplg1_fn = sprintf('%s/coef_%s_%s_%s.m4', tpath1, str_way, str_freq, str_pid); % Control Bytes File
tplg2_fn = sprintf('%s/coef_%s_%s_%s.conf', tpath2, str_way, str_freq, str_pid);
% Use those files with sof-ctl to update the component's configuration
blob3_fn = sprintf('%s/coef_%dway.blob', ctlpath3, cr.num_sinks); % Blob binary file
blob3_fn = sprintf('%s/coef_%dway.bin', ctlpath3, cr.num_sinks); % Blob binary file
alsa3_fn = sprintf('%s/coef_%dway.txt', ctlpath3, cr.num_sinks); % ALSA CSV format file
blob4_fn = sprintf('%s/coef_%dway.blob', ctlpath4, cr.num_sinks); % Blob binary file
blob4_fn = sprintf('%s/coef_%dway.bin', ctlpath4, cr.num_sinks); % Blob binary file
alsa4_fn = sprintf('%s/coef_%dway.txt', ctlpath4, cr.num_sinks); % ALSA CSV format file

% This array is an example on how to assign a buffer from pipeline 1 to output 0,
Expand Down Expand Up @@ -85,16 +85,12 @@ function export_crossover(cr)

% Generate output files

mkdir_check(tpath1);
mkdir_check(tpath2);
mkdir_check(ctlpath3);
mkdir_check(ctlpath4);
tplg_write(tplg1_fn, blob8, "CROSSOVER");
tplg2_write(tplg2_fn, blob8_ipc4, "crossover_config", 'Exported Control Bytes');
sof_tplg_write(tplg1_fn, blob8, "CROSSOVER");
sof_tplg2_write(tplg2_fn, blob8_ipc4, "crossover_config", 'Exported Control Bytes');
sof_ucm_blob_write(blob3_fn, blob8);
sof_ucm_blob_write(blob4_fn, blob8_ipc4);
alsactl_write(alsa3_fn, blob8);
alsactl_write(alsa4_fn, blob8_ipc4);
sof_alsactl_write(alsa3_fn, blob8);
sof_alsactl_write(alsa4_fn, blob8_ipc4);

% Plot Magnitude and Phase Response of each sink
sof_crossover_plot_freq(crossover.lp, crossover.hp, cr.fs, cr.num_sinks);
Expand Down Expand Up @@ -125,12 +121,3 @@ function export_crossover(cr)
end

end

% Check if directory exists, avoid warning print for existing
function mkdir_check(new_dir)

if ~exist(new_dir, 'dir')
mkdir(new_dir);
end

end
2 changes: 1 addition & 1 deletion src/audio/dcblock/tune/sof_dcblock_build_blob.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

%% Build Blob
data_size = (num_of_coeffs)*4;
[abi_bytes, abi_size] = get_abi(data_size, ipc_ver);
[abi_bytes, abi_size] = sof_get_abi(data_size, ipc_ver);

blob_size = data_size + abi_size;
blob8 = uint8(zeros(1, blob_size));
Expand Down
20 changes: 10 additions & 10 deletions src/audio/dcblock/tune/sof_example_dcblock.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function dcblock_blob_calculate(prm)
tplg1_fn = sprintf("%s/topology1/m4/dcblock_coef_%s.m4", sof_tplg, prm.id); % Control Bytes File
tplg2_fn = sprintf("%s/topology2/include/components/dcblock/%s.conf", sof_tplg, prm.id);
% Use those files with sof-ctl to update the component's configuration
blob3_fn = sprintf("%s/ipc3/dcblock/coef_%s.blob", sof_ctl, prm.id); % Blob binary file
blob3_fn = sprintf("%s/ipc3/dcblock/coef_%s.bin", sof_ctl, prm.id); % Blob binary file
alsa3_fn = sprintf("%s/ipc3/dcblock/coef_%s.txt", sof_ctl, prm.id); % ALSA CSV format file
blob4_fn = sprintf("%s/ipc4/dcblock/coef_%s.blob", sof_ctl, prm.id); % Blob binary file
blob4_fn = sprintf("%s/ipc4/dcblock/coef_%s.bin", sof_ctl, prm.id); % Blob binary file
alsa4_fn = sprintf("%s/ipc4/dcblock/coef_%s.txt", sof_ctl, prm.id); % ALSA CSV format file

endian = "little";
Expand All @@ -58,17 +58,17 @@ function dcblock_blob_calculate(prm)
blob8_ipc4 = sof_dcblock_build_blob(R_coeffs, endian, 4);

% Generate output files
tplg_write(tplg1_fn, blob8, "DCBLOCK", ...
"Exported with script sof_example_dcblock.m", ...
"cd tools/tune/dcblock; octave sof_example_dcblock.m");
sof_tplg_write(tplg1_fn, blob8, "DCBLOCK", ...
"Exported with script sof_example_dcblock.m", ...
"cd tools/tune/dcblock; octave sof_example_dcblock.m");
sof_ucm_blob_write(blob3_fn, blob8);
alsactl_write(alsa3_fn, blob8);
sof_alsactl_write(alsa3_fn, blob8);

tplg2_write(tplg2_fn, blob8_ipc4, "dcblock_config", ...
"Exported with script sof_example_dcblock.m" , ...
"cd tools/tune/dcblock; octave sof_example_dcblock.m");
sof_tplg2_write(tplg2_fn, blob8_ipc4, "dcblock_config", ...
"Exported with script sof_example_dcblock.m" , ...
"cd tools/tune/dcblock; octave sof_example_dcblock.m");
sof_ucm_blob_write(blob4_fn, blob8_ipc4);
alsactl_write(alsa4_fn, blob8_ipc4);
sof_alsactl_write(alsa4_fn, blob8_ipc4);

% Plot Filter's Transfer Function and Step Response
% As an example, plot the graphs of the first coefficient
Expand Down
2 changes: 1 addition & 1 deletion src/audio/drc/tune/sof_drc_build_blob.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
% refer to sof/src/include/user/drc.h for the config struct.
num_coefs = length(fieldnames(blob_struct));
data_size = 4 * (1 + 4 + num_coefs);
[abi_bytes, abi_size] = get_abi(data_size, ipc_ver);
[abi_bytes, abi_size] = sof_get_abi(data_size, ipc_ver);

blob_size = data_size + abi_size;
blob8 = uint8(zeros(1, blob_size));
Expand Down
12 changes: 6 additions & 6 deletions src/audio/drc/tune/sof_example_drc.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function drc_coefs_and_config_export(params, id)
tplg1_fn = sprintf("%s/topology1/m4/drc_coef_%s.m4", sof_tplg, id); % Control Bytes File
tplg2_fn = sprintf("%s/topology2/include/components/drc/%s.conf", sof_tplg, id); % Control Bytes File
% Use those files with sof-ctl to update the component's configuration
blob3_fn = sprintf("%s/ipc3/drc_coef_%s.blob", sof_ctl, id); % Blob binary file
blob3_fn = sprintf("%s/ipc3/drc_coef_%s.bin", sof_ctl, id); % Blob binary file
alsa3_fn = sprintf("%s/ipc3/drc_coef_%s.txt", sof_ctl, id); % ALSA CSV format file
blob4_fn = sprintf("%s/ipc4/drc/%s.blob", sof_ctl, id); % Blob binary file
blob4_fn = sprintf("%s/ipc4/drc/%s.bin", sof_ctl, id); % Blob binary file
alsa4_fn = sprintf("%s/ipc4/drc/%s.txt", sof_ctl, id); % ALSA CSV format file

endian = "little";
Expand All @@ -82,12 +82,12 @@ function drc_coefs_and_config_export(params, id)
my_name = mfilename();
drc_note = sprintf("Exported with script %s.m", my_name);
drc_howto = sprintf("cd tools/tune/drc; octave --no-window-system %s.m", my_name);
tplg_write(tplg1_fn, blob8, "DRC", drc_note, drc_howto);
tplg2_write(tplg2_fn, blob8_ipc4, "drc_config", drc_note, drc_howto);
sof_tplg_write(tplg1_fn, blob8, "DRC", drc_note, drc_howto);
sof_tplg2_write(tplg2_fn, blob8_ipc4, "drc_config", drc_note, drc_howto);
sof_ucm_blob_write(blob3_fn, blob8);
alsactl_write(alsa3_fn, blob8);
sof_alsactl_write(alsa3_fn, blob8);
sof_ucm_blob_write(blob4_fn, blob8_ipc4);
alsactl_write(alsa4_fn, blob8_ipc4);
sof_alsactl_write(alsa4_fn, blob8_ipc4);

% Plot x-y response in dB
sof_drc_plot_db_curve(coefs);
Expand Down
4 changes: 4 additions & 0 deletions src/audio/eq_iir/tune/sof_cmocka_data_eq_fir.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

function sof_cmocka_data_eq_fir()

sof_eq_paths(true);

% Output files and paths
sof_cmocka = '../../../../test/cmocka';

Expand Down Expand Up @@ -44,6 +46,8 @@ function sof_cmocka_data_eq_fir()
plot(refi / scale)
grid on;

sof_eq_paths(false);

end


Expand Down
4 changes: 4 additions & 0 deletions src/audio/eq_iir/tune/sof_cmocka_data_eq_iir.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

function sof_cmocka_data_eq_iir()

sof_eq_paths(true);

% Output files and paths
sof_cmocka = '../../../../test/cmocka';
chirp_fn = fullfile(sof_cmocka, 'include/cmocka_chirp_2ch.h');
Expand Down Expand Up @@ -45,6 +47,8 @@ function sof_cmocka_data_eq_iir()
plot(refi / scale)
grid on;

sof_eq_paths(false);

end


Expand Down
56 changes: 0 additions & 56 deletions src/audio/eq_iir/tune/sof_eq_alsactl_write.m

This file was deleted.

2 changes: 1 addition & 1 deletion src/audio/eq_iir/tune/sof_eq_fir_blob_decode.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end

%% Get ABI information
[abi_bytes, nbytes_abi] = sof_eq_get_abi(0);
[abi_bytes, nbytes_abi] = sof_get_abi(0);

%% Defaults
eq.b = [];
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_iir/tune/sof_eq_fir_blob_pack.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
nbytes_data = nb16 * 2;

%% Get ABI information
[abi_bytes, nbytes_abi] = sof_eq_get_abi(nbytes_data, ipc_ver);
[abi_bytes, nbytes_abi] = sof_get_abi(nbytes_data, ipc_ver);

%% Initialize uint8 array with correct size
nbytes = nbytes_abi + nbytes_data;
Expand Down
73 changes: 0 additions & 73 deletions src/audio/eq_iir/tune/sof_eq_get_abi.m

This file was deleted.

2 changes: 1 addition & 1 deletion src/audio/eq_iir/tune/sof_eq_iir_blob_decode.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
end

%% Get ABI information
[abi_bytes, nbytes_abi] = get_abi(0);
[abi_bytes, nbytes_abi] = sof_get_abi(0);

%% Defaults
eq.b = [];
Expand Down
Loading
Loading