Commit graph

3732 commits

Author SHA1 Message Date
Laurent Pinchart
9b1a2a8c8b libcamera: camera_sensor: Drop updateControlInfo() function
The CameraSensor::updateControlInfo() function is a wrapper around the
same function of the V4L2Subdevice class. It was meant to be called by
pipeline handlers that modify the sensor configuration directly,
bypassing the CameraSensor::setFormat() function. This never happened,
and the function is called once only, internally to the CameraSensor
class. No external users are foreseen, drop the function and call
V4L2Subdevice::updateControlInfo() directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-03-15 13:00:58 +02:00
Laurent Pinchart
2a0baf47eb libcamera: camera_sensor: Move related classes to subdirectory
In preparation for adding alternative implementations of the
CameraSensor class, move the code to a subdirectory to avoid cluttering
the main src/libcamera/ directory.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-03-15 13:00:58 +02:00
Laurent Pinchart
c5a8152af2 libcamera: v4l2_subdevice: Add V4L2Subdevice::Route structure
The V4L2Subdevice class deals with streams in two places:

- In routing tables, streams as expressed as a pad number and a stream
  number in a v4l2_subdev_route instance.
- In the format and selection get and set functions, streams as
  expressed using the Stream structure, which binds the pad number and
  stream number.

Expressing streams in different ways requires pipeline handlers and
other helpers to convert between the two representations. This isn't
much of an issue yet as libcamera has little stream-aware code, but it
is expected to increasingly become a burden.

To simplify the API, introduce a V4L2Subdevice::Route structure that
mimicks the kernel v4l2_subdev_route structure but represents streams as
V4L2Subdevice::Stream instances. This will improve seamless integration
of routes, formats and selection rectangles.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 13:00:49 +02:00
Laurent Pinchart
e8f01b37e8 libcamera: v4l2_subdevice: Replace Routing::toString() with operator<<()
The main (and only at the moment) use case for the Routing::toString()
function is to print a representation of the routing table in a log
message. The function is implemented using an std::stringstream, and the
returned std::string is then inserted into an std::ostream. This is
inefficient. Replace the function with a specialization of the
operator<<() and use it in the caller.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:55:09 +02:00
Laurent Pinchart
0d2ad0cd84 libcamera: v4l2_subdevice: Add stream support to get/set functions
Extend the V4L2Subdevice API with stream support for the functions that
get and set formats and selection rectangles. Add a Stream structure to
identify a subdev pad and stream, and use it to extend the V4L2Subdevice
functions that get and set formats and selection rectangles with stream
support.

To preserve the existing pad-based API, implement overloaded functions
that wrap the new stream-based API. This allows callers that are not
stream-aware to use a simpler pad-based API, instead of having to
explicitly set the stream number to 0 in all API calls.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:55:05 +02:00
Laurent Pinchart
d41e0585e9 libcamera: v4l2_subdevice: Rename V4L2SubdeviceFormat::mbus_code to code
The V4L2SubdeviceFormat::mbus_code member doesn't follow the libcamera
coding style as it should use camelCase. Fix it by renaming it to just
'code', to shorten lines in addition to fixing the coding style.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:55:03 +02:00
Laurent Pinchart
4c82481fc4 libcamera: v4l2_subdevice: Drop V4L2SubdeviceFormat::bitsPerPixel()
The V4L2SubdeviceFormat::bitsPerPixel() function is just a wrapper
around a MediaBusFormatInfo lookup. It made sense when the
MediaBusFormatInfo class was not exposed outside of the compilation
unit, but is now redundant. Drop it and use MediaBusFormatInfo in the
only caller.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:55:00 +02:00
Laurent Pinchart
7941903d62 libcamera: v4l2_subdevice: Extend MediaBusFormatInfo with metadata formats
Not all media bus formats describe image formats. Extend the
MediaBusFormatInfo class with a type member to indicate if the format
corresponds to image data or metadata, and add the (only) metatdata
format supported by the kernel to the known mediaBusFormatInfo.

