Commit Graph

5783 Commits

Author SHA1 Message Date
Milan Zamazal
d03a4fbfcd config: Check configuration file version
We don't know what the future versions of the configuration file will
look like.  The current code can process only version 1; let's check
that the read configuration is of this version.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:14 +03:00
Milan Zamazal
79a75b9088 libcamera: software_isp: Make measurement configurable
Software ISP performs performance measurement on certain part of initial
frames.  Let's make this range configurable.

For this purpose, this patch introduces new configuration options
software_isp.measure.skip and software_isp.measure.number.  Setting the
latter one to 0 disables the measurement.

Instead of the last frame, the class member and its configuration
specify the number of frames to measure.  This is easier to use for
users and doesn't require to adjust two configuration parameters when
the number of the initially skipped frames is changed.

The patch also changes the names of the class members to make them more
accurate.

Completes software ISP TODO #7.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:14 +03:00
Milan Zamazal
6e1d889cfe libcamera: software_isp: Make input buffer copying configurable
On some platforms, working directly on the input buffer is very slow due
to disabled caching.  This is why we copy the input buffer into standard
(cached) memory.  This is an unnecessary overhead on platforms with
cached buffers.

Let's make input buffer copying configurable.  The default is still
copying, as its overhead is much lower than contingent operations on
non-cached memory.  Ideally, we should improve this in future to set the
default to non-copying if we can be sure under observable circumstances
that we are working with cached buffers.

Completes software ISP TODO #6.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:13 +03:00
Milan Zamazal
e367cd9c74 Documentation: Add global configuration file documentation
Extend (and rename) the documentation of environment variables with
information about the configuration file.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:13 +03:00
Milan Zamazal
740c21eb58 pipeline: simple: Allow enabling software ISP via config file
This patch allows enabling or disabling software ISP via config file in
addition to compile time.  This can be useful for software ISP testing
on various platforms as well as for overriding the defaults in case the
defaults don't work well (e.g. hardware ISP may or may not work on
i.MX8MP depending on the kernel and libcamera patches present in the
given system).

The configuration is specified as follows:

  configuration:
    pipelines:
      simple:
        supported_devices:
          - driver: DRIVER-NAME
            software_isp: BOOLEAN
          - ...

For example:

  configuration:
    pipelines:
      simple:
        supported_devices:
          - driver: mxc-isi
            software_isp: true

The overall configuration of enabling or disabling software ISP may get
dropped in future but this patch is still useful in the meantime.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:13 +03:00
Milan Zamazal
7ba8c15dbf camera_manager: Look up pipelines match list in configuration file
Let's add a configuration file item for the pipelines match list.

The configuration snippet:

  configuration:
    pipelines_match_list:
      - rkisp1
      - simple

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:13 +03:00
Milan Zamazal
dcbde32f5e ipa: Look up IPA configurables in configuration file
This patch adds configuration options for environment variables used in
the IPA proxy.

The configuration snippet:

  configuration:
    ipa:
      config_paths:
        - config path 1
        - config path 2
        - ...
      module_paths:
        - module path 1
        - module path 2
        - ...
      proxy_paths:
        - proxy path 1
        - proxy path 2
        - ...
      force_isolation: BOOL

LIBCAMERA_<IPA_NAME>_TUNING_FILE remains configurable only via the
environment variable; this is supposed to be used only for testing and
debugging and it's not clear what to do about IPA names like "rpi/vc4"
and "rpi/pisp" exactly.

There are two ways to pass the configuration to the places where it is
needed: Either to pass it as an argument to the method calls that need
it, or to pass it to the class constructors and extract the needed
configuration from there.  This patch uses the second method as it is
less polluting the code.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:12 +03:00
Milan Zamazal
17febd7bb3 config: Add configuration retrieval helpers
Let's add some helpers to make accessing simple configuration values
simpler.  The helpers are used in the followup patches.

GlobalConfiguration::option ensures that no value is returned rather
than a value of YamlObject::empty.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:42:11 +03:00
Milan Zamazal
94236f64ff libcamera: camera_manager: Construct GlobalConfiguration instance
Global configuration is accessed via a GlobalConfiguration instance.
The instance is conceptually a singleton, but singletons are not welcome
in libcamera so we must store the (preferably single) instance
somewhere.

