| @@ -0,0 +1,730 @@ |
| | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| | 2 | /* |
| | 3 | * Dreamchip RPP-X1 ISP Driver - Userspace API |
| | 4 | * |
| | 5 | * Copyright (C) 2026 Renesas Electronics Corp. |
| | 6 | * Copyright (C) 2026 Ideas on Board Oy |
| | 7 | * Copyright (C) 2026 Ragnatech AB |
| | 8 | */ |
| | 9 | |
| | 10 | #ifndef __UAPI_RPP_X1_CONFIG_H |
| | 11 | #define __UAPI_RPP_X1_CONFIG_H |
| | 12 | |
| | 13 | #include <linux/media/v4l2-isp.h> |
| | 14 | |
| | 15 | /** |
| | 16 | * struct rppx1_window - Measurement window |
| | 17 | * |
| | 18 | * RPP-X1 measurement window. Different blocks use a window or multiple |
| | 19 | * windows for measurement purposes. This defines a common type for all of |
| | 20 | * them. The number of relevant bits depends on the block where the window is |
| | 21 | * used and is specified in the per-block description |
| | 22 | * |
| | 23 | * @h_offs: horizontal offset from the left of the frame in pixels |
| | 24 | * @v_offs: vertical offset from the top of the frame in pixels |
| | 25 | * @h_size: horizontal size of the window in pixels |
| | 26 | * @v_size: vertical size of the window in pixels |
| | 27 | */ |
| | 28 | struct rppx1_window { |
| | 29 | __u16 h_offs; |
| | 30 | __u16 v_offs; |
| | 31 | __u16 h_size; |
| | 32 | __u16 v_size; |
| | 33 | }; |
| | 34 | |
| | 35 | /** |
| | 36 | * enum rppx1_meas_chan - Measurement point for the Histogram and EXM Modules |
| | 37 | * |
| | 38 | * Measurement points for the RPP-X1 Histogram measurement module and Exposure |
| | 39 | * measurement module. |
| | 40 | * |
| | 41 | * All tap points are available for the PRE1/PRE2 pipes. Only |
| | 42 | * RPPX1_MEAS_CHAN_SEL4 and RPPX1_MEAS_CHAN_SEL7 are available for the |
| | 43 | * MAIN_POST pipe. |
| | 44 | * |
| | 45 | * @RPPX1_MEAS_CHAN_SEL0: after input acquisition |
| | 46 | * @RPPX1_MEAS_CHAN_SEL1: after black level subtraction |
| | 47 | * @RPPX1_MEAS_CHAN_SEL2: after sensor gamma linearization |
| | 48 | * @RPPX1_MEAS_CHAN_SEL3: after lens shading correction |
| | 49 | * @RPPX1_MEAS_CHAN_SEL4: after auto white balance gains |
| | 50 | * @RPPX1_MEAS_CHAN_SEL5: after defect pixel correction |
| | 51 | * @RPPX1_MEAS_CHAN_SEL6: after denoise pre-filter |
| | 52 | * @RPPX1_MEAS_CHAN_SEL7: after demosaicing |
| | 53 | */ |
| | 54 | enum rppx1_meas_chan { |
| | 55 | RPPX1_MEAS_CHAN_SEL0, |
| | 56 | RPPX1_MEAS_CHAN_SEL1, |
| | 57 | RPPX1_MEAS_CHAN_SEL2, |
| | 58 | RPPX1_MEAS_CHAN_SEL3, |
| | 59 | RPPX1_MEAS_CHAN_SEL4, |
| | 60 | RPPX1_MEAS_CHAN_SEL5, |
| | 61 | RPPX1_MEAS_CHAN_SEL6, |
| | 62 | RPPX1_MEAS_CHAN_SEL7, |
| | 63 | }; |
| | 64 | |
| | 65 | /* --------------------------------------------------------------------------- |
| | 66 | * Parameter Structures |
| | 67 | * |
| | 68 | * The same ISP block might be instantiated in multiple pipeliness and operate |
| | 69 | * on a different bitdepth/precision. For fields of varying length among |
| | 70 | * different instances of the same block, use a data type that can accommodate |
| | 71 | * the larger bitdepth/precision. |
| | 72 | */ |
| | 73 | |
| | 74 | /** |
| | 75 | * enum rppx1_params_block_type - RPP-X1 extensible params block types |
| | 76 | * |
| | 77 | * NOTE: Only append to the enumeration as the numbers are uAPI. |
| | 78 | * |
| | 79 | * @RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST: AWB Measurement Configuration |
| | 80 | * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1: PRE1 pipe White Balance Gains |
| | 81 | * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2: PRE2 White Balance Gains |
| | 82 | * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST: MAIN_POST White Balance Gains |
| | 83 | * @RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1: PRE1 pipe Exposure Measurement |
| | 84 | * @RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2: PRE2 pipe Exposure Measurement |
| | 85 | * @RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE1: PRE1 pipe Histogram Measurement |
| | 86 | * @RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE2: PRE2 pipe Histogram Measurement |
| | 87 | * @RPPX1_PARAMS_BLOCK_TYPE_HIST_POST: POST pipe Histogram Measurement |
| | 88 | * @RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1: PRE1 pipe Black Level Subtraction |
| | 89 | * @RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2: PRE2 pipe Black Level Subtraction |
| | 90 | * @RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST: POST pipe Color Correction |
| | 91 | * @RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE1: PRE1 pipe Lens Shading Correction |
| | 92 | * @RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE2: PRE2 pipe Lens Shading Correction |
| | 93 | * @RPPX1_PARAMS_BLOCK_TYPE_GA_HV: Human Vision Pipe Gamma Out Correction |
| | 94 | * @RPPX1_PARAMS_BLOCK_TYPE_GA_MV: Machine Vision Gamma Out Correction |
| | 95 | * @RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE1: PRE1 pipe Linearization (Sensor De-gamma) |
| | 96 | * @RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE2: PRE2 pipe Linearization (Sensor De-gamma) |
| | 97 | */ |
| | 98 | enum rppx1_params_block_type { |
| | 99 | RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST, |
| | 100 | RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1, |
| | 101 | RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2, |
| | 102 | RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST, |
| | 103 | RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1, |
| | 104 | RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2, |
| | 105 | RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE1, |
| | 106 | RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE2, |
| | 107 | RPPX1_PARAMS_BLOCK_TYPE_HIST_POST, |
| | 108 | RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1, |
| | 109 | RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2, |
| | 110 | RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST, |
| | 111 | RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE1, |
| | 112 | RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE2, |
| | 113 | RPPX1_PARAMS_BLOCK_TYPE_GA_HV, |
| | 114 | RPPX1_PARAMS_BLOCK_TYPE_GA_MV, |
| | 115 | RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE1, |
| | 116 | RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE2, |
| | 117 | }; |
| | 118 | |
| | 119 | /** |
| | 120 | * enum rppx1_wbmeas_mode - AWB measurement mode |
| | 121 | * |
| | 122 | * @RPPX1_WBMEAS_MODE_YCBCR: YCbCr measurement mode |
| | 123 | * @RPPX1_WBMEAS_MODE_RGB: RGB measurement mode |
| | 124 | */ |
| | 125 | enum rppx1_wbmeas_mode { |
| | 126 | RPPX1_WBMEAS_MODE_YCBCR, |
| | 127 | RPPX1_WBMEAS_MODE_RGB, |
| | 128 | }; |
| | 129 | |
| | 130 | /** |
| | 131 | * struct rppx1_wbmeas_params - AWB measurement configuration |
| | 132 | * |
| | 133 | * The Auto-White Balance measurement module is available on the MAIN_POST pipe. |
| | 134 | * It supports two measurement modes, selected by the @mode field. The |
| | 135 | * measurement window is programmed through the @wnd field. |
| | 136 | * |
| | 137 | * To support measurement in YCbCr mode a color conversion matrix with |
| | 138 | * programmable offset is available in the @ccor_coeff and @ccor_offs fields. |
| | 139 | * The color conversion matrix coefficients are represented as 16 bits signed |
| | 140 | * Q4.12 numbers ranging from -8 to +7.99. The per-color channel offsets are |
| | 141 | * represented as 25 bits 2's complement integer numbers ranging from -16777216 |
| | 142 | * to +16777215. |
| | 143 | * |
| | 144 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST) |
| | 145 | * @wnd: measurement window |
| | 146 | * @mode: measurement mode (from enum rppx1_wbmeas_mode) |
| | 147 | * @ymax_cmp: enable Y_MAX compare using @max_y |
| | 148 | * @frames: number of frames for mean value calculation (0 = 1 frame) |
| | 149 | * @reserved: padding |
| | 150 | * @ref_cr_max_r: reference Cr or max red value in RGB mode, 24 bits |
| | 151 | * @ref_cb_max_b: reference Cb or max blue value in RGB mode, 24 bits |
| | 152 | * @min_y_max_g: luminance minimum value or max green value in RGB mode, 24 bits |
| | 153 | * @max_y: luminance maximum value, only valid if @mode is set to YCbCr and |
| | 154 | * @ymax_cmp is set to enabled, 24 bits |
| | 155 | * @max_csum: chrominance sum maximum value, 24 bits |
| | 156 | * @min_c: chrominance minimum value, 24 bits |
| | 157 | * @ccor_coeff: coefficients for color conversion matrix, signed 16 bits Q4.6 |
| | 158 | * @reserved2: padding |
| | 159 | * @ccor_offs: R-G-B color conversion coefficients, signed 25 bits 2's complement |
| | 160 | * @reserved3: padding |
| | 161 | */ |
| | 162 | struct rppx1_wbmeas_params { |
| | 163 | struct v4l2_isp_params_block_header header; |
| | 164 | struct rppx1_window wnd; |
| | 165 | __u8 mode; |
| | 166 | __u8 ymax_cmp; |
| | 167 | __u8 frames; |
| | 168 | __u8 reserved; |
| | 169 | __u32 ref_cr_max_r; |
| | 170 | __u32 ref_cb_max_b; |
| | 171 | __u32 min_y_max_g; |
| | 172 | __u32 max_y; |
| | 173 | __u32 max_csum; |
| | 174 | __u32 min_c; |
| | 175 | __u16 ccor_coeff[3][3]; |
| | 176 | __u16 reserved2; |
| | 177 | __u32 ccor_offs[3]; |
| | 178 | __u32 reserved3; |
| | 179 | }; |
| | 180 | |
| | 181 | /** |
| | 182 | * struct rppx1_awbg_params - WB gain configuration |
| | 183 | * |
| | 184 | * The RPP-X1 White Balance Gain module is available in the PRE1 and PRE2 |
| | 185 | * pre-fusion pipes and in the MAIN_POST post-fusion pipe. Userspace selects |
| | 186 | * which pipe to operate by setting the @header.type field to |
| | 187 | * RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1, RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2 |
| | 188 | * or RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST. |
| | 189 | * |
| | 190 | * The White Balance module allows to specify per-color channel gains, expressed |
| | 191 | * as unsigned fixed-point values as 18 bits unsigned integers in Q6.12 format |
| | 192 | * with a maximum of 63.999. |
| | 193 | * |
| | 194 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1 or |
| | 195 | * type = RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2 or |
| | 196 | * type = RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST) |
| | 197 | * @gain_red: gain for red component, 18-bit (unsigned Q6.12) |
| | 198 | * @gain_green_r: gain for green component in red lines, 18-bit (unsigned Q6.12) |
| | 199 | * @gain_blue: gain for blue component, 18-bit (unsigned Q6.12) |
| | 200 | * @gain_green_b: gain for green component in blue lines, 18-bit (unsigned Q6.12) |
| | 201 | */ |
| | 202 | struct rppx1_awbg_params { |
| | 203 | struct v4l2_isp_params_block_header header; |
| | 204 | __u32 gain_red; |
| | 205 | __u32 gain_green_r; |
| | 206 | __u32 gain_blue; |
| | 207 | __u32 gain_green_b; |
| | 208 | }; |
| | 209 | |
| | 210 | /** |
| | 211 | * enum rppx1_exm_mode - Exposure measurement mode |
| | 212 | * |
| | 213 | * Exaposure measurement mode selection (RGB/Bayer). |
| | 214 | * |
| | 215 | * @RPPX1_EXP_MEASURING_MODE_DISABLED: no measurement |
| | 216 | * @RPPX1_EXP_MEASURING_MODE_RGB: Y/R/G/B measurement |
| | 217 | * @RPPX1_EXP_MEASURING_MODE_BAYER: Bayer RGB measurement |
| | 218 | */ |
| | 219 | enum rppx1_exm_mode { |
| | 220 | RPPX1_EXP_MEASURING_MODE_DISABLED, |
| | 221 | RPPX1_EXP_MEASURING_MODE_RGB, |
| | 222 | RPPX1_EXP_MEASURING_MODE_BAYER, |
| | 223 | }; |
| | 224 | |
| | 225 | /** |
| | 226 | * struct rppx1_exm_params - Exposure measurement configuration |
| | 227 | * |
| | 228 | * The RPP-X1 Exposure measurement unit is available on the PRE1 and PRE2 |
| | 229 | * pre-fusion pipes. Userspace selects which pipe to operate by setting |
| | 230 | * the @header.type field to RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1 or |
| | 231 | * RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2. |
| | 232 | * |
| | 233 | * Exposure measurement is performed in the RGB or Bayer domain, according to |
| | 234 | * the setting of the @mode field. The exposure measurement tap point is |
| | 235 | * selected according to the value of @channel_sel. |
| | 236 | * |
| | 237 | * The exposure measurement is performed on an input window specified in @wnd. |
| | 238 | * To each color component a programmable weight coefficient is associated. |
| | 239 | * Coefficients are represented as unsigned 8 bits integer values in Q1.7 format |
| | 240 | * ranging from 0 to 1.992. |
| | 241 | * |
| | 242 | * The @last_line fields controls when the exposure measurement completes. It |
| | 243 | * is usually programmed to the value of (@wnd.v_offs + @wnd.v_size + 1). |
| | 244 | * |
| | 245 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE1 or |
| | 246 | * type = RPPX1_PARAMS_BLOCK_TYPE_EXM_PRE2) |
| | 247 | * @wnd: measurement window coordinates |
| | 248 | * @mode: exposure measure mode (from enum rppx1_exm_mode) |
| | 249 | * @last_line: line number for which the exposure measurement completes |
| | 250 | * @channel_sel: exposure measurement point (see enum rppx1_meas_chan) |
| | 251 | * @coeff_r: coefficient for the red Bayer sample or red color channel, Q1.7 |
| | 252 | * @coeff_g_gr: coefficient for the green/red Bayer sample or green color channel, Q1.7 |
| | 253 | * @coeff_b: coefficient for the blue Bayer sample or blue color channel, Q1.7 |
| | 254 | * @coeff_gb: coefficient for the green/blue Bayer sample, unused in RGB mode, Q1.7 |
| | 255 | * @reserved: padding |
| | 256 | */ |
| | 257 | struct rppx1_exm_params { |
| | 258 | struct v4l2_isp_params_block_header header; |
| | 259 | struct rppx1_window wnd; |
| | 260 | __u32 mode; |
| | 261 | __u32 last_line; |
| | 262 | __u8 channel_sel; |
| | 263 | __u8 coeff_r; |
| | 264 | __u8 coeff_g_gr; |
| | 265 | __u8 coeff_b; |
| | 266 | __u8 coeff_gb; |
| | 267 | __u8 reserved[3]; |
| | 268 | }; |
| | 269 | |
| | 270 | /* Histogram */ |
| | 271 | #define RPPX1_HIST_WEIGHT_GRIDS_SIZE 25 |
| | 272 | |
| | 273 | /** |
| | 274 | * enum rppx1_hist_mode - Histogram measurement mode |
| | 275 | * |
| | 276 | * Histogram measurement mode. Select which channel or combination of channels |
| | 277 | * the histogram measurement is performed on. |
| | 278 | * |
| | 279 | * @RPPX1_HIST_MODE_DISABLE: histogram disabled |
| | 280 | * @RPPX1_HIST_MODE_RGB_COMBINED: combined RGB histogram |
| | 281 | * @RPPX1_HIST_MODE_R_HISTOGRAM: red channel histogram |
| | 282 | * @RPPX1_HIST_MODE_GR_HISTOGRAM: green/red channel histogram |
| | 283 | * @RPPX1_HIST_MODE_B_HISTOGRAM: blue channel histogram |
| | 284 | * @RPPX1_HIST_MODE_GB_HISTOGRAM: green/blue histogram |
| | 285 | */ |
| | 286 | enum rppx1_hist_mode { |
| | 287 | RPPX1_HIST_MODE_DISABLE, |
| | 288 | RPPX1_HIST_MODE_RGB_COMBINED, |
| | 289 | RPPX1_HIST_MODE_R_HISTOGRAM, |
| | 290 | RPPX1_HIST_MODE_GR_HISTOGRAM, |
| | 291 | RPPX1_HIST_MODE_B_HISTOGRAM, |
| | 292 | RPPX1_HIST_MODE_GB_HISTOGRAM, |
| | 293 | }; |
| | 294 | |
| | 295 | /** |
| | 296 | * struct rppx1_hist_params - Histogram measurement configuration |
| | 297 | * |
| | 298 | * The RPP-X1 Histogram measurement unit is available on the PRE1, PRE2 and |
| | 299 | * MAIN_POST pipes. Userspace selects which pipe to operate by setting the |
| | 300 | * @header.type field to RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE1, |
| | 301 | * RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE2 or |
| | 302 | * RPPX1_PARAMS_BLOCK_TYPE_HIST_POST. |
| | 303 | * |
| | 304 | * The histogram measurement point is selected using the @channel field while |
| | 305 | * histogram measurement mode is selected using the @mode field. |
| | 306 | * |
| | 307 | * Histogram measurement is performed by programming subsampling factors using |
| | 308 | * the @v_stepsize and @h_step_inc fields and by weighted windowing, by |
| | 309 | * programming the size of the measurement window @wnd with @weights associated |
| | 310 | * to each cell of the 5x5 measurement grid. Weights are represented as 5 bits |
| | 311 | * integer values ranging from 0 to 16. |
| | 312 | * |
| | 313 | * The @last_line fields controls when the histogram measurement completes. It |
| | 314 | * is usually programmed to the value of (@wnd.v_offs + @wnd.v_size - 1). |
| | 315 | * |
| | 316 | * Histogram values are calculated by applying a per-color channel coefficient |
| | 317 | * represented as an 8 bits unsigned Q1.7 integer value. The @sample_offs and |
| | 318 | * @sample_shift fields allow to reduce the color dynamic range on which |
| | 319 | * histogram data are produced. |
| | 320 | * |
| | 321 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE1, |
| | 322 | * type = RPPX1_PARAMS_BLOCK_TYPE_HIST_PRE2 or |
| | 323 | * type = RPPX1_PARAMS_BLOCK_TYPE_HIST_POST) |
| | 324 | * @wnd: measurement window coordinates |
| | 325 | * @last_line: line number for which the histogram measurement completes |
| | 326 | * @v_stepsize: vertical subsampling divider, 7 bits |
| | 327 | * @h_step_inc: horizontal subsampling step counter, 17 bits |
| | 328 | * @sample_offs: sample offset, 24 bits |
| | 329 | * @mode: histogram measurement mode (from enum rppx1_hist_mode) |
| | 330 | * @channel_sel: histogram measurement point (see enum rppx1_meas_chan) |
| | 331 | * @weights: weighting factors for each sub-window (5x5 grid) |
| | 332 | * @coeff: R-G-B coefficients, 8 bits unsigned Q1.7 |
| | 333 | * @sample_shift: sample shift, 4 bits |
| | 334 | * @reserved: padding |
| | 335 | */ |
| | 336 | struct rppx1_hist_params { |
| | 337 | struct v4l2_isp_params_block_header header; |
| | 338 | struct rppx1_window wnd; |
| | 339 | __u32 last_line; |
| | 340 | __u32 v_stepsize; |
| | 341 | __u32 h_step_inc; |
| | 342 | __u32 sample_offs; |
| | 343 | __u8 mode; |
| | 344 | __u8 channel_sel; |
| | 345 | __u8 weights[RPPX1_HIST_WEIGHT_GRIDS_SIZE]; |
| | 346 | __u8 coeff[3]; |
| | 347 | __u8 sample_shift; |
| | 348 | __u8 reserved; |
| | 349 | }; |
| | 350 | |
| | 351 | /** |
| | 352 | * struct rppx1_bls_fixed - BLS fixed subtraction values |
| | 353 | * |
| | 354 | * Fixed black level values subtracted from sensor data per Bayer channel. |
| | 355 | * Negative values result in addition. |
| | 356 | * |
| | 357 | * The PRE1 pipe BLS module operates on a 24-bits input data and fixed black |
| | 358 | * levels are stored as a signed 2's complement representation ranging from |
| | 359 | * -2^24 to 2^24-1. |
| | 360 | * |
| | 361 | * The PRE2 pipe BLS module operates on a 12-bits input data and fixed black |
| | 362 | * levels are stored as a signed 2's complement representation ranging from |
| | 363 | * -2^12 to 2^12-1. |
| | 364 | * |
| | 365 | * Userspace is expected to provide fixed black level values with a bit-depth |
| | 366 | * matching the one of pipe in use. |
| | 367 | * |
| | 368 | * These subtraction values are matched with the sensor native Bayer components |
| | 369 | * ordering according to the cropping configuration on the input port. |
| | 370 | * |
| | 371 | * @a: subtraction value for channel A |
| | 372 | * @b: subtraction value for channel B |
| | 373 | * @c: subtraction value for channel C |
| | 374 | * @d: subtraction value for channel D |
| | 375 | */ |
| | 376 | struct rppx1_bls_fixed { |
| | 377 | __u32 a; |
| | 378 | __u32 b; |
| | 379 | __u32 c; |
| | 380 | __u32 d; |
| | 381 | }; |
| | 382 | |
| | 383 | /** |
| | 384 | * enum rppx1_bls_mode - BLS subtraction mode |
| | 385 | * |
| | 386 | * Select if subtracted black level come from fixed or measured values. |
| | 387 | * |
| | 388 | * @RPPX1_BLS_MODE_FIXED: subtract fixed values |
| | 389 | * @RPPX1_BLS_MODE_MEAS: subtract measured values |
| | 390 | */ |
| | 391 | enum rppx1_bls_mode { |
| | 392 | RPPX1_BLS_MODE_FIXED, |
| | 393 | RPPX1_BLS_MODE_MEAS, |
| | 394 | }; |
| | 395 | |
| | 396 | /** |
| | 397 | * enum rppx1_bls_win_en: BLS measurement configuration |
| | 398 | * |
| | 399 | * Select the measurement window to use for measured black level values. |
| | 400 | * |
| | 401 | * @RPPX1_BLS_WIN_EN_OFF: disable measurement |
| | 402 | * @RPPX1_BLS_WIN_EN_WIN1: Enable measurement from window 1 |
| | 403 | * @RPPX1_BLS_WIN_EN_WIN2: enable measurement from window 2 |
| | 404 | * @RPPX1_BLS_WIN_EN_WIN12: enable measurement from window 1 and window 2 |
| | 405 | */ |
| | 406 | enum rppx1_bls_win_en { |
| | 407 | RPPX1_BLS_WIN_EN_OFF, |
| | 408 | RPPX1_BLS_WIN_EN_WIN1, |
| | 409 | RPPX1_BLS_WIN_EN_WIN2, |
| | 410 | RPPX1_BLS_WIN_EN_WIN12, |
| | 411 | }; |
| | 412 | |
| | 413 | /** |
| | 414 | * struct rppx1_bls_params - RPP-X1 Black Level Subtraction Module |
| | 415 | * |
| | 416 | * The RPP-X1 Black Level Subtraction module is available on the PRE1 and PRE2 |
| | 417 | * pre-fusion pipes. Userspace selects which pipe to operate by setting the |
| | 418 | * @header.type field to RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1 or |
| | 419 | * RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2. |
| | 420 | * |
| | 421 | * The BLS module operates on fixed or measured data according to the setting of |
| | 422 | * the @mode field. When RPPX1_BLS_MODE_FIXED is used userspace shall provide |
| | 423 | * the per-channel black levels in @fixed. When RPPX1_BLS_MODE_MEAS is used |
| | 424 | * userspace shall configure the measurement windows @window1 and optionally |
| | 425 | * @window2 to select the optically black pixels region in the input frame. The |
| | 426 | * @samples fields controls how many measure samples are used for averaging the |
| | 427 | * measured black levels. |
| | 428 | * |
| | 429 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE1 or |
| | 430 | * type == RPPX1_PARAMS_BLOCK_TYPE_BLS_PRE2) |
| | 431 | * @window1: BLS measurement window 1 (14 bits) |
| | 432 | * @window2: BLS measurement window 2 (14 bits) |
| | 433 | * @fixed: fixed subtraction values (see enum rppx1_bls_fixed) |
| | 434 | * @mode: BLS subtraction mode (see enum rppx1_bls_mode) |
| | 435 | * @en_windows: BLS measurement mode (see rppx1_bls_win_en) |
| | 436 | * @samples: log2 of the number of measured pixels per Bayer position |
| | 437 | * @reserved: padding |
| | 438 | */ |
| | 439 | struct rppx1_bls_params { |
| | 440 | struct v4l2_isp_params_block_header header; |
| | 441 | struct rppx1_window window1; |
| | 442 | struct rppx1_window window2; |
| | 443 | struct rppx1_bls_fixed fixed; |
| | 444 | __u8 mode; |
| | 445 | __u8 en_windows; |
| | 446 | __u8 samples; |
| | 447 | __u8 reserved[5]; |
| | 448 | }; |
| | 449 | |
| | 450 | /** |
| | 451 | * struct rppx1_ccor_params - Color CORrection configuration |
| | 452 | * |
| | 453 | * The CCOR (Color Correction) module is available on the MAIN_POST pipe. It |
| | 454 | * performs color space correction on a pixel-per-pixel basis using a 3x3 matrix |
| | 455 | * of coefficients and per-color channel offsets. |
| | 456 | * |
| | 457 | * The matrix coefficients are represented as 16 bits signed fixed point values |
| | 458 | * in Q4.12 format ranging from -8 to +7.999. |
| | 459 | * |
| | 460 | * The per-channel color offsets are represented as 2's complement values |
| | 461 | * stored in 25 bits ranging from -16777216 to 16777215. |
| | 462 | * |
| | 463 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST) |
| | 464 | * @coeff: color correction matrix coefficients, 16 bits signed Q4.12 |
| | 465 | * @reserved: padding |
| | 466 | * @offset: R, G, B offsets, 2's complement 25 bits |
| | 467 | */ |
| | 468 | struct rppx1_ccor_params { |
| | 469 | struct v4l2_isp_params_block_header header; |
| | 470 | __u16 coeff[3][3]; |
| | 471 | __u16 reserved; |
| | 472 | __u32 offset[3]; |
| | 473 | }; |
| | 474 | |
| | 475 | /* Lens Shade Correction */ |
| | 476 | #define RPPX1_LSC_SAMPLES_MAX 17 |
| | 477 | #define RPPX1_LSC_NUM_SECTORS 16 |
| | 478 | |
| | 479 | /** |
| | 480 | * struct rppx1_lsc_params - Lens Shading Correction configuration |
| | 481 | * |
| | 482 | * The RPP-X1 Lens shading correction module is available on the PRE1 and PRE2 |
| | 483 | * pre-fusion pipes. Userspace selects which pipe to operate by setting the |
| | 484 | * @header.type field to RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE1 or |
| | 485 | * RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE2. |
| | 486 | * |
| | 487 | * The module applies per-color channel correction factors @r_data, @gr_data, |
| | 488 | * @gb_data and @b_data as a 16x16 grid mapped on the image. The size of each |
| | 489 | * grid segment is expressed by the @x_sect_size and @y_sect_size arrays. Each |
| | 490 | * segment shall be at least 8 pixels in size and the sum of all horizontal |
| | 491 | * segments @x_sect_size shall match the input frame size width. |
| | 492 | * |
| | 493 | * The correction factors values are expressed as unsigned Q2.10 integers |
| | 494 | * ranging from 1 to 3.999. |
| | 495 | * |
| | 496 | * Pre-calculated interpolation factors shall be provided in the @x_grad |
| | 497 | * and @y_grad fields, expressed as 12 bits integer values. |
| | 498 | * |
| | 499 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_LSC) |
| | 500 | * @r_data: correction factors for the red channel in Q2.10 format |
| | 501 | * @gr_data: correction factors for the green (red) channel in Q2.10 format |
| | 502 | * @gb_data: correction factors for the green (blue) channel in Q2.10 format |
| | 503 | * @b_data: correction factors for the blue channel in Q2.10 format |
| | 504 | * @x_grad: Interpolation gradients for each horizontal sector (12 bits) |
| | 505 | * @y_grad: Interpolation gradients for each vertical sector (12 bits) |
| | 506 | * @x_sect_size: Horizontal sectors sizes |
| | 507 | * @y_sect_size: Vertical sectors sizes |
| | 508 | */ |
| | 509 | struct rppx1_lsc_params { |
| | 510 | struct v4l2_isp_params_block_header header; |
| | 511 | __u16 r_data[RPPX1_LSC_SAMPLES_MAX][RPPX1_LSC_SAMPLES_MAX]; |
| | 512 | __u16 gr_data[RPPX1_LSC_SAMPLES_MAX][RPPX1_LSC_SAMPLES_MAX]; |
| | 513 | __u16 gb_data[RPPX1_LSC_SAMPLES_MAX][RPPX1_LSC_SAMPLES_MAX]; |
| | 514 | __u16 b_data[RPPX1_LSC_SAMPLES_MAX][RPPX1_LSC_SAMPLES_MAX]; |
| | 515 | __u16 x_grad[RPPX1_LSC_NUM_SECTORS]; |
| | 516 | __u16 y_grad[RPPX1_LSC_NUM_SECTORS]; |
| | 517 | __u16 x_sect_size[RPPX1_LSC_NUM_SECTORS]; |
| | 518 | __u16 y_sect_size[RPPX1_LSC_NUM_SECTORS]; |
| | 519 | }; |
| | 520 | |
| | 521 | /* Gamma Out */ |
| | 522 | #define RPPX1_GA_MAX_SAMPLES 17 |
| | 523 | |
| | 524 | /** |
| | 525 | * enum rppx1_ga_seg_mode - Gamma out curve segmentation mode |
| | 526 | * |
| | 527 | * Segmentation mode of the 16 input sampling points for the Gamma Out |
| | 528 | * Correction module. |
| | 529 | * |
| | 530 | * @RPPX1_GA_SEG_MODE_LOGARITHMIC: logarithmic-like segmentation mode |
| | 531 | * @RPPX1_GA_SEG_MODE_EQUIDISTANT: equidistant segmentation mode |
| | 532 | */ |
| | 533 | enum rppx1_ga_seg_mode { |
| | 534 | RPPX1_GA_SEG_MODE_LOGARITHMIC, |
| | 535 | RPPX1_GA_SEG_MODE_EQUIDISTANT |
| | 536 | }; |
| | 537 | |
| | 538 | /** |
| | 539 | * struct rppx1_ga_params - Gamma Out Correction configuration |
| | 540 | * |
| | 541 | * The Gamma Out Correction module is available on the Human Vision Output |
| | 542 | * Pipe (HV) and the Machine Vision Output Pipe (MV). Userspace selects |
| | 543 | * which pipe to operate by setting the @header.type field to |
| | 544 | * RPPX1_PARAMS_BLOCK_TYPE_GA_HV or RPPX1_PARAMS_BLOCK_TYPE_GA_MV. |
| | 545 | * |
| | 546 | * The module allows to apply a @gamma_y gamma correction curve to RGB data |
| | 547 | * represented as a table of 16 entries. The 16 input sampling points can be |
| | 548 | * equidistant or segmented using a logarithmic scale according to the value of |
| | 549 | * @mode. |
| | 550 | * |
| | 551 | * The gamma curve values are 12 bits on the HV output pipe and 24 bits on the |
| | 552 | * MV output pipe. Userspace is expected to provide the curve values with a |
| | 553 | * bit-depth matching the one of pipe in use. |
| | 554 | * |
| | 555 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_GA_HV or |
| | 556 | * type = RPPX1_PARAMS_BLOCK_TYPE_GA_MV) |
| | 557 | * @gamma_y: gamma out curve y-axis values |
| | 558 | * @mode: gamma curve input segmentation mode (see rppx1_ga_seg_mode) |
| | 559 | * @reserved: padding |
| | 560 | */ |
| | 561 | struct rppx1_ga_params { |
| | 562 | struct v4l2_isp_params_block_header header; |
| | 563 | __u32 gamma_y[RPPX1_GA_MAX_SAMPLES]; |
| | 564 | __u8 mode; |
| | 565 | __u8 reserved[3]; |
| | 566 | }; |
| | 567 | |
| | 568 | /* Linearization (Sensor De-gamma) */ |
| | 569 | #define RPPX1_LIN_SAMPLE_POINTS_NUM 16 |
| | 570 | #define RPPX1_LIN_DEGAMMA_CURVE_NUM 17 |
| | 571 | |
| | 572 | /** |
| | 573 | * struct rppx1_lin_params - Linearization (Sensor De-gamma) configuration |
| | 574 | * |
| | 575 | * The RPP-X1 linearization module is available on the PRE1 and PRE2 pre-fusion |
| | 576 | * pipes. Userspace selects which pipe to operate by setting the @header.type |
| | 577 | * field to RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE1 or |
| | 578 | * RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE2. |
| | 579 | * |
| | 580 | * The LIN module applies the per-color channel de-gamma linearization curves |
| | 581 | * @curve_r, @curve_g and @curve_b defined on the input sampling points @dx. |
| | 582 | * |
| | 583 | * For the PRE1 pipe the de-gamma curves values are 24-bits, for the PRE2 pipe |
| | 584 | * the de-gamma curve values are 12-bits. |
| | 585 | * |
| | 586 | * For the PRE1 pipe de-gamma module sampling points @dx values are in the range |
| | 587 | * [0, 15] (4 bits). For the PRE2 pipe de-gamma module sampling points values |
| | 588 | * are in the range [0, 7] (3 bits). |
| | 589 | * |
| | 590 | * Userspace is expected to provide the curve values and sampling points with a |
| | 591 | * bit-depth matching the one of pipe in use. |
| | 592 | * |
| | 593 | * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE1 or |
| | 594 | * RPPX1_PARAMS_BLOCK_TYPE_LIN_PRE2) |
| | 595 | * @curve_r: de-gamma linearization curve for red channel |
| | 596 | * @curve_g: de-gamma linearization curve for green channel |
| | 597 | * @curve_b: de-gamma linearization curve for blue channel |
| | 598 | * @dx: input sampling points |
| | 599 | * @reserved: padding |
| | 600 | */ |
| | 601 | struct rppx1_lin_params { |
| | 602 | struct v4l2_isp_params_block_header header; |
| | 603 | __u32 curve_r[RPPX1_LIN_DEGAMMA_CURVE_NUM]; |
| | 604 | __u32 curve_g[RPPX1_LIN_DEGAMMA_CURVE_NUM]; |
| | 605 | __u32 curve_b[RPPX1_LIN_DEGAMMA_CURVE_NUM]; |
| | 606 | __u8 dx[RPPX1_LIN_SAMPLE_POINTS_NUM]; |
| | 607 | __u32 reserved; |
| | 608 | }; |
| | 609 | |
| | 610 | /** |
| | 611 | * RPPX1_PARAMS_MAX_SIZE - Maximum size of all RPP-X1 parameter blocks |
| | 612 | * |
| | 613 | * Some types are reported twice as the same block might be instantiated in |
| | 614 | * multiple pipes. |
| | 615 | */ |
| | 616 | #define RPPX1_PARAMS_MAX_SIZE \ |
| | 617 | (sizeof(struct rppx1_wbmeas_params) + \ |
| | 618 | sizeof(struct rppx1_awbg_params) + \ |
| | 619 | sizeof(struct rppx1_awbg_params) + \ |
| | 620 | sizeof(struct rppx1_awbg_params) + \ |
| | 621 | sizeof(struct rppx1_exm_params) + \ |
| | 622 | sizeof(struct rppx1_exm_params) + \ |
| | 623 | sizeof(struct rppx1_hist_params) + \ |
| | 624 | sizeof(struct rppx1_hist_params) + \ |
| | 625 | sizeof(struct rppx1_hist_params) + \ |
| | 626 | sizeof(struct rppx1_bls_params) + \ |
| | 627 | sizeof(struct rppx1_bls_params) + \ |
| | 628 | sizeof(struct rppx1_ccor_params) + \ |
| | 629 | sizeof(struct rppx1_lsc_params) + \ |
| | 630 | sizeof(struct rppx1_lsc_params) + \ |
| | 631 | sizeof(struct rppx1_ga_params) + \ |
| | 632 | sizeof(struct rppx1_ga_params) + \ |
| | 633 | sizeof(struct rppx1_lin_params) + \ |
| | 634 | sizeof(struct rppx1_lin_params)) |
| | 635 | |
| | 636 | /* --------------------------------------------------------------------------- |
| | 637 | * Statistics Structures |
| | 638 | * |
| | 639 | * The same ISP block might be instantiated in multiple pipeliness and operate |
| | 640 | * on a different bitdepth/precision. For fields of varying length among |
| | 641 | * different instances of the same block, use a data type that can accommodate |
| | 642 | * the larger bitdepth/precision. |
| | 643 | */ |
| | 644 | |
| | 645 | /** |
| | 646 | * enum rppx1_stats_block_type - RPP-X1 extensible stats block types |
| | 647 | * |
| | 648 | * NOTE: Only append to the enumeration as the numbers are uAPI. |
| | 649 | * |
| | 650 | * @RPPX1_STATS_BLOCK_TYPE_WBMEAS_POST: post-fusion white-balance measurement |
| | 651 | * @RPPX1_STATS_BLOCK_TYPE_EXM_PRE1: pre-fusion pipe1 exposure measurement |
| | 652 | * @RPPX1_STATS_BLOCK_TYPE_EXM_PRE2: pre-fusion pipe2 exposure measurement |
| | 653 | * @RPPX1_STATS_BLOCK_TYPE_HIST_PRE1: pre-fusion pipe1 histogram |
| | 654 | * @RPPX1_STATS_BLOCK_TYPE_HIST_PRE2: pre-fusion pipe2 histogram |
| | 655 | * @RPPX1_STATS_BLOCK_TYPE_HIST_POST: post-fusion histogram |
| | 656 | */ |
| | 657 | enum rppx1_stats_block_type { |
| | 658 | RPPX1_STATS_BLOCK_TYPE_WBMEAS_POST, |
| | 659 | RPPX1_STATS_BLOCK_TYPE_EXM_PRE1, |
| | 660 | RPPX1_STATS_BLOCK_TYPE_EXM_PRE2, |
| | 661 | RPPX1_STATS_BLOCK_TYPE_HIST_PRE1, |
| | 662 | RPPX1_STATS_BLOCK_TYPE_HIST_PRE2, |
| | 663 | RPPX1_STATS_BLOCK_TYPE_HIST_POST, |
| | 664 | }; |
| | 665 | |
| | 666 | /** |
| | 667 | * struct rppx1_wbmeas_stats - AWB statistics |
| | 668 | * |
| | 669 | * @header: block header (type = RPPX1_STATS_BLOCK_TYPE_WBMEAS_POST) |
| | 670 | * @cnt: Number of pixels matched |
| | 671 | * @mean_y_or_g: mean Y (or G in RGB mode) value, 24-bit |
| | 672 | * @mean_cb_or_b: mean Cb (or B in RGB mode) value, 24-bit |
| | 673 | * @mean_cr_or_r: mean Cr (or R in RGB mode) value, 24-bit |
| | 674 | */ |
| | 675 | struct rppx1_wbmeas_stats { |
| | 676 | struct v4l2_isp_block_header header; |
| | 677 | __u32 cnt; |
| | 678 | __u32 mean_y_or_g; |
| | 679 | __u32 mean_cb_or_b; |
| | 680 | __u32 mean_cr_or_r; |
| | 681 | }; |
| | 682 | |
| | 683 | /* Exposure Measurement */ |
| | 684 | #define RPPX1_EXM_NUM_WIN 25 |
| | 685 | |
| | 686 | /** |
| | 687 | * struct rppx1_exm_stats - Exposure measurement |
| | 688 | * |
| | 689 | * RPP-X1 exposure measurement calculates the mean value on 25 programmable |
| | 690 | * windows on the input picture. |
| | 691 | * |
| | 692 | * @header: block header (type = RPPX1_STATS_BLOCK_TYPE_EXM_PRE1) |
| | 693 | * @exp_mean: mean luminance values per block, up to 20-bit |
| | 694 | * @reserved: padding |
| | 695 | */ |
| | 696 | struct rppx1_exm_stats { |
| | 697 | struct v4l2_isp_block_header header; |
| | 698 | __u32 exp_mean[RPPX1_EXM_NUM_WIN]; |
| | 699 | __u32 reserved; |
| | 700 | }; |
| | 701 | |
| | 702 | /* Histogram */ |
| | 703 | #define RPPX1_HIST_NUM_BINS 32 |
| | 704 | |
| | 705 | /** |
| | 706 | * struct rppx1_hist_stats - Histogram statistics |
| | 707 | * |
| | 708 | * @header: block header (type = RPPX1_STATS_BLOCK_TYPE_HIST_POST) |
| | 709 | * @hist_bins: accumulation histogram results in unsigned 20-bit Q16.4 format |
| | 710 | */ |
| | 711 | struct rppx1_hist_stats { |
| | 712 | struct v4l2_isp_block_header header; |
| | 713 | __u32 hist_bins[RPPX1_HIST_NUM_BINS]; |
| | 714 | }; |
| | 715 | |
| | 716 | /** |
| | 717 | * RPPX1_STATS_MAX_SIZE - Maximum size of all RPP-X1 statistics |
| | 718 | * |
| | 719 | * Some types are reported twice as the same block might be instantiated in |
| | 720 | * multiple pipes. |
| | 721 | */ |
| | 722 | #define RPPX1_STATS_MAX_SIZE \ |
| | 723 | (sizeof(struct rppx1_wbmeas_stats) + \ |
| | 724 | sizeof(struct rppx1_exm_stats) + \ |
| | 725 | sizeof(struct rppx1_exm_stats) + \ |
| | 726 | sizeof(struct rppx1_hist_stats) + \ |
| | 727 | sizeof(struct rppx1_hist_stats) + \ |
| | 728 | sizeof(struct rppx1_hist_stats)) |
| | 729 | |
| | 730 | #endif /* __UAPI_RPP_X1_CONFIG_H */ |