Skip to content

Commit d1368ea

Browse files
committed
Tools: Topology: Add topology sof-hda-benchmark-micsel16/24/32
This allows to test the component basics in testbench. The micsel16/24/32 are stereo in/out topologies. The micsel_multich32 topology is stereo in the DAI copier side and 1-8ch in the host copier side. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent c77d92f commit d1368ea

14 files changed

Lines changed: 976 additions & 0 deletions
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
% Export configuration blobs for Selector
2+
3+
% SPDX-License-Identifier: BSD-3-Clause
4+
%
5+
% Copyright (c) 2025, Intel Corporation.
6+
7+
function sof_selector_blobs()
8+
9+
% Common definitions
10+
str_config = "selector_config";
11+
str_exported = "Exported with script sof_selector_blobs.m";
12+
str_howto = "cd tools/tune/selector; octave sof_selector_blobs.m"
13+
sof_tools = '../../../../tools';
14+
sof_tplg = fullfile(sof_tools, 'topology');
15+
sof_tplg_selector = fullfile(sof_tplg, 'topology2/include/components/micsel');
16+
17+
sof_selector_paths(true);
18+
19+
% Matrix for 1:1 pass-through
20+
sel.rsvd0 = 0;
21+
sel.rsvd1 = 0;
22+
sel.coeffs = diag(ones(8, 1));
23+
blob8 = sof_selector_build_blob(sel);
24+
tplg2_fn = sprintf("%s/passthrough.conf", sof_tplg_selector);
25+
sof_check_create_dir(tplg2_fn);
26+
sof_tplg2_write(tplg2_fn, blob8, str_config, str_exported, str_howto);
27+
28+
% 5.1 to stereo downmix, see ITU-R BS.775-4, Annex 4
29+
fl = 1;
30+
fr = 2;
31+
fc = 3;
32+
lfe = 4;
33+
sl = 5;
34+
sr = 6;
35+
m = zeros(8,8);
36+
m(1, fl) = 1.0000; m(1, fr) = 0.0000; m(1, fc) = 0.7071; m(1, sl) = 0.7071; m(1, sr) = 0.0000;
37+
m(2, fl) = 0.0000; m(2, fr) = 1.0000; m(2, fc) = 0.7071; m(2, sl) = 0.0000; m(2, sr) = 0.7071;
38+
m(1, lfe) = 10^(+4/20); % +10 dB, attenuate by -6 dB to left
39+
m(2, lfe) = 10^(+4/20); % +10 dB, attenuate by -6 dB to right
40+
max_sum_coef = max(sum(m, 2)); % Sum all coeffs for output channels, find max
41+
scale = 1 / max_sum_coef;
42+
sel.coeffs = scale .* m';
43+
sel
44+
blob8 = sof_selector_build_blob(sel);
45+
tplg2_fn = sprintf("%s/downmix_51_to_stereo.conf", sof_tplg_selector);
46+
sof_check_create_dir(tplg2_fn);
47+
sof_tplg2_write(tplg2_fn, blob8, str_config, str_exported, str_howto);
48+
49+
% 5.1 to mono downmix, see ITU-R BS.775-4, Annex 4
50+
fl = 1;
51+
fr = 2;
52+
fc = 3;
53+
lfe = 4;
54+
sl = 5;
55+
sr = 6;
56+
m = zeros(8,8);
57+
m(1, fl) = 0.7071; m(1, fr) = 0.7071; m(1, fc) = 1.0000; m(1, sl) = 0.5000; m(1, sr) = 0.5000;
58+
m(1, lfe) = 10^(+10/20);
59+
max_sum_coef = max(sum(m, 2)); % Sum all coeffs for output channels, find max
60+
scale = 1 / max_sum_coef;
61+
sel.coeffs = scale .* m';
62+
sel
63+
blob8 = sof_selector_build_blob(sel);
64+
tplg2_fn = sprintf("%s/downmix_51_to_mono.conf", sof_tplg_selector);
65+
sof_check_create_dir(tplg2_fn);
66+
sof_tplg2_write(tplg2_fn, blob8, str_config, str_exported, str_howto);
67+
68+
sof_selector_paths(false);
69+
end
70+
71+
function sof_selector_paths(enable)
72+
73+
common = '../../../../tools/tune/common';
74+
if enable
75+
addpath(common);
76+
else
77+
rmpath(common);
78+
end
79+
end
80+
81+
function blob8 = sof_selector_build_blob(sel)
82+
83+
s = size(sel.coeffs);
84+
blob_type = 0;
85+
blob_param_id = 0; % IPC4_SELECTOR_COEFFS_CONFIG_ID
86+
data_length = s(1) * s(2) + 2;
87+
data_size = 2 * data_length; % int16_t matrix
88+
coeffs_vec = reshape(sel.coeffs, 1, []); % convert to row vector
89+
coeffs_q10 = int16(round(coeffs_vec .* 1024)); % Q6.10
90+
ipc_ver = 4;
91+
[abi_bytes, abi_size] = sof_get_abi(data_size, ipc_ver, blob_type, blob_param_id);
92+
blob_size = data_size + abi_size;
93+
blob8 = uint8(zeros(1, blob_size));
94+
blob8(1:abi_size) = abi_bytes;
95+
j = abi_size + 1;
96+
97+
% header
98+
blob8(j:j+1) = int16_to_byte(int16(sel.rsvd0));
99+
j = j + 2;
100+
blob8(j:j+1) = int16_to_byte(int16(sel.rsvd1));
101+
j = j + 2;
102+
103+
% coeffs matrix
104+
for i = 1:(s(1) * s(2))
105+
blob8(j:j+1) = int16_to_byte(coeffs_q10(i));
106+
j = j + 2;
107+
end
108+
end
109+
110+
function bytes = int16_to_byte(word)
111+
sh = [0 -8];
112+
bytes = uint8(zeros(1,2));
113+
bytes(1) = bitand(bitshift(word, sh(1)), 255);
114+
bytes(2) = bitand(bitshift(word, sh(2)), 255);
115+
end

