Commit graph

3950 commits

Author SHA1 Message Date
Laurent Pinchart
930b4927ac Documentation: Add missing SPDX headers
Two documentation files are missing SPDX headers. Add them, with the
CC-BY-SA-4.0 license that covers all the libcamera documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-30 21:50:56 +03:00
Umang Jain
ed591e705c libcamera: v4l2_device: Log control id instead of errorIdx
v4l2_ext_controls.errorIdx (in the case of single failing control for
VIDIOC_*_EXT_CTRLS calls) represents the index of that control.
Since it is a single control, we can print the control id rather than
its index. This improves logging as the id can be easily co-related
with the controls while reading the log.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-29 11:04:14 +05:30
Laurent Pinchart
aafad4d0ca cam: drm: Skip DRM devices not capable of mode setting
The DRM helper picks the first DRM card that it can open. On platforms
that have a standalone GPU, this risks selecting a device corresponding
to the GPU instead of the display controller. Fix this by skipping
devices that don't support the KMS mode setting API. Some legacy display
controllers would be skipped as well, but libcamera doesn't run on those
systems anyway.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 16:38:58 +03:00
Laurent Pinchart
2f1efe50a9 ipa: rkisp1: awb: Remove bias from gain calculation
The red and blue gains are computed by dividing the green mean by the
red and blue means respectively. An offset of 1 is added to the dividers
to avoid divisions by zero. This introduces a bias in the gain values.
Fix it by clamping the divisors to a minimum of 1.0 instead of adding an
offset.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
9b389ce79e ipa: rkisp1: awb: Freeze AWB when means are too small
When the RGB means are too small, gains and color temperature can't be
meaningfully calculated. Freeze the AWB in that case, using the
previously calculated values.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
7dc60a5a27 ipa: rkisp1: awb: Clamp gains to prevent divisions by zero
The gain values are currently clamped to the range [0.0, 3.996] used by
the hardware. A zero value makes little sense, as it would completely
remove the contribution of the corresponding color channel from the AWB
accumulators, but worse, would lead to divisions by zero when
calculating the raw means in subsequent iterations. Prevent this by
setting the minimum gain value to 1/256.

While at it, clamp the gain values before filtering them, to improve the
stability of the control loop.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
c43c8b1fa0 ipa: rkisp1: awb: Prevent RGB means from being negative
Due to hardware rounding errors in the YCbCr means, the calculated RGB
means may be negative. This would lead to negative gains, messing up
calculation. Prevent this by clamping the means to positive values.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
7d0004a410 ipa: rkisp1: awb: Log means, gains and temperature in debug message
Extend the debug message in Awb::process() to log the means and color
temperature in addition to the gains. This is useful for debugging the
algorithm behaviour. While at it, set the showpoint flag to print a
fixed number of digits after the decimal point, making logs more
readable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Quentin Schulz
df7b9826d7 ipa: rkisp1: awb: Add support for RGB means
RkISP actually supports two modes for color means, RGB and YCbCr. The
variables where the means are stored are identically named regardless of
the color means mode that's been selected.

Since the gains are computed in RGB mode, a conversion needs to be done
when the mode is YCbCr, which is unnecessary when RGB mode is selected.

This adds support for RGB means mode too, by checking at runtime which
mode is selected at a given time. The default is still set to YCbCr mode
for now.

Cc: Quentin Schulz <foss+libcamera@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
ef38cbe9de ipa: rkisp1: awb: Store color temperature as an integer
The color temperature doesn't need floating point precision, and is
calculated by Awb::estimateCCT() as an unsigned integer. Store it with
the same data type in the frame context.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
290ebeb595 ipa: rkisp1: awb: Use frame context to fix gains calculations
The AWB statistics are computed after the ISP applies the colour gains.
This means that the red, green and blue means do not match the data
coming directly from the sensor, but are multiplied by the colour gains
that were used for the frame on which the statistics have been computed.
The AWB algorithm needs to take this into account when calculating the
colour gains for the next frame. Do so by dividing the means by the
gains that were applied to the frame, retrieved from the frame context.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
a2f34f1957 ipa: rkisp1: Document the active state and frame context
Now that data used by algorithms has been partitioned between the active
state and frame context, we have a better view of the role of each of
those structures. Document them appropriately.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:15 +03:00
Laurent Pinchart
a90dc9bc5c ipa: rkisp1: filter: Store per-frame information in frame context
Rework the algorithm's usage of the active state, to store the value of
controls for the last queued request in the queueRequest() function, and
store a copy of the values in the corresponding frame context. The
latter is used in the prepare() function to populate the ISP parameters
with values corresponding to the right frame.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:14 +03:00
Laurent Pinchart
3c3e0aa123 ipa: rkisp1: dpf: Store per-frame information in frame context
Rework the algorithm's usage of the active state, to store the value of
controls for the last queued request in the queueRequest() function, and
store a copy of the values in the corresponding frame context. The
latter is used in the prepare() function to populate the ISP parameters
with values corresponding to the right frame.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:14 +03:00
Laurent Pinchart
cb08adffe2 ipa: rkisp1: cproc: Store per-frame information in frame context
Rework the algorithm's usage of the active state, to store the value of
controls for the last queued request in the queueRequest() function, and
store a copy of the values in the corresponding frame context. The
latter is used in the prepare() function to populate the ISP parameters
with values corresponding to the right frame.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:14 +03:00
Laurent Pinchart
128f22bce5 ipa: rkisp1: awb: Store per-frame information in frame context
Rework the algorithm's usage of the active state and frame context to
store data in the right place.

