[02/10] libcamera: control_ids_core: Add DigitalGainMode enum
diff mbox series

Message ID 20261117-sklug-digital-gain-support-v1-v1-2-f0aa342ca877@ideasonboard.com
State New
Headers show
Series
  • libipa: agc: Add digital gain support
Related show

Commit Message

Stefan Klug Nov. 17, 2026, 8:47 a.m. UTC
Add a DigitalGainMode enum that works the same way for digital gain as
the AnalogGainMode works for analogue gain.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 src/libcamera/control_ids_core.yaml | 44 +++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Barnabás Pőcze Nov. 17, 2026, 10:39 a.m. UTC | #1
Hi

2026. 11. 17. 9:47 keltezéssel, Stefan Klug írta:
> Add a DigitalGainMode enum that works the same way for digital gain as
> the AnalogGainMode works for analogue gain.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>   src/libcamera/control_ids_core.yaml | 44 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 44 insertions(+)
> 
> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
> index 6504f983faa6..394447b31d3e 100644
> --- a/src/libcamera/control_ids_core.yaml
> +++ b/src/libcamera/control_ids_core.yaml
> @@ -1380,4 +1380,48 @@ controls:
>           The nominal range is [-180, 180], where 0° leaves hues unchanged and the
>           range wraps around continuously, with 180° == -180°.
>   
> +  - DigitalGainMode:

This series should close https://gitlab.freedesktop.org/camera/libcamera/-/work_items/376
one way or another.

As I have already mentioned it, to me `DigitalGainLimits` seems like a better way to
provide control over the applied digital gain. It allows switching between manual/auto
without having a separate control like `DigitalGainMode`, and it allows an application
more fine grained control over the range of digital gain used. And importantly, the
implementation is already there, `DigitalGainLimits` is all but already implemented.
Arguably, there could be reasons to limit which capabilities of the implementation
are made accessible, but I couldn't think of a good one yet for this specific case.

And I suppose one could argue that "but the auto limits are in the tuning file", but
at that point I think we have to admit we view an application and the tuning file file
as effectively inseparable, and consequently there should be a mechanism to inject tuning
files or at least override the same parameters.


> +      type: int32_t
> +      direction: inout
> +      description: |
> +        Controls the source of the digital gain that is applied during processing.
> +
> +        When set to Auto, the AEGC algorithm computes the digital gain and
> +        configures the ISP accordingly. When set to Manual, the value

It doesn't seem inconceivable to me that a platform might combine ISP + sensor digital
gain for a larger range. The `DigitalGain` documentation explicitly mentions that the gain
may be applied in distinct processing step. So I feel like I would rephrase this, e.g.:

   When set to Auto, the system will use the digital gain calculated by the AEGC algorithm.
   When set to Manual, the value of the DigitalGain control is used.


> +        of the DigitalGain control is used.
> +
> +        When transitioning from Auto to Manual mode and no DigitalGain control
> +        is provided by the application, the last value computed by the AEGC
> +        algorithm when the mode was Auto will be used. If the DigitalGainMode
> +        was never set to Auto (either because the camera started in Manual mode,
> +        or Auto is not supported by the camera), the camera should 1.0 as value.

   should >>use<< 1.0

?

> +
> +        If Manual is supported, the DigitalGain control must
> +        also be supported.
> +
> +        \sa ExposureTimeMode
> +        \sa AnalogueGain
> +      enum:
> +        - name: Auto
> +          value: 0
> +          description: |
> +            The digital gain will be calculated automatically and set by the
> +            AEGC algorithm.
> +
> +            If DigitalGain is set while this mode is active, it will be
> +            ignored, and it will also not be retained.
> +
> +            When transitioning from Manual to Auto mode, the AEGC should start
> +            its adjustments based on the last set manual DigitalGain value.
> +        - name: Manual
> +          value: 1
> +          description: |
> +            The digital gain will not be updated by the AEGC algorithm.
> +
> +            When transitioning from Auto to Manual mode, the last computed
> +            gain value is used until a new value is specified through the
> +            DigitalGain control. If an DigitalGain value is specified in the
> +            same request where the DigitalGainMode is changed from Auto to
> +            Manual, the provided DigitalGain is applied immediately.
> +
>   ...
>

Patch
diff mbox series

diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
index 6504f983faa6..394447b31d3e 100644
--- a/src/libcamera/control_ids_core.yaml
+++ b/src/libcamera/control_ids_core.yaml
@@ -1380,4 +1380,48 @@  controls:
         The nominal range is [-180, 180], where 0° leaves hues unchanged and the
         range wraps around continuously, with 180° == -180°.
 
+  - DigitalGainMode:
+      type: int32_t
+      direction: inout
+      description: |
+        Controls the source of the digital gain that is applied during processing.
+
+        When set to Auto, the AEGC algorithm computes the digital gain and
+        configures the ISP accordingly. When set to Manual, the value
+        of the DigitalGain control is used.
+
+        When transitioning from Auto to Manual mode and no DigitalGain control
+        is provided by the application, the last value computed by the AEGC
+        algorithm when the mode was Auto will be used. If the DigitalGainMode
+        was never set to Auto (either because the camera started in Manual mode,
+        or Auto is not supported by the camera), the camera should 1.0 as value.
+
+        If Manual is supported, the DigitalGain control must
+        also be supported.
+
+        \sa ExposureTimeMode
+        \sa AnalogueGain
+      enum:
+        - name: Auto
+          value: 0
+          description: |
+            The digital gain will be calculated automatically and set by the
+            AEGC algorithm.
+
+            If DigitalGain is set while this mode is active, it will be
+            ignored, and it will also not be retained.
+
+            When transitioning from Manual to Auto mode, the AEGC should start
+            its adjustments based on the last set manual DigitalGain value.
+        - name: Manual
+          value: 1
+          description: |
+            The digital gain will not be updated by the AEGC algorithm.
+
+            When transitioning from Auto to Manual mode, the last computed
+            gain value is used until a new value is specified through the
+            DigitalGain control. If an DigitalGain value is specified in the
+            same request where the DigitalGainMode is changed from Auto to
+            Manual, the provided DigitalGain is applied immediately.
+
 ...