Commit graph

4439 commits

Author SHA1 Message Date
Jacopo Mondi
891720ae8c Documentation: Add figures to document Orientation
Add figures in Documentation/rotation/ to document the plane
transformations defined by the Orientation enumeration.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-23 16:05:54 +03:00
Jacopo Mondi
cc65629b68 libcamera: camera: Introduce Orientation
Introduce the Orientation enumeration which describes the possible 2D
transformations that can be applied to an image using two basic plane
transformations.

Add to the CameraConfiguration class a new member 'orientation' which is
used to specify the image orientation in the memory buffers delivered to
applications.

The enumeration values follow the ones defined by the EXIF specification at
revision 2.32, Tag 274 'orientation'.

The newly introduced field is meant to replace
CameraConfiguration::transform which is not removed yet not to break
compilation.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-23 16:05:50 +03:00
Jacopo Mondi
042649f044 libcamera: camera_sensor: Cache rotationTransform_
The rotationTransform_ depends on a V4L2 control whose value does not
change for the whole lifetime of the camera.

Instead of re-calculating it everytime the camera is configured, cache
it at properties initialization time.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-23 16:05:46 +03:00
Daniel Scally
b5f5a89bc3 apps: qcam: Add support for RGB565
Qt supports RGB565 natively; add support for the format by mapping
the libcamera format to Qt's representation of it.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-23 13:50:18 +03:00
William Vinnicombe
d477ee97bc pipeline: rpi: vc4: Allocate more embedded data buffers
If the pipeline runs out of embedded data buffers, then it will pass
the frame to the IPA without the metadata. The IPA then has to use the
delayed controls as inputs to the algorithms. This can cause problems
with the subsequent algorithms if the sensor did not action the
controls, especially with the autofocus as that doesn't have controls
which can be passed in lieu of the metadata.

Reduce the likelihood of this by increasing the number of embedded data
buffers, as they are small so a generous number can be allocated.

Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 14:23:23 +01:00
Laurent Pinchart
d2094a0185 utils: update-kernel-headers: Support git worktrees
When operating on a git worktree, the Linux kernel directory contains a
.git file, not a .git directory. Relax the git tree check to support
both.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 16:17:18 +03:00
Naushir Patuck
d848d2a21c ipa: rpi: agc: When AGC channels are changed, start with the 1st channel
Whenever the AGC active channels are changed, start with the first
channel listed. This allows applications to rely on a particular channel
being generated first. For example, multi-exposure HDR always wants the
short channel first.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
David Plowman
daeaf681c9 ipa: rpi: agc: Avoid overwriting caller's statistics pointer
The code was inadvertently overwriting the caller's StatisticsPtr,
meaning that subsequent algorithms would get the wrong image
statistics when AGC channels changed.

This could be fix using std::ref, though I find the C-style pointer
fix easier to understand!

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
David Plowman
ac232470fb ipa: rpi: denoise: Support different denoise configurations
Some use cases may require stronger, or different, denosie settings to
others. For example, the way frames are accumulated during single
exposure HDR means that we may want stronger denoise.

This commit adds such support for different configurations that can be
defined in the tuning file.

Older tuning files, or files where there is only a single
configuration, load only the "normal" denoise configuration.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
David Plowman
0ff20bf8c1 ipa: rpi: contrast: Allow adaptive contrast enhancement to be disabled
The enableCe() function enables or disables adaptive contrast
enhancement and the restoreCe() function sets it back to its normal
state (which is what was read from the tuning file).

In future, algorithms like HDR might want to take over tonemapping
functions, so any dynamic behaviour here would upset them.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
David Plowman
9c90e56733 ipa: rpi: agc: Add an AGC stable region
Add a small "stable region" parameter (defaulting to 2%) within which
the AGC will not adjust the exposure it requests. It allows
applications to configure the AGC to avoid continual micro-adjustments
of exposure values if they are somehow sensitive to it.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
Naushir Patuck
a04fe76a45 pipeline: rpi: Make color space members in RPiCameraConfiguration public
This allows them to be accessed by the pipeline handlers when needed.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
Naushir Patuck
0d4342bf22 pipeline: rpi: Move flip handling validation code
Move the handling of Bayer order changes due to flips to run before
platformValidate(). This removes the need for this code to be split
between platformValidate() and validate() as it is right now.

Also add some validation to ensure the vc4 pipeline handler only
supports CSI2 packing or no packing.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
Naushir Patuck
2ec7f2fede build: ipa: Fix bug in building multiple IPA interfaces with the same mojom file
In the existing meson scripts, an IPA mojom interface file may not be
built if:

- There are duplicate entries for the mojom file shared by different
  pipeline handlers in pipeline_ipa_mojom_mapping, and
- The IPA is not listed first in pipeline_ipa_mojom_mapping, and
- The first listed IPA for the given mojom file is not selected in the
  build.

