Commit graph

675 commits

Author SHA1 Message Date
Laurent Pinchart
93be96431a libcamera: log: De-duplicate _log() functions and LogMessage constructor
The _log() functions, as well as the LogMessage constructor, exist in
two versions, one that takes a log category, and one that doesn't. The
latter uses the default log category. This can be simplified by passing
a LogCategory pointer to _log(), which can then be null for the default
category, and moving the retrieval of the default log category from the
LogMessage constructor to the _log() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-15 00:04:54 +03:00
Kieran Bingham
296a903fe3 libcamera: ipa_proxy: Scope ProxyState to IPAProxy
The ProxyState is only used by the IPAProxy, so it should remain inside
that scope.  This helps clarify the usage, and improves the
documentation by bringing the (future) ProxyState documentation into the
class.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-13 20:52:19 +01:00
Laurent Pinchart
9b2544d3df libcamera: bound_method: Fix type of pack for void methods
The BoundMethodPack used by the void BoundMethodArgs variant incorrectly
specified the template argument as void * instead of void. This causes
no functional problem, but results in space for an unused void * return
value being reserved. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-12 22:16:52 +03:00
Hirokazu Honda
cbb580d5af libcamera: pipeline_handler: Make queueRequest() void function
PipelineHandler::queueRequest() is asynchronously invoked in
Camera::queueRequest(). Therefore the return value of
PipelineHandler::queueRequest() is useless. This changes the
function to a void function.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-04-03 04:05:57 +03:00
Laurent Pinchart
0e39510c05 libcamera: thread: Remove the unused setEventDispatcher() function
Custom event dispatchers for threads was an API meant to provide a way
to integrate libcamera in the application's event loop. This isn't used
anymore, as libcamera now creates internal threads. Drop the unused
Thread::setEventDispatcher() function, and update the documentation
accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-29 23:49:33 +03:00
Kieran Bingham
1dfb8d45dc libcamera: request: Add a toString()
Provide a toString helper to assist in printing Request state
for debug and logging contexts.

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
Kieran Bingham
d874b3e341 libcamera: request: Provide a sequence number
Provide a sequence number on Requests which are added by the pipeline
handler.

Each pipeline handler keeps a requestSequence per CameraData and
increments everytime a request is queued on that camera.

The sequence number is associated with the Request and can be utilised
for assisting with debugging, and printing the queueing sequence of in
flight requests.

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
Kieran Bingham
dcc024760a libcamera: buffer: Break friendship with Request
The FrameBuffer class is only friends with Request so that the request
can be associated with the buffers.

FrameBuffer already has a helper to setRequest(), so let's use that
directly instead.

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
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
Naushir Patuck
787852a240 ipa: raspberrypi: Rationalise parameters to ipa::configure()
Rename ConfigInput to IPAConfig to be more consistent with the naming,
and remove ConfigInput::op, as it is never used.

Replace ConfigOutput with a ControlList type, as that is the only return
type from ipa::configure().

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-23 18:43:59 +02:00
Naushir Patuck
b876c64613 ipa: raspberrypi: Rationalise parameters to ipa::start()
Separate out the in and out parameters in ipa::start() as they are not
the same. This function now takes in a ControlList and returns out a
struct StartConfig which holds a ControlList and drop frame count for
the pipeline handler to action.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-23 18:43:59 +02:00
Naushir Patuck
eec070039d pipeline: ipa: raspberrypi: Open the CamHelper on ipa::init()
Move the opening of the CamHelper from ipa::configure() to ipa::init().
This allows the pipeline handler to get the sensor specific parameters
in pipeline_handler::match() where the ipa is initialised.

