Commit Graph

5937 Commits

Author SHA1 Message Date
Jacopo Mondi
9cd85ca867 include: linux: v4l2-controls.h: Update to v6.18
Update v4l2-controls.h to Linux kernel version v6.18.

No conflicts between downstream symbols and newly added ones.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-12-15 11:24:15 +01:00
Jacopo Mondi
e7c69915ba include: linux: media-bus-format.h: Update to v6.18
Update media-bus-format.h to Linux kernel version v6.18.

Mainline has introduced two new media bus codes whose definition
conflicts with the downstream definition of
MEDIA_BUS_FMT_RGB202020_1X60.

Update the definition of MEDIA_BUS_FMT_RGB202020_1X60 not to conflict
with the newly added symbol.

MEDIA_BUS_FMT_RGB202020_1X60, which is used by the Mali C55 ISP,
will land in v6.19 with value 0x1028, so this change actually
aligns the downstream definition with the forthcoming upstream
support for Mali C55.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-15 11:24:15 +01:00
Jacopo Mondi
5ab66fa728 include: linux: intel-ipu3.h: Update to v6.18
A rather simple update to Linux v6.18.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-12-15 11:24:15 +01:00
Jacopo Mondi
673e56ea67 include: linux: drm_fourcc.h: Update to v6.18
Update drm_fourcc.h to Linux kernel version v6.18.

As the upstream drm_fourcc.h version doesn't include definitions
for RAW Bayer formats, some of the symbols we defined
downstream now conflict with new symbols defined in mainline.

In particular, mainline has added:
 #define DRM_FORMAT_MOD_VENDOR_MTK     0x0b
 #define DRM_FORMAT_MOD_VENDOR_APPLE   0x0c

Which conflict with the downstream definitions:
 #define DRM_FORMAT_MOD_VENDOR_MIPI 0x0b
 #define DRM_FORMAT_MOD_VENDOR_RPI 0x0c

In order not to break the library ABI, maintain the downstream symbols
definitions as they are even if they conflict.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Acked-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-15 11:24:15 +01:00
Milan Zamazal
6293fa3308 libcamera: simple: Make raw streams working
When a raw stream is requested, whether alone or together with a
processed stream, its buffers must be handled outside the software ISP
machinery.  They serve as output buffers, even when a processed stream
is produced.  But when both processed and raw streams are requested, the
buffer can be completed only after the processing is finished, to make
sure it's untouched by the application as long as the processing runs.

At most one raw stream and at most one processed stream are supported
and can be combined.  An example of producing both raw and processed
files using `cam' application:

  cam -c1 -C100 -Ffile# \
    -s role=viewfinder,width=1920,height=1080,pixelformat=RGB888 \
    -s role=raw,width=3280,height=2464,pixelformat=SRGGB8

Note the difference in viewfinder and raw stream sizes due to the fact
that debayering requires enlarging the image width, which enforces
selecting a larger sensor resolution in this case.

In order to track whether a raw stream is requested and which one it is,
SimpleCameraData::rawStream_ member variable is introduced.

This is the final step to make raw streams working.

Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:43 +00:00
Milan Zamazal
3991f02209 libcamera: simple: Require metadata only when software ISP is used
If software ISP is enabled then metadata is required in the simple
pipeline.  But this doesn't apply if the software ISP is not actually
used, for example when only a raw stream is produced.  Then the pipeline
waits for metadata that never comes.

This patch fixes the problem by requiring metadata only when software
ISP is used.

Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:43 +00:00
Milan Zamazal
a19f725695 libcamera: simple: Set the number of software ISP streams to 2
When software ISP is enabled, we want to be able to provide a raw stream
in addition to the processed stream.  For this purpose, we need two
streams.  If only the processed stream is requested, it doesn't harm to
allocate two.

The number of streams is determined as a camera property in the pipeline
matching.  To be able to produce both raw and processed output, two
streams must be provided.  The actual number of streams needed (one or
two) is determined only in SimplePipelineHandler::validate().

In theory, software ISP could produce multiple processed streams but
this is out of scope of this patch series.  Hence two streams are
sufficient at the moment.

When software ISP is not enabled, the camera won't be able to produce
multiple streams (assuming there's no hardware converter) and only
single stream should be allocated as before.  The simple pipeline
handler assumes there's a linear pipeline from the camera sensor to a
video capture device, and only supports a single stream.  Branches in
the hardware pipeline that would allow capturing multiple streams from
the same camera sensor are not supported.  We have no plan to change
that, as a device that can produce multiple streams will likely be
better supported by a dedicated pipeline handler.

Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:43 +00:00
Milan Zamazal
e9252384f5 libcamera: simple: Don't enforce conversion with an added raw stream
When a raw stream is requested, either alone or together with a
processed stream, it can be produced without conversion.  Let's amend
the corresponding check on the number of configurations, so that the
mere presence of a raw stream doesn't enforce conversion.

Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:43 +00:00
Milan Zamazal
7b068dda96 libcamera: simple: Validate raw stream configurations
SimpleCameraConfiguration::validate() looks for the best configuration.
As part of enabling raw stream support, the method must consider raw
streams in addition to the processed streams.

Raw streams are adjusted from the capture format and size.

Configuration validation computes the maximum size of all the requested
streams and compares it to the output sizes.  When e.g. only a raw
stream is requested then this may result in an invalid adjustment of its
size.  This is because the output sizes are computed for processed
streams and may be smaller than capture sizes.  If a raw stream with the
capture size is requested, it may then be wrongly adjusted to a larger
size because the output sizes, which are irrelevant for raw streams
anyway, are smaller than the requested capture size.  The problem is
resolved by tracking raw and processed streams maximum sizes separately
and comparing raw stream sizes against capture rather than output sizes.

Note that with both processed and raw streams, the requested sizes must
be mutually matching, including resizing due to debayer requirements.
For example, the following `cam' setup is valid for imx219

  cam -s role=viewfinder,width=1920,height=1080 \
      -s role=raw,width=3280,height=2464

rather than

  cam -s role=viewfinder,width=1920,height=1080 \
      -s role=raw,width=1920,height=1080

due to the resolution of 1924x1080 actually selected for debayering to
1920x1080.  If the resolutions don't match mutually or don't match the
available sizes, validation adjusts them.

Setting up the right configurations is still not enough to make the raw
streams working.  Buffer handling must be changed in the simple
pipeline, which is addressed in followup patches.

Co-developed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:43 +00:00
Milan Zamazal
b98f3ee039 libcamera: simple: Handle processed and raw formats separately
Let's handle both processed and/or raw output configurations.  In
addition to the already handled processed formats and sizes, this patch
adds handling of raw formats and sizes, which correspond to the capture
formats and sizes.

When creating stream configurations, raw or processed formats are
selected according to the requested stream roles.

This is another preparatory patch without making raw outputs working.

Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:17 +00:00
Milan Zamazal
2d9b647e56 libcamera: simple: Exclude raw configurations from output conversions
In order to support raw streams, we need to add raw formats to software
ISP configurations.  In this preparatory patch, the raw formats are
excluded from output configurations for conversions.

Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-13 11:29:17 +00:00
Bryan O'Donoghue
5f51e2e545 libcamera: software_isp: lut: Make contrast available in debayer params
Provide the contrast used in IPA to Bayer parameters. Similar to the
calculated Gamma value we will pass this value into the debayer fragment
shader for further consumption.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:53 +00:00
Bryan O'Donoghue
5bfb96661f libcamera: software_isp: lut: Make gamma from lut.cpp available in debayer params
Provide the gamma used in IPA to Bayer parameters. We will pass Gamma into
the shader via a uniform and can then tweak that value from outside at
will.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:53 +00:00
Bryan O'Donoghue
724a29e3cd libcamera: software_isp: blacklevel: Make black level available in debayer params
Populate black level gain in blacklevel::prepare(). A copy is made of the gain
value in the DebayerParams structure.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:53 +00:00
Bryan O'Donoghue
3d7ef342b7 libcamera: software_isp: lut: Make CCM available in debayer params
Provide the CCM calculated in LUT to the debayer params structure for
consumption in the debayer shaders.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:52 +00:00
Bryan O'Donoghue
0640f5ac11 libcamera: software_isp: debayer: Make the debayer_ object of type class Debayer not DebayerCpu
Make the type of object Debayer not DebayerCpu thus allowing us to assign
the object to either DebayerCpu or DebayerEGL.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:52 +00:00
Bryan O'Donoghue
4cb388a1eb libcamera: software_isp: debayer: Introduce a start() / stop() methods to the debayer object
In order to initialise and deinitialise gpuisp we need to be able to setup
EGL in the same thread as Debayer::process() happens in.

This requires extending the Debayer object to provide start and stop
methods which are triggered through invokeMethod in the same way as
process() is.

Introduce start() and stop() methods to the Debayer class. Trigger those
methods as described above via invokeMethod. The debayer_egl class will
take care of initialising and de-initialising as necessary. Debayer CPU
sees no functional change.

Per feedback from Barnabas the stop method is using blocking
synchronisation and thus we drop ispWorkerThread_.removeMessages().

