Commit graph

18 commits

Author SHA1 Message Date
Paul Elder
ae7419869a utils: ipc: mojo: Error if ControlInfoMap/List doesn't prefix libcamera
The mojo parser is fine if there are types that are used in array/map
members that it does not know about. These are usually caught by the C++
compiler, because the generated code refers to unknown types. This
feature is necessary for us for supporting FrameBuffer::Plane as an
array/map member, since as long as the type has an IPADataSerializer and
the struct defined in C++, the generated code will run fine
(FrameBuffer::Plane is not defined anywhere in mojom but is used as an
array member in IPABuffer).

The types that are defined in controls.h (or any header included in
ipa_interface.h) will all be compiled by the C++ compiler fine, since
the generated files all include controls.h. The types that are there
that are not ControlInfoMap or ControlList (like ControlValue) will
still fail at the linker stage. For example:

struct A {
	array<ControlValue> a;
};

will compile fine, but will fail to link, since
IPADataSerializer<ControlValue> doesn't exist. This behavior, although
not the best, is acceptable.

The issue is that if ControlInfoMap or ControlList are used as array/map
members without the libcamera prefix, the compiler will not complain, as
the types are valid, and the linker will also not complain, as
IPADataSerializer<ControlList> and IPADataSerializer<ControlInfoMap>
both exist. However, the code generator will not recognize them as
types that require a ControlSerializer (since mojo doesn't recognize
them, so they are different from the ones that it does recognize with
the libcamera namespace), and so the ControlSerializer will not be
passed to the serializer in the generated code. This is the cause of the
FATAL breakage:

 FATAL IPADataSerializer ipa_data_serializer.cpp:437 ControlSerializer
 not provided for serialization of ControlInfoMap

Since ControlInfoMap and ControlList are the only types that will run
into this issue, we solve this by simply detecting if they are used
without the prefix, and produce an error at that point in the code
generator. As the code generator stage no longer has information on the
source code file and line, we output the struct name in which the error
was found (ninja will output the file name).

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-06-01 18:52:05 +09:00
Paul Elder
3370b6d0a0 utils: ipc: extract-docs: Extract the SPDX header
Take the SPDX header from the mojom file. Error out if the mojom file
has no SPDX header.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-05-31 13:20:19 +09:00
Paul Elder
bd06b648fb utils: ipc: Add script to extract doxygen docs from mojom files
Add a script to extract doxygen documentation comments from mojom files.
It matches based on ^\/\*\*$ for start of block and ^ \*\/$ for end of
block, and simply copies the comments to the output file along with a
header and the libcamera namespace.

Also add it to the meson file so it is usable by other meson files.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-27 17:07:04 +09:00
Paul Elder
139d885574 utils: ipc: Update mojo
Update mojo from the Chromium repository. The commit from which this was
taken is:

9c138d992bfc1fb8f4f7bcf58d00bf19c219e4e2 "Updating trunk VERSION from
4523.0 to 4524.0"

The update-mojo.sh script was used for this update.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=34
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-26 13:03:27 +09:00
Umang Jain
ff9276cc62 ipa: Move core IPA interface documentation to a .cpp file
Moving the core.mojom documentation to its corresponding .cpp file
(core_ipa_interface.cpp). This will allow Doxygen to generate the
documentation for IPABuffer, IPASettings and IPAStream structures.
Since the .mojom files are placed in include/ directory, the .cpp file
will live in $sourcedir/src/libcamera/ipa/ - which can also contain
documentation for other mojom generated IPA interfaces in subsequent
commit.

Also hide the constructors in generated IPA interface from doxygen,
via  #ifndef __DOXYGEN__. These constructors provide no major value in
documenting them, instead will spew out doxygen warnings during the
build.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-24 14:13:01 +03:00
Paul Elder
078fbff8f4 utils: ipc: Use the proper namespace for mojom structs
Structs defined in mojom previously used the namespace of the mojom file
that was being used as the source. This is obviously not the correct
namespace for structs that are defined in core.mojom. Fix the jinja
function for getting the element type including namespace, and use it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-27 17:34:58 +09:00
Kieran Bingham
70238ceca5 utils: ipc: proxy: Track IPA with a state machine
Asynchronous tasks can only be submitted while the IPA is running.

