forked from thesofproject/sof-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple demo showing how to get started with tplgtool2.py Signed-off-by: Marc Herbert <[email protected]>
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |