Skip to content

Commit 4114012

Browse files
committed
Add new topo_list_dapms.py demo
Add simple demo showing how to get started with tplgtool2.py Signed-off-by: Marc Herbert <marc.herbert@intel.com>
1 parent b3502d1 commit 4114012

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tools/topo_list_dapms.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Simple demo showing how to get started with the tplgtool2.py parser.
5+
6+
Tip: try these commands interactively in "ipython3"; with TAB completion.
7+
"""
8+
9+
import sys
10+
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType
11+
12+
TPLG_FORMAT = TplgBinaryFormat()
13+
14+
15+
def main():
16+
"Main function"
17+
18+
parsed_tplg = TPLG_FORMAT.parse_file(sys.argv[1])
19+
20+
# pylint: disable=invalid-name
21+
DAPMs = [
22+
item for item in parsed_tplg if item.header.type == TplgType.DAPM_WIDGET.name
23+
]
24+
25+
for dapm in DAPMs:
26+
27+
schedulers = [b for b in dapm.blocks if b.widget.id == DapmType.SCHEDULER.name]
28+
29+
assert len(schedulers) <= 1
30+
31+
sched = schedulers[0].widget.name if len(schedulers) == 1 else "none"
32+
33+
print(f"\n --- SCHEDULER = {sched} ------- \n")
34+
35+
for block in dapm.blocks:
36+
if block.widget.id == DapmType.SCHEDULER.name:
37+
continue
38+
print(f"{block.widget.id}: {block.widget.name}")
39+
40+
41+
if __name__ == "__main__":
42+
main()

0 commit comments

Comments
 (0)