Skip to content

Commit cad9cef

Browse files
jsarhamiRoox
authored andcommitted
tplgtool2.py: Add more info info to the nodes in picture
It is sometimes hard to draw connection between the nodes in the produced picture and user visible entities, like ALSA mixers and PCMs. The old behavior is behind '-w' or '--without_nodeinfo' flags. The copier nodes are added with, copier type: AIF_IN, AIF_OUT, DAI_IN or DAI_OUT, and with copier widgets stream name. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
1 parent 02aafc0 commit cad9cef

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

tools/tplgtool2.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ def _build_leaves(node_names: "list[str]", forward_edges: "dict[str, list[str]]"
818818
def __init__(self, grouped_tplg: GroupedTplg):
819819
"Build graph from grouped topology data."
820820
self.show_core = 'auto'
821+
self.without_nodeinfo = False
821822
self._tplg = grouped_tplg
822823
self._nodes_dict = TplgGraph._build_nodes_dict(grouped_tplg.widget_list)
823824
self._nodes_names_in_graph = TplgGraph._build_nodes_names_in_graph(grouped_tplg.graph_list, self._nodes_dict)
@@ -840,13 +841,26 @@ def node_name_in_graph(self, node: Container) -> str:
840841
"""
841842
return self._node_name_in_graph_from_name(node["widget"]["name"])
842843

844+
def node_sublabel(self, widget: Container) -> str:
845+
match widget["widget"]["id"]:
846+
case 'PGA':
847+
sublabel = f'<BR ALIGN="CENTER"/><SUB>PGA: {widget["kcontrols"][0]["hdr"]["name"]}</SUB>'
848+
case 'AIF_IN' | 'AIF_OUT' | 'DAI_IN' | 'DAI_OUT':
849+
sublabel = f'<BR ALIGN="CENTER"/><SUB>{widget["widget"]["id"]}: {widget["widget"]["sname"]}</SUB>'
850+
case _:
851+
sublabel = ""
852+
return sublabel
853+
843854
def _display_node_attrs(self, name: str, widget: Container):
844855
sublabel = ""
856+
sublabel2 = ""
845857
attr = {}
858+
if not self.without_nodeinfo:
859+
sublabel = self.node_sublabel(widget)
846860
core = GroupedTplg.get_core_id(widget)
847861
if core is not None and (self.show_core == 'always' or (self.show_core == 'auto' and self._tplg.is_multicore)):
848-
sublabel += f'<BR ALIGN="CENTER"/><SUB>core:{core}</SUB>'
849-
attr['label'] = f'<{name}{sublabel}>'
862+
sublabel2 += f'<BR ALIGN="CENTER"/><SUB>core:{core}</SUB>'
863+
attr['label'] = f'<{name}{sublabel}{sublabel2}>'
850864
pipelines = self.get_pipelines_id(name)
851865
if any(map(self._tplg.is_dynamic_pipeline, pipelines)):
852866
attr['style'] = "dashed"
@@ -1172,6 +1186,7 @@ def parse_cmdline():
11721186
parser.add_argument('-F', '--format', type=str, default="png", help="output format for generated graph, check "
11731187
"https://graphviz.gitlab.io/_pages/doc/info/output.html for all supported formats")
11741188
parser.add_argument('-V', '--live_view', action="store_true", help="generate and view topology graph")
1189+
parser.add_argument('-w', '--without_nodeinfo', action="store_true", help="show only widget names, no additional node info ")
11751190
parser.add_argument('-c', '--show_core', choices=['never', 'auto', 'always'], default='auto',
11761191
help="""control the display of component core ID in topology graph, there are 3 modes:
11771192
* never: will never show core ID.
@@ -1241,6 +1256,7 @@ def main():
12411256
if 'graph' in dump_types:
12421257
graph = TplgGraph(tplg)
12431258
graph.show_core = cmd_args.show_core
1259+
graph.without_nodeinfo = cmd_args.without_nodeinfo
12441260
graph.draw(f.stem, outdir=cmd_args.directory, file_format=cmd_args.format, live_view=cmd_args.live_view)
12451261

12461262
main()

0 commit comments

Comments
 (0)