Commit Graph

4551 Commits

Author SHA1 Message Date
Naushir Patuck
e511a57c27 ipa: rpi: imx462: Add official RPi tuning for IMX462
This sensor has now been fully tuned for the Innomaker IMX462 module.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-01 09:12:06 +01:00
David Plowman
ad891914c6 ipa: rpi: sdn: Remove legacy denoise warning
We use the legacy format for the VC4 platform, and are not planning to
change this. So remove the warning.

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>
2025-08-29 23:16:31 +01:00
David Plowman
115748428e ipa: rpi: vc4: Minor tuning changes
Sharpening is reduced slightly for official Raspberry Pi cameras, and
exposure profiles made a bit more consistent.

Denoise is reduced for the imx708 where it appears too strong.

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>
2025-08-29 23:16:31 +01:00
David Plowman
7911270353 ipa: rpi: pisp: data: Update all non-official camera tuning files
Apply the same updates to the non-official cameras as to the official
ones.

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>
2025-08-29 23:16:31 +01:00
David Plowman
ecbe4b1af3 ipa: rpi: pisp: data: Improve noise and detail tuning
Noise and detail tuning is improved for all official Raspberry Pi
cameras.

The old tunings left too much noise in and even sharpened some of
it. The new tunings remove more noise, and no longer sharpen it. Some
of the more general over-sharpening is also removed. Note that lost
detail can be recovered well using TDN (temporal denoise), which is
the recommended method to get the best results.

There are some minor adjustments to the CDN deviation, now that this
gets backed-off as TDN ramps up.

The contrast in the gamma in the bright areas is also toned down just
a little.

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>
2025-08-29 23:16:31 +01:00
David Plowman
524fb97084 ipa: rpi:: denoise: Implement TDN back-off for CDN deviation
The CDN (colour denoise) deviation gets gradually reduced frame by
frame as TDN (temporal denoise) comes in and has more effect. CDN is
more harmful to image detail than TDN, so ramping it down in favour of
TDN is beneficial.

The tuning file parameters are chosen so that existing tuning files
don't have to be updated and will carry on working "mostly like they
did" (apart from the new back-off).

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>
2025-08-29 22:56:49 +01:00
Kieran Bingham
db288a6ce4 ipa: rpi: Add Arducam B0569 IMX415 tuning files
Add an imx415 tuning file for both the VC4 and PiSP. This tuning file
has been created and supplied by Arducam to support the B0569 module.

Note that this conflicts with an already existing imx415.json and
as such is provided as imx415_b0459.json.

More work will be required to support module specific tuning file
parsing.

Acked-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-29 22:56:10 +01:00
Kieran Bingham
b4dce59978 ipa: rpi: Add Arducam B0568 IMX335 tuning files
Add an imx335 tuning file for both VC4 and PiSP. This tuning file
has been created and supplied by Arducam to support the B0568 module.

Acked-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-29 22:56:02 +01:00
Antoine Bouyer
a139cd3803 pipeline: imx8-isi: Fix crossbar's sink pad computation
In current implementation, the sink pad counter of the crossbar is not
incremented if the pad is not connected to any subdevice. This would lead
to incorrect routing and format configuration if CSI is not connected
to first sink pad.

To avoid such issue, every sink pads must be taken into account. Then if
CSI and sensor are present, current counter is used for routing at match(),
and stored in camera data to be reused during configure().

Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com>
Tested-by: Pavel Löbl <pavel@loebl.cz>
Tested-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-29 22:36:58 +01:00
Laurent Pinchart
d54e5537ca py: libcamera: Always use install path from meson python module
libcamera uses the meson python module to handle native compilation of
Python extension modules, and uses the shared_module() function when
cross-compiling due to an issue in the python module. The difference
between native and cross compilation also extends to the installation
path: native compilation lets the python module handle the paths, while
cross compilation constructs a path manually using a heuristic based on
the Python version and hardcoded components.