Fix this by using a separate list of already built mojom files
(mojoms_built) instead of overloading use of the existing
ipa_mojom_files list.  Now, ipa_mojom_files gets filled in outside of
the IPA list enumeration loop, this also guarantees the IPA
documentation gets built even if the pipeline is not selected.

Fixes: 312e9910ba ("meson: ipa: Add mapping for pipeline handler to mojom interface file")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
Naushir Patuck
9535f2c745 pipeline: rpi: Add SW downscale status to RPi::Stream
Record if additional software downscaling is needed for a particular
stream in the RPi::Stream class. Additional software downscaling may be
needed if the user required downscale factor is greater than what the
ISP hardware is capable of.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:23 +01:00
Naushir Patuck
ded9004e91 ipa: rpi: Add new algorithms for PiSP
Add new CAC, HDR, Saturation and Tonemapping algorithms.

Add a new Denoise algorithm that handles spatial/temporal/colour denoise
through one interface. With this change, the old SDN algorithm is now
considered deprecated and a warning message will be displayed if it is
enabled.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
c9fb1d44d8 ipa: rpi: Prepare AWB for PiSP support
Prepare the AWB algorithm to support the PiSP hardware. The key change
is to factor in the LS correction in the AWB zone statistics. This is
different from VC4 where the LS correction happens before statistics
gathering.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
0be32012ef ipa: rpi: Prepare ALSC for PiSP support
Prepare the ALSC algorithm to support the PiSP hardware. The key change
is to avoid factoring out the WB correction in the AWB zone statistics.

Add the ALSC correction to the global metadata so that AWB can use it to
factor the gains back in for the AWB calculations.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
56ca5091de ipa: rpi: Add PiSP definitions to the Controller hardware description
Add an entry to Controller::HardwareConfig describing the PiSP hardware
for the IPA and controller algorithms to use.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
11c939a200 ipa: rpi: Add statsInline to the Controller hardware description
Add a new boolean field (statsInline) to Controller::HardwareConfigMap.
This field indicates where the statistics are generated in the hardware
ISP pipeline. For statsInline == true, statistics are generated before
the frame is processed (e.g. the PiSP case), and statsInline == false
indicates statistics are generated after the frame is processed (e.g.
the VC4 case).

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
0548079581 ipa: rpi: Add try_lock() to RPiController::Metadata
Add the missing try_lock() member function to RPiController::Metadata.
This will allow RPiController::Metadata to be used as a template
parameter in std::scoped_lock.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
6f44b9f969 mojom: pipeline: ipa: rpi: Add fields for PiSP objects
Add the PiSP Frontend and Backend SharedMemObject file descriptors to
the ipa::init() call. This will allow the pipeline handler to pass these
objects to the IPA after construction.

Add a flag to indicate if buffer swaps are needed when starting the
ISP for the stitch block.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
71bb5b345f ipa: rpi: Add IpaBase::platformStart() member function
Add a virtual IpaBase::platformStart() member function that is called
at the end of IpaBase::start(). For the IpaVc4 derived class, this
function does nothing, but will be used in the PiSP derived class to
reset internal state on startup.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
92a74cf454 pipeline: rpi: Add SharedMemObject class
Add new SharedMemObject class that wraps a memfd memory allocation and
constructs a templated object in the memory. With appropriate locking,
this object can then be shared across different processes using the
associated allocation file handle.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
cc71d12a18 pipeline: rpi: Add Recurrent and Needs32bitConv flags to RPi::Stream
Add a new "Recurrent" stream flag. This flag indicates the stream buffer
handling/management happend from the pipeline handler exclusively. This
is used for TDN/Stitch and Config streams.

Add a new Needs32bitConv stream flag to indicate that this stream needs
a software postprocessing conversion run on it before returning out to
the application.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:22 +01:00
Naushir Patuck
f4839fb3a3 pipeline: rpi: Add RequiresMmap flag to RPi::Stream
Add a new RequiresMmap flag to the RPi::Stream class indicating that
buffers handled by the stream must be mmapped after allocation and
cached internally.

Add a new member function getBuffer(id) which can be used to obtain the
mapped buffers for a given buffer id.

Add a new member function acquireBuffer() which can be used to obtain
any mapped buffer that has not already been acquired by the caller.

As a drive-by, add the <algorithm> header to rpi_stream.cpp as it is
needed for the std::find_if() function.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-18 11:01:21 +01:00
Kieran Bingham
c258302863 py: gen-py-controls: Remove SceneFlicker workaround
The python bindings layer has to parse the libcamera controls to ensure
that they are converted to suitable names for the python layer.

Part of this strips out common prefixes from control names, however the
SceneFlicker control would end up using an illegal name if processed in
the same way as the other controls.

