1 /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */
3 * Rockchip ISP1 userspace API
4 * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
7 #ifndef _UAPI_RKISP1_CONFIG_H
8 #define _UAPI_RKISP1_CONFIG_H
10 #include <linux/types.h>
12 /* Defect Pixel Cluster Detection */
13 #define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0)
14 /* Black Level Subtraction */
15 #define RKISP1_CIF_ISP_MODULE_BLS (1U << 1)
17 #define RKISP1_CIF_ISP_MODULE_SDG (1U << 2)
18 /* Histogram statistics configuration */
19 #define RKISP1_CIF_ISP_MODULE_HST (1U << 3)
20 /* Lens Shade Control */
21 #define RKISP1_CIF_ISP_MODULE_LSC (1U << 4)
22 /* Auto White Balance Gain */
23 #define RKISP1_CIF_ISP_MODULE_AWB_GAIN (1U << 5)
25 #define RKISP1_CIF_ISP_MODULE_FLT (1U << 6)
27 #define RKISP1_CIF_ISP_MODULE_BDM (1U << 7)
29 #define RKISP1_CIF_ISP_MODULE_CTK (1U << 8)
31 #define RKISP1_CIF_ISP_MODULE_GOC (1U << 9)
32 /* Color Processing */
33 #define RKISP1_CIF_ISP_MODULE_CPROC (1U << 10)
34 /* Auto Focus Control statistics configuration */
35 #define RKISP1_CIF_ISP_MODULE_AFC (1U << 11)
36 /* Auto White Balancing statistics configuration */
37 #define RKISP1_CIF_ISP_MODULE_AWB (1U << 12)
39 #define RKISP1_CIF_ISP_MODULE_IE (1U << 13)
40 /* Auto Exposure Control statistics configuration */
41 #define RKISP1_CIF_ISP_MODULE_AEC (1U << 14)
42 /* Wide Dynamic Range */
43 #define RKISP1_CIF_ISP_MODULE_WDR (1U << 15)
44 /* Denoise Pre-Filter */
45 #define RKISP1_CIF_ISP_MODULE_DPF (1U << 16)
46 /* Denoise Pre-Filter Strength */
47 #define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH (1U << 17)
49 #define RKISP1_CIF_ISP_CTK_COEFF_MAX 0x100
50 #define RKISP1_CIF_ISP_CTK_OFFSET_MAX 0x800
52 #define RKISP1_CIF_ISP_AE_MEAN_MAX_V10 25
53 #define RKISP1_CIF_ISP_AE_MEAN_MAX_V12 81
54 #define RKISP1_CIF_ISP_AE_MEAN_MAX RKISP1_CIF_ISP_AE_MEAN_MAX_V12
56 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 16
57 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 32
58 #define RKISP1_CIF_ISP_HIST_BIN_N_MAX RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12
60 #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS 3
61 #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE 17
63 #define RKISP1_CIF_ISP_BDM_MAX_TH 0xff
66 * Black level compensation
68 /* maximum value for horizontal start address */
69 #define RKISP1_CIF_ISP_BLS_START_H_MAX 0x00000fff
70 /* maximum value for horizontal stop address */
71 #define RKISP1_CIF_ISP_BLS_STOP_H_MAX 0x00000fff
72 /* maximum value for vertical start address */
73 #define RKISP1_CIF_ISP_BLS_START_V_MAX 0x00000fff
74 /* maximum value for vertical stop address */
75 #define RKISP1_CIF_ISP_BLS_STOP_V_MAX 0x00000fff
76 /* maximum is 2^18 = 262144*/
77 #define RKISP1_CIF_ISP_BLS_SAMPLES_MAX 0x00000012
78 /* maximum value for fixed black level */
79 #define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX 0x00000fff
80 /* minimum value for fixed black level */
81 #define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN 0xfffff000
82 /* 13 bit range (signed)*/
83 #define RKISP1_CIF_ISP_BLS_FIX_MASK 0x00001fff
86 * Automatic white balance measurements
88 #define RKISP1_CIF_ISP_AWB_MAX_GRID 1
89 #define RKISP1_CIF_ISP_AWB_MAX_FRAMES 7
94 /* Maximum number of color samples supported */
95 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 17
96 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 34
97 #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
100 * Lens shade correction
102 #define RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE 8
105 * The following matches the tuning process,
106 * not the max capabilities of the chip.
108 #define RKISP1_CIF_ISP_LSC_SAMPLES_MAX 17
111 * Histogram calculation
113 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25
114 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
115 #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
118 * Defect Pixel Cluster Correction
120 #define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
123 * Denoising pre filter
125 #define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS 17
126 #define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6
131 #define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
132 #define RKISP1_CIF_ISP_STAT_AUTOEXP (1U << 1)
133 #define RKISP1_CIF_ISP_STAT_AFM (1U << 2)
134 #define RKISP1_CIF_ISP_STAT_HIST (1U << 3)
137 * enum rkisp1_cif_isp_version - ISP variants
139 * @RKISP1_V10: used at least in rk3288 and rk3399
140 * @RKISP1_V11: declared in the original vendor code, but not used
141 * @RKISP1_V12: used at least in rk3326 and px30
142 * @RKISP1_V13: used at least in rk1808
144 enum rkisp1_cif_isp_version {
151 enum rkisp1_cif_isp_histogram_mode {
152 RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
153 RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
154 RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
155 RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
156 RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
157 RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
160 enum rkisp1_cif_isp_awb_mode_type {
161 RKISP1_CIF_ISP_AWB_MODE_MANUAL,
162 RKISP1_CIF_ISP_AWB_MODE_RGB,
163 RKISP1_CIF_ISP_AWB_MODE_YCBCR
166 enum rkisp1_cif_isp_flt_mode {
167 RKISP1_CIF_ISP_FLT_STATIC_MODE,
168 RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
172 * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
173 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
174 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
176 enum rkisp1_cif_isp_exp_ctrl_autostop {
177 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
178 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
182 * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
183 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
184 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
186 enum rkisp1_cif_isp_exp_meas_mode {
187 RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
188 RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
191 /*---------- PART1: Input Parameters ------------*/
194 * struct rkisp1_cif_isp_window - measurement window.
196 * Measurements are calculated per window inside the frame.
197 * This struct represents a window for a measurement.
199 * @h_offs: the horizontal offset of the window from the left of the frame in pixels.
200 * @v_offs: the vertical offset of the window from the top of the frame in pixels.
201 * @h_size: the horizontal size of the window in pixels
202 * @v_size: the vertical size of the window in pixels.
204 struct rkisp1_cif_isp_window {
212 * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
214 * The values will be subtracted from the sensor
215 * values. Therefore a negative value means addition instead of subtraction!
217 * @r: Fixed (signed!) subtraction value for Bayer pattern R
218 * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
219 * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
220 * @b: Fixed (signed!) subtraction value for Bayer pattern B
222 struct rkisp1_cif_isp_bls_fixed_val {
230 * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
232 * @enable_auto: Automatic mode activated means that the measured values
233 * are subtracted. Otherwise the fixed subtraction
234 * values will be subtracted.
235 * @en_windows: enabled window
236 * @bls_window1: Measurement window 1 size
237 * @bls_window2: Measurement window 2 size
238 * @bls_samples: Set amount of measured pixels for each Bayer position
239 * (A, B,C and D) to 2^bls_samples.
240 * @fixed_val: Fixed subtraction values
242 struct rkisp1_cif_isp_bls_config {
245 struct rkisp1_cif_isp_window bls_window1;
246 struct rkisp1_cif_isp_window bls_window2;
248 struct rkisp1_cif_isp_bls_fixed_val fixed_val;
252 * struct rkisp1_cif_isp_dpcc_methods_config - Methods Configuration used by DPCC
254 * Methods Configuration used by Defect Pixel Cluster Correction
256 * @method: Method enable bits
257 * @line_thresh: Line threshold
258 * @line_mad_fac: Line MAD factor
259 * @pg_fac: Peak gradient factor
260 * @rnd_thresh: Rank Neighbor Difference threshold
261 * @rg_fac: Rank gradient factor
263 struct rkisp1_cif_isp_dpcc_methods_config {
273 * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
275 * Configuration used by Defect Pixel Cluster Correction
277 * @mode: dpcc output mode
278 * @output_mode: whether use hard coded methods
279 * @set_use: stage1 methods set
280 * @methods: methods config
281 * @ro_limits: rank order limits
282 * @rnd_offs: differential rank offsets for rank neighbor difference
284 struct rkisp1_cif_isp_dpcc_config {
288 struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
294 * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output).
296 * The reset values define a linear curve which has the same effect as bypass. Reset values are:
297 * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
299 * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
301 struct rkisp1_cif_isp_gamma_corr_curve {
302 __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
306 * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments
307 * (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the
308 * higher samples (9-16). The reset values for both fields is 0x44444444. This means
309 * that each sample is 4 units away from the previous one on the x-axis.
311 * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused.
312 * Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused
313 * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused.
314 * Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
316 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
322 * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
324 * @curve_r: gamma curve point definition axis for red
325 * @curve_g: gamma curve point definition axis for green
326 * @curve_b: gamma curve point definition axis for blue
327 * @xa_pnts: x axis increments
329 struct rkisp1_cif_isp_sdg_config {
330 struct rkisp1_cif_isp_gamma_corr_curve curve_r;
331 struct rkisp1_cif_isp_gamma_corr_curve curve_g;
332 struct rkisp1_cif_isp_gamma_corr_curve curve_b;
333 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
337 * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
339 * @r_data_tbl: sample table red
340 * @gr_data_tbl: sample table green (red)
341 * @gb_data_tbl: sample table green (blue)
342 * @b_data_tbl: sample table blue
343 * @x_grad_tbl: gradient table x
344 * @y_grad_tbl: gradient table y
345 * @x_size_tbl: size table x
346 * @y_size_tbl: size table y
347 * @config_width: not used at the moment
348 * @config_height: not used at the moment
350 struct rkisp1_cif_isp_lsc_config {
351 __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
352 __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
353 __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
354 __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
356 __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
357 __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
359 __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
360 __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
366 * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
368 * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA,
369 * V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS,
370 * V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVE
371 * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red).
372 * bits 8:15 - Threshold value of the RGB colors for the color selection effect.
373 * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
374 * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
375 * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
376 * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
377 * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
378 * @eff_tint: Chrominance increment values of tint (used for sepia effect)
380 struct rkisp1_cif_isp_ie_config {
392 * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
394 * @c_out_range: Chrominance pixel clipping range at output.
395 * (0 for limit, 1 for full)
396 * @y_in_range: Luminance pixel clipping range at output.
397 * @y_out_range: Luminance pixel clipping range at output.
398 * @contrast: 00~ff, 0.0~1.992
399 * @brightness: 80~7F, -128~+127
400 * @sat: saturation, 00~FF, 0.0~1.992
401 * @hue: 80~7F, -90~+87.188
403 struct rkisp1_cif_isp_cproc_config {
414 * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
416 * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
417 * @awb_wnd: white balance measurement window (in pixels)
418 * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
419 * to disable this feature
420 * @min_y: only pixels values > min_y contribute to awb measurement
421 * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
422 * smaller than threshold for awb measurements
423 * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
424 * each greater than threshold value for awb measurements
425 * @frames: number of frames - 1 used for mean value calculation
426 * (ucFrames=0 means 1 Frame)
427 * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
428 * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
429 * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
431 struct rkisp1_cif_isp_awb_meas_config {
433 * Note: currently the h and v offsets are mapped to grid offsets
435 struct rkisp1_cif_isp_window awb_wnd;
444 __u8 enable_ymax_cmp;
448 * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
450 * All fields in this struct are 10 bit, where:
451 * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
453 * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
455 * @gain_red: gain value for red component.
456 * @gain_green_r: gain value for green component in red line.
457 * @gain_blue: gain value for blue component.
458 * @gain_green_b: gain value for green component in blue line.
460 struct rkisp1_cif_isp_awb_gain_config {
468 * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
470 * All 4 threshold fields (thresh_*) are 10 bits.
471 * All 6 factor fields (fac_*) are 6 bits.
473 * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
474 * @grn_stage1: Green filter stage 1 select (range 0x0...0x8)
475 * @chr_h_mode: Chroma filter horizontal mode
476 * @chr_v_mode: Chroma filter vertical mode
477 * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
478 * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
479 * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
480 * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
481 * @lum_weight: Parameters for luminance weight function.
482 * @fac_sh1: filter factor for sharp1 level
483 * @fac_sh0: filter factor for sharp0 level
484 * @fac_mid: filter factor for mid level and for static filter mode
485 * @fac_bl0: filter factor for blur 0 level
486 * @fac_bl1: filter factor for blur 1 level (max blur)
488 struct rkisp1_cif_isp_flt_config {
506 * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
508 * @demosaic_th: threshold for bayer demosaicing texture detection
510 struct rkisp1_cif_isp_bdm_config {
515 * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
517 * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer
518 * and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is
519 * represented by 0x000 and a coefficient value of 1 as 0x080.
520 * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
522 struct rkisp1_cif_isp_ctk_config {
527 enum rkisp1_cif_isp_goc_mode {
528 RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
529 RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
533 * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
535 * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
536 * @gamma_y: gamma out curve y-axis for all color components
538 * The number of entries of @gamma_y depends on the hardware revision
539 * as is reported by the hw_revision field of the struct media_device_info
540 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
542 * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
543 * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
544 * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
547 struct rkisp1_cif_isp_goc_config {
549 __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
553 * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
555 * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
556 * @histogram_predivider: process every stepsize pixel, all other pixels are
558 * @meas_window: coordinates of the measure window
559 * @hist_weight: weighting factor for sub-windows
561 * The number of entries of @hist_weight depends on the hardware revision
562 * as is reported by the hw_revision field of the struct media_device_info
563 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
565 * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
566 * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
567 * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
570 struct rkisp1_cif_isp_hst_config {
572 __u8 histogram_predivider;
573 struct rkisp1_cif_isp_window meas_window;
574 __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
578 * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
580 * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
581 * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
582 * @meas_window: coordinates of the measure window
584 struct rkisp1_cif_isp_aec_config {
587 struct rkisp1_cif_isp_window meas_window;
591 * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
593 * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
594 * @afm_win: coordinates of the meas window
595 * @thres: threshold used for minimizing the influence of noise
596 * @var_shift: the number of bits for the shift operation at the end of the
599 struct rkisp1_cif_isp_afc_config {
601 struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
607 * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
608 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
609 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
610 * registers DPF_NF_GAIN_R, ...
611 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module
612 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
613 * gains from LSC module
614 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
615 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
616 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
618 enum rkisp1_cif_isp_dpf_gain_usage {
619 RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
620 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
621 RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
622 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
623 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
624 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
625 RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
629 * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
630 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
631 * (means 7x5 active pixel)
632 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
633 * (means 5x5 active pixel)
635 enum rkisp1_cif_isp_dpf_rb_filtersize {
636 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
637 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
641 * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
642 * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
643 * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
645 enum rkisp1_cif_isp_dpf_nll_scale_mode {
646 RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
647 RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
651 * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
653 * @coeff: Noise level Lookup coefficient
654 * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
656 struct rkisp1_cif_isp_dpf_nll {
657 __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
662 * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
664 * @fltsize: The filter size for the red and blue pixels
665 * (from enum rkisp1_cif_isp_dpf_rb_filtersize)
666 * @spatial_coeff: Spatial weights
667 * @r_enable: enable filter processing for red pixels
668 * @b_enable: enable filter processing for blue pixels
670 struct rkisp1_cif_isp_dpf_rb_flt {
672 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
678 * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
680 * @spatial_coeff: Spatial weights
681 * @gr_enable: enable filter processing for green pixels in green/red lines
682 * @gb_enable: enable filter processing for green pixels in green/blue lines
684 struct rkisp1_cif_isp_dpf_g_flt {
685 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
691 * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
693 * @mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage)
694 * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
695 * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
696 * @nf_gr_gain: Noise function Gain that replaces the AWB gain
697 * for green pixels in a red line
698 * @nf_gb_gain: Noise function Gain that replaces the AWB gain
699 * for green pixels in a blue line
701 struct rkisp1_cif_isp_dpf_gain {
710 * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
712 * @gain: noise function gain
713 * @g_flt: green filter config
714 * @rb_flt: red blue filter config
715 * @nll: noise level lookup
717 struct rkisp1_cif_isp_dpf_config {
718 struct rkisp1_cif_isp_dpf_gain gain;
719 struct rkisp1_cif_isp_dpf_g_flt g_flt;
720 struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
721 struct rkisp1_cif_isp_dpf_nll nll;
725 * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
727 * @r: filter strength of the RED filter
728 * @g: filter strength of the GREEN filter
729 * @b: filter strength of the BLUE filter
731 struct rkisp1_cif_isp_dpf_strength_config {
738 * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
740 * @dpcc_config: Defect Pixel Cluster Correction config
741 * @bls_config: Black Level Subtraction config
742 * @sdg_config: sensor degamma config
743 * @lsc_config: Lens Shade config
744 * @awb_gain_config: Auto White balance gain config
745 * @flt_config: filter config
746 * @bdm_config: demosaic config
747 * @ctk_config: cross talk config
748 * @goc_config: gamma out config
749 * @bls_config: black level subtraction config
750 * @dpf_config: De-noising pre-filter config
751 * @dpf_strength_config: dpf strength config
752 * @cproc_config: color process config
753 * @ie_config: image effects config
755 struct rkisp1_cif_isp_isp_other_cfg {
756 struct rkisp1_cif_isp_dpcc_config dpcc_config;
757 struct rkisp1_cif_isp_bls_config bls_config;
758 struct rkisp1_cif_isp_sdg_config sdg_config;
759 struct rkisp1_cif_isp_lsc_config lsc_config;
760 struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
761 struct rkisp1_cif_isp_flt_config flt_config;
762 struct rkisp1_cif_isp_bdm_config bdm_config;
763 struct rkisp1_cif_isp_ctk_config ctk_config;
764 struct rkisp1_cif_isp_goc_config goc_config;
765 struct rkisp1_cif_isp_dpf_config dpf_config;
766 struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
767 struct rkisp1_cif_isp_cproc_config cproc_config;
768 struct rkisp1_cif_isp_ie_config ie_config;
772 * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
774 * @awb_meas_config: auto white balance config
775 * @hst_config: histogram config
776 * @aec_config: auto exposure config
777 * @afc_config: auto focus config
779 struct rkisp1_cif_isp_isp_meas_cfg {
780 struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
781 struct rkisp1_cif_isp_hst_config hst_config;
782 struct rkisp1_cif_isp_aec_config aec_config;
783 struct rkisp1_cif_isp_afc_config afc_config;
787 * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
789 * @module_en_update: mask the enable bits of which module should be updated
790 * @module_ens: mask the enable value of each module, only update the module
791 * which correspond bit was set in module_en_update
792 * @module_cfg_update: mask the config bits of which module should be updated
793 * @meas: measurement config
794 * @others: other config
796 struct rkisp1_params_cfg {
797 __u32 module_en_update;
799 __u32 module_cfg_update;
801 struct rkisp1_cif_isp_isp_meas_cfg meas;
802 struct rkisp1_cif_isp_isp_other_cfg others;
805 /*---------- PART2: Measurement Statistics ------------*/
808 * struct rkisp1_cif_isp_awb_meas - AWB measured values
810 * @cnt: White pixel count, number of "white pixels" found during last
812 * @mean_y_or_g: Mean value of Y within window and frames,
813 * Green if RGB is selected.
814 * @mean_cb_or_b: Mean value of Cb within window and frames,
815 * Blue if RGB is selected.
816 * @mean_cr_or_r: Mean value of Cr within window and frames,
817 * Red if RGB is selected.
819 struct rkisp1_cif_isp_awb_meas {
827 * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
829 * @awb_mean: Mean measured data
831 struct rkisp1_cif_isp_awb_stat {
832 struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
836 * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
838 * @meas_r: Mean measured value for Bayer pattern R
839 * @meas_gr: Mean measured value for Bayer pattern Gr
840 * @meas_gb: Mean measured value for Bayer pattern Gb
841 * @meas_b: Mean measured value for Bayer pattern B
843 struct rkisp1_cif_isp_bls_meas_val {
851 * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
853 * @exp_mean: Mean luminance value of block xx
854 * @bls_val: BLS measured values
856 * The number of entries of @exp_mean depends on the hardware revision
857 * as is reported by the hw_revision field of the struct media_device_info
858 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
860 * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
861 * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
862 * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
864 * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
866 struct rkisp1_cif_isp_ae_stat {
867 __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
868 struct rkisp1_cif_isp_bls_meas_val bls_val;
872 * struct rkisp1_cif_isp_af_meas_val - AF measured values
874 * @sum: sharpness value
875 * @lum: luminance value
877 struct rkisp1_cif_isp_af_meas_val {
883 * struct rkisp1_cif_isp_af_stat - statistics auto focus data
885 * @window: AF measured value of window x
887 * The module measures the sharpness in 3 windows of selectable size via
888 * register settings(ISP_AFM_*_A/B/C)
890 struct rkisp1_cif_isp_af_stat {
891 struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
895 * struct rkisp1_cif_isp_hist_stat - statistics histogram data
897 * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point
898 * type. Bits 0-4 are the fractional part and bits 5-19 are the
901 * The window of the measurements area is divided to 5x5 sub-windows for
902 * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
903 * each sub-window independently and the final result is a weighted average of
904 * the histogram measurements on all sub-windows. The window of the
905 * measurements area and the weight of each sub-window are configurable using
906 * struct @rkisp1_cif_isp_hst_config.
908 * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
910 * The number of entries of @hist_bins depends on the hardware revision
911 * as is reported by the hw_revision field of the struct media_device_info
912 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
914 * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
915 * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
916 * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
918 struct rkisp1_cif_isp_hist_stat {
919 __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
923 * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data
925 * @awb: statistics data for automatic white balance
926 * @ae: statistics data for auto exposure
927 * @af: statistics data for auto focus
928 * @hist: statistics histogram data
930 struct rkisp1_cif_isp_stat {
931 struct rkisp1_cif_isp_awb_stat awb;
932 struct rkisp1_cif_isp_ae_stat ae;
933 struct rkisp1_cif_isp_af_stat af;
934 struct rkisp1_cif_isp_hist_stat hist;
938 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
940 * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)
941 * @frame_id: frame ID for sync
942 * @params: statistics data
944 struct rkisp1_stat_buffer {
947 struct rkisp1_cif_isp_stat params;
950 #endif /* _UAPI_RKISP1_CONFIG_H */