Having the sensor parameters available earlier will allow selective
use of the embedded data node in a future change.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-23 18:43:58 +02:00
Naushir Patuck
ff9f60ce3f ipa: Add sensor model string to IPASettings
Pass the sensor model string to the IPA init() method through the
IPASettings structure.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-23 18:43:58 +02:00
Hirokazu Honda
67e791373d libcamera: device_enumerator: Remove unnecessary rvalue references
There are std::unique_ptr rvalue reference arguments. They are
intended to pass the ownership to the functions. In the case,
it is right to let the argument be std::unique_ptr value and
pass by std::move().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-23 03:47:01 +02:00
Jean-Michel Hautbois
79b48225ad libcamera: ipu3: Pass the BDS rectangle at IPA configure call
The IPU3 IPA will need the BDS configuration when the AWB/AGC algorithm
will be integrated.
In order to do that, the configure() interface needs to be modified.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-17 15:13:50 +01:00
Paul Elder
0d0ac3cb13 ipa: ipa_interface: Add comment to defend the forward-declaration
Any struct that is defined in core.mojom with the skipHeader tag needs
to be present in ipa_interface.h, either forward-declared or #included.
Add a comment so that, in the future, people don't try to send patches
removing the seemingly unused forward-declaration.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-16 11:45:24 +09:00
Naushir Patuck
f1569db3fb libcamera: delayed_controls: Remove unneeded write when starting up
On DelayedControls::reset(), the values retrieved from the sensor device
were added to the queues with the updated flag set to true. This would
cause the helper to write out the value to the device again on the first
DelayedControls::applyControls() call. This is unnecessary, as the
controls written are identical to what is stored in the device driver.

Fix this by explicitly setting the update flag to false in
DelayedControls::reset() when adding the controls to the queue.

Additionally, use the Info() constructor when adding items to the queue
for consistency.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Fixes: 3d4b7b0059 ("libcamera: delayed_controls: Add helper for controls that apply with a delay")
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-12 14:12:55 +00:00
Naushir Patuck
96c0eb338e libcamera: delayed_controls: Add notion of priority write
If an exposure time change adjusts the vblanking limits, and we set both
VBLANK and EXPOSURE controls through the VIDIOC_S_EXT_CTRLS ioctl, the
latter may fail if the value is outside of the limits calculated by the
old VBLANK value. This is a limitation in V4L2 and cannot be fixed by
setting VBLANK before EXPOSURE in a single VIDIOC_S_EXT_CTRLS ioctl.

The workaround here is to have the DelayedControls object mark the
VBLANK control as "priority write", which then write VBLANK separately
from (and ahead of) any other controls. This way, the sensor driver will
update the EXPOSURE control with new limits before the new values is
presented, and will thus be seen as valid.

To support this, a new struct DelayedControls::ControlParams is used in
the constructor to provide the control delay value as well as the
priority write flag.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Kieran: Fix up trivial comments, merge conflicts]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-12 14:12:32 +00:00
Dafna Hirschfeld
e32d33b11d ipa: rkisp1: Fail on init if hw revision is not RKISP1_V10
In kernel 5.11 the rkisp1 uapi had changed to support different hardware
revisions. Currently only revision 10 is supported by the rkisp1 IPA and
therefore 'init' should fail if the revision is not 10.