Further more, the shutdown sequence can not be tracked with a simple
running flag. We can also be in the state 'Stopping' where we have not
yet completed all events, but we must not commence anything new.

Refactor the running_ boolean into a stateful enum to track this.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-29 12:18:02 +01:00
Laurent Pinchart
b50c12bf18 utils: ipc: proxy: Process pending messages
Events may be queued to the pipeline handler between the pipeline
handler entering the ::stop() function, and before the call to stop the
IPA has completed.

Handle these events by dispatching all pending messages at the proxy
after the IPA has fully stopped.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-24 09:24:06 +00:00
Laurent Pinchart
f041482add utils: ipc: proxy: Assert asynchronous calls execute in the running state
Signals and calls from the IPA should not occur after the IPA has been
put into the stopped state.

Add assertions to catch and prevent any messages being processed after
this.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-24 09:24:06 +00:00
Paul Elder
0612bef601 utils: ipc: Make first output parameter direct return if int32
To make it more convenient for synchronous IPA calls to return a status,
convert the first output into a direct return if it is an int32.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Naushir Patuck <naush@raspberrypi.com>
2021-03-09 11:49:13 +09:00
Paul Elder
51e5d67f8e utils: ipc: Support custom parameters to init()
Add support to the mojom-based code generator for custom parameters to
init(). Remove the parameter type and count validation as well.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-09 11:49:02 +09:00
Laurent Pinchart
5745a10911 utils: ipc: templates: Drop unused variable
The has_input variable is unused, drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-04 10:24:33 +02:00
Paul Elder
e6722b86ee meson: ipa, proxy: Generate headers and proxy with mojo
Run mojo from meson to generate the header, serializer, and proxy files
for every pipeline's mojom data definition file.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-16 19:21:39 +09:00
Paul Elder
6072ca395a utils: ipc: add parser script
On some systems, python2 might still be the default python. Enforce
python3 by wrapping the mojo parser script in a python3 script. This
also has the benefit of not modifying mojo.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-16 19:21:11 +09:00
Paul Elder
2ad8768fd6 utils: ipc: add generator script
We want to avoid changing our copy of mojo to make updates easier. Some
parameters in the mojo generator script needs to be changed though; add
a wrapper script that sets these parameters.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-16 19:21:07 +09:00
Paul Elder
7832e19a59 utils: ipc: add templates for code generation for IPC mechanism
Add templates to mojo to generate code for the IPC mechanism. These
templates generate:
- module header
- module serializer
- IPA proxy cpp, header, and worker

Given an input data definition mojom file for a pipeline.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:21:00 +09:00
Paul Elder
f4420ef8bf README, meson: Add dependency on ply and jinja2 for IPA interface generation
Specify in the readme and meson file that we depend on python3-ply and
python3-jinja2 for generating the IPA interface.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-11-11 19:23:16 +09:00
Paul Elder
82ba73535c utils: ipc: import mojo
Import mojo from the Chromium repository, so that we can use it for
generating code for the IPC mechanism. The commit from which this was
taken is:
a079161ec8c6907b883f9cb84fc8c4e7896cb1d0 "Add PPAPI constructs for
sending focus object to PdfAccessibilityTree"

This tree has been pruned to remove directories that didn't have any
necessary code:
- mojo/* except for mojo/public
  - mojo core, docs, and misc files
- mojo/public/* except for mojo/public/{tools,LICENSE}
  - language bindings for IPC, tests, and some mojo internals
- mojo/public/tools/{fuzzers,chrome_ipc}
- mojo/public/tools/bindings/generators
  - code generation for other languages

No files were modified.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-11-11 19:22:37 +09:00