This patch creates a GlobalConfiguration instance in CameraManager and
defines the corresponding access method.  CameraManager is typically
instantiated only once or a few times, it is accessible in many places
in libcamera and the configuration can be retrieved from it and passed
to other places if needed (it's read-only once created).  Using
CameraManager for the purpose is still suboptimal and we use it only due
to lack of better options.  An alternative could be Logger, which is
still a singleton and it's accessible from everywhere.  But with Logger,
we have a chicken and egg problem -- GlobalConfiguration should log
contingent problems with the configuration when it's loaded but if it is
created in the logger then there are mutual infinite recursive calls.
One possible way to deal with this is to look at the environment
variables only during logging initialisation and apply the logging
configuration when a CameraManager is constructed.  Considering there
are intentions to remove the Logger singleton, let's omit logging
configuration for now.

If there are multiple CameraManager instances, there are also multiple
GlobalConfiguration instances, each CameraManager instance is meant to
be fully independent, including configuration.  They may or may not
contain the same data, depending on whether the global configuration
file in the file system was changed in the meantime.

The configuration is stored in the private CameraManager.  It's
accessible within libcamera (via CameraManager) but it's not meant to be
accessed by applications.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:39:36 +03:00
Milan Zamazal
978dc07222 config: Introduce global runtime configuration
Currently, libcamera can be configured in runtime using several
environment variables.  With introducing more and more variables, this
mechanism reaches its limits.  It would be simpler and more flexible if
it was possible to configure libcamera in a single file.

For example, there was a request to define pipeline precedence in
runtime.  We want to compile in multiple pipelines, in order to have
them accessible within single packages in distributions.  And then being
able to select among the pipelines manually as needed based on the
particular hardware or operating system environment.  Having the
configuration file then allows easy switching between hardware, GPU or
CPU IPAs.  The configuration file can also be used to enable or disable
experimental features and avoid the need to track local patches changing
configuration options hard-wired in the code when working on new
features.

This patch introduces basic support for configuration files.
GlobalConfiguration class reads and stores the configuration.  Its
instance can be used by other libcamera objects to access the
configuration.  A GlobalConfiguration instance is supposed to be stored
in a well-defined place, e.g. a CameraManager instance.  It is possible
to have multiple GlobalConfiguration instances, which may or may not
make sense.

libcamera configuration can be specified using a system-wide
configuration file or a user configuration file.  The user configuration
file takes precedence if present.  There is currently no way to merge
multiple configuration files, the one found is used as the only
configuration file.  If no configuration file is present, nothing
changes to the current libcamera behavior (except for some log
messages related to configuration file lookup).

The configuration file is a YAML file.  We already have a mechanism for
handling YAML configuration files in libcamera and the given
infrastructure can be reused for the purpose.  However, the
configuration type is abstracted to make contingent future change of the
underlying class easier while retaining (most of) the original API.

The configuration is versioned.  This has currently no particular
meaning but is likely to have its purpose in future, especially once
configuration validation is introduced.

The configuration YAML file looks as follows:

  ---
  version: 1
  configuration:
    WHATEVER CONFIGURATION NEEDED

This patch introduces just the basic idea.  Actually using the
configuration in the corresponding places (everything what is currently
configurable via environment variables should be configurable in the
file configuration) and other enhancements are implemented in the
followup patches.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-21 09:39:34 +03:00
Stefan Klug
2f7c474479 tuning: rksip1: Add a static WideDynamicRange entry
Add a static WideDynamicRange entry that gets added by default.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
f62a1498e9 ipa: rkisp1: Add WDR algorithm
Add a WDR algorithm to do global tone mapping. Global tone mapping is
used to increase the perceived dynamic range of an image. The typical
effect is that in areas that are normally overexposed, additional
structure becomes visible.

The overall idea is that the algorithm applies an exposure value
correction to underexpose the image to the point where only a small
number of saturated pixels is left. This artificial underexposure is
then mitigated by applying a tone mapping curve.

This algorithm implements 4 tone mapping strategies:
- Linear
- Power
- Exponential
- Histogram equalization

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
026f25f32b rkisp1: agc: Agc add yTarget to frame context
The upcoming WDR algorithm needs access to the effective yTarget value
for its calculations. Add it to the frame context.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
06fe931d79 libipa: agc_mean_luminance: Add support for additional constraints
Add support for additional constraints added at runtime. This is for
example useful for WDR use cases where you want to add an upper
constraint to limit the amount of saturated pixels.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
6eb02d6759 libipa: agc_mean_luminance: Introduce effectiveYTarget() accessor
The upcoming WDR algorithm needs to know the effective y target (Which
includes the current ExposureValue). Add an accessor for that.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul ELder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
c7cc1f7f0d pipeline: rkisp1: Query kernel for available params blocks
Query the params device for RKISP1_CID_SUPPORTED_PARAMS_BLOCKS and
inject the information into the IPA hardware context for use by the
algorithms.

To be able to modify the hardware configuration at runtime, replace the
pointer with an instance and create a copy of the static hardware
specific data.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
c8f323b7ae ipa: rkisp1: Switch histogram to RGB combined mode
The Y mode of the histogram gets captured at the ISP output, before the
output formatter.  This has the side effect that the first and the last
bins are empty in case of limited YUV range.  Another side effect is
that gamma and GWDR processing is included in the histogram which makes
algorithm development very difficult. In RGB mode the histogram is taken
after xtalk (CCM) and is therefore independent of gamma and WDR. The
limited range issue also does not apply. In the ISP reference it is
however stated that "it is not possible to calculate a luminance or
grayscale histogram from an RGB histogram since the position information
is lost during its generation".

During testing the RGB histogram provided good data and better
algorithmic stability at a possible (but not measured) inaccuracy.

Another option would be to pass the color space information into the IPA
and strip the histogram accordingly. For ease of implementation switch to
the RGB mode.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
42ddab5e18 include: linux: Partially update linux headers from v6.16-rc1-310-gd968e50b5c26
Update rkisp1-config.h and v4l2-controls.h from the next branch of
https://gitlab.freedesktop.org/linux-media/media-committers.git to
include the WDR related updates. The rest was left as is to minimize the
risk of issues due to last minute changes in the upstream process.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Acked-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
96d346c935 pipeline: rkisp1: Add error log when parameter queuing fails
When the extensible parameters queued to the kernel contain an unknown
block type it fails with -EINVAL. This should not happen as user land is
supposed to check for the supported parameter types. But it took a while
to figure out where things went wrong. Add a error statement when
queuing of the parameter buffer fails for whatever reason.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
ef830669d0 ipa: rkisp1: agc: Add correction for exposure quantization
There are several occasions where quantization can lead to visible
effects.

In WDR mode it can happen that exposure times get set to very low values
(Sometimes 2-3 lines). This intentionally introduced underexposure is
corrected by the GWDR module. As exposure time is quantized by lines,
the smallest possible change in exposure time now results in a quite
visible change in perceived brightness.

On some sensors the possible gain steps are also quite large leading to
visible jumps if e.g. if the exposure time is fixed.

Mitigate that by applying a global gain to account for the error
introduced by the exposure quantization.

ToDo: This needs perfect frame synchronous control of the sensor to work
properly which is not guaranteed in all cases. It still improves the
behavior with the current regulation and can easily be skipped, be
removing the compress algorithm from the tuning file.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
57a46118a8 libipa: exposure_mode_helper: Calculate quantization gain in splitExposure()
Calculate the error introduced by quantization as "quantization gain"
and return it separately from splitExposure(). It is not included in the
digital gain, to not silently ignore the limits imposed by the AGC
configuration.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
0ba6d930de libipa: agc_mean_luminance: Configure the exposure mode helpers
Add a function to configure the exposure mode helpers with the line
length and sensor helper to take quantization effects into account.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
3d310f106a libipa: agc_mean_luminance: Fix constraint logging
The debug log statements in constraintClampGain() are after the
assignment of gain. So they correctly log when the constraint applies,
but the gain values logged are the same. Fix that.

Fixes: 42e18c96bc ("libipa: agc_mean_luminance: Add debug logging")
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
3c3b9f1091 libipa: exposure_mode_helper: Remove unnecessary clamp calls
Except for the first iteration of the loop and in the case of an empty
gains_ vector, the values were run through clamp two times which is
unnecessary. Remove that by clamping the initial value.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
0efa130b25 libipa: exposure_mode_helper: Remove double calculation of lastStageGain
lastStageGain gets recalculated unconditionally even though it is the
stageGain of the last stage. Refactor for increased simplicity and
efficiency.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
f077c58e08 libipa: exposure_mode_helper: Take exposure/gain quantization into account
In ExposureModeHelper::splitExposure() the quantization of exposure time
and gain is not taken into account. This can lead to visible flicker
when the quantization steps are too big. As a preparation to fixing
that, add a function to set the sensor line length and the current
sensor mode helper and extend the clampXXX functions to return the
quantization error.

By default the exposure time quantization is assumed to be 1us and gain
is assumed to not be quantized at all.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
1400058ed4 libipa: camera_sensor_helper: Add quantizeGain() function
Add a small utility function that calculates the quantized gain that
gets applied by a sensor when the gain code is set to gainCode(gain).
This is needed by algorithms to calculate a digital correction gain that
gets applied to mitigate the error introduce by quantization.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
737f6f8da1 tuning: rksip1: Add a static Compress entry
Add a static Compress entry that gets added by default.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-19 10:48:05 +01:00
Stefan Klug
b57ad23eb5 ipa: rkisp1: Add basic compression algorithm
The i.MX8 M Plus has a compression curve inside the compand block.  This
curve is necessary to process HDR stitched data and is useful for other
aspects like applying a digital gain to the incoming sensor data.

Add a basic algorithm for the compression curve. This algorithm has a
hardcoded input width of 20bit and output width of 12bit which matches
the imx8mp pipeline. Only a static gain is supported in this version.

Signed-off-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-09-19 10:48:05 +01:00
Laurent Pinchart
d358020932 Documentation: Rename api to public-api and drop -html suffix
The public and internal Doxygen API documentation is compiled and
installed in api-html and internal-api-html directories respectively.
The '-html' suffix doesn't provide any value, and the asymmetry between
the names can be confusing. Rename the directories to public-api and
internal-api respectively.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-09-18 22:22:58 +03:00
Stefan Klug
d317f36bd7 Documentation: mainpage: Make it easier to distinguish public and internal API
It might be confusing to consumers to see very similar looking doxygen
documentation with different content. Improve that by clearly stating
'public API' or 'internal API' on the main page.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-09-18 22:22:57 +03:00
Stefan Klug
c54eec09db Documentation: Drop unnecessary documentation-contents.rst
The libcamera.org documentation publishing process does not rely on a
particular structure of the documentation anymore. This makes
documentation-contents.rst unneeded. Drop it.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-09-18 22:22:56 +03:00
Laurent Pinchart
4a9863e053 Documentation: Improve Sphinx and Doxygen integration
The libcamera documentation comprises two parts: pages generated by
Sphinx into the Documentation/html/ directory within the build tree, and
API reference documentation generated by Doxygen into
Documentation/internal-api-html/ and Documentation/api-html/. The two
parts are generated separately, but link to each other.

From Sphinx to Doxygen, we use the doxylink extension for Sphinx to
generate links to the Doxygen pages corresponding to API elements. The
extension needs to be configured with the paths to the Doxygen
documentation, which are set based on the html/, api-html/ and
internal-api-html/ directories being placed side by side in the same
parent directory.

Furthermore, we also want to link to the API documentation from the
Sphinx toctree. As toctrees can only link to pages within the Sphinx
documents tree (or to http URLs), we have placeholder .rst documents for
api-html and internal-api-html in the Sphinx documentation tree. Those
generate the Documentation/html/internal-api-html/index.html and
Documentation/html/api-html/index.html placeholder files in the build
tree.

The other way around, the API documentation's introduction pagelinks to
Sphinx pages using relative paths. Those paths are hardcoded based on
the api-html/ and internal-api-html/ directories being children of the
html/ directory.

This results in links being broken in different ways in the build tree,
as well as in the installation directory: the toctree links direct to
the placeholder pages within the html/ directory instead of the Doxygen
documentation in sibling directories, and the Doxygen introduction links
to Sphinx are simply broken. When publishing documentation on the
website we work around those issues by overriding conf.py with a custom
version and moving the api-html/ and internal-api-html/ directories to
the html/ directory.

Fixing this is surprisingly difficult. The toctree links can't be
changed to point to a path outside of the Sphinx document tree as this
isn't supported by Sphinx. Using http URLs would link to the
libcamera.org website inside of local documentation, which isn't
acceptable. It may be possible to develop a Sphinx extension to patch
the toctree after it gets parsed, but that would be complex and likely
fragile. Modifying the install path of the Doxygen documentation to
html/api-html/ and html/internal-api-html/ causes issues as the Sphinx
documentation will then overwrite the Doxygen index.html files with the
placeholder indexes. Creating symlinks from html/api-html/ to api-html/
in the installation directory causes similar problems if 'meson install'
is run twice. Creating the symlinks in the build directory (which was
attempted with a custom Sphinx extension) is also a no-go: starting with
meson v1.8.0, installing symlinks to directories causes an exception due
to a bug in meson.

The right solution is probably to investigate usage of the doxysphinx
extension. As that's no small amount of work, let's start with a
non-perfect but simple improvement: configure doxylink based on the
api-html/ and internal-api-html/ directories being children of the
Sphinx html/ documentation, and move those two API documentation
directories to html/ during installation with a post-install script.

This fixes links in the installation directory. Links in the build
directory remain broken, with the toctree links and the links from
Doxygen to Sphinx being broken already, and the links to API elements
through doxylink now being broken too. This is considered as an
acceptable compromise and an overall improvement. The installation
directory is more important, as in the build tree people also have
access to sources. Application developers in particular are less likely
to read documentation from the libcamera build tree, they may not even
have a copy of the libcamera source tree.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-09-18 22:22:55 +03:00
Stefan Klug
aec2d99e3a Documentation: Reorganize toctree
The libcamera Sphinx documentation contains three toctrees: a main
toctree that contains all documentation pages in a flat hierarchy, and
two hidden toctrees that point to the introduction and API pages. This
architecture is mostly meant to support publishing the documentation on
the libcamera.org website. The process recreates a hybrid documentation
tree mixing content specific to the website and content extracted from
libcamera. The hidden toctrees are used to prevent Sphinx from warning
about unreferenced pages when the documentation is built as part of
libcamera.

This set of hacks work, but produce unorganized documentation in the
build directory, as well as when installed to the system. Furthermore,
they make it difficult to host multiple versions of the libcamera
documentation on the website, which we will eventually want to do as the
API stabilizes. It would be generally better to host on libcamera.org
the documentation built as part of libcamera with the same structure of
documents.

To prepare for that change, reorganize the toctrees in libcamera with
three visible trees: a toctree for users, a toctree for developers, and
a toctree for integrators. Include the public and internal API pages
in the first two trees respectively. This mimics the structure of the
documentation as currently organized on the website. The resulting
documentation becomes easier to navigate in the build and installation
directories.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-09-18 22:22:54 +03:00
Laurent Pinchart
b42da3b975 Documentation: Add api-html/ and internal-api-html/ to docs sources
The api-html/index.rst and internal-api-html/index.rst files are
missing from docs_sources. Changes to those files therefore don't
trigger a documentation rebuild. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-09-18 22:22:53 +03:00
Stefan Klug
8b8b01381d Documentation: Use the sphinx book theme
Our current theme doesn't handle many of the rst features (namely notes,
proper code highlighting, font formatting). The sphinx book theme
provides a unobtrusive design which makes the documentation way more fun
to read. The branding is minimal. The libcamera logo is included and
theme colors are set to the libcamera blue.

To get meson/sphinx to successfully compile the docs the package
"python3-sphinx-book-theme" needs to be installed (at least on debian
based systems).

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
2025-09-18 22:22:52 +03:00
Stefan Klug
42d914f20c Documentation: Enable doxygen-awesome-css
Include doxygen-awesome-css in the doxygen config.

The project's documentation indicated that the HTML_COLORSTYLE option
needs to be set to LIGHT starting with Doxygen 1.9.5. The reason isn't
explained, and tests have not shown any noticeable difference with
Doxygen 1.9.5, 1.13.2 and 1.14.0.

Unlike Doxygen itself that generates different CSS files depending on
the HTML color style, doxygen-awesome-css use the same CSS that defaults
to auto-light, and relies on adding "light-mode" to the class of the
<html> element manually to disable dark mode.

As we don't do this, doxygen-awesome-css effectively operates in
auto-light mode. Given that setting HTML_COLORSTYLE to LIGHT makes no
visible difference, leave the option unset to default to auto-light mode
that matches the actual behaviour.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
2025-09-18 22:22:51 +03:00
Stefan Klug
c8283ce8fb Documentation: Add doxygen-awesome-css
Add the doxygen-awesome files to the libcamera repository to improve
the styling of the doxygen documentation. These are from

commit 46f0661d13206b0f837784426580c5470ec6d1b7
Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date:   Thu Sep 11 21:32:39 2025 +0300

    Documentation: doxygen-awesome-css: Switch license information to SPDX

of https://github.com/jothepro/doxygen-awesome-css. Only the files
needed by libcamera are imported.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-18 22:22:50 +03:00
Laurent Pinchart
31e6c18151 Documentation: Use standard ordering for Doxyfile variables
Order the variables in Doxyfiles as in the template generated by
'doxygen -g'. This doesn't have any functional change, but provides a
standard order when adding new variables.

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>
2025-09-18 22:22:49 +03:00
Matthias Fend
e8304bc6c1 libcamera: libipa: camera_sensor: Add Himax HM1246 sensor properties
Provide the Himax HM1246 camera sensor properties and registration with
libipa for the gain code helpers.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-18 16:31:28 +01:00
Benjamin Mugnier
481c659c7e libcamera: libipa: Add vd55g1 support for libipa
Values are sourced initially from the vd55g1 user manual.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-18 12:50:02 +01:00
Benjamin Mugnier
59db8f9863 ipa: rpi: Add vd55g1 tuning files for rpi
For both vc4 and pisp, vd55g1.json has been generated using ctt with
rpi.dpc algorithm removed as this is already handled in the sensor's
ISP. vd55g1_mono.json has been adapted from vd55g1.json by removing
color correction related algorithms.

Adding Cyril Liotard as co-developer for providing the base vd55g1.json
tuning files for both vc4 and pisp. Thank you.