This changes depends on the kernel driver reporting the hardware
revision, and thus requires the rkisp1 driver from v5.11 or newer.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-11 02:13:28 +02:00
Dafna Hirschfeld
f4fe8cf588 ipa: rkisp1: Return error from IPA's configure method if it fails
The IPA of rkisp1 relies on some of the camera's controls.
Therefore it can't work if those controls are not given.
Return -EINVAL from 'configure' in that case.
Also return error from the pipeline's 'configure' method
if the IPA configure fails.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-11 02:13:28 +02:00
Dafna Hirschfeld
3b338aa5e7 libcamera: media_device: Add hwRevision method
Add a method 'hwRevision' to return the
info.hw_version reported by the driver.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-11 02:13:27 +02:00
Paul Elder
45ebe9a209 ipa: raspberrypi: Use direct return value for configure()
Now that we support returning int directly in addition to other output
parameters, improve the configure() function in the raspberrypi IPA
interface.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-09 11:49:23 +09:00
David Plowman
3a59555414 ipa: raspberrypi: Rename vblank field in SensorConfig to vblankDelay
The name vblankDelay is clearer.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-09 00:55:18 +02:00
Jacopo Mondi
f484857994 libcamera: camera_sensor: Cap resolution to max frame size
Since commit 96aecfe365 ("libcamera: camera_sensor: Use active area
size as resolution") the CameraSensor::resolution() method returned the
sensor's active pixel area size.

As the CameraSensor::resolution() method is widely used in the library
code base to retrieve the maximum frame size the sensor can produce,
in case it is smaller than the pixel area size the returned size cannot
be used to configure the sensor correctly.

Fix this by returning the maximum frame resolution the sensor can
produce, or the pixel area size in case the sensor embeds and ISP that
can upscale and the supported maximum frame size is thus larger that
the pixel array size.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-08 16:21:13 +01:00
Kieran Bingham
a36cde7834 tracing: pipeline_handler: Queue Requests
Add tracing to the base pipeline handler class to track when requests are queued.

Tracing is already available for other Request operations, but queuing a Request
is not an operation handled by the Request itself.

Add the tracepoint to the PipelineHandler::queueRequest() so the lifetime of a
Request can be viewed when tracing.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-08 11:52:10 +00:00
Laurent Pinchart
f2067dffed libcamera: v4l2_device: Make fd() function const
There are use cases for getting the file descriptor of a const
V4L2Device instance, for instance to print it in a log. Make the
function const. There's little risk of abuse here (as in code then
performing operations on the file descriptors that conceptually modify
the V4L2 device), as the fd() function is protected.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-04 10:05:35 +02:00
Naushir Patuck
cd07b604ba pipeline: ipa: raspberrypi: Pass exposure/gain values to IPA though controls
When running with sensors that had no embedded data, the pipeline handler
would fill a dummy embedded data buffer with gain/exposure values, and
pass this buffer to the IPA together with the bayer buffer. The IPA would
extract these values for use in the controller algorithms.

Rework this logic entirely by having a new RPiCameraData::BayerFrame
queue to replace the existing bayer queue. In addition to storing the
FrameBuffer pointer, this also stores all the controls tracked by
DelayedControls for that frame in a ControlList. This includes include
exposure and gain values. On signalling RPi::IPA_EVENT_SIGNAL_ISP_PREPARE
IPA event, the pipeline handler now passes this ControlList from the
RPiCameraData::BayerFrame queue.

The IPA now extracts the gain and exposure values from the ControlList
instead of using RPiController::MdParserRPi to parse the embedded data
buffer.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-04 04:14:54 +02:00
Laurent Pinchart
96aecfe365 libcamera: camera_sensor: Use active area size as resolution
When a sensor can upscale the image, the native sensor resolution isn't
equal to the largest size reported by the sensor. Use the active area
size instead, and default it to the largest enumerated size if the crop
rectangle targets are not supported.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-03-03 22:52:00 +02:00
Laurent Pinchart
330a2d688d include: linux: Update Linux headers to v5.12-rc1
Update Linux headers to v5.12-rc1, to provide the
MEDIA_ENT_F_PROC_VIDEO_ISP entity function.

The DRM FourCC and modifiers that were manually added in commits
9db0ed5e20, 38f2efb05c and 90c793c698 are kept. New Intel DRM
format modifiers are conflicting with IPU3_FORMAT_MOD_PACKED, which is
updated as a result.

The V4L2 controls and formats that were manually added in commit
43d81d43fe are kept. This causes a conflict in the V4L2 control base
for V4L2_CID_USER_BCM2835_ISP_BASE that needs to be resolved in the
downstream Raspberry Pi kernel first.

The intel-ipu3.h header is manually exported with the
scripts/headers_install.sh script. The script complained about a missing
"WITH Linux-syscall-note" license extension, which has been worked
around manually. The issue has been reported upstream in [1].

[1] https://lore.kernel.org/linux-media/20210207235610.15687-1-laurent.pinchart@ideasonboard.com/T/#u

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-03 19:41:04 +02:00
Laurent Pinchart
6e65d42257 libcamera: Enable vimc pipeline handler when tests are enabled
The addition of the new IPA IPC mechanism compiles pipeline-specific
headers to define the interface between the pipeline and the IPA.