This manually-constructed installation path is problematic for cross
compilation for the same reason it caused issue when used for native
compilation: it is not guaranteed to be right, and it can't be
overridden by users.

Switch to obtaining the installation path from the meson python module
for cross-compilation as well. This also prepares for usage of
py.extension_module() once the file suffix issue will be fixed in meson.

On Debian 13, this change replaces the incorrect path
/usr/local/lib/python3.12/site-packages/libcamera with the still (but
differently) incorrect /usr/local/lib/python3/dist-packages/libcamera.
Future fixes in meson to address this issue will make the path correct
by default.

When the path calculated by the python module is not correct, it can now
be overridden by the user through the meson python.platlibdir
configuration variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
2025-08-20 13:19:48 +03:00
Laurent Pinchart
a2b21d60c7 py: libcamera: Get dependency from meson python module unconditionally
libcamera uses the meson python module to handle native compilation of
Python extension modules.

When cross-compiling, the module uses the build machine suffix instead
of the host machine suffix in some enviroments (for instance naming the
shared object file _libcamera.cpython-313-x86_64-linux-gnu.so instead of
_libcamera.cpython-313-aarch64-linux-gnu.so when cross-compiling from
x86_64 to aarch64). This prevents using the python module in that case,
and libcamera uses the normal dependency() function to locate the Python
libraries, and the shared_module() function to build the module.

Not using the meson python module to get the Python dependency prevents
selecting a specific Python interpreter, the same way as it does for
native builds. While having multiple Python interpreter versions in a
cross-build environment is likely less common, different behaviours and
features between native and cross-compilation are still not optimal.

Improve this situation by getting the dependency from the python module
for cross-compilation as well. This also prepares for usage of
py.extension_module() once the file suffix issue will be fixed in meson.

The user will need to ensure that the Python interpreter for the build
machine matches the version of the interpreter in the cross-compilation
environment for the host machine. Otherwise, meson will fail to find the
Python dependency. Cross-compilation environment provided by Linux
distributions (such as Debian multi-arch support) should work out of the
box, but compiling libcamera manually against a cross-compilation
environment provided by Buildroot or Yocto may require manual
configuration.

When the interpreters versions do not match, meson needs to be pointed
to the build ùachine interpreter from the cross-compilation environment
using the cross file. For instance, assuming a 'br_host_dir' variable
pointing to the host directory from Buildroot, the cross file should
contain

[binaries]
python = br_host_dir / 'bin/python3'

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
2025-08-20 13:19:40 +03:00
William Vinnicombe
91365356bd py: libcamera: Improve python binding installation
The existing meson.build file installs the bindings to a manually
constructed directory that is not included in the Python path in most
distributions. For instance, on a  Debian 12 system, the modules is
intalled in /usr/lib/x86_64-linux-gnu/python3.11/site-packages/, while
the Python interpreter looks for site packages in
/usr/lib/python3/dist-packages/.

It also always builds the bindings using the system Python, as it
searches for the Python library using the standard dependency()
function. This prevents build the Python bindings for a different
interpreter version without changing the system default interpreter.

Modify the build process to use the meson python module to build the
Python bindings targets, so it installs them to the correct directories
for Python. This also allows specifying a different target Python
interpreter through the '[binaries]' section of a meson native file.

