Skip to content

Add to sof-ctl capability to print ABI header and update EQ tools to utilize it - #1792

Merged
lgirdwood merged 3 commits into
thesofproject:masterfrom
singalsu:sofctl_print_abi
Sep 13, 2019
Merged

lgirdwood merged 3 commits into
thesofproject:masterfrom
singalsu:sofctl_print_abi

Conversation

@singalsu

@singalsu singalsu commented Sep 2, 2019 •

Copy link
Copy Markdown
Collaborator

The detailed description is in the commit texts. Matlab/Octave scripts can fetch the current version header with system command for:

"sof-ctl -g payloadsize -b -o fn"

to retrieve the header bytes for ext bytes control size of payloadsize into file fn. The sof-ctl tool must be installed somewhere to executable search path of computer that runs the EQ tool. And it must be kept up-to-date to get the correct ABI header.

Edit: Use of name payloadsize is better than blobsize to understand the size bytes do not include the size of the ABI header.

@singalsu

singalsu commented Sep 2, 2019

Copy link
Copy Markdown
Collaborator Author

@lgirdwood This patch implements feature issue #791 but since the changes for feature issue #1535 are not yet done I named this [RFC]. Please explain what should happen with the proposed option "-a x:y:z" present and absent so I can implement it.

@singalsu

singalsu commented Sep 2, 2019

Copy link
Copy Markdown
Collaborator Author

@keyonjie Does this command line option add work for demux component data blob generator?

Comment thread tools/ctl/ctl.c Outdated

@keyonjie keyonjie Sep 3, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @singalsu we can already dump/print ABI header, if you don't specify '-r', it will dump the abi header:
-b set/get control in binary mode(e.g. for set, use binary input file, for get, dump out in hex format)
-r no abi header for the input file, or not dumping abi header for get.

please see details from the help:

Usage:	 ./sof-ctl [-D <device>] [-c <control name>] [-s <data>]
	 ./sof-ctl [-D <device>] [-n <control id>] [-s <data>]
	 ./sof-ctl -h

Where:
 -D device name (default is hw:0)
 -c control name e.g. numid=22,name=\"EQIIR1.0 EQIIR\""
 -n control id e.g. 22
 -s set data using ASCII CSV input file
 -b set/get control in binary mode(e.g. for set, use binary input file, for get, dump out in hex format)
 -r no abi header for the input file, or not dumping abi header for get.
 -o specify the output file.
 -t specify the component specified type.

such as:

root@test-cml:/home/test# ./sof-ctl -n 15
Control size is 300000.
Retrieving configuration for device hw:0 control numid=15.
Success.
hdr: magic 0x00464f53
hdr: type 1
hdr: size 64 bytes
hdr: abi 3:10:0
4607827,1,64,50372608,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
root@test-cml:/home/test# 

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the same thing. The usage for "-p" happens at audio tuning computer, e.g. computer where topology is defined. It needs to work with without (ssh) connection to a SOF device running a suitable topology. E.g. if I wan't a header for 128 bytes long ext bytes control:

$ sof-ctl -p 128
hdr: magic 0x00464f53
hdr: type 0
hdr: size 128 bytes
hdr: abi 3:9:0
4607827,0,128,50368512,0,0,0,0

You can see from the EQ tool commit how the command is used. This is generic and this 32 bytes header (currently) is not specific for EQs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change the code more than needed so the EQ tool uses the binary file output via "-b -f file.bin". The ASCII dump with the "hdr: " infos would be more complex to parse. So I just fread() as unsigned bytes the binary header blob. But a tool could as well parse this ASCII output if preferred.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu so do you mean on host Matlab, you need to send blob with different abi header(128B comparing with 32B)? do you have the struct definition for those 128 bytes? By the way, the hdr->size is for the payload, not for the header size.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to generate different header, we need define how to generate it, if you only want to dump the first 128bytes of the tlv kcontrol, we can just dump all of it and select the first 128B?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we create hex blobs like SOF/tools/topology/eq*.m4 we need to know the generic binary ABI header that has changed every now and then when ABI is bumped for major version. That's currently the first 32 bytes. From EQ tools point-of-view the following EQ specific configuration request has been stable. This part is variable length (the longer the more challenging the acoustics is), so I needed the size parameter for "-p size" (with ABI header size excluded as you say). The tool can't have knowledge of length of this header and where the magic value, version, and size related bytes data need to be placed.