tools/topology/topology2/cavs-benchmark-hda.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<include/components/asrc.conf>
66
<include/components/tdfb.conf>
77
<include/components/template_comp.conf>
8+
<include/components/micsel.conf>
89

910
Define {
1011
ANALOG_PLAYBACK_PCM 'Analog Playback'
@@ -39,12 +40,16 @@ Object.PCM.pcm [
3940
name $ANALOG_PLAYBACK_PCM
4041
formats 'S32_LE,S24_LE,S16_LE'
4142
rates "8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,176400,192000"
43+
channels_min 1
44+
channels_max 8
4245
}
4346
Object.PCM.pcm_caps.2 {
4447
direction "capture"
4548
name $ANALOG_CAPTURE_PCM
4649
formats 'S32_LE,S24_LE,S16_LE'
4750
rates "8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,176400,192000"
51+
channels_min 1
52+
channels_max 8
4853
}
4954
direction duplex
5055
}
@@ -527,6 +532,26 @@ IncludeByKey.BENCH_CONFIG {
527532
<include/bench/igo_nr_s32.conf>
528533
}
529534

535+
#
536+
# Micsel component
537+
#
538+
539+
"^micsel16$" {
540+
<include/bench/micsel_s16.conf>
541+
}
542+
543+
"^micsel24$" {
544+
<include/bench/micsel_s24.conf>
545+
}
546+
547+
"^micsel32$" {
548+
<include/bench/micsel_s32.conf>
549+
}
550+
551+
"^micsel_multich32$" {
552+
<include/bench/micsel_multich_s32.conf>
553+
}
554+
530555
#
531556
# RTNR component
532557
#

tools/topology/topology2/development/tplg-targets-bench.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(components
1616
"eqfir"
1717
"gain"
1818
"igo_nr"
19+
"micsel"
1920
"rtnr"
2021
"src"
2122
"src_lite"
@@ -32,6 +33,7 @@ set(component_parameters
3233
"BENCH_EQFIR_PARAMS=loudness"
3334
"BENCH_GAIN_PARAMS=default"
3435
"BENCH_IGO_NR_PARAMS=default"
36+
"BENCH_MICSEL_PARAMS=default"
3537
"BENCH_RTNR_PARAMS=default"
3638
"BENCH_SRC_PARAMS=default"
3739
"BENCH_SRC_LITE_PARAMS=default"
@@ -47,6 +49,14 @@ set(component_parameters_s24
4749
"BENCH_ARIA_PARAMS=param_2"
4850
)
4951

52+
set(components_s32
53+
"micsel_multich"
54+
)
55+
56+
set(component_parameters_s32
57+
"BENCH_MICSEL_PARAMS=downmix_51_to_stereo"
58+
)
59+
5060
# Add components with all sample formats
5161
foreach(sf ${sampleformats})
5262
foreach(comp bench_param IN ZIP_LISTS components component_parameters)
@@ -63,3 +73,11 @@ foreach(comp bench_param IN ZIP_LISTS components_s24 component_parameters_s24)
6373
#message(STATUS "Item=" ${item})
6474
list(APPEND TPLGS "${item}")
6575
endforeach()
76+
77+
set (sf "32")
78+
foreach(comp bench_param IN ZIP_LISTS components_s32 component_parameters_s32)
79+
#message(STATUS "Bench_param=" ${bench_param})
80+
set(item "sof-hda-generic\;sof-hda-benchmark-${comp}${sf}\;HDA_CONFIG=benchmark,BENCH_CONFIG=${comp}${sf},${bench_param}")
81+
#message(STATUS "Item=" ${item})
82+
list(APPEND TPLGS "${item}")
83+
endforeach()

0 commit comments

Comments
 (0)