[bod: Made method blocking not queued per Robert's bugfixes]
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:52 +00:00
Bryan O'Donoghue
364886fb13 libcamera: software_isp: Move isStandardBayerOrder to base class
isStandardBayerOrder is useful to both CPU and GPU debayer logic and
reusable as-is for both.

Move to shared location in base class.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:52 +00:00
Bryan O'Donoghue
c9f3e09634 libcamera: software_isp: Make output DMA sync contingent
The DMA sync output buffer from the GPU need only have its cache
invalidated if the CPU is going to modify the buffer. Right now this is
not required for gpuisp so only act on the output buffer if it is
non-null.

Suggested-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:52 +00:00
Bryan O'Donoghue
6b224d91a9 libcamera: software_isp: Move DMA Sync code to Debayer base class
We can reuse the DMA Sync code in the GPUISP. Move the code we need to
the base class.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:51 +00:00
Bryan O'Donoghue
e3c74bbc89 libcamera: software_isp: Move param select code to Debayer base class
Move the parameter selection code into the Debayer base class in-order to
facilitate reuse of the lookup tables in the eGL shaders.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:51 +00:00
Bryan O'Donoghue
cafb39b257 libcamera: software_isp: Move Bayer params init from DebayerCpu to Debayer
Move the initialisation of Bayer params and CCM to a new constructor in the
Debayer class.

Ensure we call the base class constructor from DebayerCpu's constructor in
the expected constructor order Debayer then DebayerCpu.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:51 +00:00
Bryan O'Donoghue
d635cd884e libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class
The DebayerCpu class has a number of variables, embedded structures and
methods which are useful to DebayerGpu implementation.

Move relevant variables and methods to base class.

Since we want to call setParams() from the GPUISP and reuse the code in
the existing CPUISP as a first step, we need to move all of the
dependent variables in DebayerCPU to the Debayer base class including
LookupTable and redCcm_.

The DebayerEGL class will ultimately be able to consume both the CCM and
non-CCM data.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:51 +00:00
Hans de Goede
134f926346 libcamera: swstats_cpu: Add processFrame() method
Add a method to the SwstatsCpu class to process a whole Framebuffer in
one go, rather then line by line. This is useful for gathering stats
when debayering is not necessary or is not done on the CPU.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[bod: various rebase splats fixed]
[bod: Added constructor Doxygen header]
[bod: Squashed a fix from Hans to calculate stats on every 4th frame]
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:51 +00:00
Hans de Goede
bf51f39f3b libcamera: software_isp: Move benchmark code to its own class
Move the code for the builtin benchmark to its own small
Benchmark class.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[bod: Fixed up some drift in this patch since initial propostion]
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:32:50 +00:00
Hans de Goede
4da17de043 libcamera: swstats_cpu: Move header to libcamera/internal/software_isp
Move the swstats_cpu.h file to include/libcamera/internal/software_isp/
so that it can be used outside the src/libcamera/software_isp/ directory.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:07:01 +00:00
Hans de Goede
85cba34493 libcamera: swstats_cpu: Drop patternSize_ documentation
patternSize_ is a private variable and its meaning is already documented
in the patternSize() getter documentation.

Move the list of valid sizes to the patternSize() getter documentation
and drop the patternSize_ documentation.

While at it also add 1x1 as valid size for use with future support
of single plane non Bayer input data.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:07:01 +00:00
Hans de Goede
7092566187 libcamera: swstats_cpu: Update statsProcessFn() / processLine0() documentation
Update the documentation of the statsProcessFn() / processLine0() src[]
pointer argument to take into account that swstats_cpu may also be used
with planar input data or with non Bayer single plane input data.

The statsProcessFn typedef is private, so no documentation is generated
for it. Move the new updated src[] pointer argument documentation to
processLine0() so that it gets included in the generated docs.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:07:01 +00:00
Bryan O'Donoghue
ab675bc06b meson: Automatically generate glsl_shaders.h from specified shader programs
Encode the bayer shader files into a header as part of the build process.
Qcam already compiles the shader files down into a QT resource file which
it references internally.

In order to share the debayering shader programs outside of qcam create a
generic header which both qcam and libcamera can operate from.

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:07:01 +00:00
Bryan O'Donoghue
19371dee41 utils: gen-shader-headers: Add a utility to generate headers from shaders
Two simple script to generate a header that contains GLSL shaders translated
to C arrays.

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:07:01 +00:00
Bryan O'Donoghue
8e5a669b29 libcamera: shaders: Move GL shader programs to src/libcamera/assets/shader
Moving the vertex and fragment shaders to src/libcamera/shaders to
allow for reuse of these inside of the SoftISP.

A comment has been added to src/apps/qcam/meson.build to force a
rebuild.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-12 23:07:01 +00:00
Milan Zamazal
0a9cf7e0eb libcamera: simple: Move colour space logging after adjustment
The log message about adjusting an unspecified colour space should log
the value after, not before, the adjustment.

Fixes: 5a33bc10e9 ("libcamera: software_isp: Assign colour spaces in configurations")
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-12-04 19:32:48 +00:00
Daniel Scally
f4c3dee217 libcamera: V4L2Subdevice: Get device by regexp
Some kernel drivers give their entities names that will differ from
implementation to implementation; for example the drivers for the
Camera Receiver Unit and CSI-2 receiver in the RZ/V2H(P) SoC give their
entities names that include their memory address, in the format
"csi-16000400.csi2". Passing that entity name to
V4L2Subdevice::fromEntityName() is too inflexible given it would only
then work if that specific CSI-2 receiver were the one being used.

Add an overload for V4L2Subdevice::fromEntityName() to instead allow
users to pass a std::basic_regex, and use std::regex_search() instead
of a direct string comparison to find a matching entity. Ths allows
us to form regular expressions like "csi-[0-9a-f]{8}.csi2" to find
the entities.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-12-04 14:46:56 +01:00
Daniel Scally
1e92c4cc0d libcamera: media_device: Get entity by regexp
Some kernel drivers give their entities names that will differ from
implementation to implementation; for example the drivers for the
Camera Receiver Unit and CSI-2 receiver in the RZ/V2H(P) SoC give their
entities names that include their memory address, in the format
"csi-16000400.csi2". Passing that entity name to
MediaDevice::getEntityByName() is too inflexible given it would only
then work if that specific CSI-2 receiver were the one being used.

Add an overload for MediaDevice::getEntityByName() that accepts a
std::basic_regex instead of a string, and use std::regex_search()
instead of a direct string comparison to find a matching entity. This
allows us to search for entites using regex patterns like
"csi-[0-9a-f]{8}.csi2".

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-12-04 14:46:50 +01:00
Daniel Scally
8d068b7470 libcamera: device_enumerator: Support regex to match entity names
Some entities in a media graph have names that might differ from
implementation to implementation; for example the Camera Receiver
Unit and CSI-2 receiver on the RZ/V2H(P) SoC have entities with names
that include their address, in the form "csi-16000400.csi2". Passing
that entity name to DeviceMatch is too inflexible given it would only
work if that specific CSI-2 receiver were the one being used.

Add an overload for DeviceMatch::add() such that users can pass in a
std::regex instead of a string. Update DeviceMatch::match() to check
for entities that are matched by the regular expressions added with
the new overload after checking for any exact matches from the vector
of strings. This allows us to use regex to match on patterns like
"csi-[0-9a-f]{8}.csi2".

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-12-04 14:46:43 +01:00
Daniel Scally
1039a0f2ee libcamera: base: Wrap <regex.h>
Provide a wrapper for regex.h to work around the false-positive
compilation errors that crop up in some versions of gcc.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-12-04 14:46:40 +01:00
Jacopo Mondi
3a835ff48c libcamera: controls: Small style fixes
The Wdr controls have been added without an empty line between them and the
existing ones. Also, a line has a space at the end.

Fix it.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-12-01 15:12:20 +01:00
Andrei Gansari
1a23227c65 pipeline: imx8-isi: Integrating MediaPipeline class
This change integrates the MediaPipeline class into the imx8-isi
pipeline handler. Purpose is to allow a dynamic discovery and
configuration of the actual subdevices graph between the sensor and
the ISI crossbar. This brings support for more complex topologies and
simplifies the implementation.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.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>
2025-11-27 16:37:57 +00:00
Andrei Gansari
056613cb12 libcamera: media_pipeline: Add accessor for MediaPipeline list of entities
Exposes internal MediaEntity::Entity list to help extracting more
information regarding linked entities.

For example, when the pad index of the last device in the list need to be
retrieved from the media pipeline user.

Exposes as const to with a dedicated access to prevent any corruption from
user. Then it is still protected so as when the list was private.

Since MediaPipeline::Entity needs also to be moved to public, then need to
add some documentation in cpp source. Existing documentation from header
file is applied when available.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.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>
2025-11-27 16:37:54 +00:00
Kieran Bingham
3c17d1fbb2 libcamera v0.6.0
The abi-compliance checker reports there are both ABI and API changes in this
release:

  Binary compatibility: 99.3%
  Source compatibility: 98.6%
  Total binary compatibility problems: 4, warnings: 1
  Total source compatibility problems: 18, warnings: 5

These have been planned to batch together a lot of recent development to
improve the public facing API, which has extended the previous merge window on
this occasion.

A full and detailed ABI report for those interested can always be generated
between any two versions with the internal tooling:

 "./utils/abi-compat.sh v0.5.2 v0.6.0"

Integration Overview:

With 211 commits and a longer merge window, this is quite a substantial
release.

Key highlights include a new global configuration file system which will
replace or extend the current use of environment variables to configure runtime
behaviours.

The core V4L2 classes can now support the V4L2 Request API - which in turn has
brought in huge developments for the i.MX8MP Dewarper support allowing full
resize, scale, rotate and crop capabilities on top of also performing lens
dewarping.

The SoftISP continues to develop, and specifically the IPU7 has been added as a
supported configuration to the pipeline.

New tuning files have been added for Raspberry Pi platforms, improving support
for the Sony IMX335, IMX415, IMX462, and ST VD55G1 image sensors, and Decompand
support has been added for the Raspberry Pi 5.

At the core, we now require Meson 1.0.1, and various improvements have been
made for thrad handling, improving synchronisation and event dispatch, as well
as fixing the serialisation operations for isolated IPA modules.

In the applications components, there are fixes to cam adding more output
formats and qcam now behaves more consistently when no camera is selected.  The
python bindings have received fixes for paths from meson, and the
FrameBuffer::planes wrapper.

On the Documentation side, there's a new theme refresh and clearer separation
between the internal and public API, and fixes to the contributing guidelines.

The following commits in this release relate to either a bug fix or an
improvement to an existing commit.

 - libcamera: base: semaphore: Do not unlock prematurely
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=225
 - apps: cam: Do not overwrite name when adding camera model
   - Fixes: aab49f903e ("cam: Do not assume Location is available")
 - Documentation: Fix documentation generation when subproject
   - Fixes: 0382d215db ("Documentation: Use Sphinx doxylink to generate links to doxygen")
 - apps: qcam: Do nothing if no camera is selected
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=177
 - utils: codegen: gen-formats.py: Fix big endian formats
   - Fixes: 7c496f1c54 ("utils: gen-formats: Support big-endian DRM formats")
 - pycamera: Fix FrameBuffer::planes wrapper
   - Fixes: b8d332cdcc ("libcamera: framebuffer: Replace vector with span in constructor")
 - libipa: agc_mean_luminance: Fix constraint logging
   - Fixes: 42e18c96bc ("libipa: agc_mean_luminance: Add debug logging")
 - libcamera: software_isp: Pass correct y-coordinate to stats
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=280
 - libcamera: controls: Expose string controls as `std::string_view`
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=256
 - pipeline: simple: Consider output sizes when choosing pipe config
   - Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/236
 - ipa: rpi: vd56g3: Fix frameIntegrationDiff value
   - Reported-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
 - libcamera: rkisp1: Mark VBLANK as priority
   - Fixes: f72c76eb6e ("rkisp1: Honor the FrameDurationLimits control")
 - libcamera: base: thread: Use `pthread_self()` when setting name
   - Fixes: 559128b1f1 ("Thread: Add name parameter")
 - pipeline: imx8-isi: Delay ISI routes config to acquire() time
   - Fixes: 92df79112f ("pipeline: imx8-isi: Add multicamera support")
 - pipeline: simple: Reduce warning of unknown pixel formats
   - Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/291
 - libcamera: pipeline_handler: Fix requestComplete on waiting requests on stop
   - Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/281
 - libcamera: software_isp: Assign colour spaces in configurations
   - Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/294
 - libipa: exposure_mode_helper: Set quantizationGain in absence of a sensor helper
   - Fixes: f077c58e08 ("libipa: exposure_mode_helper: Take exposure/gain quantization into account")
 - ipa: libipa: agc_mean_luminance: Fix yTarget handling in constraints
   - Fixes: 24247a12c7 ("ipa: libipa: Add AgcMeanLuminance base class")
 - libcamera: control_serializer: Add array info to serialized ControlValue
   - Bug: https://bugs.libcamera.org/show_bug.cgi?id=285

And the following updates have been made in this release, grouped by category:

core:
 - libcamera: converter_v4l2_m2m: Add missing `<set>` include
 - treewide: Remove top-level `const` from return types
 - libcamera: camera_sensor: getControls(): Use span
 - libcamera: camera_sensor: getFormat(): Use span
 - libcamera: ipa_proxy: Log configuration file path
 - libcamera: base: thread: eventDispatcher(): Not thread safe
 - libcamera: base: semaphore: Do not unlock prematurely
 - meson: Bump minimum version to v1.0.1
 - meson: Use dependency('dl')
 - libcamera: v4l2_videodevice: Avoid repeated calls to FrameBuffer::planes()
 - meson: Check for Python modules manually
 - libcamera: sensor: imx462: Add sensor delays to CameraSensorProperties
 - libcamera: clock_recovery: Use nanoseconds in addSample()
 - utils: Add unary negation operation to Duration
 - utils: codegen: ipc: Put default values in declaration
 - utils: codegen: ipc: Generate templated constructor
 - utils: codegen: gen-formats.py: Use jinja
 - utils: codegen: gen-formats.py: Fix big endian formats
 - libcamera: framebuffer: Replace vector with span in constructor
 - libcamera: request: addBuffer(): Do not destroy fence on failure
 - libcamera: camera_sensor_properties: Add vd55g1 camera sensor
 - include: linux: Partially update linux headers from v6.16-rc1-310-gd968e50b5c26
 - config: Introduce global runtime configuration
 - libcamera: camera_manager: Construct GlobalConfiguration instance
 - config: Add configuration retrieval helpers
 - camera_manager: Look up pipelines match list in configuration file
 - config: Check configuration file version
 - meson: Add option to disable libunwind integration
 - libcamera: base: thread: Make `removeMessages()` public
 - utils: codegen: ipc: Split proxy types
 - libcamera: controls: Expose string controls as `std::string_view`
 - subprojects: libpisp: Update to v1.3.0
 - libcamera: request: Clarify ReuseBuffers flag usage with fences
 - libcamera: base: utils: Simplify `enumerate()`
 - config: Fix doxygen 1.15.0 errors
 - libcamera: base: {unique,shared}_fd: Warn if closing fails
 - libcamera: base: utils: Simplify hex adaptor
 - libcamera: base: thread: Use `std::unique_ptr` instead of raw pointer
 - Thread: Add name parameter
 - libcamera: base: thread: Use `pthread_self()` when setting name
 - utils: checkstyle.py: Accept `Closes` commit trailer
 - libcamera: pipeline_handler: Add accessor for useCount_
 - subprojects: libyuv: Bump to version 1922
 - treewide: Use `argparse.FileType` in more places
 - libcamera: pipeline_handler: Fix requestComplete on waiting requests on stop
 - libcamera: base: thread: Use `acquire` memo. when reading event dispatcher
 - libcamera: request: Store fence `EventNotifier` directly
 - libcamera: ipa_data_serializer: Add specialization for enums
 - libcamera: simple: Detect Bayer pattern change during configure()
 - libcamera: converter: Utilise shared MediaDevice pointers
 - libcamera: Add support for V4L2 requests
 - libcamera: converter: Add V4L2 request support
 - libcamera: converter_v4l2_m2m: Add suport for V4L2 requests
 - libcamera: converter_v4l2_m2m: Always set stride
 - include: linux: Update headers for Dw100 dewarper engine
 - libcamera: converter_v4l2_m2m: Add helper to apply controls
 - libcamera: converter_v4l2_m2m: Add debug logging for formats
 - libcamera: converter: Add dw100 vertex map class
 - libcamera: converter: Add dw100 converter module
 - libcamera: internal: camera_sensor: Add accessor for mountingOrientation_
 - libcamera: Add transpose() function to size
 - libcamera: dw100_vertexmap: Implement parametric dewarping
 - libcamera: Add and implement LensDewarpEnable control
 - libcamera: control_serializer: Add array info to serialized ControlValue
 - Revert "controls: Add boolean constructors for ControlInfo"

pipeline:
 - pipeline: simple: Improve debug log in validate()
 - libcamera: pipeline: Avoid unnecessary indirection in frame info map
 - pipeline: ipu3: Drop unneeded forward declarations
 - pipeline: rkisp1: Replace error handling gotos with utils::exit_scope
 - pipeline: rpi: Use structured bindings in range-based for loop
 - pipeline: imx8-isi: Fix crossbar's sink pad computation
 - pipeline: simple: Enable simple pipelinehandler with SoftISP on Intel IPU7
 - pipelines: Use lambda functions to factor out buffer mapping code
 - pipeline: rkisp1: Add error log when parameter queuing fails
 - pipeline: rkisp1: Query kernel for available params blocks
 - rkisp1: agc: Agc add yTarget to frame context
 - pipeline: simple: Allow enabling software ISP via config file
 - libcamera: software_isp: Make input buffer copying configurable
 - libcamera: software_isp: Make measurement configurable
 - libcamera: pipeline: virtual: Move image generation to separate thread
 - libcamera: software_isp: Add valid flag to struct SwIspStats
 - libcamera: software_isp: Run sw-statistics once every 4th frame
 - libcamera: software_isp: Fix width adjustment in SwStatsCpu::setWindow
 - libcamera: software_isp: Clarify SwStatsCpu::setWindow use
 - libcamera: software_isp: Pass correct y-coordinate to stats
 - pipeline: simple: Initialize maxQueuedRequestsDevice to 4
 - pipeline: simple: Increase internal buffers for software ISP to 4
 - pipeline: simple: Allow buffer counts from 1 to 32
 - libcamera: software_isp: Clear pending async work
 - pipeline: simple: Avoid overusage of auto variables
 - libcamera: software_isp: Apply CCM swap also on green
 - pipeline: simple: Consider output sizes when choosing pipe config
 - libcamera: rkisp1: Mark VBLANK as priority
 - pipeline: imx8-isi: Delay ISI routes config to acquire() time
 - libcamera: software_isp: Fix gamma table when CCM is used
 - pipeline: simple: Reduce warning of unknown pixel formats
 - libcamera: pipeline: uvcvideo: Reject sensor configuration
 - libcamera: software_isp: Assign colour spaces in configurations
 - pipeline: virtual: Provide and validate colorspace
 - libcamera: pipeline: Utilise shared MediaDevice pointers
 - libcamera: rkisp1: Properly cancel buffers in dewarp case
 - libcamera: rkisp1: Move useDewarper_ flag into RkISP1CameraData
 - libcamera: rkisp1: Scale down in dewarper instead of resizer
 - libcamera: rkisp1: Allow upscaling when the dewarper is present
 - pipeline: rkisp1: Fix number of buffers imported into the dewarper
 - libcamera: rkisp1: Use the dw100 converter module instead of the generic v4l2 converter
 - pipeline: rksip1: Move isRaw up in scope
 - pipeline: rkisp1: Drop rawFormat variable
 - pipeline: rkisp1: Enable the dewarper based on the tuning file
 - libcamera: rkisp1: Handle requested orientation using dewarper
 - pipeline: rkisp1: Load dewarp parameters from tuning file

apps:
 - apps: common: options: Avoid copying in range based for loop
 - apps: cam: Do not overwrite name when adding camera model
 - apps: cam: drm: Drop unneeded local variable
 - py: libcamera: Improve python binding installation
 - py: libcamera: Get dependency from meson python module unconditionally
 - py: libcamera: Always use install path from meson python module
 - apps: qcam: Do nothing if no camera is selected
 - apps: cam: Support PPM output for other RGB formats
 - pycamera: Fix FrameBuffer::planes wrapper
 - apps: cam: Use signalfd
 - gstreamer: Update the TODO list
 - android: camera_hal_manager: Remove `cameraLocation()`
 - gstreamer: Associate libcamera::Stream with GstPad
 - gstreamer: Improve logging for buffer pool activation
 - gstreamer: Track RequestWrap's GstBuffer using GstPad
 - py: gen-py-formats.py: Open input file in binary mode
 - apps: cam: sdl_texture: Support NV21

documentation:
 - Documentation: Fix documentation generation when subproject
 - Documentation: Use python3 directly to check for doxylink version
 - Documentation: Use standard ordering for Doxyfile variables
 - Documentation: Add doxygen-awesome-css
 - Documentation: Enable doxygen-awesome-css
 - Documentation: Use the sphinx book theme
 - Documentation: Add api-html/ and internal-api-html/ to docs sources
 - Documentation: Reorganize toctree
 - Documentation: Improve Sphinx and Doxygen integration
 - Documentation: Drop unnecessary documentation-contents.rst
 - Documentation: mainpage: Make it easier to distinguish public and internal API
 - Documentation: Rename api to public-api and drop -html suffix
 - Documentation: Add global configuration file documentation
 - Documentation: Fix grammar and typo in meson.build comment
 - Documentation: contributing: Provide a reference to Matrix
 - Documentation: contributing: Update issue tracker
 - Documentation: contributing: Update Source references

ipa:
 - ipa: rpi: Add Arducam B0568 IMX335 tuning files
 - ipa: rpi: Add Arducam B0569 IMX415 tuning files
 - ipa: rpi:: denoise: Implement TDN back-off for CDN deviation
 - ipa: rpi: pisp: data: Improve noise and detail tuning
 - ipa: rpi: pisp: data: Update all non-official camera tuning files
 - ipa: rpi: vc4: Minor tuning changes
 - ipa: rpi: sdn: Remove legacy denoise warning
 - ipa: rpi: imx462: Add official RPi tuning for IMX462
 - ipa: rpi: ccm: Implement "manual" CCM mode
 - ipa: rpi: Add vd55g1 support for rpi
 - ipa: rpi: Add vd55g1 tuning files for rpi
 - libcamera: libipa: Add vd55g1 support for libipa
 - libcamera: libipa: camera_sensor: Add Himax HM1246 sensor properties
 - ipa: rkisp1: Add basic compression algorithm
 - libipa: camera_sensor_helper: Add quantizeGain() function
 - libipa: exposure_mode_helper: Take exposure/gain quantization into account
 - libipa: exposure_mode_helper: Remove double calculation of lastStageGain
 - libipa: exposure_mode_helper: Remove unnecessary clamp calls
 - libipa: agc_mean_luminance: Fix constraint logging
 - libipa: agc_mean_luminance: Configure the exposure mode helpers
 - libipa: exposure_mode_helper: Calculate quantization gain in splitExposure()
 - ipa: rkisp1: agc: Add correction for exposure quantization
 - ipa: rkisp1: Switch histogram to RGB combined mode
 - libipa: agc_mean_luminance: Introduce effectiveYTarget() accessor
 - libipa: agc_mean_luminance: Add support for additional constraints
 - ipa: rkisp1: Add WDR algorithm
 - ipa: Look up IPA configurables in configuration file
 - ipa: rpi: agc: Allow exposure mode to be updated in auto mode
 - ipa: software_isp: Fix context_.configuration.agc.againMin init
 - ipa: software_isp: AGC: Do not lower gain below 1.0
 - ipa: software_isp: AGC: Raise exposure or gain not both at the same time
 - ipa: software_isp: AGC: Only use integers for exposure calculations
 - ipa: simple: blc: Use 16 as starting blacklevel when there is no sensor-info
 - ipa: simple: awb: Avoid incorrect arithmetic in AWB
 - ipa: simple: awb: Use correct type in std::accumulate
 - ipa: simple: blc: Prevent division by zero in BLC
 - ipa: simple: agc: Prevent division by zero in AGC
 - ipa: rpi: pisp: Add decompand support using PiSP hardware block
 - ipa: rpi: Add FE globals as a parameter to applyDecompand()
 - ipa: rpi: pisp: Add a DecompandAlgorithm class
 - ipa: rpi: pisp: Allow an initial decompand curve to be set on the FE
 - ipa: meson.build: Remove duplicated variable
 - ipa: rpi: Fix the set function for floating statistics regions
 - ipa: rpi: lux: Handle camera mode sensitivity correctly
 - ipa: rpi: pisp: Use a floating region to get whole image Y statistics
 - ipa: rpi: vc4: Use a floating statistics region for a full image Y sum
 - ipa: rpi: lux: Use floating statistics region to obtain the current Y value
 - libipa: camera_sensor_helper: Add imx708
 - ipa: rpi: vd56g3: Fix frameIntegrationDiff value
 - ipa: libipa: agc_mean_luminance: Avoid unnecessary copies
 - ipa: rkisp1: dpf: Enable strength after enable Dpf
 - libipa: module: Allow algorithms to be disabled via the tuning file
 - libipa: exposure_mode_helper: Set quantizationGain in absence of a sensor helper
 - ipa: libipa: pwl: Allow to parse a plain yaml value as single point PWL
 - ipa: rkisp1: lux: Properly handle frame context and active state
 - ipa: libipa: agc_mean_luminance: Change luminance target to piecewise linear function
 - ipa: libipa: agc_mean_luminance: Fix yTarget handling in constraints
 - ipa: ipu3, mali-c55, rkisp1, rpi: Fix reporting non-scalar controls

tuning:
 - utils: raspberrypi: ctt: Update noise/sharpness tuning
 - utils: raspberrypi: ctt: Update vc4 tuning defaults
 - tuning: rksip1: Add a static Compress entry
 - tuning: rksip1: Add a static WideDynamicRange entry

test:
 - test: camera: Use Request::ReuseBuffers flag
 - test: utils: Add endlines
 - test: utils: Validate hex sign extension
 - lc-compliance: Ensure stream's colorspace is set after validate()

Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-27 11:55:28 +00:00
Paul Elder
4e9be7d11b ipa: ipu3, mali-c55, rkisp1, rpi: Fix reporting non-scalar controls
The ControlInfos of non-scalar controls that are reported in controls()
must have non-scalar default values for controls that have a defined
size. This is because applications should be able to directly set the
default value from a ControlInfo to the control.

Currently this is relevant to the following controls:
- ColourGains
- ColourCorrectionMatrix
- FrameDurationLimits
- AfWindows

Fix the scalarness of these controls where relevant.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> # rkisp1
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 16:52:19 +00:00
Paul Elder
cfdc281100 libcamera: control_serializer: Add array info to serialized ControlValue
Array controls (eg. ColourCorrectionMatrix, FrameDurationLimits,
ColourGains) are serialized properly by the ControlSerializer, but are
not deserialized properly. This is because their arrayness and size are
not considered during deserialization.

Fix this by adding arrayness and size to the serialized form of all
ControlValues. This is achieved by fully serializing the min/max/def
ControlValue's metadata associated with each ControlInfo entry in the
ControlInfoMap.

While at it, clean up the serialization format of ControlValues and
ControlLists:
- ControlValue's id is only used by ControlList, so add a new struct for
  ControlList entries to contain it, and remove id from ControlValue
- Remove offset from ControlInfo's entry, as it is no longer needed,
  since the serialized data of a ControlInfo has now been converted to
  simply three serialized ControlValues
- Remove the type from the serialized data of ControlValue, as it is
  already in the metadata entry

The issue regarding array controls was not noticed before because the
default value of the ControlInfo of other array controls had been set to
scalar values similar to how min/max are set, and ColourCorrectionMatrix
was the first control to properly define a non-scalar default value.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=285
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> # rkisp1
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-11-26 16:52:19 +00:00
Stefan Klug
7313f046a2 libcamera: Add and implement LensDewarpEnable control
Add a LensDewarpEnable control to enable or disable lens dewarping if it
is configured. Implement it inside the dw100 converter module.

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:30 +01:00
Stefan Klug
302f285b3b pipeline: rkisp1: Load dewarp parameters from tuning file
Load the dewarp parameters from the tuning file.

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
1784e08be3 libcamera: dw100_vertexmap: Implement parametric dewarping
Implement functions to allow lens dewarping based on the common lens
dewarp model used e.g. by OpenCV.

See https://docs.opencv.org/4.12.0/d9/d0c/group__calib3d.html for an
in depth explanation of the parameters.

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:30 +01:00
Stefan Klug
4b9251fa70 libcamera: rkisp1: Handle requested orientation using dewarper
When the dewarper is present it can handle arbitrary orientations
specified in the requested camera configuration. In that case handle all
transformations inside the dewarper (even if the sensor supports some of
them) because that makes it easier to handle coordinates for lens
dewarping inside the dewarper.

This complicates the path selection a bit, as for transformations that
include a transpose, the format before the dewarper has swapped
width/height.

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:30 +01:00
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