The active state stores two distinct categories of information:

- The consolidated value of all algorithm controls. Requests passed to
  the queueRequest() function store values for controls that the
  application wants to modify for that particular frame, and the
  queueRequest() function updates the active state with those values.
  The active state thus contains a consolidated view of the value of all
  controls handled by the algorithm.

- The value of parameters computed by the algorithm when running in auto
  mode. Algorithms running in auto mode compute new parameters every
  time statistics buffers are received (either synchronously, or
  possibly in a background thread). The latest computed value of those
  parameters is stored in the active state in the process() function.

The frame context also stores two categories of information:

- The value of the controls to be applied to the frame. These values are
  typically set in the queueRequest() function, from the consolidated
  control values stored in the active state. The frame context thus
  stores values for all controls related to the algorithm, not limited
  to the controls specified in the corresponding request, but
  consolidated from all requests that have been queued so far.

  For controls that can be specified manually or computed by the
  algorithm depending on the operation mode (such as the colour gains),
  the control value will be stored in the frame context in
  queueRequest() only when operating in manual mode. When operating in
  auto mode, the values are computed by the algorithm and stored in the
  frame context in prepare(), just before being stored in the ISP
  parameters buffer.

  The queueRequest() function can also store ancillary data in the frame
  context, such as flags to indicate if (and what) control values have
  changed compared to the previous request.

- Status information computed by the algorithm for a frame. For
  instance, the colour temperature estimated by the algorithm from ISP
  statistics calculated on a frame is stored in the frame context for
  that frame in the process() function.

The active state and frame context thus both contain identical members
for most control values, but store values that have a different meaning.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-28 05:41:14 +03:00
Laurent Pinchart
310b7a6a30 ipa: rkisp1: agc: Store per-frame information in frame context
Rework the algorithm's usage of the active state to store the value of
controls for the last queued request in the queueRequest() function, and
store a copy of the values in the corresponding frame context.

The frame context is used in the prepare() function to populate the ISP
parameters with values corresponding to the right frame.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:14 +03:00
Laurent Pinchart
b3724d3766 ipa: rkisp1: Use frame number passed to Algorithm::prepare()
Now that the Algorithm::prepare() function takes a frame number, we can
use it to replace the IPAActiveState::frameCount member.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:14 +03:00
Kieran Bingham
05e6a19373 ipa: rkisp1: Convert to use the FCQueue
Establish a queue of FrameContexts using the new FCQueue and use it to
supply the FrameContext to the algorithms.

The algorithms on the RKISP1 do not use this yet themselves, but are
able to do so after the introduction of this patch.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-09-28 05:41:12 +03:00
Laurent Pinchart
9f5ab89fb3 ipa: rkisp1: Use base FrameContext class
Inherit from the base FrameContext class in the RkISP1 IPAFrameContext.
As the IPAFrameContext is currently unused, this change is a no-op, but
it prepares the RkISP1 IPA module for frame context queue support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:10 +03:00
Kieran Bingham
906373331f ipa: rkisp1: Rename frameContext to activeState
The RkISP1 IPA module creates a single instance of its IPAFrameContext
structure, effectively using it more as an active state than a per-frame
context. To prepare for the introduction of a real per-frame context,
move all the members of the IPAFrameContext structure to a new
IPAActiveState structure. The IPAFrameContext becomes effectively
unused at runtime, and will be populated back with per-frame data after
converting the RkISP1 IPA module to using a frame context queue.