This was optimised in 08ce394465 ("meson: ipa, proxy: Only build
proxies for enabled pipelines") to only build for enabled pipelines,
however the tests directly use the VIMC pipeline handler, and require
it to be built.

Create a local variable to store the requested pipelines from the user
configuration and extend the enabled pipelines to ensure that VIMC is
always enabled if the tests are also enabled

Fixes: 08ce394465 ("meson: ipa, proxy: Only build proxies for enabled pipelines")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Sebastian Fricke<sebastian.fricke@posteo.net>
2021-02-23 12:53:15 +02:00
Laurent Pinchart
79991a9903 libcamera: camera: Constify controls argument to start()
The ControlList passed to the Camera::start() function isn't modified.
Make it const.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-21 03:32:01 +02:00
Naushir Patuck
a6c41759fc pipeline: ipa: raspberrypi: Rename IPA Interface namespace to ipa::RPi
Rename the IPA interface namespace to ipa::RPi for consistency with
the libcamera::RPi namespace label.

There is no functional change in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19 11:37:30 +00:00
Naushir Patuck
22a33aa48f pipeline: ipa: raspberrypi: Tidy-ups after IPAInterface changes
This commit addresses a couple of tidy-ups after the IPAInterface
rework:
- Rename ConfigStaggeredWrite -> ConfigSensorParams
- Rename setIsp -> setIspControls

There is no functional change in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19 11:36:47 +00:00
Niklas Söderlund
08ce394465 meson: ipa, proxy: Only build proxies for enabled pipelines
All the IPA proxies are build unconditionally consuming unneeded build
time and disk space on target. Fix this by only building the proxies for
the enabled pipelines.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-18 18:42:07 +01:00
Paul Elder
e201cb4f54 libcamera: IPAInterface: Replace C API with the new C++-only API
Remove everything related to the C API, including ipa_context,
ipa_context_wrapper, and IPAInterfaceWrapper. Also remove relevant
documentation.

ipaCreate() provided by IPA implementations, and createInterface()
provided by IPAModule (wrapper around IPA implementation) both now
return a C++ object IPAInterface instead of struct ipa_context.

Although IPAInterfaceWrapper is the only component of libipa, the
skeleton and build files for libipa are retained.

After converting the C API to the C++-only API, make all pipeline
handlers and IPAs use the new API.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

This is a combination of 21 commits:

---

libcamera: IPAModule: Replace ipa_context with IPAInterface

With the new IPC infrastructure, we no longer need the C interface as
provided by struct ipa_context. Make ipaCreate_() and createInterface()
return IPAInterface.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: ipa_context_wrapper: Remove ipa_context_wrapper

Since ipa_context has been replaced with custom IPAInterfaces, it is not
longer needed. Remove it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: IPAInterface: remove ipa_context and functions from documentation

Remove all the documentation related to ipa_context and the C IPA API,
as well as the documentation about the functions in the IPAInterface.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

---

libcamera: IPAInterface: Remove all functions from IPAInterface

Now that all the functions in the IPA interface are defined in the data
definition file and a specialized IPAInterface is generated per pipeline
handler, remove all the functions from the base IPAInterface.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: IPAInterface: make ipaCreate return IPAInterface

With the new IPC infrastructure, we no longer need the C interface as
provided by struct ipa_context. Make ipaCreate return IPAinterface.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

---

ipa: remove IPAInterfaceWrapper

As every pipeline has its own proxy, IPAInterfaceWrapper is no
longer necessary. Remove it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

---

libcamera: IPAProxy: Remove stop() override

Since stop() is part of the IPA interface, and the IPA interface is now
generated based on the data definition file per pipeline, this no longer
needs to be overrided by the base IPAProxy. Remove it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: IPAProxy, IPAManager: Switch to one-proxy-per-pipeline scheme

IPAProxy is changed in two major ways:
- Every pipeline has its own proxy, to support each pipeline's IPA
  interface
- IPAProxy implementations always encapsulate IPA modules, and switch
  internally for isolation or threaded

The IPAProxy registration mechanism is removed, as each pipeline will
have its own proxy, so the pipeline can pass the specialized class name
of the IPAProxy to the IPAManager for construction.

IPAManager is changed accordingly to support these changes:
- createIPA is a template function that takes an IPAProxy class, and
  always returns an IPAProxy
- IPAManager no longer decides on isolation, and simply creates an
  IPAProxy instance while passing the isolation flag

Consequently, the old IPAProxy classes (IPAProxyThread and
IPAProxyLinux) are removed. The IPAInterfaceTest is updated to use
the new IPAManager interface, and to construct a ProcessManager as no
single global instance is created anymore.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---

libcamera: IPAProxy: Add isolate parameter to create()

Since IPAProxy implementations now always encapsulate IPA modules, add a
parameter to create() to signal if the proxy should isolate the IPA or not.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: IPAManager: Fetch IPAProxy corresponding to pipeline

Now that each pipeline handler has its own IPAProxy implementation, make
the IPAManager fetch the IPAProxy based on the pipeline handler name.
Also, since the IPAProxy is used regardless of isolation or no
isolation, remove the isolation check from the proxy selection.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

---

libcamera: IPAManager: add isolation flag to proxy creation

When the IPA proxy is created, it needs to know whether to isolate or
not. Feed the flag at creation of the IPA proxy.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: IPAManager: Make createIPA return proxy directly

Since every pipeline knows the type of the proxy that it needs, and
since all IPAs are to be wrapped in a proxy, IPAManager no longer needs
to search in the factory list to fetch the proxy factory to construct a
factory. Instead, we define createIPA as a template function, and the
pipeline handler can declare the proxy type when it calls createIPA.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: IPAProxy: Remove registration mechanism

Implementations of IPA proxies use a registration mechanism to register
themselves with the main IPA proxy factory. This registration declares
static objects, causing a risk of things being constructed before the
proper libcamera facilities are ready. Since each pipeline handler has
its own IPA proxy and knows the type, it isn't necessary to have a proxy
factory. Remove it to alleviate the risk of early construction.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: proxy: Remove IPAProxyLinux and IPAProxyThread

We have now changed the proxy from per-IPC mechanism to per-pipeline.
The per-IPC mechanism proxies are thus no longer needed; remove them.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

tests: ipa_interface_test: Update to use new createIPA

Update the IPA interface test to use the new createIPA function from
IPAManager. Also create an instance of ProcessManager, as no single
global instance is created automatically anymore. Update meson.build to
to depend on the generated IPA interface headers.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: PipelineHandler: Remove IPA from base class

Since pipeline handlers now have their own IPA interface types, it can no
longer be defined in the base class, and each pipeline handler
implementation must declare it and its type themselves. Remove it from
the base class.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

ipa: raspberrypi: Add mojom data definition file

Add a mojom data definition for raspberrypi pipeline handler's IPAs.
This simplifies the API between the raspberrypi pipeline handler and the
IPA, and is not a direct translation of what was used before with
IPAOperationData.

Also move the enums from raspberrypi.h to raspberrypi.mojom

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: pipeline, ipa: raspberrypi: Use new data definition

Now that we can generate custom functions and data structures with mojo,
switch the raspberrypi pipeline handler and IPA to use the custom data
structures as defined in the mojom data definition file.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: pipeline, ipa: vimc: Support the new IPC mechanism

Add support to vimc pipeline handler and IPA for the new IPC mechanism.

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>

---

libcamera: pipeline, ipa: rkisp1: Support the new IPC mechanism

Add support to the rkisp1 pipeline handler and IPA for the new IPC
mechanism.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

libcamera: pipeline, ipa: ipu3: Support the new IPC mechanism

Add support to ipu3 pipeline handler and IPA for the new IPC mechanism.

[Original version]
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
[Fixed commit message and small changes]
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:22:28 +09: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
4000ed4d8d ipa: Add core.mojom
Add a base mojom file to contain empty mojom definitions of libcamera
objects, as well as documentation for the IPA interfaces that need to be
defined in the mojom files.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:21:35 +09:00
Paul Elder
21f1b555b7 libcamera: Add IPCPipe implementation based on unix socket
Add an implementation of IPCPipe using unix socket.

[Original patch]
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Error fix from Niklas]
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-02-16 19:21:29 +09:00
Paul Elder
e1ccded833 libcamera: Add IPCPipe
Create a virtual IPCPipe class that models an IPC/RPC system. IPA proxies
and proxy workers will call into the IPCPipe, rather than implementing
the IPC themselves.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:21:25 +09:00
Paul Elder
13f7d58569 libcamera: Add IPADataSerializer
Add an IPADataSerializer which implements (de)serialization of built-in
(PODs, vector, map, string) and libcamera data structures. This is
intended to be used by the proxy and the proxy worker in the IPC layer.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-16 19:21:18 +09:00
Paul Elder
892c0f4c19 libcamera: control_serializer: Save serialized ControlInfoMap in a cache
The ControlSerializer saves all ControlInfoMaps that it has already
(de)serialized, in order to (de)serialize ControlLists that contain the
ControlInfoMaps. Leverage this to cache ControlInfoMaps, such that the
ControlSerializer will not re-(de)serialize a ControlInfoMap that it has
previously (de)serialized.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16 19:20:57 +09:00
Kieran Bingham
f9c0cf2a3a libcamera: MappedBuffer: Disable copy and assignment
MappedBuffers have a custom move constructor and assignment operator to
ensure that memory is not unmapped during object manipulation.

