From d64c3903c84440357ce5c48e989f44dd981ef19b Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 21 Mar 2025 18:28:08 +0200 Subject: [PATCH 1/3] Audio: EQIIR: Tune: Fix topology blob decoding The sof-ctl blob format was changed to match the format needed by ALSA UCM2 with added TVL header. The blobs for embedding to topology are without it. The run of "process_test('eqiir', 32, 32, 48000, 1, 1);" to run full test for SOF IIR component failed to decoding of reference frequency response from blob. The fail happens because the blob decoding uses sof-ctl to generate the ABI header to help locate the EQ blob from data. As fix the sof_eq_blob_read() function is changed to add the TLV header (just zeros) to tplg1 m4 format blob read. Signed-off-by: Seppo Ingalsuo --- src/audio/eq_iir/tune/sof_eq_blob_read.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/audio/eq_iir/tune/sof_eq_blob_read.m b/src/audio/eq_iir/tune/sof_eq_blob_read.m index d95613507c91..cafead9aca9e 100644 --- a/src/audio/eq_iir/tune/sof_eq_blob_read.m +++ b/src/audio/eq_iir/tune/sof_eq_blob_read.m @@ -2,7 +2,7 @@ % SPDX-License-Identifier: BSD-3-Clause % -% Copyright (c) 2020, Intel Corporation. All rights reserved. +% Copyright (c) 2020-2025, Intel Corporation. % % Author: Seppo Ingalsuo @@ -13,6 +13,7 @@ end %% Read the file +add_tlv_header = false; switch lower(fntype) case 'bin' fh = fopen(blobfn, 'rb'); @@ -23,13 +24,21 @@ tmp = fscanf(fh, '%u,', Inf); fclose(fh); case 'm4' + % The blobs in topology are without TLV header. For simplicity + % add to beginning two 32 bit words (zeros) to be compatible + % with other blob formats. tmp = get_parse_m4(blobfn); + add_tlv_header = true; otherwise error('Illegal file type, please give fntype argument'); end -blob = uint32(tmp); +if add_tlv_header + blob = uint32([0 0 tmp']'); +else + blob = uint32(tmp); +end end From 867366433ffa4b6c2011a44145503a3cac4c1d47 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 21 Mar 2025 18:54:51 +0200 Subject: [PATCH 2/3] Audio: EQIIR: Tune: Fix EQ type detect This change fixes usage of sof_eq_blob_plot() when called with just blob file name. E.g. a FIR blob can be found from tools/ctl/ipc4/eq_fir/loudness.txt. There's no underscore after fir in the path to file. Signed-off-by: Seppo Ingalsuo --- src/audio/eq_iir/tune/sof_eq_blob_plot.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/eq_iir/tune/sof_eq_blob_plot.m b/src/audio/eq_iir/tune/sof_eq_blob_plot.m index cb096e863a6e..911acc07e7d5 100644 --- a/src/audio/eq_iir/tune/sof_eq_blob_plot.m +++ b/src/audio/eq_iir/tune/sof_eq_blob_plot.m @@ -26,13 +26,13 @@ % SPDX-License-Identifier: BSD-3-Clause % -% Copyright (c) 2016-2022, Intel Corporation. All rights reserved. +% Copyright (c) 2016-2025, Intel Corporation. % % Author: Seppo Ingalsuo %% Handle input parameters if nargin < 2 - if findstr(blobfn, '_fir_') + if findstr(blobfn, '_fir') eqtype = 'FIR'; else eqtype = 'IIR'; From 775a9acb836af23376801b56dee3c7ab23c0007e Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 21 Mar 2025 19:05:05 +0200 Subject: [PATCH 3/3] Audio: EQIIR: Tune: Replace obsolete findstr() with strfind() This fixes the warning message: "warning: findstr is obsolete; use strfind instead". Usage of the function stfind() is similar, so there are no other changes needed. Signed-off-by: Seppo Ingalsuo --- src/audio/eq_iir/tune/sof_eq_blob_plot.m | 2 +- src/audio/eq_iir/tune/sof_eq_blob_read.m | 4 ++-- src/audio/eq_iir/tune/sof_mls_freq_resp.m | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/audio/eq_iir/tune/sof_eq_blob_plot.m b/src/audio/eq_iir/tune/sof_eq_blob_plot.m index 911acc07e7d5..369c311fc96f 100644 --- a/src/audio/eq_iir/tune/sof_eq_blob_plot.m +++ b/src/audio/eq_iir/tune/sof_eq_blob_plot.m @@ -32,7 +32,7 @@ %% Handle input parameters if nargin < 2 - if findstr(blobfn, '_fir') + if strfind(blobfn, '_fir') eqtype = 'FIR'; else eqtype = 'IIR'; diff --git a/src/audio/eq_iir/tune/sof_eq_blob_read.m b/src/audio/eq_iir/tune/sof_eq_blob_read.m index cafead9aca9e..424e8c74ad93 100644 --- a/src/audio/eq_iir/tune/sof_eq_blob_read.m +++ b/src/audio/eq_iir/tune/sof_eq_blob_read.m @@ -8,7 +8,7 @@ %% Use file suffix as type if nargin < 2 - idx = findstr(blobfn, '.'); + idx = strfind(blobfn, '.'); fntype = blobfn(idx(end)+1:end); end @@ -55,7 +55,7 @@ n = 1; ln = fgets(fh); while ln ~= -1 - idx = findstr(ln, '0x'); + idx = strfind(ln, '0x'); for i = 1:length(idx) bytes(n) = hex2dec(ln(idx(i)+2:idx(i)+3)); n = n + 1; diff --git a/src/audio/eq_iir/tune/sof_mls_freq_resp.m b/src/audio/eq_iir/tune/sof_mls_freq_resp.m index 8376325c69a1..a30864d93a3b 100644 --- a/src/audio/eq_iir/tune/sof_mls_freq_resp.m +++ b/src/audio/eq_iir/tune/sof_mls_freq_resp.m @@ -22,7 +22,7 @@ % SPDX-License-Identifier: BSD-3-Clause % -% Copyright (c) 2018-2020, Intel Corporation. All rights reserved. +% Copyright (c) 2018-2025, Intel Corporation. % % Author: Seppo Ingalsuo @@ -332,12 +332,12 @@ function remote_capture(fn, cfg, t) sens =[]; desc = ''; str = fgets(fh); - idx = findstr(str, '"'); + idx = strfind(str, '"'); while length(idx) > 0 line = str(idx(1)+1:idx(2)-1); desc = sprintf('%s%s ', desc, line); str = fgets(fh); - idx = findstr(str, '"'); + idx = strfind(str, '"'); end if length(strfind(str, 'Sens')) desc = str;