diff --git a/tools/tune/dcblock/dcblock_build_blob.m b/tools/tune/dcblock/dcblock_build_blob.m index 43fa67f5c915..5abbfa80c53b 100644 --- a/tools/tune/dcblock/dcblock_build_blob.m +++ b/tools/tune/dcblock/dcblock_build_blob.m @@ -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 @@ -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' @@ -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)); diff --git a/tools/tune/dcblock/dcblock_get_abi.m b/tools/tune/dcblock/dcblock_get_abi.m deleted file mode 100644 index b65988cb99ae..000000000000 --- a/tools/tune/dcblock/dcblock_get_abi.m +++ /dev/null @@ -1,17 +0,0 @@ -function [bytes, nbytes] = dcblock_get_abi(setsize) - -%% Use sof-ctl to write ABI header into a file -abifn = 'dcblock_get_abi.bin'; -cmd = sprintf('sof-ctl -g %d -b -o %s', setsize, abifn); -system(cmd); - -%% Read file and delete it -fh = fopen(abifn, 'r'); -if fh < 0 - error("Failed to get ABI header. Is sof-ctl installed?"); -end -[bytes, nbytes] = fread(fh, inf, 'uint8'); -fclose(fh); -delete(abifn); - -end diff --git a/tools/tune/dcblock/example_dcblock.m b/tools/tune/dcblock/example_dcblock.m index 74490e5ab159..ff3d79e75a1b 100644 --- a/tools/tune/dcblock/example_dcblock.m +++ b/tools/tune/dcblock/example_dcblock.m @@ -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