The IPAActiveState structure will slowly morph into a different entity
as individual algorithm get later ported to the frame context API.

While at it, fix a typo in the documentation of the
Agc::computeExposure() function that incorrectly refers to the frame
context instead of the global context.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:10 +03:00
Laurent Pinchart
80d6657cb4 ipa: rkisp1: Sort documentation of the IPA context
The documentation of the IPA context structures is separate from the
documentation of the structure members. Sort the documentation block to
group members with their structure.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:10 +03:00
Jacopo Mondi
541f0f90cc ipa: rkisp1: Remove unused class member
The "autoExposure" class member is not used.

Remove it.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-09-28 05:41:08 +03:00
Laurent Pinchart
6349cf6ea5 ipa: ipu3: Pass controls to algorithm's queueRequest() handler
Call the Algorithm::queueRequest() function of all algorithms when a
request is queued, to pass the request controls to the algorithms. We
can now drop the copy of the control list stored in IPAFrameContext as
it isn't used anymore.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:07 +03:00
Laurent Pinchart
85c5c47325 ipa: ipu3: Use the FCQueue
Replace the manual ring buffer implementation with the FCQueue class
from libipa.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:07 +03:00
Laurent Pinchart
8d01b8a554 ipa: ipu3: Use base FrameContext class
Inherit from the base FrameContext class in the IPU3 IPAFrameContext.
This allows dropping the frame member, which is now stored in the base
class.

As the frame member of the base FrameContext class is private, the check
that accesses it in IPAIPU3::processStatsBuffer() would fail to compile.
As it won't be relevant anymore with the upcoming switch to the FCQueue
class, drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:07 +03:00
Kieran Bingham
80cfe8f0f7 ipa: libipa: algorithm: queueRequest(): Pass frame context
IPA modules have access to incoming Request's controls list and need to
store them in the frame context at queueRequest() time. Pass the frame
context to the Algorithm::queueRequest() function.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-09-28 05:41:05 +03:00
Kieran Bingham
494662f082 ipa: libipa: algorithm: process(): Pass frame number
Pass the frame number of the current frame being processed.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:04 +03:00
Kieran Bingham
87d36de543 ipa: libipa: algorithm: prepare(): Pass frame and frame Context
Pass the current frame number, and the current FrameContext for calls to
prepare.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:03 +03:00
Kieran Bingham
ef447647b6 ipa: libipa: Provide a common base for frame contexts
Provide a common FrameContext as a base for IPA modules to inherit from.

This will allow having a common set of parameters for every frame
context managed by the FCQueue implementation.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-28 05:41:03 +03:00
Umang Jain
b612496fc4 ipa: libipa: Introduce FrameContextQueue
Introduce a common implementation in libipa to represent the queue of
frame contexts.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-09-28 05:41:01 +03:00
Laurent Pinchart
2101af47e4 ipa: libipa: Pass a reference instead of pointer to Algorithm::process()
Frame contexts will become the core component of IPA modules, always
available to functions of the algorithms. To indicate and prepare for
this, turn the frame context pointer passed to Algorithm::process() into
a reference.

The RkISP1 IPA module doesn't use frame contexts yet, so pass a dummy
context for now.

While at it, drop an unneeded [[maybe_unused]] from Agc::process() and
add a missing parameter documentation for the frameContext argument to
Awb::process().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-27 14:39:47 +03:00
Laurent Pinchart
024d16b7db ipa: ipu3: af: Pass context reference to afIsOutOfFocus()
Avoid copying the whole IPA context by passing a reference to the
Af::afIsOutOfFocus() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-27 14:39:44 +03:00
Laurent Pinchart
62a3c7f3fe ipa: ipu3: Fix style of Doxygen comment blocks
Fix various issues in Doxygen comment blocks:

- \param requires an [in] or [out] tag
- \param must come before the body of the documetation
- Drop leftover \param for argument that has been removed
- Rename coarseSearchStep to kCoarseSearchStep
- White space and line wrap

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2022-09-27 14:39:42 +03:00
Naushir Patuck
a64d17b9cf pipeline: raspberrypi: Improve Unicam timeout handling
Currently, if a Unicam timeout is signalled, the pipeline handler only raises
an error message. Update the error handling to put the pipeline handler in an
internal error state, disable all device streams, and return all outstanding
requests as cancelled. Any subsequent requests that come into the pipeline
handler will also be returned as cancelled.