The kernel doesn't (yet) have any metadata format specific to sensor
embedded data. This is being addressed in the V4L2 API. In preparation
for embedded data support, already introduce the EmbeddedData type here.
Corresponding formats will be added when available.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:54:58 +02:00
Laurent Pinchart
d60fb23258 libcamera: v4l2_subdevice: Expose media bus format info as internal API
The V4L2SubdeviceFormatInfo structure, internal to the
v4l2_subdevice.cpp compilation unit, contains information about media
bus formats that will be useful in other parts of libcamera. To prepare
for this, expose the structure in the v4l2_subdevice.h header and turn
it into a class with a similar design as PixelFormatInfo.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:54:56 +02:00
Laurent Pinchart
1a1cf4a2c1 libcamera: v4l2_subdevice: Add code member to MediaBusFormatInfo
To prepare for exposing the MediaBusFormatInfo structure as an internal
API, add a code member to the structure to store the media bus code.
This makes MediaBusFormatInfo usable standalone, without having to
externally associate the code related to the info.

The entries in the mediaBusFormatInfo map are becoming too long, so
split them on multiple lines.

While at it, swap the order of the members to match the PixelFormatInfo
class for consistency.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:54:47 +02:00
Laurent Pinchart
3777d80acc libcamera: v4l2_subdevice: Rename V4L2SubdeviceFormatInfo
The V4L2SubdeviceFormatInfo structure contains information about a media
bus format, not a V4L2 subdevice format. Rename it to MediaBusFormatInfo
to clarify its purpose. Rename the formatInfoMap map accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-15 12:54:44 +02:00
Stefan Klug
d54abd32af libcamera: controls: Add policy parameter to ControlList::merge()
This is useful in many cases although not included in the stl.

Note: This is an ABI incompatible change.

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-03-12 17:04:28 +01:00
Barnabás Pőcze
2e2ba223f3 libcamera: framebuffer_allocator: Remove entry if allocation fails
Remove the entry from the `buffers_` mapping if
`Camera::exportFrameBuffers()` fails, otherwise
there would be a stale entry in the map.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-12 10:09:56 +00:00
Barnabás Pőcze
ab5816a540 libcamera: framebuffer_allocator: Use default destructor
The compiler generated destructor works fine, so use that.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-12 10:09:56 +00:00
Barnabás Pőcze
443734023c libcamera: framebuffer_allocator: Move from argument in constructor
The single argument, of type `std::shared_ptr<Camera>`,
is passed by value, so it can simply be moved from in order to
avoid calling the copy constructor.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-12 10:09:56 +00:00
Paul Elder
01935edbba cam: capture_script: Make parseRectangles work for non-array
parseRectangles currently always parses Rectangle controls as an array
of Rectangles. This causes non-array Rectangle controls to not be parsed
correctly, as when the ControlValue is get()ed, the non-array assertion
will fail.

Set the ControlValue with a single Rectangle in case a single Rectangle
has been specified in the yaml capture script to fix that.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-11 14:50:14 +00:00
Nick Hollinghurst
caed5a551b ipa: rpi: cam_helper: Extend embedded data parsing to RAW14 modes
Fix embedded data byte-skipping for 14-bit modes (4 out of 7 bytes
carry register data), and allow 14-bit modes in IMX708 PDAF parsing.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-06 12:52:14 +00:00
Nick Hollinghurst
a63af956ac libcamera: v4l2_subdevice: Add 14-bit Bayer formats
Add MEDIA_BUS_FMT_SBGGR14_1X14 etc to formatInfoMap.
Not adding any Y14 for now.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-06 12:52:14 +00:00
Kieran Bingham
be21f2747a libcamera: controls: Fix typo on thermal
The documentation for the SensorTemperature control has a spelling
mistake for thermal.

Fix it.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-03-01 23:16:09 +00:00
Suhrid Subramaniam
c64446c226 pipeline: simple: Add support for MediaTek MT8365 platforms
The camera pipeline for MediaTek MT8365 consists of the following:
Raw sensor (+ external ISP) --> SENINF --> CAMSV30 --> DRAM

SENINF (SENsor INterFace) is a CSI-2 receiver.
CAMSV30 (Camera Simple Version) is a DMA Engine which bypasses
ISP3.0 and writes directly to DRAM.
Both SENINF and CAMSV30 are supported by V4L2 drivers.

MT8365 platform consists of a hardware converter called MDP which
supports up to three streams.

Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-02-28 16:57:35 +00:00
Kieran Bingham
25a8d8b8a9 libcamera: formats: Fix planes bounds check
The plane validation in the stride helper incorrectly accepts the number
of planes as a plane index. Fix the off by one issue.

Fixes: e83727a194 ("libcamera: PixelFormatInfo: Add functions stride and frameSize")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-02-28 11:09:02 +00:00
Laurent Pinchart
f26e75fd0f libcamera: formats: Fix typos in PixelFormatInfo documentation
The PixelFormatInfo documentation has typo. Fix two of them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2024-02-27 15:39:28 +02:00
Laurent Pinchart
dae4a44067 libcamera: Use utils::to_underlying()
Replace manual implementations of the utils::to_underlying() helper with
calls to the function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2024-02-27 11:48:44 +02:00
Laurent Pinchart
6a50c960be libcamera: utils: Add to_underlying() helper function
C++23 has a std::to_underlying() helper function that converts an
enumeration value to its underlying type. Add a compatible
implementation to the libcamera::utils namespace.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2024-02-27 11:47:48 +02:00
Paul Elder
059bbcdc34 ipa: rkisp1: Support the i.MX8MP ISP version
Handle the RKISP1_V_IMX8MP version in the rkisp1 IPA. This enables basic
support of the i.MX8MP, excluding the processing blocks specific to the
new ISP version. Those will be supported later.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-02-23 15:18:34 +02:00
Laurent Pinchart
a5e6b7f0db ipa: rkisp1: Fix histogram weights configuration
The histogram weights are initialized to hardcoded 1's for each
histogram grid cell. The code uses the wrong variable for the grid size,
resulting in some weights having a 0 value. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-02-23 15:12:42 +02:00
Laurent Pinchart
528dc21b09 ipa: rkisp1: Store hardware parameters in IPA context
Versions of the ISP differ in the processing blocks they include, as
well as in the implementation of some of those blocks. In particular,
they have different numbers of histogram bins oe AE statistics cells.
The algorithms take these differences into account by checking the ISP
version reported by the driver.

These checks are currently scattered in multiple places. Centralize them
in the IPARkISP1::init() function, and store the version-dependent
hardware parameters in the IPA context, accessible by all algorithms.

While at it, drop the IPASessionConfiguration::hw member that stores the
revision number, unused by the algorithms. It can be added back laer to
the IPAHwSettings structure if needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-02-23 15:12:33 +02:00
Laurent Pinchart
971c4904ff ipa: rkisp1: agc: Wrap variable length C arrays in spans
The RkISP1 statistics structure contains multiple arrays whose length
varies depending on the hardware revision. Accessing those arrays is
error-prone, wrap them in spans at the top level to reduce risks of
out-of-bound accesses.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2024-02-23 15:12:15 +02:00
David Plowman
366077c4db pipeline: rpi: vc4: Use an unpacked format if no packed one is available
When validating a stream, and no valid packed pixel format can be
found, see if an unpacked format can be used instead.

This is particularly helpful for 8 (and 16) bit raw formats, where
asking for a packed format would previously have failed. Now the
configuration will be adjusted to give you a format (in fact, the only
format) that will work.

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>
2024-02-23 15:12:15 +02:00
Nicolas Dufresne
38d28cc5fc gstreamer: Map 10/12/14/16 bayer formats supports
These formats are now defined in upstream GStreamer main branch, so it
is now safe to use their names. Note that libcamera only supports little
endian variants of these formats.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-02-02 11:33:13 +02:00
Nicolas Dufresne
05894d2652 gstreamer: Map R8/R16 pixel format
This enables monochrome support in libcamerasrc.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-02-02 11:33:09 +02:00
Laurent Pinchart
6f1bd9cf55 libcamera: object: Add and use thread-bound assertion
Several functions in libcamera classes are marked as thread-bound,
restricting the contexts in which those functions can be called. There
is no infrastructure to enforce these restrictions, causing difficult to
debug race conditions when they are not met by callers.

As a first step to solve this, add an assertThreadBound() protected
function to the Object class to test if the calling thread context is
valid, and use it in member functions of Object subclasses marked as
thread-bound. This replaces manual tests in a few locations.

The thread-bound member functions of classes that do not inherit from
Object are not checked, and neither are the functions of classes marked
as thread-bound at the class level. These issue should be addressed in
the future.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:22 +02:00
Laurent Pinchart
56f817892c libcamera: object: Document and ensure Object deletion constraints
Object instances are meant to be deleted from the thread they are bound
to, and this requirement is documented. There are however exceptions to
the rule, as threads may be stopped and restarted, with objects bound to
them not being deleted and recreated for every stop/restart cycle. Bound
objects may therefore need to be deleted after the thread has stopped,
making it impossible to use Object::deleteLater().

Document the lifetime requirements more precisely, and enforce them with
an assertion.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:21 +02:00
Laurent Pinchart
f422624d9c libcamera: thread: Ensure deferred deletion of all objects before stopping
Objects can be scheduled for deletion with Object::deleteLater(), which
queues a deferred deletion to the thread's event loop. As the
deleteLater() function is meant to be called from a different thread,
this may race with thread termination, and deferred deletions queued
just before calling Thread::exit() may not be processed by the event
loop. Make sure they get processed when finishing the thread, before
stopping.

This eliminates the race condition that occurs when calling
Object::deleteLater() followed by Thread::exit() from the same thread.
Calling deleteLater() from neither the thread the object is bound to or
the thread calling Thread::exit() is still inherently racy.

The change fixes a failure in the object-delete unit test.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:39:05 +02:00
Laurent Pinchart
d5c9b726bd libcamera: signal: Replace object.h inclusion with forward declatation
The signal.h header doesn't need to include object.h. Replace it with a
forward declaration, and instead include object.h in source files that
require it. It can speed up compilation a little bit, but more
importantly avoids unintended dependencies from the Signal class to the
Object class to be added later as the compiler will catch them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:38:59 +02:00
Laurent Pinchart
fc4ded714d libcamera: object: Fix thread-bound reference in documentation
The Object::message() function is documented as thread-bound without
using the correct \threadbound reference. Fix it to ensure it gets
included in the thread safety context list.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-01-25 02:38:58 +02:00
Paul Elder
64502c8d4a apps: common: dng_writer: Add a default case for switch-case on a modulo
Clearly all cases in the switch are already satisfied, but some
compilers fail to realize this and spit out an error:

Compiler version: gcc 11.2.0 "aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2021.11) 11.2.0"

../../src/apps/common/dng_writer.cpp: In function ‘void thumbScanlineIPU3(const FormatInfo&, void*, const void*, unsigned int, unsigned int)’:
../../src/apps/common/dng_writer.cpp:277:55: error: ‘val4’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;
      |                                                       ^~~~
../../src/apps/common/dng_writer.cpp:277:48: error: ‘val3’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;
      |                                                ^~~~
../../src/apps/common/dng_writer.cpp:277:41: error: ‘val2’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;
      |                                         ^~~~
../../src/apps/common/dng_writer.cpp:277:34: error: ‘val1’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  277 |                 uint8_t value = (val1 + val2 + val3 + val4) >> 10;
      |                                  ^~~~

Add a default case for the switch-case on a modulo to silence this.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=207
Signed-off-by: Paul Elder <paul.elder@ideasonboard.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>
2024-01-24 17:29:24 +02:00
Kieran Bingham
4d9eac1a68 libcamera: v4l2_subdevice: Explain sort order of formatInfoMap
The sort order used in the table isn't obvious. Reference the source of
linux/media-bus-format.h at the top of the table for reference for
future updates.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 17:17:09 +00:00
Kieran Bingham
d11c6359b5 libcamera: bayer_format: Add Y12 to bayerToFormat
Support for Mono 12-bit formats were added to the mbusCodeToBayer table
without supplying the corresponding entry for converting the other way.

Add the relevant entry to the bayerToFormat table.

Fixes: ec63095716 ("libcamera: bayer_format: Add unpacked mono 12-bit format to the conversion table")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 17:17:09 +00:00
Kieran Bingham
f87e4c3908 libcamera: formats: Fix sort ordering of R10_CSI2P
Move formats::R10_CSI2P to be grouped with the formats::R10 counterpart
and keep the section of format declarations sorted in increasing bit
depth.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 17:17:09 +00:00
Naushir Patuck
2ab8b8d48a libcamera: formats: Add 16-bit mono format
Add the relevant definitions for a 16-bit mono pixel and media-bus
format.

Signed-off-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: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 17:17:09 +00:00
Laurent Pinchart
6fb55e1e70 libcamera: Remove empty formats.c
Commit e0a51061bc ("libcamera: formats: Add 14-bits Bayer RAW
formats") added an empty formats.c file by mistake (and we failed to
catch it during review). Delete it.

Fixes: e0a51061bc ("libcamera: formats: Add 14-bits Bayer RAW formats")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 02:21:39 +02:00
Elias Naur
0dc737d3e3 pipeline: rpi: Always initialize the embedded buffer in tryRunPipeline
Vc4CameraData::findMatchBuffers() may return successfully with a null
embedded buffer, in which case the embedded buffer id would be left
uninitialized.

Without this change, libcamera v0.2.0 usually crashes for me with an
assertion error:

 ipa_base.cpp:397 assertion "it != buffers_.end()" failed in prepareIsp()

Signed-off-by: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-01-23 02:21:39 +02:00
Nicolas Dufresne
ebc396fc7a gstreamer: Add meson devenv support
This change to the build system will prepend the plugin build directory
to GST_PLUGIN_PATH environment. This makes the built plugin visible to
GStreamer inside meson devenv enabling uninstalled testing. In order to
avoid polluting the user registry, the GST_REGISTRY environment is also
set.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-23 02:21:39 +02:00
Neal Gompa
fdd479dd63 libcamera: base: signal: Update Qt documentation link to Qt 6
The documentation is effectively the same, but we should be pointing
to the actively supported and used Qt version.

Signed-off-by: Neal Gompa <neal@gompa.dev>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-01-22 09:43:59 +02:00
Laurent Pinchart
0d99f2de13 libcamera: v4l2_subdevice: Enable streams API when supported
The streams API needs to be enabled explictly by setting a subdev client
capability. Do so unconditionally for subdevs that expose streams
support. We don't need any kernel version check to use the
VIDIOC_SUBDEV_S_CLIENT_CAP ioctl, as it is guaranteed to be supported by
kernels that support streams.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-17 19:36:59 +02:00
Laurent Pinchart
439cfe7fbd libipa: camera_sensor_helper: Mark createInstance() with override
The CameraSensorHelperFactory::createInstance() function overrides a
virtual function from CameraSensorHelperFactoryBase. The function
declaration doesn't mark it with the override keyword. This could cause
issues in the future if the base class' function changes, as the
compiler will not issue any warning in that case. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-12 12:49:20 +02:00
Daniel Scally
effb8f5d7c libcamera: geometry: Correct doxygen reference to classes
The classes Rectangle, Size and SizeRange are referenced with \struct in
the doxygen comments in geometry.cpp. Correct the reference to \class
to better reflect their definition.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
David Plowman
d8a17149cb ipa: rpi: vc4: data: Update tuning files for HDR
All the Raspberry Pi official camera tuning files are updated for
HDR. As stated previously, there is no mechanism in the hardware for
combining images so all this does is enable multi-channel AGC to
produce short and long exposure frames. It will be up to the
application to deal with them.

The changes are identical in every tuning file.

1. The existing AGC tuning is duplicated twice so that we have 3 AGC
channels.

2. The first is left alone (the default AGC channel), the second is
tweaked to under-expose significantly (ev -3) and the final one is
tweaked to over-exposure slightly (ev +0.5)

3. Control parameters are provided to the "rpi.hdr" algorithm to
associate these AGC channels correctly with the HDR modes.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-01-09 15:39:04 +00:00
David Plowman
7ba0053ede ipa: rpi: Implement HDR control
Sufficient plumbing is added so that the HDR mode control can be used
to engage HDR modes on platforms that support them. On the vc4
platform, this allows multi-channel AGC to run, though there is no
image merging.

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>
2024-01-09 15:39:04 +00:00