Skip to content

Commit

Permalink
Add new topo_list_dapms.py demo
Browse files Browse the repository at this point in the history
Add simple demo showing how to get started with tplgtool2.py

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed May 29, 2024
1 parent b3502d1 commit 4114012
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tools/topo_list_dapms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3

"""
Simple demo showing how to get started with the tplgtool2.py parser.
Tip: try these commands interactively in "ipython3"; with TAB completion.
"""

import sys
from tplgtool2 import TplgBinaryFormat, TplgType, DapmType

TPLG_FORMAT = TplgBinaryFormat()


def main():
"Main function"

parsed_tplg = TPLG_FORMAT.parse_file(sys.argv[1])

# pylint: disable=invalid-name
DAPMs = [
item for item in parsed_tplg if item.header.type == TplgType.DAPM_WIDGET.name
]

for dapm in DAPMs:

schedulers = [b for b in dapm.blocks if b.widget.id == DapmType.SCHEDULER.name]

assert len(schedulers) <= 1

sched = schedulers[0].widget.name if len(schedulers) == 1 else "none"

print(f"\n --- SCHEDULER = {sched} ------- \n")

for block in dapm.blocks:
if block.widget.id == DapmType.SCHEDULER.name:
continue
print(f"{block.widget.id}: {block.widget.name}")


if __name__ == "__main__":
main()

0 comments on commit 4114012

Please sign in to comment.