[RFC] tools: add python blob generator#2536
[RFC] tools: add python blob generator#2536juimonen wants to merge 1 commit intothesofproject:masterfrom
Conversation
|
just something as my python skills are not that good... based on python's "struct" module. |
lgirdwood
left a comment
There was a problem hiding this comment.
We already have a cmd line tool that prepends ABI for coefficient blobs. I want to kill the mux/demux blobs, it should be using regular ALSA enum controls.
|
@lgirdwood, so this tool is generating the whole blob for you (not just abi header). So it is not for fir/iir where you need to use complex math design tools for getting the filter coeffs, unless you are very good doing math in your head :). It is more for those components where you build the blob from multiple structs having quite simple parameters in the end. I'm not sure the mux/demux we have is usable with enums only. It is more complicated than mux/demux envisaged in asoc. Anyway, @Keyon and @mmaka1 are suggesting to move totally to blobs in processing components: Also, having this tool around would not close any options, but you could actually create the mux/demux blob (which was never possible before in public). |
|
@juimonen I want rid of any blob that is used for runtime config unless it's loading coefficients |
|
Even for coefficients we should have a header and a syntax that identifies blob type/versions/etc. There's nothing worse than a random set of bytes, it's unmanageable. |
|
@plbossart so all the blobs we are sending have sof_abi_hdr with component specific data after it. That has abi versions etc. If you are talking about for example fir/iir specific structs, they are in sof includes and removed from kernel uapi. So if you'd like to use those in user space software, you need to somehow include sof headers. Anyway I made this tool to help someone to create a blob, as it is requested from me all the time and as there is currently nothing more public than @singalsuo eq matlab scripts, and they are specific to eq. I'm not trying to promote use of blobs here, I will try to modify the demux out of blob (and var array), the intent of you and @lgirdwood is now pretty clear to me. I've been just little bit hesitant to touch the demux on fw side as it is not written by me. But it seems nothing happens unless I try to do it myself :) people are busy... |
Please feel free to touch anything you like on FW side. :-) |
|
@juimonen Would you mind add one more feature here to have another option to create a simple snd_ctl_tlv wrapper outside sof headers? This will help to make the blob directly usable with alsaucm with cset-tlv |
|
@xiulipan sure will do! |
|
@xiulipan so you want this to replace the sof header, or as extra around sof header + blob? |
|
@xiulipan and btw where is this cset-tlv? Can't seem to find it? is it some chromium specific thing? |
|
@juimonen From my test using byte blob with UCM, I found the binary accepted by SOF should be looks like So I would like to have another option to append a snd_ctl_tlv header. The |
Provide a general tool for creating binary blobs for sof process components. Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
|
|
||
| items_per_line = 8 | ||
|
|
||
| def conv_and_get_type(val): |
There was a problem hiding this comment.
| def conv_and_get_type(val): | |
| def conv_and_get_type(val): |
This comment was generated by: AutoPEP8
| except ValueError: | ||
| pass | ||
|
|
||
| parser = argparse.ArgumentParser(description='Print C struct as hex blob for alsa conf.', epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
There was a problem hiding this comment.
| parser = argparse.ArgumentParser(description='Print C struct as hex blob for alsa conf.', epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
This comment was generated by: AutoPEP8
| pass | ||
|
|
||
| parser = argparse.ArgumentParser(description='Print C struct as hex blob for alsa conf.', epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | ||
| parser.add_argument("--abiver", "-a", type=int, nargs=3, help='sof abi version major minor patch') |
There was a problem hiding this comment.
| parser.add_argument("--abiver", "-a", type=int, nargs=3, help='sof abi version major minor patch') | |
| parser = argparse.ArgumentParser(description='Print C struct as hex blob for alsa conf.', |
This comment was generated by: AutoPEP8
|
|
||
| parser = argparse.ArgumentParser(description='Print C struct as hex blob for alsa conf.', epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | ||
| parser.add_argument("--abiver", "-a", type=int, nargs=3, help='sof abi version major minor patch') | ||
| parser.add_argument('--controlid', "-c", type=int, nargs=1, help='define controlid and wrap the blob around snd_ctl_tlv header') |
There was a problem hiding this comment.
| parser.add_argument('--controlid', "-c", type=int, nargs=1, help='define controlid and wrap the blob around snd_ctl_tlv header') | |
| epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
This comment was generated by: AutoPEP8
| parser = argparse.ArgumentParser(description='Print C struct as hex blob for alsa conf.', epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | ||
| parser.add_argument("--abiver", "-a", type=int, nargs=3, help='sof abi version major minor patch') | ||
| parser.add_argument('--controlid', "-c", type=int, nargs=1, help='define controlid and wrap the blob around snd_ctl_tlv header') | ||
| parser.add_argument("--members", "-m", nargs='+', help='char values specifying the types of the struct members') |
There was a problem hiding this comment.
| parser.add_argument("--members", "-m", nargs='+', help='char values specifying the types of the struct members') | |
| parser.add_argument("--abiver", "-a", type=int, nargs=3, | |
| help='sof abi version major minor patch') | |
| parser.add_argument('--controlid', "-c", type=int, nargs=1, | |
| help='define controlid and wrap the blob around snd_ctl_tlv header') | |
| parser.add_argument("--members", "-m", nargs='+', | |
| help='char values specifying the types of the struct members') |
This comment was generated by: AutoPEP8
| if args.controlid: | ||
| topo_hdr_extra = struct.pack(topo_ctl_members, args.controlid[0], size_extra) | ||
|
|
||
| #pack header |
There was a problem hiding this comment.
| #pack header | |
| # pack header |
This comment was generated by: AutoPEP8
| #pack header | ||
| topo_hdr = struct.pack(topo_hdr_members, magic, comp_type, size, abi, reserved) | ||
|
|
||
| #pack payload |
There was a problem hiding this comment.
| #pack payload | |
| # pack payload |
This comment was generated by: AutoPEP8
| #pack payload | ||
| topo_data = struct.pack(topo_data_members, *(values_t)) | ||
|
|
||
| #full blob |
There was a problem hiding this comment.
| #full blob | |
| # full blob |
This comment was generated by: AutoPEP8
| else: | ||
| topo_full = topo_hdr + topo_data | ||
|
|
||
| #for sof topology m4 |
There was a problem hiding this comment.
| #for sof topology m4 | |
| # for sof topology m4 |
This comment was generated by: AutoPEP8
|
|
||
| print("'\n") | ||
|
|
||
| #for sof ctl tool |
There was a problem hiding this comment.
| #for sof ctl tool | |
| # for sof ctl tool |
This comment was generated by: AutoPEP8
|
@xiuli new version updated. with specifying argument -c "control_id", the tool should create snd_ctl_tlv around the blob. |
lgirdwood
left a comment
There was a problem hiding this comment.
What's the difference between this and the C version ?
|
Please resubmit with "main" as PR base branch. |
Provide a general tool for creating binary blobs for sof process
components.
Signed-off-by: Jaska Uimonen jaska.uimonen@intel.com