Any further error handling (e.g. a reset with camera stop()/start()) is up to
the application to perform as it requires.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-23 11:01:21 +01:00
Naushir Patuck
883e2089db pipeline: raspberrypi: Add an error state
Add an error state used internally in the Raspberry Pi pipeline handler.
Currently this state is never set, but will be in a subsequent commit when a
device timeout has been signalled.

Add a isRunning() helper to identify if the state machine is in a stopped/error
state.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-23 11:01:21 +01:00
Laurent Pinchart
685da13d02 ipa: meson: Fix identation
meson.build files are indented with 4 spaces, not 2.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-20 21:54:32 +03:00
Jacopo Mondi
cf5d0cbb34 cam: capture_script: Introduce 'loop' property
Add support to the capture script for properties that control the script
execution. Script properties are specified in the 'properties' section
before the actual list of controls specified in the 'frames' section.

Define a first 'loop' property that allows repeating the frame list
periodically. All the frame ids in the 'frames' section shall be smaller
than the loop control.

Modify the capture script example to show usage of the 'loop' property
and better document the frames list while at it.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-09-20 15:39:50 +02:00
Matthias Fend
74ab3f778c libcamera: ipa_manager: Fix build without openssl
Since commit bedef55d95 ("libcamera: pub_key: Gracefully handle failures
to load public key") the build will fail if openssl is not found on the
host system.

Use the existing HAVE_IPA_PUBKEY define to avoid accessing pubKey_ which
does not exist when building without openssl.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2022-09-15 16:13:40 +05:30
Umang Jain
eb7e83b346 meson: Enable vimc IPA for tests
Vimc pipeline handler is enabled unconditionally if the meson config
option '-Dtest' is true. However, this is not true for the vimc IPA.
Hence, a meson configuration such as:

    -Dpipelines=raspberrypi -Dipas=raspberrypi -Dtest=true

will include the vimc pipeline handler (in addition to raspberrypi)
but will skip the vimc IPA which can lead to failure of unit tests
that depends on vimc to execute.

One such unit test was identified as a result of this issue on
RaspberryPi:

ERROR IPAModule ipa_module.cpp:278 ipa_vimc.so: Failed to open IPA library: No such file or directory
test IPA module src/ipa/vimc/ipa_vimc.so is invalid

due to the non-existent ipa_vimc.so.

Fix this by including the vimc IPA unconditionally when the tests are
enabled, similar to how the vim pipeline-handler is included.

Fixes: 6e65d42257 ("libcamera: Enable vimc pipeline handler when tests are enabled")
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-15 15:56:19 +05:30
Rishikesh Donadkar
0a4d1b8d45 test: gstreamer: gstreamer_test: Remove redundant word
Remove redundant "create" in the error message.

Signed-off-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
Reviewed-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2022-09-12 22:44:56 +05:30
Vedant Paranjape
46340ced12 test: gstreamer: Fix failure of gstreamer_multistream_test
Multistream test failed with the following logs, to run on Raspberry Pi 4 due
to a bug introduced in one of the recent patches refactoring the code
that fails to set the camera-name property with a valid camera id
string.

WARN libcamerasrc gstlibcamerasrc.cpp:347:gst_libcamera_src_open:<libcamera> error: Could not find a camera named ''.
WARN libcamerasrc gstlibcamerasrc.cpp:347:gst_libcamera_src_open:<libcamera> error: libcamera::CameraMananger::get() returned nullptr

This patch assigns the camera->id() to the variable cameraName_ that is
later used to set element property "camera-name" needed to call the
specific camera which supports multistreams. Move the code to set
element property "camera-name" to base class GstreamerTest.

Fixes: 5646849b59 ("test: gstreamer: Check availability of cameras before running")
Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
Reviewed-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2022-09-12 22:44:54 +05:30
Vedant Paranjape
046f83e8df gstreamer: Check gstreamer version before using newer macros
GST_VIDEO_TRANSFER_BT601 and GST_VIDEO_TRANSFER_BT2020_10 macros are
defined in GST Version 1.18.0.

Usage of these macros causes gstlibcamera compilation failure if
GST_VERSION < 1.18.0. These macros are used only if GST_VERSION >= 1.18.0.
Fix the following compilation error:

../src/gstreamer/gstlibcamera-utils.cpp:157:7: error: ‘GST_VIDEO_TRANSFER_BT601’ was not declared in this scope; did you mean ‘GST_VIDEO_TRANSFER_BT709’?
  157 |  case GST_VIDEO_TRANSFER_BT601:
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
      |       GST_VIDEO_TRANSFER_BT709
../src/gstreamer/gstlibcamera-utils.cpp:159:7: error: ‘GST_VIDEO_TRANSFER_BT2020_10’ was not declared in this scope; did you mean ‘GST_VIDEO_TRANSFER_BT2020_12’?
  159 |  case GST_VIDEO_TRANSFER_BT2020_10:
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |       GST_VIDEO_TRANSFER_BT2020_12

Fixes: fc9783acc6 ("gstreamer: Provide colorimetry <> ColorSpace mappings")
Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
Reviewed-by: Rishikesh Donadkar <rishikeshdonadkar@gmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
2022-09-12 22:44:53 +05:30
Christian Rauch
5fd18af233 libcamera: controls: initialise control info to ControlTypeNone by default
The default ControlInfo constructor allows partially initialising the
min/max/def values. Uninitialised values are assigned to 0 by default.
This implicit initialisation makes it impossible to distinguish between
an uninitialised and an explicitly 0-initialised ControlValue.

Default construct the ControlValue in the ControlInfo default contructor to
explicitly represent uninitialised values by the ControlTypeNone type.

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2022-09-12 18:29:11 +09:00
Christian Rauch
cbc2be34ed libcamera: control_serializer: store/load all ControlValue types
The min/max/def ControlValue of a ControlInfo can take arbitrary types that
are different from each other and different from the ControlId type.
The serialiser serialises these ControlValue separately by their type but
does not store the type. The deserialiser assumes that ControlValue types
match the ControlId type. If this is not the case, deserialisation will try
to deserialise values of the wrong type.

Fix this by serialising each of the min/max/def ControlValue's ControlType
and storing it just before the serialised ControlValue.

Fixes: https://bugs.libcamera.org/show_bug.cgi?id=137

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
Tested-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2022-09-12 18:28:59 +09:00
Laurent Pinchart
560ceb1ea8 libcamera: v4l2_subdevice: Silence warning for unknown metadata formats
Commit e297673e76 ("libcamera: v4l2_device: Adjust colorspace based on
pixel format") has introduced a warning when trying to convert a color
space from V4L2 to libcamera if the media bus code is unknown. This was
meant to catch unknown image formats, but turned out to be also
triggered for metadata formats.

Color spaces are not applicable to metadata formats, there should thus
be no warning. Fix it by skipping the color space translation and
returning std::nullopt directly if the kernel reports
V4L2_COLORSPACE_DEFAULT. This doesn't introduce any change in behaviour
other than getting rid of the warning, as the V4L2Device::toColorSpace()
function returns std::nullopt already in that case.

Fixes: e297673e76 ("libcamera: v4l2_device: Adjust colorspace based on pixel format")
Reported-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2022-09-08 16:43:32 +03:00
Utkarsh Tiwari
5a9fd9a95c qcam: Fix crash when switching from non existant camera
When switching to different camera we try to release the camera
previously used. But if that camera has been unplugged, then its
instance would have been destroyed. Accessing it leads to seg fault.

Fix by checking camera_ to see if it exists.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=147
Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2022-09-08 11:20:53 +03:00
Laurent Pinchart
6225d647b4 pipeline: uvcvideo: Fail match() if the camera has no supported format
A UVC device could expose only formats that are not supported by
libcamera. The pipeline handler doesn't currently consider this as an
error, and happily creates a camera. The camera won't be usable, and
worse, generateConfiguration() and validate() will crash as those
functions assume that at least one format is supported.

Fix this by failing match() if none of the formats exposed by the camera
are supported. Log an error message in that case to notify the user.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=145
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Christian Rauch <Rauch.Christian@gmx.de>
2022-09-07 00:32:10 +03:00
Laurent Pinchart
f98919307e pipeline: uvcvideo: Cache supported formats in UVCCameraData
Populate and cache the list of supported formats in
UVCCameraData::init(), to avoid repeating the operation every time
generateConfiguration() is called. Combine this with the search for
the largest size advertised by the camera to avoid iterating over the
formats twice in init().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Christian Rauch <Rauch.Christian@gmx.de>
2022-09-07 00:32:08 +03:00
Laurent Pinchart
52660f2b13 pipeline: uvcvideo: Move camera ID generation to UVCCameraData class
Move the camera ID generation to UVCCameraData, and cache the ID in that
class. This will be useful to access the ID in multiple locations, such
as when printing error messages.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Christian Rauch <Rauch.Christian@gmx.de>
2022-09-07 00:30:04 +03:00