From 451ab76da11f710c0164609801476e377081df87 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 19 Dec 2024 18:03:26 +0200 Subject: [PATCH 1/5] Tools: Tune: Common: Prefix all scripts names with sof This patch renames the common helper functions with sof_prefix. The other scripts are updated to use the updated names. There is no change in functionality. Signed-off-by: Seppo Ingalsuo --- src/audio/aria/tune/sof_aria_blobs.m | 16 ++++++++-------- .../crossover/tune/sof_crossover_build_blob.m | 4 ++-- src/audio/crossover/tune/sof_example_crossover.m | 8 ++++---- src/audio/dcblock/tune/sof_dcblock_build_blob.m | 2 +- src/audio/dcblock/tune/sof_example_dcblock.m | 16 ++++++++-------- src/audio/drc/tune/sof_drc_build_blob.m | 2 +- src/audio/drc/tune/sof_example_drc.m | 8 ++++---- .../tune/sof_example_multiband_drc.m | 8 ++++---- .../tune/sof_multiband_drc_build_blob.m | 2 +- src/audio/tdfb/tune/sof_bf_blob_pack.m | 2 +- src/audio/tdfb/tune/sof_bf_export.m | 8 ++++---- .../{alsactl_write.m => sof_alsactl_write.m} | 4 ++-- .../common/{blob_write.m => sof_blob_write.m} | 2 +- ...check_create_dir.m => sof_check_create_dir.m} | 2 +- tools/tune/common/{get_abi.m => sof_get_abi.m} | 2 +- .../common/{tplg2_write.m => sof_tplg2_write.m} | 2 +- .../common/{tplg_write.m => sof_tplg_write.m} | 2 +- tools/tune/common/sof_ucm_blob_write.m | 2 +- tools/tune/mfcc/setup_mfcc.m | 14 +++++++------- 19 files changed, 53 insertions(+), 53 deletions(-) rename tools/tune/common/{alsactl_write.m => sof_alsactl_write.m} (90%) rename tools/tune/common/{blob_write.m => sof_blob_write.m} (91%) rename tools/tune/common/{check_create_dir.m => sof_check_create_dir.m} (90%) rename tools/tune/common/{get_abi.m => sof_get_abi.m} (95%) rename tools/tune/common/{tplg2_write.m => sof_tplg2_write.m} (94%) rename tools/tune/common/{tplg_write.m => sof_tplg_write.m} (94%) diff --git a/src/audio/aria/tune/sof_aria_blobs.m b/src/audio/aria/tune/sof_aria_blobs.m index 212a4d83b480..a3adaa8c668e 100644 --- a/src/audio/aria/tune/sof_aria_blobs.m +++ b/src/audio/aria/tune/sof_aria_blobs.m @@ -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); @@ -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; diff --git a/src/audio/crossover/tune/sof_crossover_build_blob.m b/src/audio/crossover/tune/sof_crossover_build_blob.m index e5f48fd61a13..17f1c2c60fc5 100644 --- a/src/audio/crossover/tune/sof_crossover_build_blob.m +++ b/src/audio/crossover/tune/sof_crossover_build_blob.m @@ -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'; @@ -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)); diff --git a/src/audio/crossover/tune/sof_example_crossover.m b/src/audio/crossover/tune/sof_example_crossover.m index 297834ae03bf..6dbf9350e5e7 100644 --- a/src/audio/crossover/tune/sof_example_crossover.m +++ b/src/audio/crossover/tune/sof_example_crossover.m @@ -89,12 +89,12 @@ function export_crossover(cr) 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); diff --git a/src/audio/dcblock/tune/sof_dcblock_build_blob.m b/src/audio/dcblock/tune/sof_dcblock_build_blob.m index df4722cd8f10..41d0c1565ab3 100644 --- a/src/audio/dcblock/tune/sof_dcblock_build_blob.m +++ b/src/audio/dcblock/tune/sof_dcblock_build_blob.m @@ -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)); diff --git a/src/audio/dcblock/tune/sof_example_dcblock.m b/src/audio/dcblock/tune/sof_example_dcblock.m index 139f812ee869..cf818bf4f6bf 100644 --- a/src/audio/dcblock/tune/sof_example_dcblock.m +++ b/src/audio/dcblock/tune/sof_example_dcblock.m @@ -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 diff --git a/src/audio/drc/tune/sof_drc_build_blob.m b/src/audio/drc/tune/sof_drc_build_blob.m index 48ef29b31a65..72bd7288be16 100644 --- a/src/audio/drc/tune/sof_drc_build_blob.m +++ b/src/audio/drc/tune/sof_drc_build_blob.m @@ -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)); diff --git a/src/audio/drc/tune/sof_example_drc.m b/src/audio/drc/tune/sof_example_drc.m index 896556e74f5b..671f05273938 100644 --- a/src/audio/drc/tune/sof_example_drc.m +++ b/src/audio/drc/tune/sof_example_drc.m @@ -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); diff --git a/src/audio/multiband_drc/tune/sof_example_multiband_drc.m b/src/audio/multiband_drc/tune/sof_example_multiband_drc.m index 2626c1600310..200d0cd4f4ea 100644 --- a/src/audio/multiband_drc/tune/sof_example_multiband_drc.m +++ b/src/audio/multiband_drc/tune/sof_example_multiband_drc.m @@ -117,12 +117,12 @@ function export_multiband_drc(prm) deemp_coefs, crossover_coefs, drc_coefs, ... endian, 4); -tplg_write(tplg1_fn, blob8, "MULTIBAND_DRC"); -tplg2_write(tplg2_fn, blob8_ipc4, "multiband_drc_config", "Exported with script sof_example_multiband_drc.m"); +sof_tplg_write(tplg1_fn, blob8, "MULTIBAND_DRC"); +sof_tplg2_write(tplg2_fn, blob8_ipc4, "multiband_drc_config", "Exported with script sof_example_multiband_drc.m"); 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); sof_multiband_drc_paths(false); diff --git a/src/audio/multiband_drc/tune/sof_multiband_drc_build_blob.m b/src/audio/multiband_drc/tune/sof_multiband_drc_build_blob.m index ab3fc063a8ec..520c38e9a2e4 100644 --- a/src/audio/multiband_drc/tune/sof_multiband_drc_build_blob.m +++ b/src/audio/multiband_drc/tune/sof_multiband_drc_build_blob.m @@ -28,7 +28,7 @@ crossover_data_num = numel(crossover_coefs); drc_data_num = numel(fieldnames(drc_coefs(1))) * length(drc_coefs); data_size = 4 * (1 + 1 + 1 + 8 + emp_data_num + deemp_data_num + crossover_data_num + drc_data_num); -[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)); diff --git a/src/audio/tdfb/tune/sof_bf_blob_pack.m b/src/audio/tdfb/tune/sof_bf_blob_pack.m index 2717595aa10a..d1e91931f215 100644 --- a/src/audio/tdfb/tune/sof_bf_blob_pack.m +++ b/src/audio/tdfb/tune/sof_bf_blob_pack.m @@ -143,7 +143,7 @@ nbytes_data = nb16 * 2; %% Get ABI information -[abi_bytes, nbytes_abi] = get_abi(nbytes_data, ipc_version); +[abi_bytes, nbytes_abi] = sof_get_abi(nbytes_data, ipc_version); %% Initialize uint8 array with correct size nbytes = nbytes_abi + nbytes_data; diff --git a/src/audio/tdfb/tune/sof_bf_export.m b/src/audio/tdfb/tune/sof_bf_export.m index 874ac6f9f78b..9f330bb4653f 100644 --- a/src/audio/tdfb/tune/sof_bf_export.m +++ b/src/audio/tdfb/tune/sof_bf_export.m @@ -85,7 +85,7 @@ else fprintf(1, 'Exporting to %s\n', bf.sofctl3_fn); mkdir_check(bf.sofctl3_path); - alsactl_write(bf.sofctl3_fn, bp3); + sof_alsactl_write(bf.sofctl3_fn, bp3); end if isempty(bf.sofctl4_fn) @@ -93,7 +93,7 @@ else fprintf(1, 'Exporting to %s\n', bf.sofctl4_fn); mkdir_check(bf.sofctl4_path); - alsactl_write(bf.sofctl4_fn, bp4); + sof_alsactl_write(bf.sofctl4_fn, bp4); end if isempty(bf.export_note) @@ -107,7 +107,7 @@ 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, bf.export_howto); + sof_tplg_write(bf.tplg1_fn, bp3, 'DEF_TDFB_PRIV', export_note, bf.export_howto); end if isempty(bf.tplg2_fn) @@ -115,7 +115,7 @@ 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, bf.export_howto); + sof_tplg2_write(bf.tplg2_fn, bp4, "tdfb_config", export_note, bf.export_howto); end if ~isempty(bf.ucmbin3_fn) diff --git a/tools/tune/common/alsactl_write.m b/tools/tune/common/sof_alsactl_write.m similarity index 90% rename from tools/tune/common/alsactl_write.m rename to tools/tune/common/sof_alsactl_write.m index 92fa67c3844f..17a3db23f421 100644 --- a/tools/tune/common/alsactl_write.m +++ b/tools/tune/common/sof_alsactl_write.m @@ -1,7 +1,7 @@ -function alsactl_write(fn, blob8) +function sof_alsactl_write(fn, blob8) %% Write blob -check_create_dir(fn); +sof_check_create_dir(fn); fh = fopen(fn, 'w'); if fh < 0 fprintf(1, 'Error: Could not open file %s\n', fn); diff --git a/tools/tune/common/blob_write.m b/tools/tune/common/sof_blob_write.m similarity index 91% rename from tools/tune/common/blob_write.m rename to tools/tune/common/sof_blob_write.m index e13bea505bba..6a71618fb960 100644 --- a/tools/tune/common/blob_write.m +++ b/tools/tune/common/sof_blob_write.m @@ -1,4 +1,4 @@ -function blob_write(fn, blob8) +function sof_blob_write(fn, blob8) %% Write blob diff --git a/tools/tune/common/check_create_dir.m b/tools/tune/common/sof_check_create_dir.m similarity index 90% rename from tools/tune/common/check_create_dir.m rename to tools/tune/common/sof_check_create_dir.m index 9d9ccd7f0e8a..49f4b67c52b0 100644 --- a/tools/tune/common/check_create_dir.m +++ b/tools/tune/common/sof_check_create_dir.m @@ -1,4 +1,4 @@ -function check_create_dir(fn) +function sof_check_create_dir(fn) %% Check path of filename create directory if missing % diff --git a/tools/tune/common/get_abi.m b/tools/tune/common/sof_get_abi.m similarity index 95% rename from tools/tune/common/get_abi.m rename to tools/tune/common/sof_get_abi.m index f00b74d9f141..34ebaa3c8e92 100644 --- a/tools/tune/common/get_abi.m +++ b/tools/tune/common/sof_get_abi.m @@ -1,4 +1,4 @@ -function [bytes, nbytes] = get_abi(setsize, ipc_ver, type, param_id) +function [bytes, nbytes] = sof_get_abi(setsize, ipc_ver, type, param_id) %% Return current SOF ABI header % diff --git a/tools/tune/common/tplg2_write.m b/tools/tune/common/sof_tplg2_write.m similarity index 94% rename from tools/tune/common/tplg2_write.m rename to tools/tune/common/sof_tplg2_write.m index cff82f79f1ca..d010f0a17261 100644 --- a/tools/tune/common/tplg2_write.m +++ b/tools/tune/common/sof_tplg2_write.m @@ -1,4 +1,4 @@ -function tplg2_write(fn, blob8, component, comment, howto) +function sof_tplg2_write(fn, blob8, component, comment, howto) % SPDX-License-Identifier: BSD-3-Clause % diff --git a/tools/tune/common/tplg_write.m b/tools/tune/common/sof_tplg_write.m similarity index 94% rename from tools/tune/common/tplg_write.m rename to tools/tune/common/sof_tplg_write.m index 2834af82a919..833d82a76bfb 100644 --- a/tools/tune/common/tplg_write.m +++ b/tools/tune/common/sof_tplg_write.m @@ -1,4 +1,4 @@ -function tplg_write(fn, blob8, name, comment, howto) +function sof_tplg_write(fn, blob8, name, comment, howto) if nargin < 4 comment = 'Exported Control Bytes'; diff --git a/tools/tune/common/sof_ucm_blob_write.m b/tools/tune/common/sof_ucm_blob_write.m index 2a60b0021861..2633c6571013 100644 --- a/tools/tune/common/sof_ucm_blob_write.m +++ b/tools/tune/common/sof_ucm_blob_write.m @@ -23,7 +23,7 @@ function sof_ucm_blob_write(fn, blob8) ublob8(9:end) = blob8; %% Write blob -check_create_dir(fn); +sof_check_create_dir(fn); fh = fopen(fn, 'wb'); if fh < 0 fprintf(1, 'Error: Could not open file %s\n', fn); diff --git a/tools/tune/mfcc/setup_mfcc.m b/tools/tune/mfcc/setup_mfcc.m index 9a1d02335b93..9b27703e98bd 100644 --- a/tools/tune/mfcc/setup_mfcc.m +++ b/tools/tune/mfcc/setup_mfcc.m @@ -70,7 +70,7 @@ function export_mfcc_setup(cfg) sh16 = [0 -8]; %% Get ABI information -[abi_bytes, nbytes_abi] = get_abi(nbytes_data, cfg.ipc_ver); +[abi_bytes, nbytes_abi] = sof_get_abi(nbytes_data, cfg.ipc_ver); %% Initialize correct size uint8 array nbytes = nbytes_abi + nbytes_data; @@ -120,13 +120,13 @@ function export_mfcc_setup(cfg) %% Export switch cfg.tplg_ver case 1 - tplg_write(cfg.tplg_fn, b8, "DEF_MFCC_PRIV", ... - "Exported with script setup_mfcc.m", ... - "cd tools/tune/mfcc; octave setup_mfcc.m"); + sof_tplg_write(cfg.tplg_fn, b8, "DEF_MFCC_PRIV", ... + "Exported with script setup_mfcc.m", ... + "cd tools/tune/mfcc; octave setup_mfcc.m"); case 2 - tplg2_write(cfg.tplg_fn, b8, "mfcc_config", ... - "Exported MFCC configuration", ... - "cd tools/tune/mfcc; octave setup_mfcc.m"); + sof_tplg2_write(cfg.tplg_fn, b8, "mfcc_config", ... + "Exported MFCC configuration", ... + "cd tools/tune/mfcc; octave setup_mfcc.m"); otherwise error("Illegal cfg.tplg_ver, use 1 for topology v1 or 2 topology v2."); end From 0f0036f39927880bed9ccd216ec9d039871df58c Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 30 Dec 2024 11:39:20 +0200 Subject: [PATCH 2/5] Tools: Tune: Common: Add directory create check to tplg write helpers This patch adds to sof_tplg_write() and sof_tplg2_write() helper functions create of file directory path if such is missing. Other format blob export functions already have the same check. The duplicated checks are removed from component specific blobs create functions. Signed-off-by: Seppo Ingalsuo --- src/audio/crossover/tune/sof_example_crossover.m | 13 ------------- src/audio/tdfb/tune/sof_bf_export.m | 6 ------ tools/tune/common/sof_tplg2_write.m | 1 + tools/tune/common/sof_tplg_write.m | 1 + 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/audio/crossover/tune/sof_example_crossover.m b/src/audio/crossover/tune/sof_example_crossover.m index 6dbf9350e5e7..1d588a1a2565 100644 --- a/src/audio/crossover/tune/sof_example_crossover.m +++ b/src/audio/crossover/tune/sof_example_crossover.m @@ -85,10 +85,6 @@ function export_crossover(cr) % Generate output files -mkdir_check(tpath1); -mkdir_check(tpath2); -mkdir_check(ctlpath3); -mkdir_check(ctlpath4); 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); @@ -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 diff --git a/src/audio/tdfb/tune/sof_bf_export.m b/src/audio/tdfb/tune/sof_bf_export.m index 9f330bb4653f..a1856cc2a769 100644 --- a/src/audio/tdfb/tune/sof_bf_export.m +++ b/src/audio/tdfb/tune/sof_bf_export.m @@ -84,7 +84,6 @@ fprintf(1, 'No sof-ctl3 output file specified.\n'); else fprintf(1, 'Exporting to %s\n', bf.sofctl3_fn); - mkdir_check(bf.sofctl3_path); sof_alsactl_write(bf.sofctl3_fn, bp3); end @@ -92,7 +91,6 @@ fprintf(1, 'No sof-ctl4 output file specified.\n'); else fprintf(1, 'Exporting to %s\n', bf.sofctl4_fn); - mkdir_check(bf.sofctl4_path); sof_alsactl_write(bf.sofctl4_fn, bp4); end @@ -106,7 +104,6 @@ fprintf(1, 'No topology1 output file specified.\n'); else fprintf(1, 'Exporting to %s\n', bf.tplg1_fn); - mkdir_check(bf.tplg1_path); sof_tplg_write(bf.tplg1_fn, bp3, 'DEF_TDFB_PRIV', export_note, bf.export_howto); end @@ -114,19 +111,16 @@ fprintf(1, 'No topology2 output file specified.\n'); else fprintf(1, 'Exporting to %s\n', bf.tplg2_fn); - mkdir_check(bf.tplg2_path); sof_tplg2_write(bf.tplg2_fn, bp4, "tdfb_config", export_note, bf.export_howto); end if ~isempty(bf.ucmbin3_fn) fprintf(1, 'Exporting to %s\n', bf.ucmbin3_fn); - mkdir_check(bf.sofctl3_path); sof_ucm_blob_write(bf.ucmbin3_fn, bp3); end if ~isempty(bf.ucmbin4_fn) fprintf(1, 'Exporting to %s\n', bf.ucmbin4_fn); - mkdir_check(bf.sofctl4_path); sof_ucm_blob_write(bf.ucmbin4_fn, bp4); end diff --git a/tools/tune/common/sof_tplg2_write.m b/tools/tune/common/sof_tplg2_write.m index d010f0a17261..6322fa136cdd 100644 --- a/tools/tune/common/sof_tplg2_write.m +++ b/tools/tune/common/sof_tplg2_write.m @@ -23,6 +23,7 @@ function sof_tplg2_write(fn, blob8, component, comment, howto) end %% Write blob +sof_check_create_dir(fn); fh = fopen(fn, 'w'); if fh < 0 fprintf(1, 'Error: Could not open file %s\n', fn); diff --git a/tools/tune/common/sof_tplg_write.m b/tools/tune/common/sof_tplg_write.m index 833d82a76bfb..358782bd30a7 100644 --- a/tools/tune/common/sof_tplg_write.m +++ b/tools/tune/common/sof_tplg_write.m @@ -14,6 +14,7 @@ function sof_tplg_write(fn, blob8, name, comment, howto) blob8_new(1:n_orig) = blob8; %% Write blob +sof_check_create_dir(fn); fh = fopen(fn, 'w'); if fh < 0 fprintf(1, 'Error: Could not open file %s\n', fn); From 6620ef8192ab18480373928e48af2ad8107924f9 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 19 Dec 2024 18:06:53 +0200 Subject: [PATCH 3/5] Audio: EQIIR: Tune: Use common helper functions for exported blobs This patch updates the equalizer tools to use the common helper functions instead of the originally developed similar functions for equalizers. The old duplicated functions are deleted. Signed-off-by: Seppo Ingalsuo --- .../eq_iir/tune/sof_cmocka_data_eq_fir.m | 4 + .../eq_iir/tune/sof_cmocka_data_eq_iir.m | 4 + src/audio/eq_iir/tune/sof_eq_alsactl_write.m | 56 -------------- .../eq_iir/tune/sof_eq_fir_blob_decode.m | 2 +- src/audio/eq_iir/tune/sof_eq_fir_blob_pack.m | 2 +- src/audio/eq_iir/tune/sof_eq_get_abi.m | 73 ------------------- .../eq_iir/tune/sof_eq_iir_blob_decode.m | 2 +- src/audio/eq_iir/tune/sof_eq_iir_blob_pack.m | 2 +- src/audio/eq_iir/tune/sof_eq_tplg2_write.m | 45 ------------ src/audio/eq_iir/tune/sof_eq_tplg_write.m | 47 ------------ src/audio/eq_iir/tune/sof_example_fir_eq.m | 8 +- .../eq_iir/tune/sof_example_iir_bandsplit.m | 4 +- src/audio/eq_iir/tune/sof_example_iir_eq.m | 8 +- src/audio/eq_iir/tune/sof_example_spk_eq.m | 16 ++-- 14 files changed, 30 insertions(+), 243 deletions(-) delete mode 100644 src/audio/eq_iir/tune/sof_eq_alsactl_write.m delete mode 100644 src/audio/eq_iir/tune/sof_eq_get_abi.m delete mode 100644 src/audio/eq_iir/tune/sof_eq_tplg2_write.m delete mode 100644 src/audio/eq_iir/tune/sof_eq_tplg_write.m diff --git a/src/audio/eq_iir/tune/sof_cmocka_data_eq_fir.m b/src/audio/eq_iir/tune/sof_cmocka_data_eq_fir.m index 6fc47aee2f14..fd9e4a91f797 100644 --- a/src/audio/eq_iir/tune/sof_cmocka_data_eq_fir.m +++ b/src/audio/eq_iir/tune/sof_cmocka_data_eq_fir.m @@ -9,6 +9,8 @@ function sof_cmocka_data_eq_fir() +sof_eq_paths(true); + % Output files and paths sof_cmocka = '../../../../test/cmocka'; @@ -44,6 +46,8 @@ function sof_cmocka_data_eq_fir() plot(refi / scale) grid on; +sof_eq_paths(false); + end diff --git a/src/audio/eq_iir/tune/sof_cmocka_data_eq_iir.m b/src/audio/eq_iir/tune/sof_cmocka_data_eq_iir.m index 388a14039c48..6c9b3732f283 100644 --- a/src/audio/eq_iir/tune/sof_cmocka_data_eq_iir.m +++ b/src/audio/eq_iir/tune/sof_cmocka_data_eq_iir.m @@ -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'); @@ -45,6 +47,8 @@ function sof_cmocka_data_eq_iir() plot(refi / scale) grid on; +sof_eq_paths(false); + end diff --git a/src/audio/eq_iir/tune/sof_eq_alsactl_write.m b/src/audio/eq_iir/tune/sof_eq_alsactl_write.m deleted file mode 100644 index f6c49128dbc6..000000000000 --- a/src/audio/eq_iir/tune/sof_eq_alsactl_write.m +++ /dev/null @@ -1,56 +0,0 @@ -function sof_eq_alsactl_write(fn, blob8) - -%% -% Copyright (c) 2016, Intel Corporation -% All rights reserved. -% -% Redistribution and use in source and binary forms, with or without -% modification, are permitted provided that the following conditions are met: -% * Redistributions of source code must retain the above copyright -% notice, this list of conditions and the following disclaimer. -% * Redistributions in binary form must reproduce the above copyright -% notice, this list of conditions and the following disclaimer in the -% documentation and/or other materials provided with the distribution. -% * Neither the name of the Intel Corporation nor the -% names of its contributors may be used to endorse or promote products -% derived from this software without specific prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -% POSSIBILITY OF SUCH DAMAGE. -% -% Author: Seppo Ingalsuo -% - -%% Write blob -fh = fopen(fn, 'w'); - -%% Pad blob length to multiple of four bytes -n_orig = length(blob8); -n_new = ceil(n_orig/4); -blob8_new = zeros(1, n_new*4); -blob8_new(1:n_orig) = blob8; - -%% Convert to 32 bit -blob32 = zeros(1, n_new, 'uint32'); -k = 2.^[0 8 16 24]; -for i=1:n_new - j = (i-1)*4; - blob32(i) = blob8_new(j+1)*k(1) + blob8_new(j+2)*k(2) ... - + blob8_new(j+3)*k(3) + blob8_new(j+4)*k(4); -end -for i=1:n_new-1 - fprintf(fh, '%ld,', blob32(i)); -end -fprintf(fh, '%ld,\n', blob32(end)); -fclose(fh); - -end diff --git a/src/audio/eq_iir/tune/sof_eq_fir_blob_decode.m b/src/audio/eq_iir/tune/sof_eq_fir_blob_decode.m index 5efa140b0f08..4d0ecbe52725 100644 --- a/src/audio/eq_iir/tune/sof_eq_fir_blob_decode.m +++ b/src/audio/eq_iir/tune/sof_eq_fir_blob_decode.m @@ -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 = []; diff --git a/src/audio/eq_iir/tune/sof_eq_fir_blob_pack.m b/src/audio/eq_iir/tune/sof_eq_fir_blob_pack.m index 9fd5f0aec8a5..66bd3142fc55 100644 --- a/src/audio/eq_iir/tune/sof_eq_fir_blob_pack.m +++ b/src/audio/eq_iir/tune/sof_eq_fir_blob_pack.m @@ -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; diff --git a/src/audio/eq_iir/tune/sof_eq_get_abi.m b/src/audio/eq_iir/tune/sof_eq_get_abi.m deleted file mode 100644 index 6677af48c6ec..000000000000 --- a/src/audio/eq_iir/tune/sof_eq_get_abi.m +++ /dev/null @@ -1,73 +0,0 @@ -function [bytes, nbytes] = sof_eq_get_abi(setsize, ipc_ver, type, param_id) - -%% Return current SOF ABI header -% -% [bytes, nbytes] = sof_eq_get_abi(setsize, ipc_ver, type, param_id) -% Input -% setsize - size of the payload blob -% ipc_ver - 3 or 4, defaults to 3 -% type - for IPC3, normally 0, defaults to 0 -% param_id - for IPC4, 0 - 255, defaults to 0 -% -% Output -% bytes - returned uint8 type array -% nbytes - length of the array - -% SPDX-License-Identifier: BSD-3-Clause -% -% Copyright(c) 2018 Intel Corporation. All rights reserved. -% -% Author: Seppo Ingalsuo - -if nargin < 2 - ipc_ver = 3; -end -if nargin < 3 - type = 0; -end -if nargin < 4 - param_id = 0; -end - -abifn = 'eq_get_abi.bin'; -switch ipc_ver - case 3 - %% Use sof-ctl to write ABI header into a file - cmd = sprintf('sof-ctl -g %d -t %d -b -o %s', setsize, type, abifn); - [bytes, nbytes] = get_abi_with_sofctl(cmd, abifn); - case 4 - cmd = sprintf('sof-ctl -i 4 -g %d -p %d -b -o %s', setsize, param_id, abifn); - [bytes, nbytes] = get_abi_with_sofctl(cmd, abifn); - otherwise - fprintf(1, 'Illegal ipc_ver %d\n', ipc_ver); - error('Failed.'); -end - -end - -function [bytes, nbytes] = get_abi_with_sofctl(cmd, abifn) - -[ret, ~] = system(cmd); -if ret - error('Failed to run sof-ctl. Is it installed?'); -end -fh = fopen(abifn, 'r'); -if fh < 0 - error('Failed to read abi header produced by sof-ctl'); -end -[bytes, nbytes] = fread(fh, inf, 'uint8'); -fclose(fh); -delete(abifn); - -end - -function bytes = w32b(word) - -sh = [0 -8 -16 -24]; -bytes = uint8(zeros(1,4)); -bytes(1) = bitand(bitshift(word, sh(1)), 255); -bytes(2) = bitand(bitshift(word, sh(2)), 255); -bytes(3) = bitand(bitshift(word, sh(3)), 255); -bytes(4) = bitand(bitshift(word, sh(4)), 255); - -end diff --git a/src/audio/eq_iir/tune/sof_eq_iir_blob_decode.m b/src/audio/eq_iir/tune/sof_eq_iir_blob_decode.m index d721d9c34770..f54c88f63eb5 100644 --- a/src/audio/eq_iir/tune/sof_eq_iir_blob_decode.m +++ b/src/audio/eq_iir/tune/sof_eq_iir_blob_decode.m @@ -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 = []; diff --git a/src/audio/eq_iir/tune/sof_eq_iir_blob_pack.m b/src/audio/eq_iir/tune/sof_eq_iir_blob_pack.m index 35b9fffc0ed7..829a07e81843 100644 --- a/src/audio/eq_iir/tune/sof_eq_iir_blob_pack.m +++ b/src/audio/eq_iir/tune/sof_eq_iir_blob_pack.m @@ -43,7 +43,7 @@ nbytes_data = nbytes_head + nbytes_coef; %% 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 correct size uint8 array nbytes = nbytes_abi + nbytes_data; diff --git a/src/audio/eq_iir/tune/sof_eq_tplg2_write.m b/src/audio/eq_iir/tune/sof_eq_tplg2_write.m deleted file mode 100644 index e3f28ddfa9a2..000000000000 --- a/src/audio/eq_iir/tune/sof_eq_tplg2_write.m +++ /dev/null @@ -1,45 +0,0 @@ -function sof_eq_tplg2_write(fn, blob8, component, comment) - -% SPDX-License-Identifier: BSD-3-Clause -% -% Copyright (c) 2023, Intel Corporation. All rights reserved. -% -% Author: Seppo Ingalsuo - -if nargin < 2 - comment = 'Exported EQ'; -end - -%% Check that blob length is multiple of 32 bits -n_blob = length(blob8); -n_test = ceil(n_blob/4)*4; -if (n_blob ~= n_test) - fprintf(1, 'Error: ´Blob length %d is not multiple of 32 bits\n', ... - n_blob); - error('Failed.'); -end - -%% Write blob -fh = fopen(fn, 'w'); -nl = 8; -fprintf(fh, '# %s %s\n', comment, date()); -fprintf(fh, 'Object.Base.data.\"%s\" {\n', component); -fprintf(fh, '\tbytes \"\n'); -for i = 1:nl:n_blob - fprintf(fh, '\t\t'); - for j = 0:nl-1 - n = i + j; - if n < n_blob - fprintf(fh, '0x%02x,', blob8(n)); - end - if n == n_blob - fprintf(fh, '0x%02x"', blob8(n)); - end - end - fprintf(fh, '\n'); -end -fprintf(fh, '}\n'); -fclose(fh); -fprintf('Blob size %d was written to file %s\n', n_blob, fn); - -end diff --git a/src/audio/eq_iir/tune/sof_eq_tplg_write.m b/src/audio/eq_iir/tune/sof_eq_tplg_write.m deleted file mode 100644 index f178be8ba215..000000000000 --- a/src/audio/eq_iir/tune/sof_eq_tplg_write.m +++ /dev/null @@ -1,47 +0,0 @@ -function sof_eq_tplg_write(fn, blob8, priv, comment) - -% SPDX-License-Identifier: BSD-3-Clause -% -% Copyright (c) 2018-2020, Intel Corporation. All rights reserved. -% -% Author: Seppo Ingalsuo - -if nargin < 4 - comment = 'Exported EQ'; -end - -%% Check that blob length is multiple of 32 bits -n_blob = length(blob8); -n_test = ceil(n_blob/4)*4; -if (n_blob ~= n_test) - fprintf(1, 'Error: ´Blob length %d is not multiple of 32 bits\n', ... - n_blob); - error('Failed.'); -end - -%% Write blob -fh = fopen(fn, 'w'); -nl = 8; -fprintf(fh, '# %s %s\n', comment, date()); -fprintf(fh, 'CONTROLBYTES_PRIV(%s,\n', priv); -fprintf(fh, '` bytes "'); -for i = 1:nl:n_blob - if i > 1 - fprintf(fh, '` '); - end - for j = 0:nl-1 - n = i + j; - if n < n_blob - fprintf(fh, '0x%02x,', blob8(n)); - end - if n == n_blob - fprintf(fh, '0x%02x"', blob8(n)); - end - end - fprintf(fh, '''\n'); -end -fprintf(fh, ')\n'); -fclose(fh); -fprintf('Blob size %d was written to file %s\n', n_blob, fn); - -end diff --git a/src/audio/eq_iir/tune/sof_example_fir_eq.m b/src/audio/eq_iir/tune/sof_example_fir_eq.m index a3d5fdbeadd6..a9d377068049 100644 --- a/src/audio/eq_iir/tune/sof_example_fir_eq.m +++ b/src/audio/eq_iir/tune/sof_example_fir_eq.m @@ -231,10 +231,10 @@ function sof_eq_pack_export(bm, fn, note) sof_ucm_blob_write(fullfile(fn.cpath3, fn.bin), bp); end if ~isempty(fn.txt) - sof_eq_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); + sof_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); end if ~isempty(fn.tplg1) - sof_eq_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note); + sof_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note); end bp = sof_eq_fir_blob_pack(bm, 4); % IPC4 @@ -242,10 +242,10 @@ function sof_eq_pack_export(bm, fn, note) sof_ucm_blob_write(fullfile(fn.cpath4, fn.bin), bp); end if ~isempty(fn.txt) - sof_eq_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); + sof_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); end if ~isempty(fn.tplg2) - sof_eq_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'fir_eq', note); + sof_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'fir_eq', note); end end diff --git a/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m b/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m index 23b96646d5cf..b8561b5074ba 100644 --- a/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m +++ b/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m @@ -133,11 +133,11 @@ function sof_eq_pack_export(bm, bin_fn, ascii_fn, tplg_fn, priv, note) end if ~isempty(ascii_fn) - sof_eq_alsactl_write(ascii_fn, bp); + sof_alsactl_write(ascii_fn, bp); end if ~isempty(tplg_fn) - sof_eq_tplg_write(tplg_fn, bp, priv, note); + sof_tplg_write(tplg_fn, bp, priv, note); end end diff --git a/src/audio/eq_iir/tune/sof_example_iir_eq.m b/src/audio/eq_iir/tune/sof_example_iir_eq.m index 50d966a17c41..c2cc7a85279d 100644 --- a/src/audio/eq_iir/tune/sof_example_iir_eq.m +++ b/src/audio/eq_iir/tune/sof_example_iir_eq.m @@ -359,10 +359,10 @@ function sof_eq_pack_export(bm, fn, note) sof_ucm_blob_write(fullfile(fn.cpath3, fn.bin), bp); end if ~isempty(fn.txt) - sof_eq_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); + sof_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); end if ~isempty(fn.tplg1) - sof_eq_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note); + sof_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note); end bp = sof_eq_iir_blob_pack(bm, 4); % IPC4 @@ -370,10 +370,10 @@ function sof_eq_pack_export(bm, fn, note) sof_ucm_blob_write(fullfile(fn.cpath4, fn.bin), bp); end if ~isempty(fn.txt) - sof_eq_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); + sof_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); end if ~isempty(fn.tplg2) - sof_eq_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'iir_eq', note); + sof_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'iir_eq', note); end end diff --git a/src/audio/eq_iir/tune/sof_example_spk_eq.m b/src/audio/eq_iir/tune/sof_example_spk_eq.m index e7612796c393..ffd3c090abdd 100644 --- a/src/audio/eq_iir/tune/sof_example_spk_eq.m +++ b/src/audio/eq_iir/tune/sof_example_spk_eq.m @@ -142,13 +142,13 @@ function sof_example_spk_eq() assign_response, ... [ bq_fir ]); bp_fir = sof_eq_fir_blob_pack(bm_fir, 3); % IPC3 - sof_eq_alsactl_write(fullfile(fir.cpath3, fir.txt), bp_fir); + sof_alsactl_write(fullfile(fir.cpath3, fir.txt), bp_fir); sof_ucm_blob_write(fullfile(fir.cpath3, fir.bin), bp_fir); - sof_eq_tplg_write(fullfile(fn.tpath1, fir.tplg1), bp_fir, fir.priv, fir.comment); + sof_tplg_write(fullfile(fn.tpath1, fir.tplg1), bp_fir, fir.priv, fir.comment); bp_fir = sof_eq_fir_blob_pack(bm_fir, 4); % IPC4 - sof_eq_alsactl_write(fullfile(fir.cpath4, fir.txt), bp_fir); + sof_alsactl_write(fullfile(fir.cpath4, fir.txt), bp_fir); sof_ucm_blob_write(fullfile(fir.cpath4, fir.bin), bp_fir); - sof_eq_tplg2_write(fullfile(fir.tpath2, fir.tplg2), bp_fir, 'eq_fir', fir.comment); + sof_tplg2_write(fullfile(fir.tpath2, fir.tplg2), bp_fir, 'eq_fir', fir.comment); end %% Export IIR part @@ -159,13 +159,13 @@ function sof_example_spk_eq() assign_response, ... [ bq_iir ]); bp_iir = sof_eq_iir_blob_pack(bm_iir, 3); % IPC3 - sof_eq_alsactl_write(fullfile(iir.cpath3, iir.txt), bp_iir); + sof_alsactl_write(fullfile(iir.cpath3, iir.txt), bp_iir); sof_ucm_blob_write(fullfile(iir.cpath3, iir.bin), bp_iir); - sof_eq_tplg_write(fullfile(fn.tpath1, iir.tplg1), bp_iir, iir.priv, iir.comment); + sof_tplg_write(fullfile(fn.tpath1, iir.tplg1), bp_iir, iir.priv, iir.comment); bp_iir = sof_eq_iir_blob_pack(bm_iir, 4); % IPC4 - sof_eq_alsactl_write(fullfile(iir.cpath4, iir.txt), bp_iir); + sof_alsactl_write(fullfile(iir.cpath4, iir.txt), bp_iir); sof_ucm_blob_write(fullfile(iir.cpath4, iir.bin), bp_iir); - sof_eq_tplg2_write(fullfile(iir.tpath2, iir.tplg2), bp_iir, 'eq_iir', iir.comment); + sof_tplg2_write(fullfile(iir.tpath2, iir.tplg2), bp_iir, 'eq_iir', iir.comment); end sof_eq_paths(0); From 836ece4e6f57dd9a4bb1ffd91674e9b73430d7a9 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 19 Dec 2024 20:03:59 +0200 Subject: [PATCH 4/5] Audio: EQ: Tune: Add to blobs instructions how to generate The common functions version of topology blob export supports the howto comment. These changes add the instructions text to all equalizer blobs. Signed-off-by: Seppo Ingalsuo --- src/audio/eq_iir/tune/sof_example_fir_eq.m | 5 +++-- src/audio/eq_iir/tune/sof_example_iir_eq.m | 5 +++-- src/audio/eq_iir/tune/sof_example_spk_eq.m | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/audio/eq_iir/tune/sof_example_fir_eq.m b/src/audio/eq_iir/tune/sof_example_fir_eq.m index a9d377068049..29a69f94a219 100644 --- a/src/audio/eq_iir/tune/sof_example_fir_eq.m +++ b/src/audio/eq_iir/tune/sof_example_fir_eq.m @@ -226,6 +226,7 @@ function sof_example_fir_eq() % Pack and write file common function for all exports function sof_eq_pack_export(bm, fn, note) +howto = 'cd src/audio/eq_iir/tune; octave --no-window-system sof_example_fir_eq.m'; bp = sof_eq_fir_blob_pack(bm, 3); % IPC3 if ~isempty(fn.bin) sof_ucm_blob_write(fullfile(fn.cpath3, fn.bin), bp); @@ -234,7 +235,7 @@ function sof_eq_pack_export(bm, fn, note) sof_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); end if ~isempty(fn.tplg1) - sof_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note); + sof_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note, howto); end bp = sof_eq_fir_blob_pack(bm, 4); % IPC4 @@ -245,7 +246,7 @@ function sof_eq_pack_export(bm, fn, note) sof_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); end if ~isempty(fn.tplg2) - sof_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'fir_eq', note); + sof_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'fir_eq', note, howto); end end diff --git a/src/audio/eq_iir/tune/sof_example_iir_eq.m b/src/audio/eq_iir/tune/sof_example_iir_eq.m index c2cc7a85279d..94b015671509 100644 --- a/src/audio/eq_iir/tune/sof_example_iir_eq.m +++ b/src/audio/eq_iir/tune/sof_example_iir_eq.m @@ -354,6 +354,7 @@ function sof_example_iir_eq() % Pack and write file common function for all exports function sof_eq_pack_export(bm, fn, note) +howto = 'cd src/audio/eq_iir/tune; octave --no-window-system sof_example_iir_eq.m'; bp = sof_eq_iir_blob_pack(bm, 3); % IPC3 if ~isempty(fn.bin) sof_ucm_blob_write(fullfile(fn.cpath3, fn.bin), bp); @@ -362,7 +363,7 @@ function sof_eq_pack_export(bm, fn, note) sof_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); end if ~isempty(fn.tplg1) - sof_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note); + sof_tplg_write(fullfile(fn.tpath1, fn.tplg1), bp, fn.priv, note, howto); end bp = sof_eq_iir_blob_pack(bm, 4); % IPC4 @@ -373,7 +374,7 @@ function sof_eq_pack_export(bm, fn, note) sof_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); end if ~isempty(fn.tplg2) - sof_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'iir_eq', note); + sof_tplg2_write(fullfile(fn.tpath2, fn.tplg2), bp, 'iir_eq', note, howto); end end diff --git a/src/audio/eq_iir/tune/sof_example_spk_eq.m b/src/audio/eq_iir/tune/sof_example_spk_eq.m index ffd3c090abdd..5acc7a304172 100644 --- a/src/audio/eq_iir/tune/sof_example_spk_eq.m +++ b/src/audio/eq_iir/tune/sof_example_spk_eq.m @@ -30,6 +30,7 @@ function sof_example_spk_eq() fir.priv = 'DEF_EQFIR_PRIV'; iir.comment = 'Speaker FIR+IIR EQ created with example_spk_eq.m'; fir.comment = 'Speaker FIR+IIR EQ created with example_spk_eq.m'; +howto = 'cd src/audio/eq_iir/tune; octave --no-window-system sof_example_spk_eq.m'; %% File names fir.txt = 'spk.txt'; @@ -144,11 +145,11 @@ function sof_example_spk_eq() bp_fir = sof_eq_fir_blob_pack(bm_fir, 3); % IPC3 sof_alsactl_write(fullfile(fir.cpath3, fir.txt), bp_fir); sof_ucm_blob_write(fullfile(fir.cpath3, fir.bin), bp_fir); - sof_tplg_write(fullfile(fn.tpath1, fir.tplg1), bp_fir, fir.priv, fir.comment); + sof_tplg_write(fullfile(fn.tpath1, fir.tplg1), bp_fir, fir.priv, fir.comment, howto); bp_fir = sof_eq_fir_blob_pack(bm_fir, 4); % IPC4 sof_alsactl_write(fullfile(fir.cpath4, fir.txt), bp_fir); sof_ucm_blob_write(fullfile(fir.cpath4, fir.bin), bp_fir); - sof_tplg2_write(fullfile(fir.tpath2, fir.tplg2), bp_fir, 'eq_fir', fir.comment); + sof_tplg2_write(fullfile(fir.tpath2, fir.tplg2), bp_fir, 'eq_fir', fir.comment, howto); end %% Export IIR part @@ -161,11 +162,11 @@ function sof_example_spk_eq() bp_iir = sof_eq_iir_blob_pack(bm_iir, 3); % IPC3 sof_alsactl_write(fullfile(iir.cpath3, iir.txt), bp_iir); sof_ucm_blob_write(fullfile(iir.cpath3, iir.bin), bp_iir); - sof_tplg_write(fullfile(fn.tpath1, iir.tplg1), bp_iir, iir.priv, iir.comment); + sof_tplg_write(fullfile(fn.tpath1, iir.tplg1), bp_iir, iir.priv, iir.comment, howto); bp_iir = sof_eq_iir_blob_pack(bm_iir, 4); % IPC4 sof_alsactl_write(fullfile(iir.cpath4, iir.txt), bp_iir); sof_ucm_blob_write(fullfile(iir.cpath4, iir.bin), bp_iir); - sof_tplg2_write(fullfile(iir.tpath2, iir.tplg2), bp_iir, 'eq_iir', iir.comment); + sof_tplg2_write(fullfile(iir.tpath2, iir.tplg2), bp_iir, 'eq_iir', iir.comment, howto); end sof_eq_paths(0); From e26b072fc33a9ffd610865e2ff4be3785c010d5a Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 19 Dec 2024 20:16:16 +0200 Subject: [PATCH 5/5] Audio: Tune: Change file suffix from .blob to bin To align the suffix for binary blob files for UCM cset-tlv and sof-ctl the file naming is changed from .blob to .bin. The .bin is better associated for binary files. Signed-off-by: Seppo Ingalsuo --- src/audio/crossover/tune/sof_example_crossover.m | 4 ++-- src/audio/dcblock/tune/sof_example_dcblock.m | 4 ++-- src/audio/drc/tune/sof_example_drc.m | 4 ++-- src/audio/eq_iir/tune/sof_example_fir_eq.m | 8 ++++---- src/audio/eq_iir/tune/sof_example_iir_bandsplit.m | 2 +- src/audio/eq_iir/tune/sof_example_iir_eq.m | 14 +++++++------- src/audio/eq_iir/tune/sof_example_spk_eq.m | 4 ++-- .../multiband_drc/tune/sof_example_multiband_drc.m | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/audio/crossover/tune/sof_example_crossover.m b/src/audio/crossover/tune/sof_example_crossover.m index 1d588a1a2565..6d642122aab6 100644 --- a/src/audio/crossover/tune/sof_example_crossover.m +++ b/src/audio/crossover/tune/sof_example_crossover.m @@ -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, diff --git a/src/audio/dcblock/tune/sof_example_dcblock.m b/src/audio/dcblock/tune/sof_example_dcblock.m index cf818bf4f6bf..cf6d856656a3 100644 --- a/src/audio/dcblock/tune/sof_example_dcblock.m +++ b/src/audio/dcblock/tune/sof_example_dcblock.m @@ -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"; diff --git a/src/audio/drc/tune/sof_example_drc.m b/src/audio/drc/tune/sof_example_drc.m index 671f05273938..febf320aad99 100644 --- a/src/audio/drc/tune/sof_example_drc.m +++ b/src/audio/drc/tune/sof_example_drc.m @@ -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"; diff --git a/src/audio/eq_iir/tune/sof_example_fir_eq.m b/src/audio/eq_iir/tune/sof_example_fir_eq.m index 29a69f94a219..a1e47396ce7e 100644 --- a/src/audio/eq_iir/tune/sof_example_fir_eq.m +++ b/src/audio/eq_iir/tune/sof_example_fir_eq.m @@ -24,7 +24,7 @@ function sof_example_fir_eq() %% ------------------- %% Example 1: Loudness %% ------------------- -fn.bin = 'loudness.blob'; +fn.bin = 'loudness.bin'; fn.txt = 'loudness.txt'; fn.tplg1 = 'eq_fir_coef_loudness.m4'; fn.tplg2 = 'loudness.conf'; @@ -55,7 +55,7 @@ function sof_example_fir_eq() %% ------------------- %% Example 2: Mid boost %% ------------------- -fn.bin = 'mid.blob'; +fn.bin = 'mid.bin'; fn.txt = 'mid.txt'; fn.tplg1 = 'eq_fir_coef_mid.m4'; fn.tplg2 = 'midboost.conf'; @@ -82,7 +82,7 @@ function sof_example_fir_eq() %% ------------------- %% Example 3: Flat EQ %% ------------------- -fn.bin = 'flat.blob'; +fn.bin = 'flat.bin'; fn.txt = 'flat.txt'; fn.tplg1 = 'eq_fir_coef_flat.m4'; fn.tplg2 = 'flat.conf'; @@ -109,7 +109,7 @@ function sof_example_fir_eq() %% -------------------------- %% Example 4: Pass-through EQ %% -------------------------- -fn.bin = 'pass.blob'; +fn.bin = 'pass.bin'; fn.txt = 'pass.txt'; fn.tplg1 = 'eq_fir_coef_pass.m4'; fn.tplg2 = 'passthrough.conf'; diff --git a/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m b/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m index b8561b5074ba..37a34342c678 100644 --- a/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m +++ b/src/audio/eq_iir/tune/sof_example_iir_bandsplit.m @@ -20,7 +20,7 @@ function sof_example_iir_bandsplit() %% -------------------------------------------------- %% Example: Band-split 2ch to 4ch low and high bands %% -------------------------------------------------- -blob_fn = fullfile(cpath, 'bandsplit.blob'); +blob_fn = fullfile(cpath, 'bandsplit.bin'); alsa_fn = fullfile(cpath, 'bandsplit.txt'); tplg_fn = fullfile(tpath, 'eq_iir_bandsplit.m4'); comment = 'Bandsplit, created with example_iir_bandsplit.m'; diff --git a/src/audio/eq_iir/tune/sof_example_iir_eq.m b/src/audio/eq_iir/tune/sof_example_iir_eq.m index 94b015671509..69449164394b 100644 --- a/src/audio/eq_iir/tune/sof_example_iir_eq.m +++ b/src/audio/eq_iir/tune/sof_example_iir_eq.m @@ -24,7 +24,7 @@ function sof_example_iir_eq() %% ------------------- %% Example 1: Loudness %% ------------------- -fn.bin = 'loudness.blob'; +fn.bin = 'loudness.bin'; fn.txt = 'loudness.txt'; fn.tplg1 = 'eq_iir_coef_loudness.m4'; fn.tplg2 = 'loudness.conf'; @@ -55,7 +55,7 @@ function sof_example_iir_eq() %% ------------------------------------ %% Example 2: Bass boost %% ------------------------------------ -fn.bin = 'bassboost.blob'; +fn.bin = 'bassboost.bin'; fn.txt = 'bassboost.txt'; fn.tplg1 = 'eq_iir_coef_bassboost.m4'; fn.tplg2 = 'bassboost.conf'; @@ -82,7 +82,7 @@ function sof_example_iir_eq() %% ------------------------------------ %% Example 3: Band-pass %% ------------------------------------ -fn.bin = 'bandpass.blob'; +fn.bin = 'bandpass.bin'; fn.txt = 'bandpass.txt'; fn.tplg1 = 'eq_iir_coef_bandpass.m4'; fn.tplg2 = 'bandpass.conf'; @@ -109,7 +109,7 @@ function sof_example_iir_eq() %% ------------------- %% Example 4: Flat IIR %% ------------------- -fn.bin = 'flat.blob'; +fn.bin = 'flat.bin'; fn.txt = 'flat.txt'; fn.tplg1 = 'eq_iir_coef_flat.m4'; fn.tplg2 = 'flat.conf'; @@ -136,7 +136,7 @@ function sof_example_iir_eq() %% --------------------------- %% Example 5: Pass-through IIR %% --------------------------- -fn.bin = 'pass.blob'; +fn.bin = 'pass.bin'; fn.txt = 'pass.txt'; fn.tplg1 = 'eq_iir_coef_pass.m4'; fn.tplg2 = 'passthrough.conf'; @@ -180,7 +180,7 @@ function sof_example_iir_eq() fn.txt = sprintf('highpass_%dhz_%ddb_%dkhz.txt', fc, g, fsk); comment = sprintf('%d Hz second order high-pass, gain %d dB, created with sof_example_iir_eq.m', ... fc, g); - fn.bin = sprintf('highpass_%dhz_%ddb_%dkhz.blob', fc, g, fsk); + fn.bin = sprintf('highpass_%dhz_%ddb_%dkhz.bin', fc, g, fsk); %% Design IIR high-pass eq_hp = hp_iir_eq(fs, fc, g); @@ -207,7 +207,7 @@ function sof_example_iir_eq() %% Example 7: Merge previous desigs to single blob for use as presets %% ------------------------------------------------------------------ -fn.bin = 'bundle.blob'; +fn.bin = 'bundle.bin'; fn.txt = 'bundle.txt'; fn.tplg1 = 'eq_iir_bundle.m4'; fn.tplg2 = 'bundle.conf'; diff --git a/src/audio/eq_iir/tune/sof_example_spk_eq.m b/src/audio/eq_iir/tune/sof_example_spk_eq.m index 5acc7a304172..3a91ae04db6a 100644 --- a/src/audio/eq_iir/tune/sof_example_spk_eq.m +++ b/src/audio/eq_iir/tune/sof_example_spk_eq.m @@ -34,11 +34,11 @@ function sof_example_spk_eq() %% File names fir.txt = 'spk.txt'; -fir.bin = 'spk.blob'; +fir.bin = 'spk.bin'; fir.tplg1 = 'eq_fir_coef_spk.m4'; fir.tplg2 = 'example_speaker.conf'; iir.txt = 'spk.txt'; -iir.bin = 'spk.blob'; +iir.bin = 'spk.bin'; iir.tplg1 = 'eq_iir_coef_spk.m4'; iir.tplg2 = 'example_speaker.conf'; diff --git a/src/audio/multiband_drc/tune/sof_example_multiband_drc.m b/src/audio/multiband_drc/tune/sof_example_multiband_drc.m index 200d0cd4f4ea..9ebd3ef56b97 100644 --- a/src/audio/multiband_drc/tune/sof_example_multiband_drc.m +++ b/src/audio/multiband_drc/tune/sof_example_multiband_drc.m @@ -39,9 +39,9 @@ function export_multiband_drc(prm) tplg1_fn = sprintf("%s/topology/topology1/m4/multiband_drc_coef_%s.m4", sof_tools, prm.name); % Control Bytes File tplg2_fn = sprintf("%s/topology/topology2/include/components/multiband_drc/%s.conf", sof_tools, prm.name); % Control Bytes File % Use those files with sof-ctl to update the component's configuration -blob3_fn = sprintf("%s/ctl/ipc3/multiband_drc/%s.blob", sof_tools, prm.name); % Blob binary file +blob3_fn = sprintf("%s/ctl/ipc3/multiband_drc/%s.bin", sof_tools, prm.name); % Blob binary file alsa3_fn = sprintf("%s/ctl/ipc3/multiband_drc/%s.txt", sof_tools, prm.name); % ALSA CSV format file -blob4_fn = sprintf("%s/ctl/ipc4/multiband_drc/%s.blob", sof_tools, prm.name); % Blob binary file +blob4_fn = sprintf("%s/ctl/ipc4/multiband_drc/%s.bin", sof_tools, prm.name); % Blob binary file alsa4_fn = sprintf("%s/ctl/ipc4/multiband_drc/%s.txt", sof_tools, prm.name); % ALSA CSV format file endian = "little";