Therefore the EQ design tool that today can't parse C headers needs an utility to report the generic header part. The above example "sof-ctl -n 15" output is not of any help in this task. We don't know what control # the EQ will be assigned and we don't usually have SOF on the computer when Matlab/Octave runs. Also we should not depend on ssh connection to a device when some simple EQ shape like generic 50 Hz high-pass is designed. If we have an up-to-date sof-ctl utility in the computer where the EQ tool run it is able to give the correct blob header. If the created blob fails the ABI check the tuning engineer should update the sof-ctl executable that carries this information from SOF build.

Do you see problems with this idea?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie this option intends to help external tools to prepend the correct ABI data for tuning.

@singalsu singalsu Sep 6, 2019 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this this today this with @keyonjie. He proposed to rename new switch to "-g" for "generate header use case". It's the third offline type use case in addition to set/get data. Is this OK change @lgirdwood ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu @keyonjie yes, as long as switch is unique and you guys agree on use case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now renamed the switch to -g, the features are now all implemented.

@singalsu singalsu left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mentioned issue need to be fixed with PR update.

Comment thread tools/tune/eq/eq_fir_blob_pack.m Outdated
Comment thread tools/ctl/ctl.c Outdated
Comment thread tools/ctl/ctl.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie this option intends to help external tools to prepend the correct ABI data for tuning.

@singalsu singalsu changed the title [RFC]Add to sof-ctl capability to print ABI header and update EQ tools to utilize it Add to sof-ctl capability to print ABI header and update EQ tools to utilize it Sep 10, 2019
@singalsu

Copy link
Copy Markdown
Collaborator Author

I renamed this without [RFC] since the required features are now present.

@jajanusz

Copy link
Copy Markdown
Contributor

I renamed this without [RFC] since the required features are now present.

So we can merge, right?

@keyonjie keyonjie left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu almost good, please revisit the error handling in the main() function, as we are changing the block sequence(open out_fd firstly now), we need to change the sequence of those labels also.

Comment thread tools/ctl/ctl.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu since this is common for both binary and CSV txt, can we move this to read_done, then we can save one in the "if (ctl_data->binary) {}" case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, thanks!

Comment thread tools/ctl/ctl.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goto struct_free;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks for finding this!

Comment thread tools/ctl/ctl.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goto out_fd_close;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sequence here is changed, so we need revisit them for each item below, e.g.

	/* The control need to be defined. */
	if (!ctl_data->cname) {
		fprintf(stderr, "Error: No control was requested.\n");
		usage(argv[0]);
--		goto struct_free;
++		goto out_fd_close;
	}

	/* open input file */
	if (input_file) {
		ctl_data->in_fd = open(input_file, O_RDONLY);
		if (ctl_data->in_fd <= 0) {
			fprintf(stderr, "error: %s\n", strerror(errno));
--			goto struct_free;
++		        goto out_fd_close;
		}
	}

	/* set up ctl_elem, allocate buffers */
	ret = ctl_setup(ctl_data);
	if (ret < 0) {
		fprintf(stderr, "Error: ctl_data setup failed, ret:%d", ret);
--		goto out_fd_close;
++		goto in_fd_close;
	}

and change at the end of the function like this:

data_free:
	ret = ctl_free(ctl_data);
in_fd_close:
	if (ctl_data->in_fd)
		close(ctl_data->in_fd);
out_fd_close:
	if (ctl_data->out_fd)
		close(ctl_data->out_fd);
struct_free:
	free(ctl_data);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I got it!

This patch adds command line option "-g" to generate and with help
of options "-o <file>" to store the current ABI version header data
into file. Use "-b" to change the default CSV format to binary.

It is used by external tools to create configuration data blobs for
SOF audio processing components.

The parameter for size is the configuration data payload size with
the size of sof_abi_hdr struct excluded. It does not impact the
the length of printed header. It just places the length into the
correct location in the header.

This patch also fixes the permissions of file output. The mode
need to be provided for open() to avoid having no access to
created file and allow overwrite of existing file.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch avoids the need to main SOF ABI version information in
Matlab/Octave file eq_get_abi.m for equalizer tools. The ABI
header is fetched via new "-p" command line option for sof-ctl.

The BSD 3 clause copyright text is also updated to new short style.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@lgirdwood

Copy link
Copy Markdown
Member

CI failures unrelated to this PR, the usual suspect.

@lgirdwood
lgirdwood merged commit 92ec08d into thesofproject:master Sep 13, 2019
@singalsu
singalsu deleted the sofctl_print_abi branch January 27, 2021 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants