Commit Graph

5891 Commits

Author SHA1 Message Date
Stefan Klug
a111bb6903 libcamera: Add transpose() function to size
Add a transpose() function to size that applies the
Transformation::Transpose operation in the size. This is useful when
handling orientation adjustments.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:30 +01:00
Stefan Klug
9df164fa42 libcamera: internal: camera_sensor: Add accessor for mountingOrientation_
To properly handle the orientation in the dewarper, the mounting
orientation of the sensor needs to be queryable. Add that.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
ff1908a7a1 pipeline: rkisp1: Enable the dewarper based on the tuning file
To do actual lens dewarping, the dewarper will be configured based on
the tuning file.

As a first step implement the basic loading of the
tuning file and enable/disable the dewarper for the given camera based
on the existence of the "Dewarp" entry under a new top level element
'modules' in the tuning file.

Note: This is an backwards incompatible change in that the dewarper is
currently included in the chain unconditionally. Some users may want to
not use the dewarper, so it is sensible to make that configurable.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
ef14661487 pipeline: rkisp1: Drop rawFormat variable
In raw mode we know there is only a single configuration so there
is no need to iterate over all configurations to find the format.
Drop that.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
fa78167e3a pipeline: rksip1: Move isRaw up in scope
In raw mode the number of configurations is actively limited to 1. It is
therefore safe to move isRaw up one level to simplify the code and
prepare for later use.

During that rework it was noticed that the old code actually has a bug
in that it reduces the number of configurations to 1 in case a raw
config is found, but it doesn't reduce the config vector to that raw
config, but the first config.

Change that behavior to check the first config and either remove all
remaining configs if the first is raw or drop all raw configs if the
first is non-raw.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
13e5c71294 libcamera: rkisp1: Use the dw100 converter module instead of the generic v4l2 converter
The dewarper integration into the rkisp1 pipeline is quite complicated.
Simplify that by switching to the now available ConverterDW100Module. As
there is no other known converter in combination with the rkisp1 ISP this
is a safe step to do.

This change also paves the way to implement dw100 specific features later.

The input crop implemented in the dw100 kernel driver is quite limited
in that it doesn't allow arbitrary crop rectangles but only scale
factors quantized to the underlying fixed point representation and only
aspect ratio preserving crops.

The vertex map based implementation allows for pixel perfect crops. The
only downside is that ScalerCrop can no longer be set dynamically on
older kernels. A corresponding warning is already implemented in the
converter module.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
ffde6b28f3 libcamera: converter: Add dw100 converter module
The DW100 Dewarp engine is present on i.MX8MP SoC and possibly others.
This patch provides a dedicated converter module that allows easy
integration of such a dewarper into a pipeline handler.

In this patch only the ScalerCrop control is implemented. Support for
additional functionality will be added in later patches.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
b48d41a853 libcamera: converter: Add dw100 vertex map class
Using a custom vertex map the dw100 dewarper is capable of doing
complex and useful transformations on the image data. This class
implements a pipeline featuring:
- Arbitrary ScalerCrop
- Full transform support (Flip, 90deg rotations)
- Arbitrary move, scale, rotate

ScalerCrop and Transform is implemented to provide a interface that is
standardized libcamera wide. The rest is implemented on top for more
flexible dw100 specific features.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
19cbbd65fe pipeline: rkisp1: Fix number of buffers imported into the dewarper
When the dewarper is used, an addition buffer loop with
kRkISP1MinBufferCount buffers is created between ISP and dewarper. When
the dewarper is configured, it stores the bufferCount value of the
requested stream configurations. This number of buffers is then imported
when the dewarper is started.

On the input stream of the dewarper the bufferCount is currently left
unchanged, meaning it carries the bufferCount as supplied by the user
instead of the bufferCount of the additional loop. Fix that by setting
the bufferCount to kRkISP1MinBufferCount.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
d5c6e78a60 libcamera: rkisp1: Allow upscaling when the dewarper is present
When the dewarper is present, there is no need to forbid upscaling of
the image data.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
ca20801aa1 libcamera: rkisp1: Scale down in dewarper instead of resizer
In order to allow digital zooming, scale down in the dewarper instead of
the resizer. That means forwarding the full sensor size data to the
dewarper. The ScalerCrop rectangle will also be applied at the dewarper.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
852491e420 libcamera: rkisp1: Move useDewarper_ flag into RkISP1CameraData
The decision if the dewarper shall be used is not per pipeline but per
camera and per configuration (raw streams can't use it). Move the
corresponding flag into the camera data class. Rename the flag to
"usesDewarper" which is easier understand when we later add the ability
to enable/disable the dewarper on a per camera basis which will be
expressed using a "canUseDewarper" flag.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Stefan Klug
46ded9a8da libcamera: converter_v4l2_m2m: Add debug logging for formats
Getting the requested input/output format is crucial for debugging. Add
log statements for that.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2025-11-26 17:39:29 +01:00
Umang Jain
801c3c3010 libcamera: converter_v4l2_m2m: Add helper to apply controls
Add applyControls() helper to apply controls for a stream.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2025-11-26 17:39:28 +01:00
Xavier Roumegue
ae4cd6e427 include: linux: Update headers for Dw100 dewarper engine
Include the DW100 dewarper header as part of linux headers.
It will be used to set the V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP
control by ConverterDW100

Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-11-26 17:39:28 +01:00
Stefan Klug
0b0f32e736 libcamera: rkisp1: Properly cancel buffers in dewarp case
In case the buffer returned from the ISP was canceled, the upstream
buffer was not correctly marked as canceled. Move the cancel
functionality into an own helper function and correctly cancel the
upstream buffers. Add missing cancellation in case queuing to the
dewarper fails.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2025-11-26 17:39:28 +01:00
Stefan Klug
0d48cb6bb0 libcamera: converter_v4l2_m2m: Always set stride
Ensure the stride is properly set after a call to validateOutput().

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2025-11-26 17:39:28 +01:00
Stefan Klug
6d8109f4f1 libcamera: converter_v4l2_m2m: Add suport for V4L2 requests
To actually use requests with the m2m device, requests need to be
allocated on the underlying media device. This can only be done if the
media device is opened which means acquiring it. Add a function to check
if the m2m device supports requests by acquiring the media device,
asking it and then releasing it again. Also add a function to allocate
requests that acquires the internal media device and releases it after
allocating the requests.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:28 +01:00
Stefan Klug
041625628c libcamera: converter: Add V4L2 request support
Add V4L2 request support to the V4L2M2MConverter class. Extend the
functions related to buffer queuing with an optional request parameter
that gets passed to the lower layers.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2025-11-26 17:39:28 +01:00
Stefan Klug
cdc2620549 libcamera: Add support for V4L2 requests
The V4L2 requests API provides support to atomically tie controls to a
set of buffers. This is especially common for m2m devices. Such a
request is represented by an fd that is allocated via
MEDIA_IOC_REQUEST_ALLOC and then passed to the various V4L2 functions.

Implement a V4L2Request class to wrap such an fd and add the
corresponding utility functions.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 17:39:20 +01:00
Stefan Klug
39c052c1e9 libcamera: converter: Utilise shared MediaDevice pointers
With the upcoming addition of V4L2 requests support, the converters need
to keep a handle to the corresponding media device.

Prepare for that by changing the constructor parameter from a raw
pointer to a shared pointer.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2025-11-26 16:33:52 +01:00
Kieran Bingham
97227ebed3 libcamera: pipeline: Utilise shared MediaDevice pointers
Adapt the PipelineHandler::acquireMediaDevice() support function to
return a shared pointer instead of the underlying raw pointer.

Propagate this update to all pipeline handlers that use the MediaDevice
and store a std::shared_ptr<MediaDevice> accordingly.

This is required to support media devices that are potentially shared
among multiple pipeline handlers, like a dewarper implemented as v4l2
m2m device.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2025-11-26 16:33:41 +01:00
Stefan Klug
4e720d5bae ipa: libipa: agc_mean_luminance: Fix yTarget handling in constraints
The yTarget loading code is broken and works neither for plain values
nor for arrays of values to form a PWL. Fix this by supporting both
cases. If a list is provided in the tuning file construct a PWL,
otherwise construct a single point PWL with the given value.

Fixes: 24247a12c7 ("ipa: libipa: Add AgcMeanLuminance base class")
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-25 17:47:30 +01:00
Stefan Klug
3ed8dabe5a ipa: libipa: agc_mean_luminance: Change luminance target to piecewise linear function
In some situations it is necessary to specify the target brightness
value depending on the overall lux level. Replace the float
relativeLuminanceTraget by a PWL. As the PWL loading code loads a plain
value as single point PWL, backwards compatibility to existing tuning
files is ensured.

While at it, order the class members in reverse xmas tree notation.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 17:47:16 +01:00
Stefan Klug
7dd713ba2e ipa: rkisp1: lux: Properly handle frame context and active state
With the upcoming regulation rework the processing order in the IPA is
updated a bit so that process() updates the active state with new
measurements and fills the metadata with the data from the corresponding
frame context. In prepare() all parameters for one frame are tied
together using the most up to date values from active state.

Change the lux algorithm to support that order of events. Also prepare
for cases where stats can be null which can happen with the upcoming
regulation rework.

While at it fix a formatting issue reported by checkstyle and drop a
unnecessary local variable.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 17:42:34 +01:00
Stefan Klug
3b4414ccaa ipa: libipa: pwl: Allow to parse a plain yaml value as single point PWL
In the tuning files, it is useful to specify some values as PWL that
produces a different output value depending on an input value. For
example it is useful to specify the relativeLuminanceTarget depending on
the lux level, so that the regulation regulates a bit darker in low
light scenes. For simple setups this is not necessary and a single value
is sufficient.

This patch extends the yaml loading code, so that a single point PWL can
also be specified as a plain value. This way the following yaml
expressions are all valid:

yTarget: [ 1000, 0.15, 2000, 0.17 ]  # Regular PWL
yTarget: [ 0, 0.17 ]                 # Single point PWL
yTarget: 0.17                        # Same as above

For cases (I'm not aware of any) where a single point Pwl is not allowed
there is no change as that must be checked externally anyways.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
2025-11-25 17:40:38 +01:00
Stefan Klug
dadeb67fcc libipa: exposure_mode_helper: Set quantizationGain in absence of a sensor helper
In commit f077c58e08 ("libipa: exposure_mode_helper: Take
exposure/gain quantization into account") calculation of the
quantization gain was added to ExposureModeHelper::clampGain(). This
works as expected when a sensor helper is configured but the gain is not
reset to 1.0 in case the sensor helper is not configured. This leads to
incorrect gain calculations in ExposureModeHelper::splitExposure() as
that expects the quantization gain to be valid in any case. Fix that by
setting the quantization gain to 1.0 in case no sensor helper is
configured.

Fixes: f077c58e08 ("libipa: exposure_mode_helper: Take exposure/gain quantization into account")
Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/292
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-25 17:32:50 +01:00
Umang Jain
5d8f4d0a20 lc-compliance: Ensure stream's colorspace is set after validate()
StreamConfiguration::colorspace is a std::optional<> and if unset by
the user, it should be populated by the pipeline handler after the
CameraConfiguration::validate().

Add a EXPECT_TRUE() check to ensure that each stream in the
CameraConfiguration has a colorspace set.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 16:16:48 +00:00
Umang Jain
5d2d005306 pipeline: virtual: Provide and validate colorspace
Virtual pipeline handler should provide colorSpace in
generateConfiguration() and validate the colorspace in validate().
It is mandatory for a pipeline handler to set the colorspace if it
is unset in the stream configuration, during validate().

For choosing the colorspace for the generated NV12 frames, following
points have been taken into account:
- The transfer function should be Rec.709 for NV12
- The YCbCr encoding has been chosen Rec.709 as it is the most common
  than Rec.601/Rec.2020
- Range should be 'Limited' as with the NV12 pixel format.

Hence, the closest colorspace match is ColorSpace::Rec709 which is
set for the virtual pipeline handler.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Robert Mader <robert.mader@collabora.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 16:16:48 +00:00
Umang Jain
7e8c274d18 libcamera: simple: Detect Bayer pattern change during configure()
Bayer pattern on the sensor can change while configuring it with the
intended capture format. This is due to the transform being applied on
the sensor which supports [v/h]flips.

During configure(), the simple pipeline handler does not detect any
bayer pattern changes that can arise due to the transformations being
applied via SimpleCameraData:setupFormats(). In such cases, the video
node will be configured in-correctly, without realising the bayer
pattern has changed on the sensor, for the given capture format.

This patch detects the bayer pattern change after the sensor has
been configured and retrieves the corresponding V4L2 pixel format
to correctly configure the video node and the input to converter or
Soft-ISP.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 16:16:47 +00:00
Kieran Bingham
18732fecf1 Documentation: contributing: Update Source references
The libcamera project is no longer in 'early' stages of development, and
we do make releases.

Update the Source Code section to reflect this reality and report on the
current expectations of release numbering schemes.

Furthermore update the development mirror as hosted on Freedesktop and
deprecate the LinuxTV mirror, as Freedesktop also hosts our release tar
balls and CI infrastructure.

Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 12:02:55 +00:00
Kieran Bingham
51b1740014 Documentation: contributing: Update issue tracker
The issue tracker no longer resides at bugs.libcamera.org.

While this URL is still available and redirects to the new tracker,
update the documentation to point to the canonical address.

Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 12:02:55 +00:00
Kieran Bingham
210a67f8b9 Documentation: contributing: Provide a reference to Matrix
The libcamera IRC channel is bridged to Matrix which provides
a convenient way to stay connected to the room.

Provide a link to join via matrix.

Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-25 12:02:52 +00:00
Isaac Scott
43ab0d487b libipa: module: Allow algorithms to be disabled via the tuning file
It is beneficial to have the option during development to disable and
enable algorithms via the tuning file without having to delete their
entries.

Add support for an optional "enabled" parameter to accomplish this.

Usage example:
version: 1
algorithms:
  - Agc:
      enabled: true
  - Awb:
      enabled: false

This will enable AGC, and disable AWB. If the enabled flag is not
present, the algorithm will be enabled.

Signed-off-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Kieran: Reflow text]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-24 17:29:11 +00:00
Milan Zamazal
5a33bc10e9 libcamera: software_isp: Assign colour spaces in configurations
StreamConfiguration's should have colorSpace set.  This is not the case
in the simple pipeline.  Let's set it there.  This also fixes a crash in
`cam' due to accessing an unset colorSpace.

We set the colour spaces according to the pixel format.  This is not
completely correct because pixel formats and colour spaces are
different, although not completely independent, things.  But for the
lack of a better practical option to determine the colour space, we use
this.

Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/294
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-21 17:25:09 +00:00
Barnabás Pőcze
037960d8b3 libcamera: ipa_data_serializer: Add specialization for enums
Instead of handling enums specially in the code generation templates,
create a specialization of `IPADataSerializer` that handles enums.

Every enum is serialized as a `uint32_t`, with `static_assert` to
ensure that every possible value fits. Previously, enums were
(de)serialized in `(de)serializer_field()` based on the size of
their underlying types. Afer this change, every enum is uniformly
handled as a `uint32_t`.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-21 15:52:23 +01:00
Barnabás Pőcze
4f8b1290e4 libcamera: request: Store fence EventNotifier directly
Simplify a bit by storing the `EventNotifier` objects directly in the
`std::map` instead of wrapping them in unique_ptr. An other advantage
is that it removes one allocation per fence.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-21 15:40:27 +01:00
Barnabás Pőcze
eca695f291 libcamera: pipeline: uvcvideo: Reject sensor configuration
The UVC pipeline handler cannot set the sensor configuration so if the
desired `CameraConfiguration` specifies one, then reject it.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-21 11:49:05 +01:00
Barnabás Pőcze
ebda108111 libcamera: base: thread: Use acquire memo. when reading event dispatcher
Use `std::memory_order_acquire` everywhere the dispatcher is loaded
to guarantee synchronization with the release-store that places
the pointer there.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-11-21 10:24:55 +01:00
Barnabás Pőcze
d971584579 apps: cam: sdl_texture: Support NV21
SDL also supports NV21 with the same `SDL_UpdateNVTexture()`,
so add support for it.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-21 09:28:16 +01:00
Stefan Klug
731a340c80 libcamera: pipeline_handler: Fix requestComplete on waiting requests on stop
The requestComplete signal is not emitted when the camera is stopped and
the request is still in the waitingRequests_ queue. Fix that by calling
doQueueRequest() on the waiting requests after marking them as
cancelled. This ensures that the requests gets a proper sequence number
and are added to the queuedRequests_ list. This list is then iterated in
completeRequest() and leads to the requestComplete signal.

Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/281
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-11-19 14:25:52 +01:00
Kieran Bingham
517b863bae pipeline: simple: Reduce warning of unknown pixel formats
The Simple Pipeline is designed to support a wide variety of pipeline
configurations and attached devices and will enumerate the pixel formats
of the connected sensors to map these to libcamera formats where
available.

In fixed pipelines, where the pixel format is not mapped correctly it is
a desired behaviour to express this warning so that the pixelformat can
be added, while in the simple-pipeline case we do not expect warnings
for every discovered pixel format which is not supported by libcamera.

This currently manifests itself as very highly verbose warnings about
unsupported pixel formats are not desired when there are working formats
that have already been enumerated.

Fortunately in commit 434edb7b44 ("libcamera: formats: Fix warning for
unknown V4L2 pixfmt") we have a mechanism to disable the warning for
occasions where we wish to ignore unsupported formats.

Use this feature to disable the warning in the core V4L2PixelFormat and
instead report only a debug level print from the simple pipeline
handler.

On devices such as the Pinephone, this removes overly verbose warnings
for tiled YUV formats:

[0:06:39.291083146] [1922] ERROR SimplePipeline simple.cpp:1600 No valid pipeline for sensor 'gc2145 0-003c', skipping
[0:06:39.302229740] [1922]  WARN V4L2 v4l2_pixelformat.cpp:346 Unsupported V4L2 pixel format HM12
[0:06:39.302779117] [1922]  WARN V4L2 v4l2_pixelformat.cpp:346 Unsupported V4L2 pixel format HM12
[0:06:39.303417578] [1922]  WARN V4L2 v4l2_pixelformat.cpp:346 Unsupported V4L2 pixel format HM12
[0:06:39.303928998] [1922]  WARN V4L2 v4l2_pixelformat.cpp:346 Unsupported V4L2 pixel format HM12
[0:06:39.304615751] [1922]  WARN V4L2 v4l2_pixelformat.cpp:346 Unsupported V4L2 pixel format HM12

Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/291
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-19 12:50:36 +00:00
Milan Zamazal
443e5a6c31 libcamera: software_isp: Fix gamma table when CCM is used
Software CPU ISP computes a gamma lookup table.  The table incorporates
black level and contrast.  All entries in the table below the black
level are set to 0.  This is not necessarily correct all the time.

Let's consider this case: The CCM is

  [1 0 0]
  [0 1 0]
  [0 0 0]

and contrast is set to zero.  The gamma table has all the entries above
the black level set to 186 (due to zero contrast) and all the entries
below the black level set to 0.  CCM is applied before gamma, a
non-black level pixel has the blue component set to 0 with the CCM
above.  Now, when the gamma lookup is applied, the red and green
components are set to 186, while the blue component is set to 0.  The
resulting pixel is then yellow rather than grey (as it should be with
zero contrast).

There are two ways to fix this: Either clamping pixel colour channels to
the black level in debayering or setting the below black level entries
in the gamma lookup table to the lowest value of the gamma table rather
than 0.  Both should have the same effect.  Let's opt for the latter for
its simplicity.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-19 10:38:08 +00:00
Barnabás Pőcze
b9fd53fbef treewide: Use argparse.FileType in more places
Convert some scripts to use `argparse.FileType` where the change is relatively
easily doable. This allows better error messages as e.g. missing input files
will be detected during argument parsing. And it also makes writing to stdout
in absence of an explicit argument simpler.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-11-17 09:19:36 +01:00
Barnabás Pőcze
901aae13c1 py: gen-py-formats.py: Open input file in binary mode
Other code generation scripts do that already and let pyyaml deal with
decoding utf-8, etc. So do the same here as well.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-11-17 09:19:23 +01:00
Rui Wang
30779421e8 ipa: rkisp1: dpf: Enable strength after enable Dpf
The filter strength configuration block was previously only enabled on the
first frame (frame == 0). Apply the strength values when denoise is active.
This prevents the strength config from being disabled on subsequent frames.

Signed-off-by: Rui Wang <rui.wang@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-11-14 22:03:22 +01:00
Laurent Pinchart
6d19c813b0 subprojects: libyuv: Bump to version 1922
The libyuv wrap uses a libyuv commit between versions 1770 and 1772,
more than 5 years old. This specifies CMake 2.8 as the minimum required
version.

The most recent CMake has dropped compatibility with versions older than
3.5 in CMake 4.0. CMake 3.5 was released in 2016, and all distributions
we care about ship more recent versions. With CMake 4.0 or newer,
shipped for instance by Gentoo, compilation of the libyuv wrap fails.

Update the wrap to version 1922, which is the latest numbered version
(libyuv doesn't tag release by increases a version number in the
README.chromium file). This requires CMake 3.16, released 6 years ago,
and available in at least the last two LTS of major distributions.

This update introduces two issues. First, due to a bug in Meson (see
https://github.com/mesonbuild/meson/issues/10764), PIC handling is
broken when a CMake project wraps a static library into another static
library that has no additional source file. Work around it by wrapping
the libyuv static library again, manually setting 'pic' to true.

The second issue is that libyuv fails to compile for armhf platforms
that don't support NEON instructions. This is the case on Debian 12 and
13 that ship armhf toolchains with NEON disabled by default. The issue
causes CI failures. As the libyuv wrap is a convenience measure, disable
NEON optimization on armfd platforms the same way Debian does in its
armhf packages. If NEON support is important, the build environment
should provide a suitable libyuv.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-13 12:17:16 +02:00
Andrei Gansari
9ece9a1525 pipeline: imx8-isi: Delay ISI routes config to acquire() time
Fixes behavior when calling 'cam -l' during a live stream from a camera
in another process.

Issue is that multiple process should be able to list (match procedure)
the camera supported. But only the unique process that lock the media
devices in order to be able to configure then start the pipeline should
setup the routes, graphs, etc.

Thus, the setRouting() is to be moved to a PipelineHandlerISI::acquireDevice()
implementation to override the default Pipeline::acquireDevice() function.

Fixes: 92df79112f ("pipeline: imx8-isi: Add multicamera support")
Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-11 18:37:55 +00:00
Antoine Bouyer
48b2b7928c libcamera: pipeline_handler: Add accessor for useCount_
Add an accessor for useCount_ parameter, so that PipelineHandler
child classes can access it to verify whether the media device
is already locked or not.

Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
[Kieran: fix extraneous ;]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-11 18:37:36 +00:00
Barnabás Pőcze
485c50033c utils: checkstyle.py: Accept Closes commit trailer
`Closes: <url>` is recognized by gitlab[0] and closes the referenced issue
automatically when a commit is made to the project's default branch. Now
that issues are hosted on gitlab, it will be the preferred way to reference
the fixed issue from a commit, so replace the previously used `Bug` with it
in the checkstlye.py script.

[0]: https://docs.gitlab.com/user/project/issues/managing_issues/#default-closing-pattern

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-11-11 13:10:02 +01:00