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
122 #define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2)
124 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0)
125 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1)
126 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2)
127 #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3)
129 /* 0-2 for sets 1-3 */
130 #define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0)
131 #define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3)
133 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0)
134 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1)
135 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2)
136 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3)
137 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4)
138 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8)
139 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9)
140 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10)
141 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11)
142 #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12)
144 #define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0)
145 #define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8)
146 #define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0)
147 #define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8)
148 #define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0)
149 #define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8)
150 #define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0)
151 #define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8)
152 #define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0)
153 #define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8)
155 #define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v) ((v) << ((n) * 4))
156 #define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v) ((v) << ((n) * 4 + 2))
158 #define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v) ((v) << ((n) * 4))
159 #define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v) ((v) << ((n) * 4 + 2))
162 * Denoising pre filter
164 #define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS 17
165 #define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6
170 #define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
171 #define RKISP1_CIF_ISP_STAT_AUTOEXP (1U << 1)
172 #define RKISP1_CIF_ISP_STAT_AFM (1U << 2)
173 #define RKISP1_CIF_ISP_STAT_HIST (1U << 3)
176 * enum rkisp1_cif_isp_version - ISP variants
178 * @RKISP1_V10: Used at least in RK3288 and RK3399.
179 * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
180 * of entries in grids and histogram as v10.
181 * @RKISP1_V12: Used at least in RK3326 and PX30.
182 * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
184 * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
185 * and histogram as v10.
187 enum rkisp1_cif_isp_version {
195 enum rkisp1_cif_isp_histogram_mode {
196 RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
197 RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
198 RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
199 RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
200 RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
201 RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
204 enum rkisp1_cif_isp_awb_mode_type {
205 RKISP1_CIF_ISP_AWB_MODE_MANUAL,
206 RKISP1_CIF_ISP_AWB_MODE_RGB,
207 RKISP1_CIF_ISP_AWB_MODE_YCBCR
210 enum rkisp1_cif_isp_flt_mode {
211 RKISP1_CIF_ISP_FLT_STATIC_MODE,
212 RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
216 * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
217 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
218 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
220 enum rkisp1_cif_isp_exp_ctrl_autostop {
221 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
222 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
226 * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
227 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
228 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
230 enum rkisp1_cif_isp_exp_meas_mode {
231 RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
232 RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
235 /*---------- PART1: Input Parameters ------------*/
238 * struct rkisp1_cif_isp_window - measurement window.
240 * Measurements are calculated per window inside the frame.
241 * This struct represents a window for a measurement.
243 * @h_offs: the horizontal offset of the window from the left of the frame in pixels.
244 * @v_offs: the vertical offset of the window from the top of the frame in pixels.
245 * @h_size: the horizontal size of the window in pixels
246 * @v_size: the vertical size of the window in pixels.
248 struct rkisp1_cif_isp_window {
256 * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
258 * The values will be subtracted from the sensor
259 * values. Therefore a negative value means addition instead of subtraction!
261 * @r: Fixed (signed!) subtraction value for Bayer pattern R
262 * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
263 * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
264 * @b: Fixed (signed!) subtraction value for Bayer pattern B
266 struct rkisp1_cif_isp_bls_fixed_val {
274 * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
276 * @enable_auto: Automatic mode activated means that the measured values
277 * are subtracted. Otherwise the fixed subtraction
278 * values will be subtracted.
279 * @en_windows: enabled window
280 * @bls_window1: Measurement window 1 size
281 * @bls_window2: Measurement window 2 size
282 * @bls_samples: Set amount of measured pixels for each Bayer position
283 * (A, B,C and D) to 2^bls_samples.
284 * @fixed_val: Fixed subtraction values
286 struct rkisp1_cif_isp_bls_config {
289 struct rkisp1_cif_isp_window bls_window1;
290 struct rkisp1_cif_isp_window bls_window2;
292 struct rkisp1_cif_isp_bls_fixed_val fixed_val;
296 * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration
298 * This structure stores the configuration of one set of methods for the DPCC
299 * algorithm. Multiple methods can be selected in each set (independently for
300 * the Green and Red/Blue components) through the @method field, the result is
301 * the logical AND of all enabled methods. The remaining fields set thresholds
302 * and factors for each method.
304 * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)
305 * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)
306 * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)
307 * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)
308 * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)
309 * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
311 struct rkisp1_cif_isp_dpcc_methods_config {
321 * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
323 * Configuration used by Defect Pixel Cluster Correction. Three sets of methods
324 * can be configured and selected through the @set_use field. The result is the
325 * logical OR of all enabled sets.
327 * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)
328 * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)
329 * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)
330 * @methods: Methods sets configuration
331 * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)
332 * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
334 struct rkisp1_cif_isp_dpcc_config {
338 struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
344 * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output).
346 * The reset values define a linear curve which has the same effect as bypass. Reset values are:
347 * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
349 * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
351 struct rkisp1_cif_isp_gamma_corr_curve {
352 __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
356 * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments
357 * (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the
358 * higher samples (9-16). The reset values for both fields is 0x44444444. This means
359 * that each sample is 4 units away from the previous one on the x-axis.
361 * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused.
362 * Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused
363 * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused.
364 * Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
366 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
372 * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
374 * @curve_r: gamma curve point definition axis for red
375 * @curve_g: gamma curve point definition axis for green
376 * @curve_b: gamma curve point definition axis for blue
377 * @xa_pnts: x axis increments
379 struct rkisp1_cif_isp_sdg_config {
380 struct rkisp1_cif_isp_gamma_corr_curve curve_r;
381 struct rkisp1_cif_isp_gamma_corr_curve curve_g;
382 struct rkisp1_cif_isp_gamma_corr_curve curve_b;
383 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
387 * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
389 * @r_data_tbl: sample table red
390 * @gr_data_tbl: sample table green (red)
391 * @gb_data_tbl: sample table green (blue)
392 * @b_data_tbl: sample table blue
393 * @x_grad_tbl: gradient table x
394 * @y_grad_tbl: gradient table y
395 * @x_size_tbl: size table x
396 * @y_size_tbl: size table y
397 * @config_width: not used at the moment
398 * @config_height: not used at the moment
400 struct rkisp1_cif_isp_lsc_config {
401 __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
402 __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
403 __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
404 __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
406 __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
407 __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
409 __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
410 __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
416 * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
418 * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA,
419 * V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS,
420 * V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVE
421 * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red).
422 * bits 8:15 - Threshold value of the RGB colors for the color selection effect.
423 * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
424 * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
425 * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
426 * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
427 * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
428 * @eff_tint: Chrominance increment values of tint (used for sepia effect)
430 struct rkisp1_cif_isp_ie_config {
442 * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
444 * @c_out_range: Chrominance pixel clipping range at output.
445 * (0 for limit, 1 for full)
446 * @y_in_range: Luminance pixel clipping range at output.
447 * @y_out_range: Luminance pixel clipping range at output.
448 * @contrast: 00~ff, 0.0~1.992
449 * @brightness: 80~7F, -128~+127
450 * @sat: saturation, 00~FF, 0.0~1.992
451 * @hue: 80~7F, -90~+87.188
453 struct rkisp1_cif_isp_cproc_config {
464 * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
466 * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
467 * @awb_wnd: white balance measurement window (in pixels)
468 * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
469 * to disable this feature
470 * @min_y: only pixels values > min_y contribute to awb measurement
471 * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
472 * smaller than threshold for awb measurements
473 * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
474 * each greater than threshold value for awb measurements
475 * @frames: number of frames - 1 used for mean value calculation
476 * (ucFrames=0 means 1 Frame)
477 * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
478 * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
479 * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
481 struct rkisp1_cif_isp_awb_meas_config {
483 * Note: currently the h and v offsets are mapped to grid offsets
485 struct rkisp1_cif_isp_window awb_wnd;
494 __u8 enable_ymax_cmp;
498 * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
500 * All fields in this struct are 10 bit, where:
501 * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
503 * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
505 * @gain_red: gain value for red component.
506 * @gain_green_r: gain value for green component in red line.
507 * @gain_blue: gain value for blue component.
508 * @gain_green_b: gain value for green component in blue line.
510 struct rkisp1_cif_isp_awb_gain_config {
518 * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
520 * All 4 threshold fields (thresh_*) are 10 bits.
521 * All 6 factor fields (fac_*) are 6 bits.
523 * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
524 * @grn_stage1: Green filter stage 1 select (range 0x0...0x8)
525 * @chr_h_mode: Chroma filter horizontal mode
526 * @chr_v_mode: Chroma filter vertical mode
527 * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
528 * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
529 * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
530 * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
531 * @lum_weight: Parameters for luminance weight function.
532 * @fac_sh1: filter factor for sharp1 level
533 * @fac_sh0: filter factor for sharp0 level
534 * @fac_mid: filter factor for mid level and for static filter mode
535 * @fac_bl0: filter factor for blur 0 level
536 * @fac_bl1: filter factor for blur 1 level (max blur)
538 struct rkisp1_cif_isp_flt_config {
556 * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
558 * @demosaic_th: threshold for bayer demosaicing texture detection
560 struct rkisp1_cif_isp_bdm_config {
565 * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
567 * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer
568 * and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is
569 * represented by 0x000 and a coefficient value of 1 as 0x080.
570 * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
572 struct rkisp1_cif_isp_ctk_config {
577 enum rkisp1_cif_isp_goc_mode {
578 RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
579 RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
583 * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
585 * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
586 * @gamma_y: gamma out curve y-axis for all color components
588 * The number of entries of @gamma_y depends on the hardware revision
589 * as is reported by the hw_revision field of the struct media_device_info
590 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
592 * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
593 * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
594 * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
596 struct rkisp1_cif_isp_goc_config {
598 __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
602 * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
604 * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
605 * @histogram_predivider: process every stepsize pixel, all other pixels are
607 * @meas_window: coordinates of the measure window
608 * @hist_weight: weighting factor for sub-windows
610 * The number of entries of @hist_weight depends on the hardware revision
611 * as is reported by the hw_revision field of the struct media_device_info
612 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
614 * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
615 * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
616 * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
619 struct rkisp1_cif_isp_hst_config {
621 __u8 histogram_predivider;
622 struct rkisp1_cif_isp_window meas_window;
623 __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
627 * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
629 * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
630 * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
631 * @meas_window: coordinates of the measure window
633 struct rkisp1_cif_isp_aec_config {
636 struct rkisp1_cif_isp_window meas_window;
640 * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
642 * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
643 * @afm_win: coordinates of the meas window
644 * @thres: threshold used for minimizing the influence of noise
645 * @var_shift: the number of bits for the shift operation at the end of the
648 struct rkisp1_cif_isp_afc_config {
650 struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
656 * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
657 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
658 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
659 * registers DPF_NF_GAIN_R, ...
660 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module
661 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
662 * gains from LSC module
663 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
664 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
665 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
667 enum rkisp1_cif_isp_dpf_gain_usage {
668 RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
669 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
670 RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
671 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
672 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
673 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
674 RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
678 * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
679 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
680 * (means 7x5 active pixel)
681 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
682 * (means 5x5 active pixel)
684 enum rkisp1_cif_isp_dpf_rb_filtersize {
685 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
686 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
690 * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
691 * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
692 * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
694 enum rkisp1_cif_isp_dpf_nll_scale_mode {
695 RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
696 RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
700 * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
702 * @coeff: Noise level Lookup coefficient
703 * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
705 struct rkisp1_cif_isp_dpf_nll {
706 __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
711 * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
713 * @fltsize: The filter size for the red and blue pixels
714 * (from enum rkisp1_cif_isp_dpf_rb_filtersize)
715 * @spatial_coeff: Spatial weights
716 * @r_enable: enable filter processing for red pixels
717 * @b_enable: enable filter processing for blue pixels
719 struct rkisp1_cif_isp_dpf_rb_flt {
721 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
727 * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
729 * @spatial_coeff: Spatial weights
730 * @gr_enable: enable filter processing for green pixels in green/red lines
731 * @gb_enable: enable filter processing for green pixels in green/blue lines
733 struct rkisp1_cif_isp_dpf_g_flt {
734 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
740 * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
742 * @mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage)
743 * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
744 * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
745 * @nf_gr_gain: Noise function Gain that replaces the AWB gain
746 * for green pixels in a red line
747 * @nf_gb_gain: Noise function Gain that replaces the AWB gain
748 * for green pixels in a blue line
750 struct rkisp1_cif_isp_dpf_gain {
759 * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
761 * @gain: noise function gain
762 * @g_flt: green filter config
763 * @rb_flt: red blue filter config
764 * @nll: noise level lookup
766 struct rkisp1_cif_isp_dpf_config {
767 struct rkisp1_cif_isp_dpf_gain gain;
768 struct rkisp1_cif_isp_dpf_g_flt g_flt;
769 struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
770 struct rkisp1_cif_isp_dpf_nll nll;
774 * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
776 * @r: filter strength of the RED filter
777 * @g: filter strength of the GREEN filter
778 * @b: filter strength of the BLUE filter
780 struct rkisp1_cif_isp_dpf_strength_config {
787 * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
789 * @dpcc_config: Defect Pixel Cluster Correction config
790 * @bls_config: Black Level Subtraction config
791 * @sdg_config: sensor degamma config
792 * @lsc_config: Lens Shade config
793 * @awb_gain_config: Auto White balance gain config
794 * @flt_config: filter config
795 * @bdm_config: demosaic config
796 * @ctk_config: cross talk config
797 * @goc_config: gamma out config
798 * @bls_config: black level subtraction config
799 * @dpf_config: De-noising pre-filter config
800 * @dpf_strength_config: dpf strength config
801 * @cproc_config: color process config
802 * @ie_config: image effects config
804 struct rkisp1_cif_isp_isp_other_cfg {
805 struct rkisp1_cif_isp_dpcc_config dpcc_config;
806 struct rkisp1_cif_isp_bls_config bls_config;
807 struct rkisp1_cif_isp_sdg_config sdg_config;
808 struct rkisp1_cif_isp_lsc_config lsc_config;
809 struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
810 struct rkisp1_cif_isp_flt_config flt_config;
811 struct rkisp1_cif_isp_bdm_config bdm_config;
812 struct rkisp1_cif_isp_ctk_config ctk_config;
813 struct rkisp1_cif_isp_goc_config goc_config;
814 struct rkisp1_cif_isp_dpf_config dpf_config;
815 struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
816 struct rkisp1_cif_isp_cproc_config cproc_config;
817 struct rkisp1_cif_isp_ie_config ie_config;
821 * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
823 * @awb_meas_config: auto white balance config
824 * @hst_config: histogram config
825 * @aec_config: auto exposure config
826 * @afc_config: auto focus config
828 struct rkisp1_cif_isp_isp_meas_cfg {
829 struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
830 struct rkisp1_cif_isp_hst_config hst_config;
831 struct rkisp1_cif_isp_aec_config aec_config;
832 struct rkisp1_cif_isp_afc_config afc_config;
836 * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
838 * @module_en_update: mask the enable bits of which module should be updated
839 * @module_ens: mask the enable value of each module, only update the module
840 * which correspond bit was set in module_en_update
841 * @module_cfg_update: mask the config bits of which module should be updated
842 * @meas: measurement config
843 * @others: other config
845 struct rkisp1_params_cfg {
846 __u32 module_en_update;
848 __u32 module_cfg_update;
850 struct rkisp1_cif_isp_isp_meas_cfg meas;
851 struct rkisp1_cif_isp_isp_other_cfg others;
854 /*---------- PART2: Measurement Statistics ------------*/
857 * struct rkisp1_cif_isp_awb_meas - AWB measured values
859 * @cnt: White pixel count, number of "white pixels" found during last
861 * @mean_y_or_g: Mean value of Y within window and frames,
862 * Green if RGB is selected.
863 * @mean_cb_or_b: Mean value of Cb within window and frames,
864 * Blue if RGB is selected.
865 * @mean_cr_or_r: Mean value of Cr within window and frames,
866 * Red if RGB is selected.
868 struct rkisp1_cif_isp_awb_meas {
876 * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
878 * @awb_mean: Mean measured data
880 struct rkisp1_cif_isp_awb_stat {
881 struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
885 * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
887 * @meas_r: Mean measured value for Bayer pattern R
888 * @meas_gr: Mean measured value for Bayer pattern Gr
889 * @meas_gb: Mean measured value for Bayer pattern Gb
890 * @meas_b: Mean measured value for Bayer pattern B
892 struct rkisp1_cif_isp_bls_meas_val {
900 * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
902 * @exp_mean: Mean luminance value of block xx
903 * @bls_val: BLS measured values
905 * The number of entries of @exp_mean depends on the hardware revision
906 * as is reported by the hw_revision field of the struct media_device_info
907 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
909 * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
910 * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
911 * to the maximum of the two.
913 * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
915 struct rkisp1_cif_isp_ae_stat {
916 __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
917 struct rkisp1_cif_isp_bls_meas_val bls_val;
921 * struct rkisp1_cif_isp_af_meas_val - AF measured values
923 * @sum: sharpness value
924 * @lum: luminance value
926 struct rkisp1_cif_isp_af_meas_val {
932 * struct rkisp1_cif_isp_af_stat - statistics auto focus data
934 * @window: AF measured value of window x
936 * The module measures the sharpness in 3 windows of selectable size via
937 * register settings(ISP_AFM_*_A/B/C)
939 struct rkisp1_cif_isp_af_stat {
940 struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
944 * struct rkisp1_cif_isp_hist_stat - statistics histogram data
946 * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point
947 * type. Bits 0-4 are the fractional part and bits 5-19 are the
950 * The window of the measurements area is divided to 5x5 sub-windows for
951 * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
952 * sub-window independently and the final result is a weighted average of the
953 * histogram measurements on all sub-windows. The window of the measurements
954 * area and the weight of each sub-window are configurable using
955 * struct @rkisp1_cif_isp_hst_config.
957 * The histogram contains 16 bins in V10 and 32 bins in V12.
959 * The number of entries of @hist_bins depends on the hardware revision
960 * as is reported by the hw_revision field of the struct media_device_info
961 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
963 * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
964 * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
965 * equal to the maximum of the two.
967 struct rkisp1_cif_isp_hist_stat {
968 __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
972 * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data
974 * @awb: statistics data for automatic white balance
975 * @ae: statistics data for auto exposure
976 * @af: statistics data for auto focus
977 * @hist: statistics histogram data
979 struct rkisp1_cif_isp_stat {
980 struct rkisp1_cif_isp_awb_stat awb;
981 struct rkisp1_cif_isp_ae_stat ae;
982 struct rkisp1_cif_isp_af_stat af;
983 struct rkisp1_cif_isp_hist_stat hist;
987 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
989 * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)
990 * @frame_id: frame ID for sync
991 * @params: statistics data
993 struct rkisp1_stat_buffer {
996 struct rkisp1_cif_isp_stat params;
999 #endif /* _UAPI_RKISP1_CONFIG_H */