The behaviour is not changed for cross-compilation, as the meson python
module has known issues in that case.

Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
2025-08-20 13:19:32 +03:00
Laurent Pinchart
6e68c391f8 apps: cam: drm: Drop unneeded local variable
The planes variable in the Device::createFrameBuffer() function is a
reference to buffer.planes() that is only used as a range initializer in
a range-based for loop. Use buffer.planes() directly and drop the
variable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-08-19 18:46:20 +03:00
Laurent Pinchart
470fa978a8 pipeline: rpi: Use structured bindings in range-based for loop
Simplify a range-based for loop by replacing an iterator with structure
bindings. This makes the code easier to read.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-08-19 18:46:18 +03:00
Laurent Pinchart
34b9d31700 pipeline: rkisp1: Replace error handling gotos with utils::exit_scope
Use utils::exit_scope in PipelineHandlerRkISP1::allocateBuffers() to
avoid gotos for error handling.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-08-19 18:46:15 +03:00
Laurent Pinchart
6498d3a94f pipeline: ipu3: Drop unneeded forward declarations
Multiple classes are forward-declared in frames.h, without being used in
that header file. Drop the unneeded forward declarations.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-08-19 18:46:13 +03:00
Laurent Pinchart
83243a2f24 libcamera: v4l2_videodevice: Avoid repeated calls to FrameBuffer::planes()
The V4L2VideoDevice::dequeueBuffer() calls buffer->planes() multiple
times. Store the planes array in a local variable to make this more
efficient.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2025-08-19 18:46:09 +03:00
Laurent Pinchart
392e9044b1 meson: Use dependency('dl')
Support for locating libdl through dependency('dl') was broken before
meson v0.62.0. Now that we require a newer version, drop the hack and
use the dependency() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-08-19 18:00:01 +03:00
Barnabás Pőcze
aa4338eed5 apps: cam: Do not overwrite name when adding camera model
If `addModel` is true, then the previously set `name` will be overwritten.
This does not seem to be the intended behaviour, so fix it by using `+=`.

Before:

  Available cameras:
  1: 'imx219' (/base/soc@0/bus@30800000/i2c@30a30000/camera@10)

After:

  Available cameras:
  1: External camera 'imx219' (/base/soc@0/bus@30800000/i2c@30a30000/camera@10)

Fixes: aab49f903e ("cam: Do not assume Location is available")
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-08-19 12:02:25 +02:00
Barnabás Pőcze
7609719514 libcamera: base: semaphore: Do not unlock prematurely
In `Semaphore::release()`, unlocking the mutex before signalling the condition
variable can be problematic, especially with "temporary" objects such as the
ones `BoundMethodBase::activatePack()` uses to handle `ConnectionTypeBlocking`.

Specifically, `Semaphore::acquire()` might lock the mutex after `Semaphore::release()`
has unlocked it, but before it had the chance to notify the condition variable.
In that case `Semaphore::acquire()` can succeed, and execution may proceed to
destroy the `Semaphore` object while the other thread is in the process of
running `std::condition_variable::notify_all()`.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=225
Fixes: 66e7c5b774 ("libcamera: Add Semaphore class")
Signed-off-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-08-19 09:44:24 +02:00
Barnabás Pőcze
1bd66f54a6 libcamera: base: thread: eventDispatcher(): Not thread safe
The function is not actually thread safe contrary to its documentation.
Since it is currently not used in an unsafe context, simply remove the
mention of thread safety from the documentation.

The variable must still remain atomic because it is accessed internally
from different threads, e.g. `Thread::postMessage()`.

Also add an assertion to enforce this.

Signed-off-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-08-18 13:56:51 +02:00
Barnabás Pőcze
af43c2f945 apps: common: options: Avoid copying in range based for loop
The copy can trigger `-Wrange-loop-construct` and is not needed,
so use a reference to avoid it.

Signed-off-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-08-15 11:22:28 +02:00
Stefan Klug
452fbd2295 libcamera: ipa_proxy: Log configuration file path
It is often helpful to know which tuning file is used. Add a log
statement with INFO level for that.

As the core logic has multiple return paths, adding the log statement is
not straight forward. Extract finder logic into a ipaConfigurationFile()
function and call that with the name and optionally the fallbackName
from the configurationFile() function.

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>
2025-08-13 18:12:08 +02:00
Barnabás Pőcze
caf00087ba libcamera: pipeline: Avoid unnecessary indirection in frame info map
There is no reason to allocate the frame info objects dynamically,
and then store raw pointers in the `std::map` in the rkisp1
and ipu3 pipeline handler.

