Skip to content

Commit b47f352

Browse files
singalsugolowanow
authored andcommitted
Tools: Move has_wname_prefix to tplgtool2.py
This patch moves the helper function has_wname_prefix() from topo_vol_kcontrols.py to tplgtool2.py. It will be used by a new script to find bytes controls. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 94bbe9d commit b47f352

2 files changed

Lines changed: 26 additions & 27 deletions

File tree

tools/topo_vol_kcontrols.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# from .tplg files, create another script.
1111

1212
import sys
13-
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType, SofVendorToken
13+
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType, SofVendorToken, has_wname_prefix
1414

1515
TPLG_FORMAT = TplgBinaryFormat()
1616

@@ -58,31 +58,5 @@ def print_volume_kcontrols(gain_block):
5858
print(wname_prefix + vkc.hdr.name)
5959

6060

61-
# This could probably be moved to tplgtool2.py?
62-
def has_wname_prefix(widget):
63-
"""Is the kcontrol name prefixed with the widget name? ("PGAxx" or "Dmicxx")
64-
Check SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME"""
65-
66-
wname_elems = [
67-
prv.elems
68-
for prv in widget.priv
69-
if prv.elems[0].token
70-
== SofVendorToken.SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME.name
71-
]
72-
73-
if len(wname_elems) == 0: # typically: topo v1
74-
no_wname_prefix = 0
75-
elif len(wname_elems) == 1: # typically: topo v2
76-
assert len(wname_elems[0]) == 1
77-
no_wname_prefix = wname_elems[0][0].value
78-
else:
79-
assert False, f"Unexpected len of wname_elems={wname_elems}"
80-
81-
assert no_wname_prefix in (0, 1)
82-
83-
# Double-negation: "no_wname false" => prefix
84-
return not no_wname_prefix
85-
86-
8761
if __name__ == "__main__":
8862
main()

tools/tplgtool2.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,31 @@ def find_interweaved_pipelines(self) -> "list[tuple[Container, list[Container]]]
12431243
pipelines.append((comps[0], [self._nodes_dict[name] for name in endpoints if name.startswith('PCM')]))
12441244
return pipelines
12451245

1246+
def has_wname_prefix(widget):
1247+
"""Is the kcontrol name prefixed with the widget name? ("PGAxx" or "Dmicxx")
1248+
Check SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME"""
1249+
1250+
wname_elems = [
1251+
prv.elems
1252+
for prv in widget.priv
1253+
if prv.elems[0].token
1254+
== SofVendorToken.SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME.name
1255+
]
1256+
1257+
if len(wname_elems) == 0: # typically: topo v1
1258+
no_wname_prefix = 0
1259+
elif len(wname_elems) == 1: # typically: topo v2
1260+
assert len(wname_elems[0]) == 1
1261+
no_wname_prefix = wname_elems[0][0].value
1262+
else:
1263+
assert False, f"Unexpected len of wname_elems={wname_elems}"
1264+
1265+
assert no_wname_prefix in (0, 1)
1266+
1267+
# Double-negation: "no_wname false" => prefix
1268+
return not no_wname_prefix
1269+
1270+
12461271
if __name__ == "__main__":
12471272
from pathlib import Path
12481273

0 commit comments

Comments
 (0)