Because of the user-defined move constructor, the implicitly-declared
copy-constructor will already be deleted, however delete it explicitly
to help readability of the code, and make it clear that the object can
not be copied.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:21 +00:00
Kieran Bingham
640f48d603 libcamera: Utilise LIBCAMERA_DISABLE_COPY
Replace existing use cases where the copy constructor and copy
assignment operator are deleted with the LIBCAMERA_DISABLE_COPY
statement

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:20 +00:00
Kieran Bingham
83c5a2a7aa libcamera: controls: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
The ControlId and Control classes disable the copy constructor and
assignment operator, but they should also prevent move construction and
assignment.

Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE to fully disable these
functions.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:17 +00:00
Kieran Bingham
234ee71517 libcamera: media_object: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
Convert MediaLink, MediaPad, and MediaEntity to declare
LIBCAMERA_DISABLE_COPY_AND_MOVE. These classes already deleted their
copy constructor but not the assignment operator.

They should also not be movable, so expand to fully disable both copying
and moving.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:35:12 +00:00
Kieran Bingham
74f103486c libcamera: buffer: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
Convert the existing copy, move and assignment operators to use the new
macros.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:34:18 +00:00
Kieran Bingham
41b6d83e6a libcamera: class: Provide move and copy disablers
It can be difficult to correctly parse the syntax for copy/move and the
associated assignment operators.

Provide helpers as syntactic sugar to facilitate disabling either the
copy constructor, and copy assignment operator, and the move constructor
and move assignment operator in a way which is explicit and clear.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 14:34:04 +00:00
Kieran Bingham
1473add188 libcamera: Move extensible to class
The Extensible concept is a generic Class helper. To prepare for
further class helper additions, move the specific extensible
implementation and header to a more generic class header and source.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-12 11:56:00 +00:00
Laurent Pinchart
e36a6f4043 libcamera: Drop unneeded depend_files from meson custom targets
The meson custom_target() function accepts a 'depend_files' argument to
list additional dependency files. Files already listed in the 'command'
argument are handled automatically, and don't need to be added manually.
Drop them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-11 18:20:49 +02:00
Laurent Pinchart
db27029ce4 meson: Fix coding style when declaring arrays
The meson.build files mix array declarations with and without a space
after the opening and before the closing square bracket. The vast
majority of cases don't use spaces, so standardize on that.

While it it, fix indentation in a few places.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-11 18:20:22 +02:00