Instead, store the objects directly in the map. This removes
the need for manually calling new/delete, simplifies the code,
and eliminates one memory allocation per frame.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-13 15:41:30 +02:00
Barnabás Pőcze
43dfbe2541 libcamera: camera_sensor: getFormat(): Use span
The function takes a const std::vector reference, but it does
not actually need an `std::vector`. So use a `libcamera::Span`
instead to avoid forcing the caller to construct a vector.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-08-13 12:48:47 +02:00
Barnabás Pőcze
39d37fce12 libcamera: camera_sensor: getControls(): Use span
The function takes a const std::vector reference, but it does
not actually need an `std::vector`. So use a `libcamera::Span`
instead to avoid forcing the caller to construct a vector.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-08-13 12:48:42 +02:00
Umang Jain
01a9b83f38 pipeline: simple: Improve debug log in validate()
Improve the debug log while adjusting the StreamConfiguration's
pixel format. The log should clearly indicate the requested pixel
format and the adjusted pixel format.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-11 18:44:29 +01:00
Barnabás Pőcze
14882b8314 treewide: Remove top-level const from return types
Top-level `const` qualifiers are not useful, so avoid them. This is done
either by simply removing the top-level `const`, or making the function
return a reference to const where that is appropriate.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-08-11 12:21:32 +02:00
Barnabás Pőcze
3b72e7d306 Revert "controls: Add boolean constructors for ControlInfo"
This reverts commit 10cdc914da.

The constructors introduced by that commit are not used anywhere,
and they do not match the existing practice for boolean controls.

Specifically, every single boolean control is described by calling
the `ControlInfo(ControlValue, ControlValue, ControlValue)`
constructor. Crucially, that constructor does not set `values_`,
while the two removed constructors do. And whether or not `values_`
has any elements is currently used as an implicit sign to decide
whether or not the control is "enum-like", and those are assumed
to have type `int32_t`.

For example, any boolean control described using any of the two
removed constructors would cause an assertion in failure in
`CameraSession::listControls()` when calling `value.get<int32_t>()`.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-08-11 09:32:58 +02:00
Barnabás Pőcze
a7cda79dee libcamera: converter_v4l2_m2m: Add missing <set> include
`std::set` is directly used in the file, but not directly included.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-11 09:32:27 +02:00
Umang Jain
053fedb5ed gstreamer: Report camera properties as device properties
Iterate over all libcamera camera properties and report them as
device properties. Each libcamera ControlType is mapped to the
corresponding gstreamer GType. If the ControlValue is an array of
values (ControlValue::isArray()), GValue with type GST_TYPE_ARRAY
is used to set the value of that ControlValue with the corresponding
GType.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 19:04:44 +01:00
Umang Jain
0794edcae6 gstreamer: Move existing GValue helpers to gstreamer-utils
Move the existing GValue helpers from gstlibcamera-controls.cpp.in
to gstreamer-utils.cpp. The intention here is to make these helpers
available to other parts of gstreamer source element, for example,
reporting camera properties in GstDeviceProvider.

The function signature has been changed to match with the other
gstreamer-utils utility functions:

value_get_rectangle() =>  gst_libcamera_gvalue_get_rectangle()
value_set_rectangle() =>  gst_libcamera_gvalue_set_rectangle()
value_set_point()     =>  gst_libcamera_gvalue_set_point()
value_set_size()      =>  gst_libcamera_gvalue_set_size()

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 19:04:44 +01:00
Umang Jain
f96c4df423 gstreamer: Split value_set_rectangle() GValue helper
Split the value_set_rectangle() GValue helper into further
helpers pertaining to libcamera::Point and libcamera::Size.
This would help to cover additional cases where helpers
are needed for Point and Size individually (in subsequent commits).

