-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tplgtool2: print all supported formats of PCM and adjust alignment #1105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the examples, very useful. Not sure we need that many though. Instead, we miss at least one before/after example.
tools/tplgtool2.py
Outdated
fmt = fmt_list[cap_index][0] # only show first format | ||
fmts = '' | ||
for fmt in fmt_list[cap_index]: | ||
fmts = fmts + fmt + ' ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmts = ' '.join(fmt_list[cap_index])
tools/tplgtool2.py
Outdated
f"rate_min={rate_min};rate_max={rate_max};ch_min={ch_min};ch_max={ch_max};") | ||
print(f"pcm {pcm_id:>2}: {name:<22};type={pcm_type:<8};" | ||
f"rate_min={rate_min:>6};rate_max={rate_max:>6};ch_min={ch_min};ch_max={ch_max};" | ||
f"fmt={fmts}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"fmt={fmts}") | |
f"fmts={fmts}") |
tools/tplgtool2.py
Outdated
rate_min = cap["rate_min"] | ||
rate_max = cap["rate_max"] | ||
ch_min = cap["channels_min"] | ||
ch_max = cap["channels_max"] | ||
print(f"pcm={name};id={pcm_id};type={pcm_type};fmt={fmt};" | ||
f"rate_min={rate_min};rate_max={rate_max};ch_min={ch_min};ch_max={ch_max};") | ||
print(f"pcm {pcm_id:>2}: {name:<22};type={pcm_type:<8};" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output looks much better. However the previous code was producing consistent output easy to parse because everything was formated key=value;
. this PR breaks that.
I think we can have both the parsable output AND the indentation; try something like this:
name_semi = pcm["pcm_name"] + ";"
.
.
.
print(f"pcm={pcm_id:>2}; name={name_semi:<21} ...")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's find the longest filed of each column, and use it for formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marc-hb @aiChaoSONG Thanks for your review and suggestions! All comments addressed in v2. Can you please give a check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marc-hb Chao confirmed our test cases use output of ./tools/sof-tplgreader.py to check PCM streams, not output of this tplgtool2.py So we can make the output more human friendly. Now I still follow key=value;
in v2 patches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chao confirmed our test cases use output of ./tools/sof-tplgreader.py to check PCM streams, not output of this tplgtool2.py
We don't know who parses the output of this script. It has existed for a very long time.
Now I still follow key=value ;
Thanks! The new whitespace could still break someone but that should be very quick and easy to fix.
aa9e339
to
50656c1
Compare
Make print_pcm_info() show all supported formats of a PCM, not only the first format. And show the formats after other attributes, thus other attributes may have better alignment. Signed-off-by: Mengdong Lin <[email protected]>
print_pcm_info() will show pcm ID before its name. Also adjust alignment: - id: 2 characters, right alignment. - name: left alignment to the longest PCM name. - type (playback/capture/duplex): 8 characters, left alignment. - rate: 6 characters, right alignment, for highest rate '192000'. Strings longer than the alignment won't be cut. Signed-off-by: Mengdong Lin <[email protected]>
No one is parsing this output yet, let merge and do improvement incrementally. |
No one can tell that. |
Make print_pcm_info() show all supported formats of a PCM. The alignment and order of PCM attributes are also adjusted.
Update history:
v2: use fmts = ' '.join(fmt_list[cap_index]) to get all supported formats
follow previous "key=value;" format for PCM ID and name.
make PCM name right-aligned to the longest PCM name
Example: sof-mtl-max98357a-rt5682-ssp2-ssp0-2ch-pdm1.tplg
Before change:
After change: