Commit Graph

4956 Commits

Author SHA1 Message Date
Mattijs Korpershoek
66b0bcbbee android: hal: Add AIDL camera HAL
This is a combination of 31 commits.

android: hal: provider: Import legacy provider 2.4 HAL from AOSP

AOSP does not ship an up-to-date (libhardware) camera provider HAL.

In order to write an AIDL HAL compatible with libcamera, we need
some reference codebase to start from.

Import the 2.4 legacy HAL from AOSP from tag android-15.0.0_r12.
Folder path: //hardware/interfaces/camera/provider/2.4/default/
commit ad2ba1b851b6 ("[DON'T BLOCK] Test ownership migration rules")

Note: only the "legacy" part has been imported since external cameras are
supported via android.hardware.camera.provider-V1-external-service.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Import helpers from camera.device-external-impl

The ExternalCameraDevice AIDL HAL provides some convience functions to
convert between libhardware structures and AIDL classes.
It also provides a wrapper to convert common::Status to ScopedAStatus.

We need those convience functions for our HAL implementation as well.

Since they are not in a separate library, we can't simply link against it.

Make a local copy for our own usage here.

Import from android-15.0.0_r12 tag
Folder path: //hardware/interfaces/camera/device/default/
commit ad2ba1b851b6 ("[DON'T BLOCK] Test ownership migration rules")

Note: this only imports the conversion code.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Rename device-external-impl -> device-libcamera-impl

For now camera.device-libcamera-impl only supports conversion functions.

This is already useful for the provider implementation in order to
convert from common::Status to AScopedStatus.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: Use Android-Apache-2.0 instead of hardware_interfaces_license

hardware_interfaces_license is only available for projects in:
//hardware/interfaces//

Since our HAL is not located in that folder, we cannot use it.

  variant "android_common": depends on
  //hardware/interfaces:hardware_interfaces_license which is
  not visible to this module

Switch to Android-Apache-2.0 which is the same license and is
available in all Android projects.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Remove 32-bits build targets

Recent Android versions (with kernel version 6.2+) require 64-bits userspace.

Therefore, there is no point in keeping unused 32-bits build targets.
Remove them.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Rename 2.4 -> 2.5 to prepare HIDL update

The most recent libbhardware (legacy) based camera provider HAL in AOSP
is the 2.5 version located in //hardware/interfaces/camera/provider/2.5/default/
LegacyCameraProviderImpl_2_5 is implemented as a subclass of
LegacyCameraProviderImpl_2_4.

We don't want this subclassing to be done because it makes converting to AIDL
more difficult.
Instead, we want the new 2.5 function (notifyDeviceStateChange()) to
be part of our class.

In order to prepare for importing the 2.5 codebase, rename all mentions
from 2.4 -> 2.5.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Import HIDL v2.5 provider HAL from AOSP

The most recent libbhardware (legacy) based camera provider HAL in AOSP
is the 2.5 version located in //hardware/interfaces/camera/provider/2.5/default/
LegacyCameraProviderImpl_2_5 is implemented as a subclass of
LegacyCameraProviderImpl_2_4.

We don't want tho subclass because it makes converting to AIDL more difficult.
Instead, we want the new 2.5 function (notifyDeviceStateChange()) to
be part of our class.

Import the 2.5 code from tag android-15.0.0_r12.
Folder path: //hardware/interfaces/camera/provider/2.5/default/
commit ad2ba1b851b6 ("[DON'T BLOCK] Test ownership migration rules")