The libcamera::Rectangle's GValue helper can be easily
constructed with the new Point and Size helpers. Hence,
this patch does not introduce any functional changes.

Signed-off-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 19:04:44 +01:00
Benjamin Mugnier
409d1b29da libcamera: libipa: Add vd56g3 support for libipa
Values are sourced initially from the vd56g3 user manual.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 17:49:24 +01:00
Benjamin Mugnier
0c4b789195 ipa: rpi: Add vd56g3 tuning files for rpi
For both vc4 and pisp, vd56g3.json has been generated using ctt with
rpi.dpc algorithm removed as this is already handled in the sensor's
ISP. vd56g3_mono.json has been adapted from vd56g3.json by removing
color correction related algorithms.

Adding Cyril Liotard and Jean Poire as co-developers for providing the
base vd56g3.json tuning files for vc4 and pisp respectively. Thank you.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Co-developed-by: Cyril Liotard <cyril.liotard@st.com>
Signed-off-by: Cyril Liotard <cyril.liotard@st.com>
Co-developed-by: Jean Poire <jean.poire@st.com>
Signed-off-by: Jean Poire <jean.poire@st.com>
Reviewed-by: Naushir Patuck <naush@rasbperrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 17:49:19 +01:00
Benjamin Mugnier
c64bf58baa ipa: rpi: Add vd56g3 support for rpi
The cam_helper gain formula and frameIntegrationDiff can be found in the
vd56g3 user manual.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Naushir Patuck <naush@rasbperrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 17:48:12 +01:00
Benjamin Mugnier
6f1af6f578 libcamera: camera_sensor_properties: Add vd56g3 camera sensor
Add unit cell size from the 'pixel size' element in the datasheet.
Delays are set to 2 in case a setting is entered at the very end of the
N frame, the N+1 frame will miss it and only the N+2 frame will use this
new setting.

Note that vd56g3 has a diagonal color test pattern, but does not match
any description in specified test patterns and therefore is ignored.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
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-08-06 17:48:12 +01:00
Laurent Pinchart
4e567d1981 libcamera: v4l2_videodevice: Use scope_exit
The V4L2VideoDevice::queueBuffer() function performs the same cleanup
action in many error paths. Use scope_exit to simplify it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-08-06 15:11:32 +01:00
Barnabás Pőcze
b37e69d434 libcamera: process: Remove ProcessManager singleton
The `ProcessManager` is a singleton class to handle `SIGCHLD` signals
and report the exit status to the particular `Process` instance.

However, having a singleton in a library is not favourable and it is
even less favourable if it installs a signal handler.

Using pidfd it is possible to avoid the need for the signal handler;
and the `Process` objects can watch their pidfd themselves, eliminating
the need for the `ProcessManager` class altogether.

`P_PIDFD` for `waitid()` was introduced in Linux 5.4, so this change
raises the minimum supported kernel version. `clone3()`, `CLONE_PIDFD`,
`pidfd_send_signal()` were all introduced earlier.

Furthermore, the call to the `unshare()` system call can be removed
as those options can be passed to `clone3()` directly.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-08-05 09:28:47 +02:00
Barnabás Pőcze
4db96b6e66 libcamera: process: Use close_range() when available
Use the `close_range()` system call when available as it is simpler
and faster than iterating `/proc/self/fd/`.

Signed-off-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-08-05 09:28:47 +02:00
Barnabás Pőcze
d44ec357d2 libcamera: process: Move closeAllFdsExcept()
Remove `closeAllFdsExcept()` from the `Process` class and have it as a
local function since it is not needed "outside" and does not depend on
any part of the `Process` class.

