Skip to content

Commit

Permalink
Tools: Tune: TDFB: Add support for IPC4 and tplg2 blobs
Browse files Browse the repository at this point in the history
This patch adds generation of.conf format blobs for tplg2
with IPC4 format blob. The blob ABI header retrieving is
changed to common helper functions path those already have
the support.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu authored and kv2019i committed Oct 20, 2023
1 parent 2eeae16 commit 3f2ebb8
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 67 deletions.
4 changes: 2 additions & 2 deletions tools/tune/tdfb/bf_blob_pack.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function blob8 = bf_blob_pack(bf)
function blob8 = bf_blob_pack(bf, ipc_version)

%% Pack TDFB struct to bytes
%
Expand Down Expand Up @@ -143,7 +143,7 @@
nbytes_data = nb16 * 2;

%% Get ABI information
[abi_bytes, nbytes_abi] = eq_get_abi(nbytes_data);
[abi_bytes, nbytes_abi] = get_abi(nbytes_data, ipc_version);

%% Initialize uint8 array with correct size
nbytes = nbytes_abi + nbytes_data;
Expand Down
7 changes: 5 additions & 2 deletions tools/tune/tdfb/bf_defaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
bf.array_angle = [0 0 0]; % Array rotation angles for xyz
bf.tplg_fn = '';
bf.sofctl_fn = '';
bf.tplg_path = '../../topology/topology1/m4/tdfb';
bf.sofctl_path = '../../ctl/tdfb';
bf.tplg1_path = '../../topology/topology1/m4/tdfb';
bf.tplg2_path = '../../topology/topology2/include/components/tdfb';
bf.sofctl3_path = '../../ctl/ipc3/tdfb';
bf.sofctl4_path = '../../ctl/ipc4/tdfb';
bf.data_path = './data';
bf.endian = 'little';
bf.fn = 1;
Expand Down Expand Up @@ -56,5 +58,6 @@
bf.diffuse_fn = {''};
bf.random_fn = {''};
bf.mat_fn = {''};
bf.export_note = '';

end
58 changes: 44 additions & 14 deletions tools/tune/tdfb/bf_export.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
% bf_export(bf)
%
% Inputs
% bf.sofctl_fn ..... filename of ascii text format blob
% bf.tplg_fn ....... filename of topology m4 format blob
% bf.sofctl3_fn .... filename of ascii text format blob
% bf.sofctl4_fn .... filename of ascii text format blob
% bf.tplg1_fn ...... filename of topology m4 format blob
% bf.tplg2_fn ...... filename of topology m4 format blob
% bf ............... the design procedure output

% SPDX-License-Identifier: BSD-3-Clause
Expand All @@ -13,7 +15,8 @@

function bf = bf_export(bf)

% Use functionc from EQ tool, test utils
% Use functionc from common, test utils
addpath('../common');
addpath('../eq');
addpath('../../test/audio/test_utils');

Expand Down Expand Up @@ -73,23 +76,50 @@

%% Build blob
bf.all_filters = filters;
bp = bf_blob_pack(bf);
bp3 = bf_blob_pack(bf, 3);
bp4 = bf_blob_pack(bf, 4);

%% Export
if isempty(bf.sofctl_fn)
fprintf(1, 'No sof-ctl output file specified.\n');
if isempty(bf.sofctl3_fn)
fprintf(1, 'No sof-ctl3 output file specified.\n');
else
fprintf(1, 'Exporting to %s\n', bf.sofctl_fn);
mkdir_check(bf.sofctl_path);
eq_alsactl_write(bf.sofctl_fn, bp);
fprintf(1, 'Exporting to %s\n', bf.sofctl3_fn);
mkdir_check(bf.sofctl3_path);
alsactl_write(bf.sofctl3_fn, bp3);
end

if isempty(bf.tplg_fn)
fprintf(1, 'No topology output file specified.\n');
if isempty(bf.sofctl4_fn)
fprintf(1, 'No sof-ctl4 output file specified.\n');
else
fprintf(1, 'Exporting to %s\n', bf.tplg_fn);
mkdir_check(bf.tplg_path);
eq_tplg_write(bf.tplg_fn, bp, 'DEF_TDFB_PRIV');
fprintf(1, 'Exporting to %s\n', bf.sofctl4_fn);
mkdir_check(bf.sofctl4_path);
alsactl_write(bf.sofctl4_fn, bp4);
end

if isempty(bf.export_note)
export_note = sprintf("Exported with script example_%s_array.m", bf.array);
else
export_note = bf.export_note;
end

if isempty(bf.tplg1_fn)
fprintf(1, 'No topology1 output file specified.\n');
else
fprintf(1, 'Exporting to %s\n', bf.tplg1_fn);
mkdir_check(bf.tplg1_path);
tplg_write(bf.tplg1_fn, bp3, 'DEF_TDFB_PRIV', export_note);
end