The SceneFlicker control has now been removed as part of the
introduction of the AeFlickerMode and AeFlickerPeriod controls.

Remove the workaround in the python layer.

Fixes: 6fdbf3f38c ("libcamera: controls: Add controls for AEC/AGC flicker avoidance")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-16 16:38:08 +01:00
David Plowman
d05009d34c py: Add the SensorConfiguration class
We provide access to the various fields of the new SensorConfiguration
class. The class also needs a constructor so that Python applications
can make one and put it into the CameraConfiguration.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-16 16:21:04 +01:00
Andrey Konovalov
161be650a8 libcamera: converter: drop unnecessary #include directive
libcamera/internal/media_device.h includes linux/media.h already.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Suggested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-06 02:39:05 +03:00
Andrey Konovalov
b2b5129d0c libcamera: converter: A few fixes to ConverterFactoryBase documentation
The description of ConverterFactoryBase::registerType() referred to
a converter factory as "converter class" and "converter". Fix that.

Also make the descriptions of ConverterFactoryBase::compatibles() and
ConverterFactoryBase::create() a bit more specific.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-10-06 02:39:05 +03:00
David Plowman
ff41de7ba1 ipa: rpi: Avoid skipping IPAs on the first frame after the drop frames
We avoid skipping the IPAs while frameCount_ is less than
dropFrameCount_, indicating that these frames will not be sent to the
application. This means that when these numbers are equal then this is
the first frame the application will get, so again, we must avoid
skipping the IPAs. Consequently the test here must avoid the case of
equality.

Fixes: 51533fecae ("ipa: rpi: Fix frame count logic when running algorithms")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-10-05 17:04:06 +01:00
Naushir Patuck
eaf82088b1 libcamera: rpi: Simplify validate() and configure() for YUV/RGB streams
This commit simplifies the validate() and configure() calls in the
pipeline handler in a number of ways:

- Determine the V4L2DeviceFormat structure fields for all streams
  in validate(), cache them and reuse in configure() instead of
  re-generating this structure multiple times.

- Remove setting a default pixel format in validate(), this code patch
  will not be used.

- Use the recently added updateStreamConfig() and toV4L2DeviceFormat()
  helpers to populate fields in the V4L2DeviceFormat and StreamConfiguration
  structures to reduce code duplication.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:44:39 +03:00
Naushir Patuck
b60a5c34fb libcamera: rpi: Change default stream formats
Switch to XRGB8888 as a default Viewfinder role output format, this is a
more correct description of the ISP hardware output, and what is
accepted by the Raspberry Pi hardware.

Switch to YUV420 as a default output format for everything else, as this
format is best supported by encoding (e.g. H.264, JPEG) sinks on the
Raspberry Pi platform.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:43:38 +03:00
Naushir Patuck
723c0abb40 libcamera: rpi: Simplify validate() and configure() for RAW streams
This commit simplifies the validate() and configure() calls in the
pipeline handler in a number of ways:

- Only pass the RPiCameraConfiguration structure into platformValidate()
  and platformConfigure().

- Determine the V4L2DeviceFormat structure fields for all streams in
  validate(), cache them and reuse in configure() instead of
  re-generating this structure multiple times.

- Use the recently added updateStreamConfig() and toV4L2DeviceFormat()
  helpers to populate fields in the V4L2DeviceFormat and
  StreamConfiguration structures to reduce code duplication.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:42:36 +03:00
Naushir Patuck
71bbf10a2f libcamera: rpi: Add some helpers to PipelineHandlerBase
Add a helper updateStreamConfig() that updates the format related fields
in a StreamConfiguration from a given V4L2DeviceFormat structure.

Add and override to the toV4L2DeviceFormat() helper that returns a
V4L2DeviceFormat structure populated from the format related fields in
a StreamConfiguration.

Both these helper functions will be used in a future commit to simplify
the Raspberry Pi pipeline handler configuration/validation code.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:42:23 +03:00
Naushir Patuck
0602cbc596 libcamera: rpi: Cache rawStreams and outStreams
Currently, the stream configuration is stored in two vectors, rawStreams
and outStreams for convenience. However, these vectors are constructed
in both platformValidate() and platformConfigure().

This change caches these vectors in the RPiCameraConfiguration class to
construct them only once in platformValidate().

Pass a pointer to the current configuration to platformValidate() and
platformConfigure() so that they can access the streams vectors.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:42:12 +03:00
Naushir Patuck
2a5120f674 libcamera: rpi: Make isRaw/isYuv/isRgb static functions
Move the existing isRaw()/isYuv()/isRgb()into a static function of
PipelineHandlerBase. This will allow them to be shared with the
pipeline handler derived class.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:41:57 +03:00
Jacopo Mondi
792511a3df libcamera: rpi: Fix wrong comment indentation
The closing line of a comment block was aligned with spaces and not
tabs. Fix it.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:41:44 +03:00
Naushir Patuck
3caaafafa8 libcamera: rpi: Allow platformValidate() to adjust format strides
Propagate any changes to the format stride done by platformValidate().
The stride value may be adjusted for performace reasons.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:41:31 +03:00
Jacopo Mondi
40d50263f5 libcamera: rpi: Handle SensorConfiguration
Handle the SensorConfiguration provided by the application in the
pipeline validate() and configure() call chains.