Signed-off-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-08-05 09:28:47 +02:00
Barnabás Pőcze
b43691af94 libcamera: process: closeAllFdsExcept(): Take vector by value
Instead of creating a new vector, take the vector by value to make it
possible for the caller to use move construction when calling the function.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-08-05 09:28:47 +02:00
Barnabás Pőcze
7a42f3c3d8 libcamera: process: start(): Use span instead of vector
Use a span instead of a const reference to a vector, this does not
change the behaviour and allows e.g. arrays to be used to hold
arguments/file descriptors.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-31 11:42:35 +02:00
Barnabás Pőcze
5de79e93f0 libcamera: process: Use pid_ member to decide if running
Instead of using a separate member variable, use `pid_ > 0` to determine
if the process is still running. Previously the value of `pid_` was not
reset to -1 when the process terminated, but since it is only meaningful
while the process is running, reset it to -1 in `Process::died()`.

Neither `pid_` nor `running_` are exposed, so this change has no effect
on the public interface or observable behaviour.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-31 11:42:35 +02:00
Barnabás Pőcze
b0db9388f6 libcamera: base: log: Take LogCategory by reference
When no log category is specified, `nullptr` is passed, and
then the `_log()` function implementations replace that with
`LogCategory::defaultCategory()`. But since the call site always
knows the log category, this condition can be removed and the
`_LOG1()` macro can use `LogCategory::defaultCategory()`.

So remove the condition from the `_log()` implementations and
use references to refer to log categories.

Signed-off-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-07-31 11:39:13 +02:00
Jaslo Ziska
096b9416b2 gstreamer: Enable bayer formats with 10/12/14/16 bits
GStreamer supports 10/12/14/16-bit bayer formats since version 1.24.

Signed-off-by: Jaslo Ziska <jaslo@ziska.de>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-31 00:04:04 +03:00
Jaslo Ziska
84c0b9dd0a gstreamer: Log and check adjusted camera configuration
As CameraConfiguration::validate() might alter the configuration
previously negotiated with downstream, log an info when this happens as
GStreamer source elements are not supposed to do that.

Also check if downstream can accept this new stream configuration and if
not, return a not-negotiated error.

Signed-off-by: Jaslo Ziska <jaslo@ziska.de>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-31 00:04:04 +03:00
Jaslo Ziska
36bec972d3 gstreamer: Fix reconfiguration condition check
gst_pad_peer_query_accept_caps() might only check if the caps are
acceptable with the peer element, but not recursively with all
downstream elements. If the reconfigure flag was set because the
pipeline downstream changed, gst_pad_peer_query_accept_caps() might still
return true, even though downstream can't handle the current caps, which
causes a not-negotiated error.

This commit fixes this issue by emitting a query event which
recursively checks with all downstream elements. Because at this point
we are only interested in whether the current caps are still acceptable,
use the currently used caps as a filter and then check if the query
returned empty caps.

Signed-off-by: Jaslo Ziska <jaslo@ziska.de>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <uajain@igalia.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-31 00:04:03 +03:00
Barnabás Pőcze
4a469b302c libcamera: camera: Do not call generateConfiguration() synchronously
Most pipeline handler methods are dispatched in the internal `CameraManager`
thread. `PipelineHandler::generateConfiguration()` is called directly,
however, which likely goes against the expectations, so call it on the
internal thread.

Before 14618cdd0c ("libcamera: base: bound_method: Move return value")
this could not be done because the function returns `std::unique_ptr`, and
that type cannot be copied.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=273
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-28 12:35:18 +02:00
Barnabás Pőcze
e0fcbea494 libcamera: control_serializer: Accept empty ControlList
Accept empty `ControlList`s without an info map. Serialization
supports `ControlList`s without an associated `ControlInfoMap`
object. However, for deserialization, a "v4l2" control list
without an info map resulted in a fatal error.

After 30114cadd8 ("ipa: rpi: Defer initialising AF LensPosition ControlInfo and value")
the `lensControls` member of `ipa::RPi::ConfigResult` is left empty
and without an info map in every case, not just when a lens is not present.
This causes the above assertion to trigger every single time.

Also fix the indefinite article of "a ControlInfoMap" in the
error message.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-07-28 11:34:37 +02:00