Hi Loic, et.al,

On 24-Jul-26 14:42, Loic Poulain wrote:
> Add the uapi header camss-ope-config.h defining the ISP parameter
> structures used by the CAMSS Offline Processing Engine (OPE) driver.
> This includes structures for white balance, chroma enhancement and
> color correction configuration.
> 
> Signed-off-by: Loic Poulain <[email protected]>
> ---
>  include/uapi/linux/camss-ope-config.h | 160 
> ++++++++++++++++++++++++++++++++++
>  1 file changed, 160 insertions(+)
> 
> diff --git a/include/uapi/linux/camss-ope-config.h 
> b/include/uapi/linux/camss-ope-config.h
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..800e6ef1dba218ca33b565e1e51d6647f02f8753
> --- /dev/null
> +++ b/include/uapi/linux/camss-ope-config.h
> @@ -0,0 +1,160 @@
> +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
> +/*
> + * Qualcomm CAMSS Offline Processing Engine (OPE) ISP parameters UAPI
> + *
> + * Uses the generic V4L2 extensible ISP parameters buffer format defined in
> + * <uapi/linux/media/v4l2-isp.h>.
> + *
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +
> +#ifndef _UAPI_LINUX_CAMSS_OPE_CONFIG_H
> +#define _UAPI_LINUX_CAMSS_OPE_CONFIG_H
> +
> +#include <linux/types.h>
> +#include <linux/media/v4l2-isp.h>
> +
> +/**
> + * enum camss_ope_params_block_type - CAMSS ISP parameter block identifiers
> + *
> + * Each value identifies one ISP processing block.  The value is placed in
> + * the @type field of &struct v4l2_isp_params_block_header.
> + */
> +enum camss_ope_params_block_type {
> +     CAMSS_OPE_PARAMS_WB_GAIN = 1,
> +     CAMSS_OPE_PARAMS_CHROMA_ENHAN = 2,
> +     CAMSS_OPE_PARAMS_COLOR_CORRECT = 3,
> +};

I don't think we want this enum to be OPE specific. The whole idea behind
the extensible ISP parameters is that there is a single set of parameter
definitions spanning multiple ISP generations.

There is going to be a mirroring patch for libcamera defining some C++
magic around this header:

https://patchwork.libcamera.org/patch/27430/

and this will be used in the camss libcamera IPA and we don't want to
have one version of the libcamera wrapper per ISP "generation".

So I think this should all be moved back to a generic camss-config.h
(or maybe camss-parameters.h ?) and then if for the planned Hamoa /
Monoca inline ISP work of we need say a new version of CAMSS_PARAMS_WB_GAIN
just add a CAMSS_OPE_PARAMS_WB_GAIN_V2 for that.

That is the whole idea behind the extensible params, otherwise libcamera
will effectively need to have 1 IPA per ISP generation / type which is
not what we want.

Regards,

Hans





