Commit Graph

28 Commits

Author SHA1 Message Date
Yong Zhi 79f914e8ab sof-ctl: minor update for help text
The option -s is also needed for binary input file.

Signed-off-by: Yong Zhi <yong.zhi@intel.com>
2023-12-07 13:29:40 +02:00
Peter Ujfalusi 3bc70b6251 sof-ctl: Add initial support for handling blobs for IPC4
For IPC4 we are re-using the sof_abi_hdr to encapsulate the blob from/to
user space with minor deviation from IPC3:
- ABI magic is different
- the type is used as param_id in IPC4 (it carries the same functionality)

The IPC type can be specified with -i and defaults to 3 (IPC3).

-p is added as a new option for param_id, but -t and -p will do the same
thing.

After reading a blob, print a message for unexpected ABI magic number, but
do not block the execution.

To generate a header for 100 bytes payload:

For IPC3:
sof-ctl -g 100 -t 2
sof-ctl -i 3 -g 100 -t 2

For IPC4:
sof-ctl -i 4 -g 100 -p 2

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2023-02-10 10:53:55 +00:00
Li-Yu Yu 5cfc37040b sof-ctl: Fix -Wformat,-Wsometimes-uninitialized
* Use %z specifier for size types to avoid format
  specifier warnings on arm32
* in ctl_dump(), size_t n may be used uninitialized
  if ctl_data->out_fd > 0 and !ctl_data->binary.

Signed-off-by: Li-Yu Yu <aaronyu@google.com>
2022-04-29 12:42:55 +01:00
Lionel Koenig b0b8bc7a34 sof-ctl: Allow setting arbitrary size for controls
sof-ctl assumed the binary control were of size of a
multiple of unsigned integer.
This caused the control byte array to be truncated when the
size of the control was 6 bytes.
This change allow setting any size of control in binary form.
Using CSV will always end up with a number of unsigned integer size.

I tested this change using the Google RTC Audio processing with control
of size:
  - 6 bytes,
  - 2 bytes
  - and 4 bytes.

Signed-off-by: Lionel Koenig <lionelk@google.com>
2022-03-22 13:46:49 +00:00
Paul Olaru e3ac593f86 tools: ctl: Fix various errors
Most of the errors are unused variables, plus an unused label. Those are
benign.

One of the errors was the following:

/work/repos/sof/tools/ctl/ctl.c: In function ‘ctl_set_get’:
/work/repos/sof/tools/ctl/ctl.c:497:1: error: control reaches end of
non-void function [-Werror=return-type]
  497 | }
      | ^

This error had caused an undefined-behaviour-driven bug internally (an
error being displayed with a return code of 0, when it shouldn't have
been possible to display that message if the return code was 0). At line
614 of the old code, the message "Error: could not Set control, ret:0"
was displayed.

The errors only show up when you add -Wall -Werror to the compile
options of ctl, which I will do in the next commit.

Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
2021-11-10 08:34:53 +02:00
Daniel Baluta 1203a46633 tools: ctl: Fix getopt() stop condition
getopt() returns an int, which in our implementation is assigned to a
char type var.

On some platforms char is unsigned thus making getopt() return value
always > 0.

Use int instead of char here to fix the stop condition for parameter
parsing.

This makes sof-ctl work on ARM platforms.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2021-07-22 17:06:52 +01:00
Dharageswari R 49d432dded sof-ctl: Add support for read-only, write-only and read-write kcontrol
This patch checks for the access type of kcontrol and returns error
only when the access type is not read or write.

Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
2020-08-27 11:19:28 +01:00
Seppo Ingalsuo d013fbc6d7 Tools: Add current sof_abi_hdr struct print capability to sof-ctl
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>
2019-09-13 10:25:58 +01:00
Dragos Tarcatu 90873c5d35 sof-ctl: fix segfault when no ctl name given
If no control name is passed to sof-ctl, it currently pops an error,
dumps the usage and then segfaults:

root@gr-mrb:~# sof-ctl -D hw:0
Error: No control was requested.
Usage:   ...
Segmentation fault (core dumped)

Fix all that by jumping to the right label.

Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
2019-09-02 21:27:37 +02:00
Keyon Jie 720cdcda67 sof-ctl: fix ABI dumping doesn't work issue
For dumping to output file without '-r', we need to dump ABI header,
here fix it.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-17 12:00:54 +02:00
Keyon Jie d2e5c6a78a sof-ctl: split and move ctl_setup out of main()
Move ctl_elem pointers and buffer initialization out of main(), and
replace calling alloca APIs with malloc ones to make they are shareable
between different functions.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie d5f359c0f4 sof-ctl: add '-t' to support specifying the component type
Firmware may use different component specified type in abi header, to
support more than one kcontrols for the same component, here add '-t' to
support specifying this component specified type in the abi header.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie a29032420b sof-ctl: add labels to handle failure paths
Add labels in main() to handle kinds of failure cases, with the code
cleanup together.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie e86ba1dcbf sof-ctl: add '-o' support to dump ctl data to a specified file
Here add '-o' to support output control data to the specified file, in
binary format.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie cc717a539e sof-ctl: add separated function for control set/get
Add a separated function ctl_set_get() for tlv set/get, and call it from
main().

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 5de89ad8c1 sof-ctl: add functions for buffer allocate and free
Split buffer allocating and freeing part from main(), add separated
functions and call them from main().

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie f3bc979112 sof-ctl: add macros for buffer offsets
Add macros for offsets in the ctl_data buffer, and switch to use them.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie fe28746bba sof-ctl: add '-r' to support raw data mode
Using '-r' with '-s' means no abi header for the input file, and asks
for not dumping abi header when using '-r' without '-s'.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 0c2f1a6cdc sof-ctl: add header_init() for abi header initialization
This will be needed for raw data(without abi header) input file.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 89b4df8c6c sof-ctl: add support to dump kcontrol in binary mode
When specified with '-b', let's dump out kcontrol value in 16bit hex
format.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 32b1021080 sof-ctl: add '-b' mode to support binary format input file
Adding support to binary input file, using '-b' to indicate that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 98794eef79 sof-ctl: add function to get file size
This will be used on large input file scenario, we need to allocate
buffer according to the input file size.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 985f49a786 sof-ctl: create functions for data dumping
We might dump kcontrol values in different format, create data_dump()
and csv_data_dump() for that.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie 49c0f91a75 sof-ctl: allocate ctl_data struct and switch to use it
Allocate ctl_data struct, initialize it and switch to use it to replace
the local variables.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie efcda78053 sof-ctl: add ctl_data struct for params sharing between functions
Add a globle struct which will store params and be shared among
functions in the later commits, to make the code more readable.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Keyon Jie e5096aeb85 sof-ctl: fix a print out format
Adding '\n' after "hdr: type" output to make the header dumping more
easier to be read.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2019-07-03 15:29:59 +01:00
Liam Girdwood 1782676acf tools: ctl: dump header information from CSV and DSP data
Dump the ABI header from source CSV or DSP data. This will make it
obvious if there are any ABI differences.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2019-06-05 10:04:39 +01:00
Liam Girdwood 2bb9ebe20d ctl: rename sof-eqctl to sof-ctl
This tool is generic and can be used with any binary kcontrol to
send data to/from components at runtime.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2019-06-05 10:04:39 +01:00