Add a header that describes the 3A statistics buffer and the parameters buffer for C3 ISP
Showing the changes to include/uapi (1 of 2 files). Show all
Unified · Split
| @@ -0,0 +1,564 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ | |
| 2 | +/* | |
| 3 | + * Copyright (C) 2024 Amlogic, Inc. All rights reserved | |
| 4 | + */ | |
| 5 | + | |
| 6 | +#ifndef _UAPI_C3_ISP_CONFIG_H_ | |
| 7 | +#define _UAPI_C3_ISP_CONFIG_H_ | |
| 8 | + | |
| 9 | +#include <linux/types.h> | |
| 10 | + | |
| 11 | +/* | |
| 12 | + * Frames are split into zones of almost equal width and height - a zone is a | |
| 13 | + * rectangular tile of a frame. The metering blocks within the ISP collect | |
| 14 | + * aggregated statistics per zone. | |
| 15 | + */ | |
| 16 | +#define C3_ISP_AE_MAX_ZONES (17 * 15) | |
| 17 | +#define C3_ISP_AF_MAX_ZONES (17 * 15) | |
| 18 | +#define C3_ISP_AWB_MAX_ZONES (32 * 24) | |
| 19 | + | |
| 20 | +/* The maximum number of point on the diagonal of the frame for statistics */ | |
| 21 | +#define C3_ISP_AE_MAX_PT_NUM 18 | |
| 22 | +#define C3_ISP_AF_MAX_PT_NUM 18 | |
| 23 | +#define C3_ISP_AWB_MAX_PT_NUM 33 | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * struct c3_isp_awb_zone_stats - AWB statistics of a zone | |
| 27 | + * | |
| 28 | + * AWB zone stats is aligned with 8 bytes | |
| 29 | + * | |
| 30 | + * @rg: the ratio of R / G in a zone | |
| 31 | + * @bg: the ratio of B / G in a zone | |
| 32 | + * @pixel_sum: the total number of pixels used in a zone | |
| 33 | + */ | |
| 34 | +struct c3_isp_awb_zone_stats { | |
| 35 | + __u16 rg; | |
| 36 | + __u16 bg; | |
| 37 | + __u32 pixel_sum; | |
| 38 | +}; | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * struct c3_isp_awb_stats - Auto white balance statistics information. | |
| 42 | + * | |
| 43 | + * AWB statistical information of all zones. | |
| 44 | + * | |
| 45 | + * @stats: array of auto white balance statistics | |
| 46 | + */ | |
| 47 | +struct c3_isp_awb_stats { | |
| 48 | + struct c3_isp_awb_zone_stats stats[C3_ISP_AWB_MAX_ZONES]; | |
| 49 | +} __attribute__((aligned(16))); | |
| 50 | + | |
| 51 | +/** | |
| 52 | + * struct c3_isp_ae_zone_stats - AE statistics of a zone | |
| 53 | + * | |
| 54 | + * AE zone stats is aligned with 8 bytes. | |
| 55 | + * This is a 5-bin histogram and the total sum is normalized to 0xffff. | |
| 56 | + * So hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4) | |
| 57 | + * | |
| 58 | + * @hist0: the global normalized pixel count for bin 0 | |
| 59 | + * @hist1: the global normalized pixel count for bin 1 | |
| 60 | + * @hist3: the global normalized pixel count for bin 3 | |
| 61 | + * @hist4: the global normalized pixel count for bin 4 | |
| 62 | + */ | |
| 63 | +struct c3_isp_ae_zone_stats { | |
| 64 | + __u16 hist0; | |
| 65 | + __u16 hist1; | |
| 66 | + __u16 hist3; | |
| 67 | + __u16 hist4; | |
| 68 | +}; | |
| 69 | + | |
| 70 | +/** | |
| 71 | + * struct c3_isp_ae_stats - Exposure statistics information | |
| 72 | + * | |
| 73 | + * AE statistical information consists of all blocks information and a 1024-bin | |
| 74 | + * histogram. | |
| 75 | + * | |
| 76 | + * @stats: array of auto exposure block statistics | |
| 77 | + * @reserved: undefined buffer space | |
| 78 | + * @hist: a 1024-bin histogram for the entire image | |
| 79 | + */ | |
| 80 | +struct c3_isp_ae_stats { | |
| 81 | + struct c3_isp_ae_zone_stats stats[C3_ISP_AE_MAX_ZONES]; | |
| 82 | + __u32 reserved[2]; | |
| 83 | + __u32 hist[1024]; | |
| 84 | +} __attribute__((aligned(16))); | |
| 85 | + | |
| 86 | +/** | |
| 87 | + * struct c3_isp_af_zone_stats - AF statistics of a zone | |
| 88 | + * | |
| 89 | + * AF zone stats is aligned with 8 bytes. | |
| 90 | + * The zonal accumulated contrast metrics are stored in floating point format | |
| 91 | + * with 16 bits mantissa and 5 or 6 bits exponent. Apart from contrast metrics | |
| 92 | + * we accumulate squared image and quartic image data over the zone. | |
| 93 | + * | |
| 94 | + * @i2_mat: the mantissa of zonal squared image pixel sum | |
| 95 | + * @i4_mat: the mantissa of zonal quartic image pixel sum | |
| 96 | + * @e4_mat: the mantissa of zonal multi-directional quartic edge sum | |
| 97 | + * @e4_exp: the exponent of zonal multi-directional quartic edge sum | |
| 98 | + * @i2_exp: the exponent of zonal squared image pixel sum | |
| 99 | + * @i4_exp: the exponent of zonal quartic image pixel sum | |
| 100 | + */ | |
| 101 | +struct c3_isp_af_zone_stats { | |
| 102 | + __u16 i2_mat; | |
| 103 | + __u16 i4_mat; | |
| 104 | + __u16 e4_mat; | |
| 105 | + __u16 e4_exp : 5; | |
| 106 | + __u16 i2_exp : 5; | |
| 107 | + __u16 i4_exp : 6; | |
| 108 | +}; | |
| 109 | + | |
| 110 | +/** | |
| 111 | + * struct c3_isp_af_stats - Auto Focus statistics information | |
| 112 | + * | |
| 113 | + * AF statistical information of each zone | |
| 114 | + * | |
| 115 | + * @stats: array of auto focus block statistics | |
| 116 | + * @reserved: undefined buffer space | |
| 117 | + */ | |
| 118 | +struct c3_isp_af_stats { | |
| 119 | + struct c3_isp_af_zone_stats stats[C3_ISP_AF_MAX_ZONES]; | |
| 120 | + __u32 reserved[2]; | |
| 121 | +} __attribute__((aligned(16))); | |
| 122 | + | |
| 123 | +/** | |
| 124 | + * struct c3_isp_stats_info - V4L2_META_FMT_C3ISP_STATS | |
| 125 | + * | |
| 126 | + * Contains ISP statistics | |
| 127 | + * | |
| 128 | + * @awb: auto white balance stats | |
| 129 | + * @ae: auto exposure stats | |
| 130 | + * @af: auto focus stats | |
| 131 | + */ | |
| 132 | +struct c3_isp_stats_info { | |
| 133 | + struct c3_isp_awb_stats awb; | |
| 134 | + struct c3_isp_ae_stats ae; | |
| 135 | + struct c3_isp_af_stats af; | |
| 136 | +}; | |
| 137 | + | |
| 138 | +/** | |
| 139 | + * enum c3_isp_params_buffer_version - C3 ISP parameters block versioning | |
| 140 | + * | |
| 141 | + * @C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block | |
| 142 | + */ | |
| 143 | +enum c3_isp_params_buffer_version { | |
| 144 | + C3_ISP_PARAMS_BUFFER_V0, | |
| 145 | +}; | |
| 146 | + | |
| 147 | +/** | |
| 148 | + * enum c3_isp_params_block_type - Enumeration of C3 ISP parameter blocks | |
| 149 | + * | |
| 150 | + * Each block configures a specific processing block of the C3 ISP. | |
| 151 | + * The block type allows the driver to correctly interpret the parameters block | |
| 152 | + * data. | |
| 153 | + * | |
| 154 | + * @C3_ISP_PARAMS_BLOCK_AWB_GAINS: White balance gains | |
| 155 | + * @C3_ISP_PARAMS_BLOCK_AWB_CONFIG: AWB statistic format configuration for all | |
| 156 | + * blocks that control how stats are generated | |
| 157 | + * @C3_ISP_PARAMS_BLOCK_AE_CONFIG: AE statistic format configuration for all | |
| 158 | + * blocks that control how stats are generated | |
| 159 | + * @C3_ISP_PARAMS_BLOCK_AF_CONFIG: AF statistic format configuration for all | |
| 160 | + * blocks that control how stats are generated | |
| 161 | + * @C3_ISP_PARAMS_BLOCK_PST_GAMMA: post gamma parameters | |
| 162 | + * @C3_ISP_PARAMS_BLOCK_CCM: Color correction matrix parameters | |
| 163 | + * @C3_ISP_PARAMS_BLOCK_CSC: Color space conversion parameters | |
| 164 | + * @C3_ISP_PARAMS_BLOCK_BLC: Black level correction parameters | |
| 165 | + * @C3_ISP_PARAMS_BLOCK_SENTINEL: First non-valid block index | |
| 166 | + */ | |
| 167 | +enum c3_isp_params_block_type { | |
| 168 | + C3_ISP_PARAMS_BLOCK_AWB_GAINS, | |
| 169 | + C3_ISP_PARAMS_BLOCK_AWB_CONFIG, | |
| 170 | + C3_ISP_PARAMS_BLOCK_AE_CONFIG, | |
| 171 | + C3_ISP_PARAMS_BLOCK_AF_CONFIG, | |
| 172 | + C3_ISP_PARAMS_BLOCK_PST_GAMMA, | |
| 173 | + C3_ISP_PARAMS_BLOCK_CCM, | |
| 174 | + C3_ISP_PARAMS_BLOCK_CSC, | |
| 175 | + C3_ISP_PARAMS_BLOCK_BLC, | |
| 176 | + C3_ISP_PARAMS_BLOCK_SENTINEL | |
| 177 | +}; | |
| 178 | + | |
| 179 | +#define C3_ISP_PARAMS_BLOCK_FL_DISABLE (1U << 0) | |
| 180 | +#define C3_ISP_PARAMS_BLOCK_FL_ENABLE (1U << 1) | |
| 181 | + | |
| 182 | +/** | |
| 183 | + * struct c3_isp_params_block_header - C3 ISP parameter block header | |
| 184 | + * | |
| 185 | + * This structure represents the common part of all the ISP configuration | |
| 186 | + * blocks. Each parameters block shall embed an instance of this structure type | |
| 187 | + * as its first member, followed by the block-specific configuration data. The | |
| 188 | + * driver inspects this common header to discern the block type and its size and | |
| 189 | + * properly handle the block content by casting it to the correct block-specific | |
| 190 | + * type. | |
| 191 | + * | |
| 192 | + * The @type field is one of the values enumerated by | |
| 193 | + * :c:type:`c3_isp_params_block_type` and specifies how the data should be | |
| 194 | + * interpreted by the driver. The @size field specifies the size of the | |
| 195 | + * parameters block and is used by the driver for validation purposes. The | |
| 196 | + * @flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL*. | |
| 197 | + * | |
| 198 | + * When userspace wants to disable an ISP block the | |
| 199 | + * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit should be set in the @flags field. In | |
| 200 | + * this case userspace may optionally omit the remainder of the configuration | |
| 201 | + * block, which will be ignored by the driver. | |
| 202 | + * | |
| 203 | + * When a new configuration of an ISP block needs to be applied userspace | |
| 204 | + * shall fully populate the ISP block and omit setting the | |
| 205 | + * C3_ISP_PARAMS_BLOCK_FL_DISABLED bit in the @flags field. | |
| 206 | + * | |
| 207 | + * Userspace is responsible for correctly populating the parameters block header | |
| 208 | + * fields (@type, @flags and @size) and the block-specific parameters. | |
| 209 | + * | |
| 210 | + * For example: | |
| 211 | + * | |
| 212 | + * .. code-block:: c | |
| 213 | + * | |
| 214 | + * void populate_pst_gamma(struct c3_isp_params_block_header *block) { | |
| 215 | + * struct c3_isp_params_pst_gamma *gamma = | |
| 216 | + * (struct c3_isp_params_pst_gamma *)block; | |
| 217 | + * | |
| 218 | + * gamma->header.type = C3_ISP_PARAMS_BLOCK_PST_GAMMA; | |
| 219 | + * gamma->header.flags = C3_ISP_PARAMS_BLOCK_FL_ENABLE; | |
| 220 | + * gamma->header.size = sizeof(*gamma); | |
| 221 | + * | |
| 222 | + * for (unsigned int i = 0; i < 129; i++) | |
| 223 | + * gamma->pst_gamma_lut[i] = i; | |
| 224 | + * } | |
| 225 | + * | |
| 226 | + * @type: The parameters block type from :c:type:`c3_isp_params_block_type` | |
| 227 | + * @flags: A bitmask of block flags | |
| 228 | + * @size: Size (in bytes) of the parameters block, including this header | |
| 229 | + */ | |
| 230 | +struct c3_isp_params_block_header { | |
| 231 | + __u16 type; | |
| 232 | + __u16 flags; | |
| 233 | + __u32 size; | |
| 234 | +}; | |
| 235 | + | |
| 236 | +/** | |
| 237 | + * struct c3_isp_params_awb_gains - Gains for auto-white balance | |
| 238 | + * | |
| 239 | + * This struct allows users to configure the gains for white balance. | |
| 240 | + * There are four gain settings corresponding to each colour channel in | |
| 241 | + * the bayer domain. All of the gains are stored in Q4.8 format. | |
| 242 | + * | |
| 243 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_AWB_GAINS | |
| 244 | + * from :c:type:`c3_isp_params_block_type` | |
| 245 | + * | |
| 246 | + * @header: The C3 ISP parameters block header | |
| 247 | + * @gr_gain: Multiplier for Gr channel (Q4.8 format) | |
| 248 | + * @r_gain: Multiplier for R channel (Q4.8 format) | |
| 249 | + * @b_gain: Multiplier for B channel (Q4.8 format) | |
| 250 | + * @gb_gain: Multiplier for Gb channel (Q4.8 format) | |
| 251 | + */ | |
| 252 | +struct c3_isp_params_awb_gains { | |
| 253 | + struct c3_isp_params_block_header header; | |
| 254 | + __u16 gr_gain; | |
| 255 | + __u16 r_gain; | |
| 256 | + __u16 b_gain; | |
| 257 | + __u16 gb_gain; | |
| 258 | +} __attribute__((aligned(8))); | |
| 259 | + | |
| 260 | +/** | |
| 261 | + * enum c3_isp_params_awb_tap_points - Tap points for the AWB statistics | |
| 262 | + * @C3_ISP_AWB_STATS_TAP_OFE: immediately after the optical frontend block | |
| 263 | + * @C3_ISP_AWB_STATS_TAP_GE: immediately after the green equal block | |
| 264 | + * @C3_ISP_AWB_STATS_TAP_BEFORE_WB: immediately before the white balance block | |
| 265 | + * @C3_ISP_AWB_STATS_TAP_AFTER_WB: immediately after the white balance block | |
| 266 | + */ | |
| 267 | +enum c3_isp_params_awb_tap_points { | |
| 268 | + C3_ISP_AWB_STATS_TAP_OFE = 0, | |
| 269 | + C3_ISP_AWB_STATS_TAP_GE, | |
| 270 | + C3_ISP_AWB_STATS_TAP_BEFORE_WB, | |
| 271 | + C3_ISP_AWB_STATS_TAP_AFTER_WB, | |
| 272 | +}; | |
| 273 | + | |
| 274 | +/** | |
| 275 | + * struct c3_isp_params_awb_config - Stats settings for auto-white balance | |
| 276 | + * | |
| 277 | + * This struct allows the configuration of the statistics generated for auto | |
| 278 | + * white balance. | |
| 279 | + * | |
| 280 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_AWB_CONFIG | |
| 281 | + * from :c:type:`c3_isp_params_block_type` | |
| 282 | + * | |
| 283 | + * @header: the C3 ISP parameters block header | |
| 284 | + * @tap_point: the tap point from enum c3_isp_params_awb_tap_point | |
| 285 | + * @satur_vald: AWB statistic over saturation control | |
| 286 | + * value: 0: disable, 1: enable | |
| 287 | + * @horiz_zones_num: active number of hotizontal zones [0..32] | |
| 288 | + * @vert_zones_num: active number of vertical zones [0..24] | |
| 289 | + * @rg_min: minimum R/G ratio (Q4.8 format) | |
| 290 | + * @rg_max: maximum R/G ratio (Q4.8 format) | |
| 291 | + * @bg_min: minimum B/G ratio (Q4.8 format) | |
| 292 | + * @bg_max: maximum B/G ratio (Q4.8 format) | |
| 293 | + * @rg_low: R/G ratio trim low (Q4.8 format) | |
| 294 | + * @rg_high: R/G ratio trim hight (Q4.8 format) | |
| 295 | + * @bg_low: B/G ratio trim low (Q4.8 format) | |
| 296 | + * @bg_high: B/G ratio trim high (Q4.8 format) | |
| 297 | + * @zone_weight: array of weights for AWB statistics zones [0..15] | |
| 298 | + * @horiz_coord: the horizontal coordinate of points on the diagonal [0..2888] | |
| 299 | + * @vert_coord: the vertical coordinate of points on the diagonal [0..2240] | |
| 300 | + */ | |
| 301 | +struct c3_isp_params_awb_config { | |
| 302 | + struct c3_isp_params_block_header header; | |
| 303 | + __u8 tap_point; | |
| 304 | + __u8 satur_vald; | |
| 305 | + __u8 horiz_zones_num; | |
| 306 | + __u8 vert_zones_num; | |
| 307 | + __u16 rg_min; | |
| 308 | + __u16 rg_max; | |
| 309 | + __u16 bg_min; | |
| 310 | + __u16 bg_max; | |
| 311 | + __u16 rg_low; | |
| 312 | + __u16 rg_high; | |
| 313 | + __u16 bg_low; | |
| 314 | + __u16 bg_high; | |
| 315 | + __u8 zone_weight[C3_ISP_AWB_MAX_ZONES]; | |
| 316 | + __u16 horiz_coord[C3_ISP_AWB_MAX_PT_NUM]; | |
| 317 | + __u16 vert_coord[C3_ISP_AWB_MAX_PT_NUM]; | |
| 318 | +} __attribute__((aligned(8))); | |
| 319 | + | |
| 320 | +/** | |
| 321 | + * enum c3_isp_params_ae_tap_points - Tap points for the AE statistics | |
| 322 | + * @C3_ISP_AE_STATS_TAP_GE: immediately after the green equal block | |
| 323 | + * @C3_ISP_AE_STATS_TAP_MLS: immediately after the mesh lens shading block | |
| 324 | + */ | |
| 325 | +enum c3_isp_params_ae_tap_points { | |
| 326 | + C3_ISP_AE_STATS_TAP_GE = 0, | |
| 327 | + C3_ISP_AE_STATS_TAP_MLS, | |
| 328 | +}; | |
| 329 | + | |
| 330 | +/** | |
| 331 | + * struct c3_isp_params_ae_config - Stats settings for auto-exposure | |
| 332 | + * | |
| 333 | + * This struct allows the configuration of the statistics generated for | |
| 334 | + * auto exposure. | |
| 335 | + * | |
| 336 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_AE_CONFIG | |
| 337 | + * from :c:type:`c3_isp_params_block_type` | |
| 338 | + * | |
| 339 | + * @header: the C3 ISP parameters block header | |
| 340 | + * @horiz_zones_num: active number of horizontal zones [0..17] | |
| 341 | + * @vert_zones_num: active number of vertical zones [0..15] | |
| 342 | + * @tap_point: the tap point from enum c3_isp_params_ae_tap_point | |
| 343 | + * @zone_weight: array of weights for AE statistics zones [0..15] | |
| 344 | + * @horiz_coord: the horizontal coordinate of points on the diagonal [0..2888] | |
| 345 | + * @vert_coord: the vertical coordinate of points on the diagonal [0..2240] | |
| 346 | + * @reserved: applications must zero this array | |
| 347 | + */ | |
| 348 | +struct c3_isp_params_ae_config { | |
| 349 | + struct c3_isp_params_block_header header; | |
| 350 | + __u8 tap_point; | |
| 351 | + __u8 horiz_zones_num; | |
| 352 | + __u8 vert_zones_num; | |
| 353 | + __u8 zone_weight[C3_ISP_AE_MAX_ZONES]; | |
| 354 | + __u16 horiz_coord[C3_ISP_AE_MAX_PT_NUM]; | |
| 355 | + __u16 vert_coord[C3_ISP_AE_MAX_PT_NUM]; | |
| 356 | + __u16 reserved[3]; | |
| 357 | +} __attribute__((aligned(8))); | |
| 358 | + | |
| 359 | +/** | |
| 360 | + * enum c3_isp_params_af_tap_points - Tap points for the AF statistics | |
| 361 | + * @C3_ISP_AF_STATS_TAP_SNR: immediately after the spatial noise reduce block | |
| 362 | + * @C3_ISP_AF_STATS_TAP_DMS: immediately after the demosaic block | |
| 363 | + */ | |
| 364 | +enum c3_isp_params_af_tap_points { | |
| 365 | + C3_ISP_AF_STATS_TAP_SNR = 0, | |
| 366 | + C3_ISP_AF_STATS_TAP_DMS, | |
| 367 | +}; | |
| 368 | + | |
| 369 | +/** | |
| 370 | + * struct c3_isp_params_af_config - Stats settings for auto-focus | |
| 371 | + * | |
| 372 | + * This struct allows the configuration of the statistics generated for | |
| 373 | + * auto focus. | |
| 374 | + * | |
| 375 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_AF_CONFIG | |
| 376 | + * from :c:type:`c3_isp_params_block_type` | |
| 377 | + * | |
| 378 | + * @header: the C3 ISP parameters block header | |
| 379 | + * @tap_point: the tap point from enum c3_isp_params_af_tap_point | |
| 380 | + * @horiz_zones_num: active number of hotizontal zones [0..17] | |
| 381 | + * @vert_zones_num: active number of vertical zones [0..15] | |
| 382 | + * @reserved: applications must zero this array | |
| 383 | + * @horiz_coord: the horizontal coordinate of points on the diagonal [0..2888] | |
| 384 | + * @vert_coord: the vertical coordinate of points on the diagonal [0..2240] | |
| 385 | + */ | |
| 386 | +struct c3_isp_params_af_config { | |
| 387 | + struct c3_isp_params_block_header header; | |
| 388 | + __u8 tap_point; | |
| 389 | + __u8 horiz_zones_num; | |
| 390 | + __u8 vert_zones_num; | |
| 391 | + __u8 reserved[5]; | |
| 392 | + __u16 horiz_coord[C3_ISP_AF_MAX_PT_NUM]; | |
| 393 | + __u16 vert_coord[C3_ISP_AF_MAX_PT_NUM]; | |
| 394 | +} __attribute__((aligned(8))); | |
| 395 | + | |
| 396 | +/** | |
| 397 | + * struct c3_isp_params_pst_gamma - Post gamma configuration | |
| 398 | + * | |
| 399 | + * This struct allows the configuration of the look up table for | |
| 400 | + * post gamma. The gamma curve consists of 129 points, so need to | |
| 401 | + * set lut[129]. | |
| 402 | + * | |
| 403 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_PST_GAMMA | |
| 404 | + * from :c:type:`c3_isp_params_block_type` | |
| 405 | + * | |
| 406 | + * @header: the C3 ISP parameters block header | |
| 407 | + * @lut: lookup table for P-Stitch gamma [0..1023] | |
| 408 | + * @reserved: applications must zero this array | |
| 409 | + */ | |
| 410 | +struct c3_isp_params_pst_gamma { | |
| 411 | + struct c3_isp_params_block_header header; | |
| 412 | + __u16 lut[129]; | |
| 413 | + __u16 reserved[3]; | |
| 414 | +} __attribute__((aligned(8))); | |
| 415 | + | |
| 416 | +/** | |
| 417 | + * struct c3_isp_params_ccm - ISP CCM configuration | |
| 418 | + * | |
| 419 | + * This struct allows the configuration of the matrix for | |
| 420 | + * color correction. The matrix consists of 3 x 3 points, | |
| 421 | + * so need to set matrix[3][3]. | |
| 422 | + * | |
| 423 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_CCM | |
| 424 | + * from :c:type:`c3_isp_params_block_type` | |
| 425 | + * | |
| 426 | + * @header: the C3 ISP parameters block header | |
| 427 | + * @matrix: a 3 x 3 matrix used for color correction, | |
| 428 | + * the value of matrix[x][y] is orig_value x 256. [-4096..4095] | |
| 429 | + * @reserved: applications must zero this array | |
| 430 | + */ | |
| 431 | +struct c3_isp_params_ccm { | |
| 432 | + struct c3_isp_params_block_header header; | |
| 433 | + __s16 matrix[3][3]; | |
| 434 | + __u16 reserved[3]; | |
| 435 | +} __attribute__((aligned(8))); | |
| 436 | + | |
| 437 | +/** | |
| 438 | + * struct c3_isp_params_csc - ISP Color Space Conversion configuration | |
| 439 | + * | |
| 440 | + * This struct allows the configuration of the matrix for color space | |
| 441 | + * conversion. The matrix consists of 3 x 3 points, so need to set matrix[3][3]. | |
| 442 | + * | |
| 443 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_CSC | |
| 444 | + * from :c:type:`c3_isp_params_block_type` | |
| 445 | + * | |
| 446 | + * @header: the C3 ISP parameters block header | |
| 447 | + * @matrix: a 3x3 matrix used for the color space conversion, | |
| 448 | + * the value of matrix[x][y] is orig_value x 256. [-4096..4095] | |
| 449 | + * @reserved: applications must zero this array | |
| 450 | + */ | |
| 451 | +struct c3_isp_params_csc { | |
| 452 | + struct c3_isp_params_block_header header; | |
| 453 | + __s16 matrix[3][3]; | |
| 454 | + __u16 reserved[3]; | |
| 455 | +} __attribute__((aligned(8))); | |
| 456 | + | |
| 457 | +/** | |
| 458 | + * struct c3_isp_params_blc - ISP Black Level Correction configuration | |
| 459 | + * | |
| 460 | + * This struct allows the configuration of the block level offset for each | |
| 461 | + * color channel. | |
| 462 | + * | |
| 463 | + * header.type should be set to C3_ISP_PARAMS_BLOCK_BLC | |
| 464 | + * from :c:type:`c3_isp_params_block_type` | |
| 465 | + * | |
| 466 | + * @header: the C3 ISP parameters block header | |
| 467 | + * @gr_ofst: Gr blc offset (Q4.12 format) | |
| 468 | + * @r_ofst: R blc offset (Q4.12 format) | |
| 469 | + * @b_ofst: B blc offset (Q4.12 format) | |
| 470 | + * @gb_ofst: Gb blc offset(Q4.12 format) | |
| 471 | + */ | |
| 472 | +struct c3_isp_params_blc { | |
| 473 | + struct c3_isp_params_block_header header; | |
| 474 | + __u16 gr_ofst; | |
| 475 | + __u16 r_ofst; | |
| 476 | + __u16 b_ofst; | |
| 477 | + __u16 gb_ofst; | |
| 478 | +}; | |
| 479 | + | |
| 480 | +/** | |
| 481 | + * define C3_ISP_PARAMS_MAX_SIZE - Maximum size of all C3 ISP Parameters | |
| 482 | + * | |
| 483 | + * Though the parameters for the C3 ISP are passed as optional blocks, the | |
| 484 | + * driver still needs to know the absolute maximum size so that it can allocate | |
| 485 | + * a buffer sized appropriately to accommodate userspace attempting to set all | |
| 486 | + * possible parameters in a single frame. | |
| 487 | + */ | |
| 488 | +#define C3_ISP_PARAMS_MAX_SIZE \ | |
| 489 | + (sizeof(struct c3_isp_params_awb_gains) + \ | |
| 490 | + sizeof(struct c3_isp_params_awb_config) + \ | |
| 491 | + sizeof(struct c3_isp_params_ae_config) + \ | |
| 492 | + sizeof(struct c3_isp_params_af_config) + \ | |
| 493 | + sizeof(struct c3_isp_params_pst_gamma) + \ | |
| 494 | + sizeof(struct c3_isp_params_ccm) + \ | |
| 495 | + sizeof(struct c3_isp_params_csc) + \ | |
| 496 | + sizeof(struct c3_isp_params_blc)) | |
| 497 | + | |
| 498 | +/** | |
| 499 | + * struct c3_isp_params_cfg - C3 ISP configuration parameters | |
| 500 | + * | |
| 501 | + * This struct contains the configuration parameters of the C3 ISP | |
| 502 | + * algorithms, serialized by userspace into an opaque data buffer. Each | |
| 503 | + * configuration parameter block is represented by a block-specific structure | |
| 504 | + * which contains a :c:type:`c3_isp_param_block_header` entry as first | |
| 505 | + * member. Userspace populates the @data buffer with configuration parameters | |
| 506 | + * for the blocks that it intends to configure. As a consequence, the data | |
| 507 | + * buffer effective size changes according to the number of ISP blocks that | |
| 508 | + * userspace intends to configure. | |
| 509 | + * | |
| 510 | + * The parameters buffer is versioned by the @version field to allow modifying | |
| 511 | + * and extending its definition. Userspace should populate the @version field to | |
| 512 | + * inform the driver about the version it intends to use. The driver will parse | |
| 513 | + * and handle the @data buffer according to the data layout specific to the | |
| 514 | + * indicated revision and return an error if the desired revision is not | |
| 515 | + * supported. | |
| 516 | + * | |
| 517 | + * For each ISP block that userspace wants to configure, a block-specific | |
| 518 | + * structure is appended to the @data buffer, one after the other without gaps | |
| 519 | + * in between nor overlaps. Userspace shall populate the @total_size field with | |
| 520 | + * the effective size, in bytes, of the @data buffer. | |
| 521 | + * | |
| 522 | + * The expected memory layout of the parameters buffer is:: | |
| 523 | + * | |
| 524 | + * +-------------------- struct c3_isp_params_cfg ---- ------------------+ | |
| 525 | + * | version = C3_ISP_PARAM_BUFFER_V0; | | |
| 526 | + * | data_size = sizeof(struct c3_isp_params_awb_gains) + | | |
| 527 | + * | sizeof(struct c3_isp_params_awb_config); | | |
| 528 | + * | +------------------------- data ---------------------------------+ | | |
| 529 | + * | | +------------ struct c3_isp_params_awb_gains) ------------------+ | | |
| 530 | + * | | | +--------- struct c3_isp_params_block_header header -----+ | | | | |
| 531 | + * | | | | type = C3_ISP_PARAMS_BLOCK_AWB_GAINS; | | | | | |
| 532 | + * | | | | flags = C3_ISP_PARAMS_BLOCK_FL_NONE; | | | | | |
| 533 | + * | | | | size = sizeof(struct c3_isp_params_awb_gains); | | | | | |
| 534 | + * | | | +---------------------------------------------------------+ | | | | |
| 535 | + * | | | gr_gain = ...; | | | | |
| 536 | + * | | | r_gain = ...; | | | | |
| 537 | + * | | | b_gain = ...; | | | | |
| 538 | + * | | | gb_gain = ...; | | | | |
| 539 | + * | | +------------------ struct c3_isp_params_awb_config ----------+ | | | |
| 540 | + * | | | +---------- struct c3_isp_param_block_header header ------+ | | | | |
| 541 | + * | | | | type = C3_ISP_PARAMS_BLOCK_AWB_CONFIG; | | | | | |
| 542 | + * | | | | flags = C3_ISP_PARAMS_BLOCK_FL_NONE; | | | | | |
| 543 | + * | | | | size = sizeof(struct c3_isp_params_awb_config) | | | | | |
| 544 | + * | | | +---------------------------------------------------------+ | | | | |
| 545 | + * | | | tap_point = ...; | | | | |
| 546 | + * | | | satur_vald = ...; | | | | |
| 547 | + * | | | horiz_zones_num = ...; | | | | |
| 548 | + * | | | vert_zones_num = ...; | | | | |
| 549 | + * | | +-------------------------------------------------------------+ | | | |
| 550 | + * | +-----------------------------------------------------------------+ | | |
| 551 | + * +---------------------------------------------------------------------+ | |
| 552 | + * | |
| 553 | + * @version: The C3 ISP parameters buffer version | |
| 554 | + * @data_size: The C3 ISP configuration data effective size, excluding this | |
| 555 | + * header | |
| 556 | + * @data: The C3 ISP configuration blocks data | |
| 557 | + */ | |
| 558 | +struct c3_isp_params_cfg { | |
| 559 | + __u32 version; | |
| 560 | + __u32 data_size; | |
| 561 | + __u8 data[C3_ISP_PARAMS_MAX_SIZE]; | |
| 562 | +}; | |
| 563 | + | |
| 564 | +#endif | |