Co-Developed-by: Cyril Liotard <cyril.liotard@st.com>
Signed-off-by: Cyril Liotard <cyril.liotard@st.com>
Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Acked-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-18 12:50:02 +01:00
Benjamin Mugnier
5e038387f1 ipa: rpi: Add vd55g1 support for rpi
The cam_helper gain formula and frameIntegrationDiff can be found in the
vd55g1 user manual.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Acked-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-18 12:50:02 +01:00
Benjamin Mugnier
57ca25b61e libcamera: camera_sensor_properties: Add vd55g1 camera sensor
Add unit cell size from the 'pixel size' element in the datasheet.
Controls are buffered within the sensor and are always applied at frame
N+2.

Signed-off-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2025-09-18 12:50:02 +01:00
Barnabás Pőcze
0e096da4b4 libcamera: request: addBuffer(): Do not destroy fence on failure
Take the unique pointer to the `Fence` object by rvalue reference
so that it is not destroyed if the function returns an error code
and does not take ownership of the unique pointer.

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-09-16 17:48:46 +02:00
Stefan Klug
49439d6de5 pycamera: Fix FrameBuffer::planes wrapper
In commit b8d332cdcc ("libcamera: framebuffer: Replace vector with
span in constructor") the FrameBuffer::planes() function was modified to
return a Span instead of a vector. This leads to the following runtime
exception in the python binding:

TypeError: Unregistered type : libcamera::Span<libcamera::FrameBuffer::Plane const, 18446744073709551615ul>

Fix that by manually converting the Span to a vector.

Note: The best solution would be to implement a Span type caster for
pybind11. But implementing and testing that properly is a bit more
involved than expected. As we don't need bidirectional mapping, use the
same workaround as for FrameMetadata::planes() for now.

While at it, update the lambda for pyFrameMetadata.planes() to call the
inner planes() only once.

Fixes: b8d332cdcc ("libcamera: framebuffer: Replace vector with span in constructor")
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-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-09-16 16:37:42 +02:00
Laurent Pinchart
b8d332cdcc libcamera: framebuffer: Replace vector with span in constructor
The FrameBuffer constructor takes a list of planes as an std::vector.
The caller may stores the planes in a different type of container,
resulting in the needless allocation of a temporary vector. Replace it
with a span.

Suggested-by: Daniel Rákos <daniel.rakos@rastergrid.com>
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-09-08 20:40:18 +02:00
Laurent Pinchart
5e351b89f0 pipelines: Use lambda functions to factor out buffer mapping code
Multiple pipeline handlers duplicate code related to mapping params and
stats buffers to IPA modules. Factor out the code to lambda functions to
share it between the two buffer types.

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>
2025-09-08 20:40:18 +02:00
Barnabás Pőcze
7602181be1 utils: codegen: gen-formats.py: Fix big endian formats
First, there is a single big endian format defined in `formats.yaml`: RGB565_BE.
However, while the yaml file specifies "big_endian: true", the python script
looks for a key named "big-endian". Causing `RGB565{,_BE}` both to be the same.

Second, the python script simply appends " | DRM_FORMAT_BIG_ENDIAN" to the
fourcc of the format. However, there is no definition of that macro is
available in the only user, `formats.h.in`.

Fix the first one by checking for "big_endian" in the script as well, and
fix the second one by defining a constant with the same value and using that.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Fixes: 7c496f1c54 ("utils: gen-formats: Support big-endian DRM formats")
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-09-08 10:56:38 +02:00
Barnabás Pőcze
479a9031f5 utils: codegen: gen-formats.py: Use jinja
Currently the gen-formats.py script can only be used to generate C++
code because it hard-codes part of the template. Use jinja to fully
remove any such dependency.

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-09-08 10:56:35 +02:00