if isempty(bf.tplg2_fn)
fprintf(1, 'No topology2 output file specified.\n');
else
fprintf(1, 'Exporting to %s\n', bf.tplg2_fn);
mkdir_check(bf.tplg2_path);
tplg2_write(bf.tplg2_fn, bp4, "tdfb_config", export_note);
end

rmpath('../../test/audio/test_utils');
rmpath('../eq');
rmpath('../common');

end
20 changes: 14 additions & 6 deletions tools/tune/tdfb/bf_filenames_helper.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,26 @@
[az_str_pm] = angles_to_str(bf.steer_az);
[el_str_pm] = angles_to_str(bf.steer_el);

if strcmp(bf.array, 'line')
el_str_show = '';
else
el_str_show = sprintf('_el%s', el_str_pm);
end

if nargin > 1
idstr = sprintf('%s_az%sel%sdeg_%dkhz', ...
id, az_str_pm, el_str_pm, round(bf.fs/1e3));
idstr = sprintf('%s_az%s%s_%dkhz', ...
id, az_str_pm, el_str_show, round(bf.fs/1e3));
else
idstr = sprintf('%s%s_%smm_az%sel%sdeg_%dkhz', ...
idstr = sprintf('%s%s_%smm_az%s%s_%dkhz', ...
bf.array, mic_n_str, mic_d_str, ...
az_str_pm, el_str_pm, round(bf.fs/1e3));
az_str_pm, el_str_show, round(bf.fs/1e3));
end

% Contain multiple (az, el) angles
bf.sofctl_fn = fullfile(bf.sofctl_path, sprintf('coef_%s.txt', idstr));
bf.tplg_fn = fullfile(bf.tplg_path, sprintf('coef_%s.m4', idstr));
bf.sofctl3_fn = fullfile(bf.sofctl3_path, sprintf('coef_%s.txt', idstr));
bf.tplg1_fn = fullfile(bf.tplg1_path, sprintf('coef_%s.m4', idstr));
bf.sofctl4_fn = fullfile(bf.sofctl4_path, sprintf('%s.txt', idstr));
bf.tplg2_fn = fullfile(bf.tplg2_path, sprintf('%s.conf', idstr));


for n = 1:length(bf.steer_az)
Expand Down
7 changes: 5 additions & 2 deletions tools/tune/tdfb/example_line_0mm36mm146mm182mm.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ function example_line_0mm36mm146mm182mm()

function line_xyz(fs, fir_length, az)

tplg_fn = sprintf('coef_line4_0mm36mm146mm182mm_%dkhz.m4', fs/1e3);
sofctl_fn = sprintf('coef_line4_0mm36mm146mm182mm_%dkhz.txt', fs/1e3);
tplg1_fn = sprintf('coef_line4_0mm36mm146mm182mm_%dkhz.m4', fs/1e3);
sofctl3_fn = sprintf('coef_line4_0mm36mm146mm182mm_%dkhz.txt', fs/1e3);
tplg2_fn = sprintf('line4_0mm36mm146mm182mm_%dkhz.conf', fs/1e3);
sofctl4_fn = sprintf('line4_0mm36mm146mm182mm_%dkhz.txt', fs/1e3);

% Get defaults
close all;
Expand Down Expand Up @@ -52,6 +54,7 @@ function line_xyz(fs, fir_length, az)
bf = bf_design(bf);

% Export files for topology and sof-ctl
bf.export_note = 'Created with script example_line_0mm36mm146mm182mm.m';
bf_export(bf);

end
13 changes: 9 additions & 4 deletions tools/tune/tdfb/example_pass_config.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ function example_pass_config()
bf.w = [1 0 0 0; 1 0 0 0]'; % Two FIR filters with first tap set to one

% Files
bf.sofctl_fn = fullfile(bf.sofctl_path, 'coef_line2_pass.txt');
bf.tplg_fn = fullfile(bf.tplg_path, 'coef_line2_pass.m4');
bf.export_note = 'Exported with script example_pass_config.m';
bf.sofctl3_fn = fullfile(bf.sofctl3_path, 'coef_line2_pass.txt');
bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line2_pass.m4');
bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line2_pass.txt');
bf.tplg2_fn = fullfile(bf.tplg2_path, 'line2_pass.conf');
bf_export(bf);

% Setup for four channels
Expand All @@ -43,8 +46,10 @@ function example_pass_config()
bf.w = [1 0 0 0; 1 0 0 0; 1 0 0 0; 1 0 0 0]'; % Four FIR filters with first tap set to one

% Files
bf.sofctl_fn = fullfile(bf.sofctl_path, 'coef_line4_pass.txt');
bf.tplg_fn = fullfile(bf.tplg_path, 'coef_line4_pass.m4');
bf.sofctl3_fn = fullfile(bf.sofctl3_path, 'coef_line4_pass.txt');
bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line4_pass.m4');
bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line4_pass.txt');
bf.tplg2_fn = fullfile(bf.tplg2_path, 'line4_pass.conf');
bf_export(bf);

end
Loading

0 comments on commit 3f2ebb8

Please sign in to comment.