During validation, first make sure SensorConfiguration is valid, then
handle it to compute the sensor format.

For the VC4 platform where the RAW stream follows the sensor's
configuration adjust the RAW stream configuration to match the sensor
configuration.

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:41:29 +03:00
Jacopo Mondi
f446c23842 libcamera: camera_sensor: Support SensorConfiguration
Add a class function to the CameraSensor class to apply a full
configuration to the sensor.

The configuration shall be fully populated and shall apply without
modifications to the sensor.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:39:22 +03:00
Jacopo Mondi
1602043e62 libcamera: camera: Introduce SensorConfiguration
Introduce SensorConfiguration in the libcamera API.

The SensorConfiguration is part of the CameraConfiguration class
and allows applications to control the sensor settings.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:35:42 +03:00
Jacopo Mondi
9780f46f64 Documentation: Introduce Camera Sensor Model
Introduce a documentation page about the 'camera sensor model'
implemented by libcamera.

The camera sensor model serves to provide to applications a reference
description of the processing steps that take place in a camera sensor
in order to precisely control the sensor configuration through the
forthcoming SensorConfiguration class.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-27 14:35:33 +03:00
Naushir Patuck
e991a2887e pipeline: rpi: Reset the frame lengths queue during configure
The IPA stores a list of the last 10 frame lengths applied to the
sensor for determining the timeout to use. This list gets reset on
start(), but there is a path through the code that accesses this list
in configure() which happens earlier, causing a logical error.

Fix this by constructing the list with 10 initial values of 0s.

Bug: https://github.com/raspberrypi/libcamera/issues/64
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>
2023-09-25 16:08:35 +01:00
Naushir Patuck
51533fecae ipa: rpi: Fix frame count logic when running algorithms
The frame counter test to determine if we run the IPA algorithms has a
logic bug where it treats dropFrameCount_ and mistrustCount_ as frame
numbers, not counts of frames (which it is). The implication is that
startup convergence and initial settings take one extra frame to apply.
Fix this.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-25 16:01:21 +01:00
Naushir Patuck
870943f80a libcamera: formats: Fix typo in YV444 V4L2PixelFormat listing
This format was defined with the V4L2_PIX_FMT_YUV444M fourcc instead of
the correct V4L2_PIX_FMT_YVU444M fourcc.

Fixes: 3b9fe4ae99 ("libcamera: formats: Add YUV444 and YVU444 pixel formats")
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2023-09-25 16:01:21 +01:00
Laurent Pinchart
1d61614142 meson: Simplify check for _FORTIFY_SOURCE
Use the compiler.get_define() function to get the value of
_FORTIFY_SOURCE instead of iterating over the cpp_args. This simplies
the code, but also guarantees to return the actual value of
_FORTIFY_SOURCE, even if defined through other means than through the
meson cpp_args.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: George Burgess IV <gbiv@google.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-21 15:24:37 +02:00
Harvey Yang
dbe4e0e945 android: camera_device: Fix requestedStream handling
The Android CameraDevice class adds a sourceStream for each Mapped
stream requested by the framework.

When mapping multiple framework streams to the same sourceStream, the
implementation of CameraDevice::processCaptureRequest wrongly erases the
just added sourceStream from the list of streams to request to
libcamera.

Fix this by adding the stream instead of erasing it.

Fixes: 7ea83eba0d ("android: camera_device: Postpone mapped streams handling")
Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-21 12:44:09 +02:00
George Burgess IV
9c5eb9237c meson: Don't set _FORTIFY_SOURCE for ChromeOS
ChromeOS is moving to a platform default of `_FORTIFY_SOURCE=3`, and
this definition conflicts with that:

<command line>:4:9: error: '_FORTIFY_SOURCE' macro redefined
[-Werror,-Wmacro-redefined]

Rather than adding logic to keep up with their local configuration, it
seems best to leave setting _FORTIFY_SOURCE on ChromeOS up to ChromeOS.

Signed-off-by: George Burgess IV <gbiv@google.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2023-09-19 11:25:08 +03:00
Naushir Patuck
90e0fea6c6 ipa: rpi: Fix segfault when parsing invalid json file
If the json file parsing failed due to a malformed file, the root
pointer would be null. This was not tested and caused a segfault when
trying to use the pointer to retrieve the version key.

Fix this by bailing out early if the parser returns a null pointer.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2023-09-16 17:33:44 +02:00