> +
> +/**
> + * struct camss_ope_params_wb_gain - White Balance gains
> + *
> + * Implements the CLC_WB pipeline module.  The pipeline applies three
> + * sequential operations per channel:
> + *   1. Subtract sub-offset (black-level subtraction)
> + *   2. Multiply by gain    (colour balance)
> + *   3. Add add-offset      (output pedestal)
> + *
> + * Gains are 15uQ10 (15-bit unsigned, 10 fractional bits). Offsets
> + * are 16-bit unsigned, normalised to full input scale (65535 = 1.0)
> + *
> + * @header:   block header; @header.type = CAMSS_OPE_PARAMS_WB_GAIN
> + * @g_gain:   green channel gain (15uQ10, 1024 = 1.0)
> + * @b_gain:   blue  channel gain (15uQ10, 1024 = 1.0)
> + * @r_gain:   red   channel gain (15uQ10, 1024 = 1.0)
> + * @g_sub:    green sub-offset, subtracted before gain (16u)
> + * @b_sub:    blue  sub-offset, subtracted before gain (16u)
> + * @r_sub:    red   sub-offset, subtracted before gain (16u)
> + * @g_add:    green add-offset, added after gain (16u)
> + * @b_add:    blue  add-offset, added after gain (16u)
> + * @r_add:    red   add-offset, added after gain (16u)
> + */
> +struct camss_ope_params_wb_gain {
> +     struct v4l2_isp_params_block_header header;
> +     __u16 g_gain;
> +     __u16 b_gain;
> +     __u16 r_gain;
> +     __u16 g_sub;
> +     __u16 b_sub;
> +     __u16 r_sub;
> +     __u16 g_add;
> +     __u16 b_add;
> +     __u16 r_add;
> +     __u16 _pad[3];
> +} __attribute__((aligned(8)));
> +
> +/**
> + * struct camss_ope_params_chroma_enhan - RGB to YUV colour transfer matrix
> + *
> + * Implements the CLC_CHROMA_ENHAN pipeline module. All coefficients are
> + * signed 12-bit fixed-point Q3.8 (range roughly -8.0 to +7.996).
> + *
> + * RGB2Y - Luma (Y) coefficients
> + * Y = v0 * R + v1 * G + v2 * B
> + *
> + * @luma_v0:  R-to-Y coefficient (12sQ8)
> + * @luma_v1:  G-to-Y coefficient (12sQ8)
> + * @luma_v2:  B-to-Y coefficient (12sQ8)
> + * @luma_k:   Y output offset    (9s,  0 = no offset)
> + *
> + * RGB2Cb - Chroma (Cb) coefficients
> + * Cb = a x ((B - G) + b(R - G)) + KCb
> + * with:
> + *   a = ap, when (B-G) + b(R-G) > 0; a = am, when (B-G) + b(R-G) ≤ 0;
> + *   b = bp when (R-G) > 0; b = bm when (R-G) ≤ 0
> + *
> + * @coeff_ap: Cb positive coefficient (12sQ8)
> + * @coeff_am: Cb negative coefficient (12sQ8)
> + * @coeff_bp: Cb positive coefficient (12sQ8)
> + * @coeff_bm: Cb negative coefficient (12sQ8)
> + * @kcb:      Cb output offset        (11s)
> + *
> + * RGB2Cr - Chroma (Cr) coefficients:
> + * Cr = c x ((R - G) + d(B - G)) + KCr
> + * with:
> + *   c = cp, when (R-G) + d(B-G) > 0; c = cm, when (R-G) + d(B-G) ≤ 0
> + *   d = dp when (B-G) > 0; d = dm when (B-G) ≤ 0
> + *
> + * @coeff_cp: Cr positive coefficient (12sQ8)
> + * @coeff_cm: Cr negative coefficient (12sQ8)
> + * @coeff_dp: Cr positive coefficient (12sQ8)
> + * @coeff_dm: Cr negative coefficient (12sQ8)
> + * @kcr:      Cr output offset        (11s)
> + *
> + * @header: generic block header; @header.type = 
> CAMSS_OPE_PARAMS_CHROMA_ENHAN
> + */
> +struct camss_ope_params_chroma_enhan {
> +     struct v4l2_isp_params_block_header header;
> +     __u16 luma_v0;
> +     __u16 luma_v1;
> +     __u16 luma_v2;
> +     __u16 luma_k;
> +     __u16 coeff_ap;
> +     __u16 coeff_am;
> +     __u16 coeff_bp;
> +     __u16 coeff_bm;
> +     __u16 coeff_cp;
> +     __u16 coeff_cm;
> +     __u16 coeff_dp;
> +     __u16 coeff_dm;
> +     __u16 kcb;
> +     __u16 kcr;
> +     __u16 _pad[2];
> +} __attribute__((aligned(8)));
> +
> +/**
> + * struct camss_ope_params_color_correct - colour correction matrix
> + *
> + * Implements the CLC_CC pipeline module.  The matrix computes:
> + *   Out_ch0 (G) = a0*G + b0*B + c0*R + k0
> + *   Out_ch1 (B) = a1*G + b1*B + c1*R + k1
> + *   Out_ch2 (R) = a2*G + b2*B + c2*R + k2
> + *
> + * @header:  block header; @header.type = CAMSS_OPE_PARAMS_COLOR_CORRECT
> + * @a:       G-input coefficients per output channel (12s;
> + *           a[0]=Out_G, a[1]=Out_B, a[2]=Out_R)
> + * @b:       B-input coefficients (12s)
> + * @c:       R-input coefficients (12s)
> + * @k:       per-output-channel offsets (typically 9s effective)
> + * @qfactor: Q-format selector (2u):
> + *           0 = 12sQ7  (range ~-16.0 .. +15.992)
> + *           1 = 12sQ8  (range  ~-8.0 ..  +7.996)
> + *           2 = 12sQ9  (range  ~-4.0 ..  +3.998)
> + *           3 = 12sQ10 (range  ~-2.0 ..  +1.999)
> + */
> +struct camss_ope_params_color_correct {
> +     struct v4l2_isp_params_block_header header;
> +     __u16 a[3];
> +     __u16 b[3];
> +     __u16 c[3];
> +     __u16 k[3];
> +     __u16 qfactor;
> +     __u16 _pad[3];
> +} __attribute__((aligned(8)));
> +
> +#define CAMSS_OPE_PARAMS_MAX_PAYLOAD         \
> +     (sizeof(struct camss_ope_params_wb_gain)        +\
> +      sizeof(struct camss_ope_params_chroma_enhan)   +\
> +      sizeof(struct camss_ope_params_color_correct))
> +
> +#endif /* _UAPI_LINUX_CAMSS_OPE_CONFIG_H */
> 


Reply via email to