Commit Graph

4969 Commits

Author SHA1 Message Date
Konsta
8bf59a6bbd android: hal: Convert to apex 2026-04-30 16:11:18 +03:00
Konsta
14780c69ca android: Add soong blueprint makefiles for ipa data 2026-04-30 16:11:18 +03:00
Konsta
aa46cf68d9 android: Pass project version to gen-version.sh
* To have version number in meson generated src/libcamera/version.cpp
  on NDK build.
2026-04-30 16:11:18 +03:00
Konsta
caeab4e6ef android: Don't set soversion
Change-Id: Ic8056f5bf13d9706fb1671dbfbebeb03c45515c8
2026-04-30 16:11:18 +03:00
Konsta
d1d0c73304 HACK: android: Make libjpeg optional
* To build using NDK.
2026-04-30 16:11:18 +03:00
Konsta
0ee1303114 HACK: android: Fixes to build as part of AOSP 2026-04-30 16:11:18 +03:00
Konsta
5910141a68 HACK: android: Remove support for color spaces 2026-04-30 16:11:18 +03:00
Roman Stratiienko
2a1ba049b9 HACK: android: Set cfg.bufferCount to some value
Otherwise Android framework will fail to configure camera.

Change-Id: I8d89a8ae52b248781c1fce9e890d3a6fc258e4f4
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2026-04-30 16:11:18 +03:00
Roman Stratiienko
91d99ba46e HACK: android: Report IPA signature is always valid
Without gnutls libcamera will always require proxy service for IPA.
Building within Android using meson.build has a problem with producing
executables, therefore disable check to allow dlopen() IPA instead.

Suggested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Change-Id: Ia1262cc7198ca196860b5f6526b55c8071b07f1f
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2026-04-30 16:11:18 +03:00
Maxime Fournier
b02341aa90 android: hal: implement signalStreamFlush with race condition handling
Add proper implementation of signalStreamFlush() to handle stream buffer
flushing before reconfiguration. Features:
- Stream configuration counter to prevent race conditions
- Validation of stream IDs against configured streams
- Inflight buffer tracking and reporting for affected streams
- Warning when buffers are detected to prevent fatal errors

Increments mStreamConfigCounter during configureStreams() and uses atomic
operations to detect stale signalStreamFlush() calls, ensuring proper
synchronization during stream reconfiguration.

Further details about the race condition scenario can be found at [1].

[1] https://android.googlesource.com/platform/hardware/interfaces/+/master/camera/device/aidl/android/hardware/camera/device/ICameraDeviceSession.aidl#489

Signed-off-by: Maxime Fournier <mfournier@baylibre.com>
2026-04-30 16:11:18 +03:00
Maxime Fournier
7e2ca2b541 android: hal: implement isReconfigurationRequired function
Add session parameter comparison logic to determine when stream
reconfiguration is needed. Compares critical parameters between
old and new session configurations:
- ANDROID_CONTROL_AE_TARGET_FPS_RANGE (frame rate changes)
- ANDROID_FLASH_MODE (flash/torch mode changes)
- ANDROID_CONTROL_VIDEO_STABILIZATION_MODE (stabilization changes)

Returns true if any parameter changes would require complete stream
reconfiguration, enabling more efficient camera session management.

Signed-off-by: Maxime Fournier <mfournier@baylibre.com>
2026-04-30 16:11:18 +03:00
Maxime Fournier
3002f283ea android: hal: implement repeatingRequestEnd callback
Add proper implementation of repeatingRequestEnd() function for Android
Camera HAL compliance. Validates stream IDs and logs notification about
the final frame number when repeating requests end.

This is a lightweight notification callback that informs the HAL when
repeating capture requests will terminate at a specific frame number
for given streams, as required by the Android Camera HAL specification.

Always return Status::OK since the method must always succeed as described in [1].

[1] https://android.googlesource.com/platform/hardware/interfaces/+/master/camera/device/aidl/android/hardware/camera/device/ICameraDeviceSession.aidl#570

Signed-off-by: Maxime Fournier <mfournier@baylibre.com>
2026-04-30 16:11:18 +03:00
Maxime Fournier
276d062e23 android: camera: fix unsupported camera control validation
Add runtime validation for camera controls before setting them to prevent
spam errors. Check controls.find() for ANDROID_SCALER_CROP_REGION and
ANDROID_STATISTICS_FACE_DETECT_MODE before attempting to set values.

Fixes error spam:
- "Control 0x0000001b is not valid" (ScalerCrop)
- "Control 0x0000271a is not valid" (FaceDetectMode)

Only sets controls that are supported by the specific camera hardware,
improving HAL compliance and reducing log noise.

Signed-off-by: Maxime Fournier <mfournier@baylibre.com>
2026-04-30 16:11:18 +03:00
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