This:
- Removes the '-impl' library (it's a template-based header only)
- Add notifyDeviceStateChange() method
- Update copyright notice

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Remove templated CameraProvider struct

CameraProvider is implemented as a wrapper structure in order to
be backwards compatible with various HIDL versions.

Since this code is about to get upgraded to AIDL, we don't care about the
deprecated HIDL support.

Remove the HIDL interface layer and make LegacyCameraProviderImpl
implement the ICameraProvider interface.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Rename legacy -> libcamera

This provider HAL is libcamera specific. As a first step we will still rely on
libhardware as interface, but that can get plumbed in future reworks.

Rename from "legacy" to "libcamera" to make it clear that this provider HAL is
for supporting cameras using libcamera.

While at it, also update the LOG_TAGs to match the new naming.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Send libcamera logs to logcat

By default libcamera logs only warnings and errors to stdout.

Use LIBCAMERA_LOG_LEVELS and LIBCAMERA_LOG_FILE to ensure
that libcamera logs info+ logs are send to logcat.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Remove V2_5 namespace to prepare for AIDL

Most AIDL HALs don't use the AIDL version inside the C++ namespace.
Follow that practice and remove it here as well.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Don't hard-code the hwbinder thread count

Following example from //hardware/interfaces/camera/provider/default,
use a constant instead of hard-coding the thread count.

This will simplify AIDL migration to match what is done for the
ExternalCameraProvider.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Don't use intermediate variable for LAZY_SERVICE

The intermediate bool variable is not needed since we can use the pre-processor
for this.

Remove it as done in ExternalCameraProvider.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Add a stub implementation for provider

In order to implement the provider HAL in AIDL, we need to
instantiate a ICameraDevice.
A ICameraDevice implementation must inherit from BnCameraDevice.

Add a minimal stub, named LibcameraDevice which builds.
This can be used by the provider HAL in getCameraDeviceInterface().

Note that we no longer depend on hidl_defaults so get rid of that as well.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Migrate from v3.5 HIDL to AIDL v1

This migrates the provider HAL from HIDL into AIDL.

This includes the following changes:
- Replace use std::string instead of hidl_string
- Use CameraDeviceStatus enum instead of CAMERA_DEVICE_STATUS
- Use std::shared_ptr<> instead of android::sp<>
- Use method argument naming from ExternalCameraProvider
- Return ndk::ScopedAStatus instead of camera::common::Status
- Remove support of vendor tags as it's un-implemented in libcamera

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Implement BnCameraDevice interface

Implement all required operations of a BnCameraDevice with the exception
for session handling.

Session being a quite complex topic, it will be enabled after the
LibcameraDeviceSession class is implemented.

This is based on the both the legacy 3.2 HIDL HAL and
the External AIDL located in:

//hardware/interfaces/camera/device/3.2/default/CameraDevice
//hardware/interfaces/camera/device/default/ExternalCameraDevice

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: session: Import legacy 3.2 CameraDeviceSession from AOSP

In order to write an AIDL HAL compatible with libcamera, we need
some reference codebase to start from.

Import the 3.2 legacy HAL from AOSP from tag android-15.0.0_r12.
Folder path: //hardware/interfaces/camera/device/3.2/default/
commit ad2ba1b851b6 ("[DON'T BLOCK] Test ownership migration rules")

Note: only the "legacy" part has been imported since external cameras are
supported via android.hardware.camera.provider-V1-external-service.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: session: rename CameraDeviceSession -> LibcameraDeviceSession

This is going to be libcamera specific, so rename it accordingly.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: session: Remove V3_2 namespace to prepare for AIDL

Most AIDL HALs don't use the AIDL version inside the C++ namespace.
Follow that practice and remove it here as well.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: session: Remove HIDL trampoline code to prepare for AIDL

We don't need this, as it's HIDL specific.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: session: Migrate from v3.2 HIDL to AIDL v1

This migrates the DeviceSession class from HIDL into AIDL.

This includes the following changes:
- Use std::shared_ptr<> instead of android::sp<>
- Use std::string instead of hidl_string
- Use std::vector instead of hidl_vec
- Remove V1_0 namespace for camera::common::helper
- Use HandleImporter from camera::common::helper
- Use AIDLMessageQueues and change data type from uint8_t -> int8_t
- Use makeFromAidl() for fence handling
- Use std::move() instead of hand-cloning fences
- Use new NotifyMsg API with class enums
- Use NativeHandle instead off native_handle_t* when needed

Note: by switching to dupToAidl(), we must ensure that the original handle
is deleted.

Note: All AIDL specific operations are stubbed for now, as we are not sure that
those are implemented by libcamera's hw_module.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Use LibcameraDeviceSession class

Now that LibcameraDeviceSession is implemented, we can use it in
LibcameraDevice.

With this change, we can see preview using com.android.camera2 app and
take pictures via libcamera.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: Rename outdated LOG_TAGs

These were leftovers from the code import from AOSP.

Update to use the new naming scheme so that it's easier to grep
for this HAL in logcat.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: Remove un-needed dependencies

While converting to AIDL, we failed to remove the HIDL
dependencies.

Cleanup the dependencies and also depend on common-helper instead of
the deprecated common@1.0-helper.

Note that for device, we cannot get rid of libhidlbase because of our
usage of HandleImporter.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: Remove lazy service support

We have never used the lazy implementation and don't even know how
to test it.

To simplify the codebase, get rid of it.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: add libcamera_aidl_defaults

Add a new libcamera_aidl_defaults which is used by the
camera library.

This allows us to remove lots of duplicated shared_libs since
they are defined in the new defaults.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: provider: Return ILLEGAL_ARGUMENT when callback is nullptr

When a user attempts to setCallback() using a nullptr, we should
return ILLEGAL_ARGUMENT, not OK.

Update the condition and while at it, drop the braces which are
not needed for a single statement.

Not: this is tested by VTS.

Test: atest PerInstance/CameraAidlTest#setCallback/1_android_hardware_camera_provider_ICameraProvider_libcamera_0
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Fix openInjectSession() return code

The AIDL doc states that we should return OPERATION_NOT_SUPPORTED when
this is not implemented.

Fix the return code. This is tested with VTS.

Test: atest PerInstance/CameraAidlTest#configureInjectionStreamsAvailableOutputs/1_android_hardware_camera_provider_ICameraProvider_libcamera_0
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Fix torch related return codes

When these operations are not supported, we should return
OPERATION_NOT_SUPPORTED instead of ILLEGAL_ARGUMENT.

Fix both return codes.

This is tested by VTS.

Test: atest PerInstance/CameraAidlTest#turnOnTorchWithStrengthLevel/1_android_hardware_camera_provider_ICameraProvider_libcamera_0
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: device: Return ILLEGAL_ARGUMENT on invalid output buffer

When we are importing an invalid output buffer, we should return
ILLEGAL_ARGUMENT, not INTERNAL_ERROR.

Fix this.

This is tested by VTS.

Test: atest PerInstance/CameraAidlTest#processCaptureRequestInvalidBuffer/1_android_hardware_camera_provider_ICameraProvider_libcamera_0
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

android: hal: Cleanup makefiles
2026-04-30 16:11:18 +03:00
Roman Stratiienko
1b54a0dbae android: Fallback to some default min/max frame duration
Instead of failing to initialize pipeline.
(uvccamera pipeline doesn't expose these controls)

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2026-04-30 16:11:18 +03:00
Vitor Sato Eschholz
e60f44b965 android: Remove discontiguous planes check from camera buffer
The way discontiguous planes are checked in generic_camera_buffer
ignores that they can be placed in the same dmabuf. This is the
case for AM62x boards, where multiplanar formats are stored
continuously in the memory and referenced through only one
File Descriptor.

Remove the check from generic_camera_buffer.cpp to allow the
creation of CameraBuffers for AM62x boards. The verification
for discontiguous planes are done in v4l2_videodevice.cpp.

Signed-off-by: Vitor Sato Eschholz <vsatoes@baylibre.com>
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2026-04-30 16:11:18 +03:00
Mattijs Korpershoek
485875b0a8 android: camera3_hal: Add stubs for CAMERA_MODULE_API_VERSION_2_5
CAMERA_MODULE_API_VERSION_2_5 provides new functions such as
isStreamCombinationSupported().

isStreamCombinationSupported() is tested by VtsAidlHalCameraProvider_TargetTest

Add stubs for implementing these to fix more VTS.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2026-04-30 16:11:18 +03:00
Mattijs Korpershoek
fe37826bf4 android: mm: generic: Use GraphicBufferAllocator instead of gralloc.h
gralloc.h is a very old API that has been deprecated at least since
Android P (9).

Switch over to a higher level abstraction of gralloc from libui, which
is compatible with Android 11 and up.
Libui:
* is provided in the VNDK (so it's available to vendors).
* is also used in the camera vts test named VtsAidlHalCameraProvider_TargetTest.

Drop the libhardware stub since we no longer need it.

Notes:
* GraphicsBufferAllocator being a Singleton, buffer lifecycle
  management is easier.
* The imported headers from Android generate the -Wextra-semi warning.
  To avoid patching the files, a pragma has been added before inclusion.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2026-04-30 16:11:18 +03:00
Mattijs Korpershoek
8691ade614 android: Stub GraphicBufferAllocator for build tests
If we want to keep building libcamera on traditional Linux systems with:
  -Dandroid=enabled -Dandroid_platform=generic

We should stub GraphicBufferAllocator, which is not available.
It's only available when building with the VNDK or when building within the
AOSP tree.

Also remove some deprecated methods and inclusions which are not needed for
the stub class.

Note: the imported headers from Android generate the -Wextra-semi warning.
      To avoid patching the files, a pragma has been added before inclusion.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
2026-04-30 16:11:18 +03:00
Naushir Patuck
a0f996c21c ipa: rpi: imx500: Update exposure profiles
Allow the max gain to go upto 16x.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:18 +03:00
David Plowman
2c5a3a0e9c ipa: rpi: awb: Update neural network AWB tunings for vc4 platform
The network was trained against CT curves measured for PiSP, so use
those as results are generally a bit better.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2026-04-30 16:11:18 +03:00
David Plowman
aa7e6d7e2e ipa: rpi: Update imx500 tuning files to include neural network AWB
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Richard Oliver
4ee74d6373 ipa: rpi: Expose frameCount in extracted IMX500 tensors
When injecting input tensors, the output results are expected to be made
available at a specific frame. This change exports tensors' frameCount
so that an appropriate comparison can be made by the controlling
application.

Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Konsta
5ae5aea2e1 pipeline: rpi: pisp: Use correct cfe devices
* Raspberry Pi 5 ISP (PiSP) support submitted to upstream libcamera is
  different from their own libcamera fork [1].
* These match the naming used in driver that was merged in upstream
  Linux 6.13 kernel [2].
* Revert back to the correct cfe devices that match the current kernel [3].

[1]: https://github.com/raspberrypi/libcamera
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c#n126
[3]: 317477113b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c (L139-L194)
2026-04-30 16:11:18 +03:00
Naushir Patuck
df8ba90d44 pipeline: rpi: pisp: Enable FE stats crop if needed
If the decimation width is greater than the max stats width, add a
centre crop on the image to allow the stats to be gathered correctly.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Naushir Patuck
ac83d6fb72 RASPBERRYPI ONLY: Handle mandatory stream flags
Look for the RAW mandatory stream flag in the pipeline handler config
file. If this flag is set, it guarantees that the application will
provide buffers for Unicam Image, so override the minUnicamBuffers and
minTotalUnicamBuffers config parameters in the following way:

- If startup drop frames are required, allocate at least 1 internal buffer.
- If no startup drop frames are required, do not allocate any internal buffers.

Look for the Output 0 mandatory stream flag in in the pipeline handler
config file. If this flag is set, it guarantees that the application
will provide buffers for the ISP, do not allocate any internal buffers
for the device.

Add a new rpi_apps.yaml pipeline handler config file that enables both
these flags.  To use the file, set the following env variable for a
custom build:

export LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml

or for a packaged install:

export LIBCAMERA_RPI_CONFIG_FILE=/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Naushir Patuck
7b1d459071 ipa: rpi: imx500: Fix stringop-truncation warning
This warning is issued by the compiler because the strncpy copies across
the whole string array, leaving no place for the nul terminator. Fix it
by copying sizeof(str) - 1 elements.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Naushir Patuck
ad64f9e8cc ipa: rpi: Add support for the Sony IMX500 camera sensor
Add a Sony IMX500 camera helper to the IPA. This also includes support
for the on-chip CNN hardware accelerator and parsing of the neural
network data stream returned in the metadata buffer.

Add tuning files for both VC4 and PiSP platforms.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Naushir Patuck
81fd85c271 ipa: rpi: Handle the new CNN controls in the IPA
Add code to handle the new CNN vendor controls in the Raspberry Pi IPA.

The value of CnnInputTensorInfo is cached as it is the only stateful
input control.

All other controls are output controls, and the values are copied into
directly from the rpiMetadata object if present. The camera helpers
populate the rpiMetadata object if the sensor supports on-board CNN
processing, such as the IMX500.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:18 +03:00
Naushir Patuck
6405af684d controls: ipa: rpi: Add CNN controls
Add the follwing RPi vendor controls to handle Convolutional Neural
Network processing:

CnnOutputTensor
CnnOutputTensorInfo
CnnEnableInputTensor
CnnInputTensor
CnnInputTensorInfo
CnnKpiInfo

These controls will be used to support the new Raspberry Pi AI Camera,
using an IMX500 sensor with on-board neural network processing.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
2026-04-30 16:11:17 +03:00
Laurent Pinchart
4765309efe ipa: rpi: awb_nn: Rename YamlObject to ValueNode
The global rename of YamlObject to ValueNode in commit 554c5c7fa1
missed awb_nn.cpp. Fix it.

Fixes: 554c5c7fa1 ("libcamera: Rename YamlObject to ValueNode")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2026-04-24 20:33:28 +03:00
Laurent Pinchart
16063986bb libcamera: global_configuration: Override options with environment variables
libcamera supports several environment variables that can override
configuration options. This requires components that use such overrides
to call the special envOption() and envListOption() functions, spreading
knowledge of the overrides through the code base. This will hinder
future enhancements to the global configuration, such as implementing
per-camera options that will override pipeline handler-level options. To
prepare for that, move handling of the environment variables to the
GlobalConfiguration class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:09:31 +03:00
Laurent Pinchart
f06ad77043 libcamera: global_configuration: Populate empty configuration
If no configuration file can be parsed, populate an empty configuration.
This will serve as a base to store the configuration options set through
environment variables.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:18 +03:00
Laurent Pinchart
0ef232b486 libcamera: global_configuration: Drop Option type
The GlobalConfiguration::Option type was introduced to decouple the
configuration option storage from its users, and make changes to the
underlying implementation easier. While the type could indeed be changed
to map to a different class, the API would need to remain the same. The
Option type therefore brings little value. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:15 +03:00
Laurent Pinchart
24c965a234 libcamera: global_configuration: Rename Configuration to Option
The GlobalConfiguration::Configuration type represent a configuration
option. Rename it to Option to make this clearer. This shortens lines as
an added bonus.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:12 +03:00
Laurent Pinchart
800a861b01 libcamera: global_configuration: Rename yamlConfiguration_
Once parsed, the global configuration isn't a YAML file anymore. Rename
the yamlConfiguration_ to configuration_.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:11 +03:00
Laurent Pinchart
49d87c613b libcamera: global_configuration: Add missing include and comment
global_configuration.h uses std::initializer_list, include the
corresponding header. Add a comment in global_configuration.cpp to close
an anonymous namespace, as mandated by the coding style.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:09 +03:00
Laurent Pinchart
e2aea3f4e1 libcamera: global_configuration: Reorder functions
Member functions should be implemented in the .cpp file in the same
order as in the class definition, within each access group. Move them to
the right location. While at it, move load() before loadFile() in the
class definition to match execution order, making 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: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:07 +03:00
Laurent Pinchart
1c3e1baa6e libcamera: Pass CameraManager around instead of GlobalConfiguration
The GlobalConfiguration is explicitly passed around through constructors
of various objects that need access to the configuration. This ad-hoc
solution works for the specific use cases it was meant to support, but
isn't very generic. We have a top-level object in libcamera, the
CameraManager, that also needs to be accessed from various locations and
is passed to object constructors. Standardize on passing the
CameraManager everywhere, and access the global configuration through
it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:09:05 +03:00
Laurent Pinchart
52e65c9f38 libcamera: value_node: Add functions to erase child nodes
There will be a need to erase child nodes when implementing support for
overriding configuration options. Add two erase() functions to the
ValueNode class, mimicking the add() API.

More erase() overloads could be added, for instance taking iterators as
parameters, to improve efficiency. This should be considered later, when
usage of the ValueNode class will expand, based on the actual usage
patterns.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:08:51 +03:00
Laurent Pinchart
bb1f1f1da9 libcamera: value_node: Support looking up descendant node by path
Looking up a descendant node based on a path is a common operation. Add
a helper function to do so, to avoid loops in the callers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:48 +03:00
Laurent Pinchart
719dbcdcde libcamera: value_node: Support adding nested children in one operation
The GlobalConfiguration class will need to add nested children to a
ValueNode. Add a new overload to the add() function for this purpose.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:08:44 +03:00
Laurent Pinchart
eafc366012 libcamera: value_node: Add mutable children accessors
Add two at() functions that return mutable pointer to child nodes, based
on an index for lists and a key for dictionaries.

The API differs from const children accessors that use operator[] and
return a reference in order to allow better error handling: while the
const accessors return a reference to a global instance of an empty
ValueNode when the requested child doesn't exist, a mutable accessor
can't do the same without allowing modifying the empty global instance.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:41 +03:00
Laurent Pinchart
b25556c691 libcamera: value_node: Add mutable adapters
The ValueNode class was initially designed to store read-only property
trees. It is useful to also provide mutable access. Add non-const
adapters and iterators and adapters. This allows obtaining a mutable
ValueNode instance when traversing a tree.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:38 +03:00
Laurent Pinchart
7f854199a3 libcamera: value_node: Add constructor with value
The new constructor takes a value, allowing creation of a leaf ValueNode
with a value in a single operation instead of having to call set() on an
empty node.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:32 +03:00
Laurent Pinchart
554c5c7fa1 libcamera: Rename YamlObject to ValueNode
The YamlObject class is now a generic data container to model trees of
values. Rename it to ValueNode and expand the class documentation.

While at it, drop the unneeded libcamera:: namespace prefix when using
the ValueNode class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:08:25 +03:00
Laurent Pinchart
9be3ed8104 libcamera: yaml_object: Miscellaneous documentation improvements
Fix a few documentation issues:

- Drop unneeded \fn
- Sort \brief and \tparam correctly
- Add missing \tparam and \param
- Explain the T and U template parameters for get()
- Standardize the naming of dictionary keys as "key"
- Fix typo

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:19 +03:00
Laurent Pinchart
7133680dd7 libcamera: yaml_parser: Split YamlObject from YamlParser
The YamlObject class was designed to represent data parsed from YAML
files. It is outgrowing the initial needs. Move it to a separate file to
prepare for a rename.

Most files that include yaml_parser.h only need access to a YamlObject.
Switch them to yaml_object.h. pipeline_base.cpp was including
yaml_parser.h indirectly through pipeline_base.h, include it directly
now.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:16 +03:00
Laurent Pinchart
31a817cda2 libcamera: yaml_parser: Drop unneeded \fn Doxygen commands
There's no need to specify the function name in Doxygen comment blocks
with \fn if the documentation directly precedes the function definition.
Drop the unneeded \fn.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:11 +03:00
Laurent Pinchart
bc0318e8c8 libcamera: yaml_parser: Move Size handling to geometry.cpp
The YamlObject::Accessor structure is designed to extend the YamlObject
class with new getter and setter types without modifying
yaml_parser.cpp. This feature is used for various libcamera classes,
while standard C++ types are handled in yaml_parser.cpp.

The Size class is an outlier: it is a libcamera class, but is handled in
yaml_parser.cpp. Move it to geometry.cpp. Drop the std::vector<Size>
specialization as it is currently unused.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:08:09 +03:00
Laurent Pinchart
2894f2c14b libcamera: yaml_parser: Un-friend YamlParserContext from YamlObject
YamlParserContext is a friend of the YamlObject class to access private
member variables. Now that YamlObject exposes functions to set a value
and add children, this is not needed anymore. Decouple the two classes.

The YamlParserContext::readValue() function now takes a const reference
to the EventPtr as the YamlParserContext::parseNextYamlObject() function
needs to access it in the error handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:08:05 +03:00
Laurent Pinchart
f59a6f6857 libcamera: yaml_parser: Add functions to add children
Add YamlObject::add() functions to add children to a list or dictionary
object. This will be used by the YamlParserContext to replace direct
access to YamlObject member variables to decouple the two classes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:08:01 +03:00
Laurent Pinchart
6657a19247 libcamera: yaml_parser: Add function to set a YamlObject value
Add a YamlObject::set() function to set the value of an object, with
specializations for scalar types.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:07:57 +03:00
Laurent Pinchart
3a387cc81d libcamera: yaml_parser: Replace getList() with get() specializations
The YamlObject class has two member function templates to get values:
the get() function gets a scalar value, while the getList() function
gets a vector of scalar values.

As get() is a function template, we can provide specializations for
vector types. This makes the code more systematic, and therefore more
readable. Replace all getList() occurrences, and drop the getList()
function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 18:07:53 +03:00
Laurent Pinchart
56e679ee09 libcamera: yaml_parser: Rename Getter to Accessor
In preparation for support to set the value of a YamlObject, rename the
Getter structure to Accessor. The structure will be extended with a
set() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
2026-04-24 18:07:50 +03:00
Laurent Pinchart
01f5db9559 libcamera: yaml_parser: Use std::make_unique<>
The YamlParser::parse() function constructs a std::unique_ptr<> instance
with a manual call to operator new. Replace it with std::make_unique<>.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2026-04-24 18:07:44 +03:00
Jacopo Mondi
178007f8ad libcamera: mali-c55: Fix sensor size computation
The last size in the list is always selected unconditionally because
the current best distance is not updated properly during the search.

Fix the size computation procedure which has an inverted assignment.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Tested-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2026-04-24 14:38:44 +01:00
Jacopo Mondi
88c636b097 libcamera: mali-c55: Implement capture for memory-to-memory
Plumb in the MaliC55 pipeline handler support for capturing frames
from memory using the CRU.

Introduce a data flow which uses the CRU to feed the ISP through
the IVC.

In detail:

- push incoming request to a pending queue until a buffer from the CRU
  is available
- delay the call to ipa_->fillParams() to the CRU buffer ready event
- once the IPA has computed parameters feed the ISP through the IVC
  with buffers from the CRU, params and statistics
- Handle completion of in-flight requests: in m2m mode buffers are
  queued earlier to the ISP capture devices. If the camera is stopped
  these buffers are returned earlier in error state: complete the
  Request bypassing the IPA operations
- As cancelled Requests might now be completed earlier then IPA events,
  modify the IPA event handler to ignore Requests that have been
  completed already

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2026-04-24 14:38:27 +01:00
Jacopo Mondi
e14c06c19a libcamera: mali-c55: Do not rely on bufferCount
Do not rely on bufferCount for the allocation of parameters and stats
buffers but add instead kMaliC55BufferCount which is also used to limit
the number of in-flight requests supported by the pipeline handler.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 10:22:48 +02:00
Jacopo Mondi
3b6c01fd94 libcamera: mali-c55: Configure camera in memory-to-memory
Add support for memory-to-memory Camera to the
PipelineHandlerMaliC55::configure() function.

Start by enabling the IVC links, then configure the CRU and
propagate the format to the IVC.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 10:22:48 +02:00
Jacopo Mondi
ac9e8dd724 libcamera: mali-c55: Register memory input camera
Add support to Mali C55 pipeline handler for memory-to-memory camera
mode.

The Mali-C55, as integrated in the Renesas RZ/V2H(P) SoC, is fed with
images saved to memory by the CRU unit and read on behalf of the ISP
by the IVC.

Update the pipeline handler's match() function to search for the CRU
media entity necessary to register a memory input camera. Create and
initialize a CameraData instance for the memory camera use case if a
valid CRU is found and initialize the IVC components used to feed the
ISP with images read from memory.

Do not implement camera configuration for the time being to reuce
the patch size. It will be provided in the following patches.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2026-04-24 10:22:48 +02:00
Jacopo Mondi
2dc20dcba0 libcamera: mali-c55: Split TPG and Inline camera handling
In order to prepare to support memory input cameras, split the handling of
the TPG and Inline camera cases.

The Mali C55 pipeline handler uses the entity and subdevice stored in the
CameraData to support both the handling of the TPG and of the Inline (CSI-2
+ sensor) use cases. Adding support for memory cameras by using the CRU unit
would add yet-another special case making the code harder to follow and
more prone to errors.

Split the handling of the TPG and Inline cameras by introducing an
std::variant<> variable and to deflect the functions called on the
camera data to the correct type by using overloaded std::visit<>().

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2026-04-24 10:22:48 +02:00
Jacopo Mondi
c52e8cde3e libcamera: utils: Add overloaded visitor helpers
std::visit() allows quite elegant type-matching implementation of the
visitor pattern.

The 'overloaded' type helpers allow to define a hierarchy of overloaded
operator() implementations which can be used by std::visit().

Currently only the Virtual pipeline handler uses this type-matching
implementation of std::visit(). To prepare to add another user in the
Mali C55 pipeline handler move the 'overloaded' helper type to
libcamera::utils for easier re-use.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
2026-04-24 10:22:48 +02:00