Skip to content

Commit

Permalink
Tools: Tune: Add tplg2 support to dcblock setup tool
Browse files Browse the repository at this point in the history
This patch adds generate of blob for tplg2 and ipc4 in
formats .conf, text, and binary formats.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu authored and kv2019i committed Sep 14, 2023
1 parent 3eada7c commit dec770d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
8 changes: 6 additions & 2 deletions tools/tune/dcblock/dcblock_build_blob.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function blob8 = dcblock_build_blob(R_coeffs, endian)
function blob8 = dcblock_build_blob(R_coeffs, endian, ipc_ver)

%% Settings
bits_R = 32; %Q2.30
Expand All @@ -8,6 +8,10 @@
endian = 'little'
endif

if nargin < 3
ipc_ver = 3;
endif

%% Shift values for little/big endian
switch lower(endian)
case 'little'
Expand All @@ -24,7 +28,7 @@

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

blob_size = data_size + abi_size;
blob8 = uint8(zeros(1, blob_size));
Expand Down
17 changes: 0 additions & 17 deletions tools/tune/dcblock/dcblock_get_abi.m

This file was deleted.

22 changes: 15 additions & 7 deletions tools/tune/dcblock/example_dcblock.m
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
function example_dcblock();

% Set the parameters here
tplg_fn = "../../topology/topology1/m4/dcblock_coef_default.m4" % Control Bytes File
tplg1_fn = "../../topology/topology1/m4/dcblock_coef_default.m4" % Control Bytes File
tplg2_fn = "../../topology/topology2/include/components/dcblock/default.conf"
% Use those files with sof-ctl to update the component's configuration
blob_fn = "../../ctl/dcblock_coef.blob" % Blob binary file
alsa_fn = "../../ctl/dcblock_coef.txt" % ALSA CSV format file
blob3_fn = "../../ctl/ipc3/dcblock_coef.blob" % Blob binary file
alsa3_fn = "../../ctl/ipc3/dcblock_coef.txt" % ALSA CSV format file
blob4_fn = "../../ctl/ipc4/dcblock_coef.blob" % Blob binary file
alsa4_fn = "../../ctl/ipc4/dcblock_coef.txt" % ALSA CSV format file

endian = "little";
R_coeffs = [0.98, 0.98, 0.98, 0.98, 0.98, 0.98, 0.98, 0.98];

addpath ./../common

blob8 = dcblock_build_blob(R_coeffs, endian);
blob8_ipc4 = dcblock_build_blob(R_coeffs, endian, 4);

% Generate output files
addpath ./../common
tplg_write(tplg1_fn, blob8, "DCBLOCK");
blob_write(blob3_fn, blob8);
alsactl_write(alsa3_fn, blob8);

tplg_write(tplg_fn, blob8, "DCBLOCK");
blob_write(blob_fn, blob8);
alsactl_write(alsa_fn, blob8);
tplg2_write(tplg2_fn, blob8_ipc4, "dcblock_config", "Exported with script example_dcblock.m");
blob_write(blob4_fn, blob8_ipc4);
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

0 comments on commit dec770d

Please sign in to comment.