1/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */
2/*
3 * Rockchip ISP1 userspace API
4 * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
5 */
6
7#ifndef _RKISP1_CONFIG_H
8#define _RKISP1_CONFIG_H
9
10#include <linux/types.h>
11
12#include <linux/media/v4l2-isp.h>
13
14/* Defect Pixel Cluster Detection */
15#define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0)
16/* Black Level Subtraction */
17#define RKISP1_CIF_ISP_MODULE_BLS (1U << 1)
18/* Sensor De-gamma */
19#define RKISP1_CIF_ISP_MODULE_SDG (1U << 2)
20/* Histogram statistics configuration */
21#define RKISP1_CIF_ISP_MODULE_HST (1U << 3)
22/* Lens Shade Control */
23#define RKISP1_CIF_ISP_MODULE_LSC (1U << 4)
24/* Auto White Balance Gain */
25#define RKISP1_CIF_ISP_MODULE_AWB_GAIN (1U << 5)
26/* Filter */
27#define RKISP1_CIF_ISP_MODULE_FLT (1U << 6)
28/* Bayer Demosaic */
29#define RKISP1_CIF_ISP_MODULE_BDM (1U << 7)
30/* Cross Talk */
31#define RKISP1_CIF_ISP_MODULE_CTK (1U << 8)
32/* Gamma Out Curve */
33#define RKISP1_CIF_ISP_MODULE_GOC (1U << 9)
34/* Color Processing */
35#define RKISP1_CIF_ISP_MODULE_CPROC (1U << 10)
36/* Auto Focus Control statistics configuration */
37#define RKISP1_CIF_ISP_MODULE_AFC (1U << 11)
38/* Auto White Balancing statistics configuration */
39#define RKISP1_CIF_ISP_MODULE_AWB (1U << 12)
40/* Image Effect */
41#define RKISP1_CIF_ISP_MODULE_IE (1U << 13)
42/* Auto Exposure Control statistics configuration */
43#define RKISP1_CIF_ISP_MODULE_AEC (1U << 14)
44/* Wide Dynamic Range */
45#define RKISP1_CIF_ISP_MODULE_WDR (1U << 15)
46/* Denoise Pre-Filter */
47#define RKISP1_CIF_ISP_MODULE_DPF (1U << 16)
48/* Denoise Pre-Filter Strength */
49#define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH (1U << 17)
50
51#define RKISP1_CIF_ISP_CTK_COEFF_MAX 0x100
52#define RKISP1_CIF_ISP_CTK_OFFSET_MAX 0x800
53
54#define RKISP1_CIF_ISP_AE_MEAN_MAX_V10 25
55#define RKISP1_CIF_ISP_AE_MEAN_MAX_V12 81
56#define RKISP1_CIF_ISP_AE_MEAN_MAX RKISP1_CIF_ISP_AE_MEAN_MAX_V12
57
58#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 16
59#define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 32
60#define RKISP1_CIF_ISP_HIST_BIN_N_MAX RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12
61
62#define RKISP1_CIF_ISP_AFM_MAX_WINDOWS 3
63#define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE 17
64
65#define RKISP1_CIF_ISP_BDM_MAX_TH 0xff
66
67/*
68 * Black level compensation
69 */
70/* maximum value for horizontal start address */
71#define RKISP1_CIF_ISP_BLS_START_H_MAX 0x00000fff
72/* maximum value for horizontal stop address */
73#define RKISP1_CIF_ISP_BLS_STOP_H_MAX 0x00000fff
74/* maximum value for vertical start address */
75#define RKISP1_CIF_ISP_BLS_START_V_MAX 0x00000fff
76/* maximum value for vertical stop address */
77#define RKISP1_CIF_ISP_BLS_STOP_V_MAX 0x00000fff
78/* maximum is 2^18 = 262144*/
79#define RKISP1_CIF_ISP_BLS_SAMPLES_MAX 0x00000012
80/* maximum value for fixed black level */
81#define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX 0x00000fff
82/* minimum value for fixed black level */
83#define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN 0xfffff000
84/* 13 bit range (signed)*/
85#define RKISP1_CIF_ISP_BLS_FIX_MASK 0x00001fff
86
87/*
88 * Automatic white balance measurements
89 */
90#define RKISP1_CIF_ISP_AWB_MAX_GRID 1
91#define RKISP1_CIF_ISP_AWB_MAX_FRAMES 7
92
93/*
94 * Gamma out
95 */
96/* Maximum number of color samples supported */
97#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 17
98#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 34
99#define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
100
101/*
102 * Lens shade correction
103 */
104#define RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE 8
105
106/*
107 * The following matches the tuning process,
108 * not the max capabilities of the chip.
109 */
110#define RKISP1_CIF_ISP_LSC_SAMPLES_MAX 17
111
112/*
113 * Histogram calculation
114 */
115#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25
116#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
117#define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
118
119/*
120 * Defect Pixel Cluster Correction
121 */
122#define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
123
124#define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2)
125
126#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0)
127#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1)
128#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2)
129#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3)
130
131/* 0-2 for sets 1-3 */
132#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0)
133#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3)
134
135#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0)
136#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1)
137#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2)
138#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3)
139#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4)
140#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8)
141#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9)
142#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10)
143#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11)
144#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12)
145
146#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0)
147#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8)
148#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0)
149#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8)
150#define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0)
151#define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8)
152#define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0)
153#define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8)
154#define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0)
155#define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8)
156
157#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v) ((v) << ((n) * 4))
158#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v) ((v) << ((n) * 4 + 2))
159
160#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v) ((v) << ((n) * 4))
161#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v) ((v) << ((n) * 4 + 2))
162
163/*
164 * Denoising pre filter
165 */
166#define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS 17
167#define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6
168
169/*
170 * Compand
171 */
172#define RKISP1_CIF_ISP_COMPAND_NUM_POINTS 64
173
174/*
175 * Wide Dynamic Range
176 */
177#define RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV 32
178#define RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF (RKISP1_CIF_ISP_WDR_CURVE_NUM_INTERV + 1)
179#define RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS 4
180
181/*
182 * Measurement types
183 */
184#define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
185#define RKISP1_CIF_ISP_STAT_AUTOEXP (1U << 1)
186#define RKISP1_CIF_ISP_STAT_AFM (1U << 2)
187#define RKISP1_CIF_ISP_STAT_HIST (1U << 3)
188
189/**
190 * enum rkisp1_cif_isp_version - ISP variants
191 *
192 * @RKISP1_V10: Used at least in RK3288 and RK3399.
193 * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
194 * of entries in grids and histogram as v10.
195 * @RKISP1_V12: Used at least in RK3326 and PX30.
196 * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
197 * histogram as v12.
198 * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
199 * and histogram as v10.
200 */
201enum rkisp1_cif_isp_version {
202 RKISP1_V10 = 10,
203 RKISP1_V11,
204 RKISP1_V12,
205 RKISP1_V13,
206 RKISP1_V_IMX8MP,
207};
208
209enum rkisp1_cif_isp_histogram_mode {
210 RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
211 RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
212 RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
213 RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
214 RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
215 RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
216};
217
218enum rkisp1_cif_isp_awb_mode_type {
219 RKISP1_CIF_ISP_AWB_MODE_MANUAL,
220 RKISP1_CIF_ISP_AWB_MODE_RGB,
221 RKISP1_CIF_ISP_AWB_MODE_YCBCR
222};
223
224enum rkisp1_cif_isp_flt_mode {
225 RKISP1_CIF_ISP_FLT_STATIC_MODE,
226 RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
227};
228
229/**
230 * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
231 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
232 * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
233 */
234enum rkisp1_cif_isp_exp_ctrl_autostop {
235 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
236 RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
237};
238
239/**
240 * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
241 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
242 * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
243 */
244enum rkisp1_cif_isp_exp_meas_mode {
245 RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
246 RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
247};
248
249/*---------- PART1: Input Parameters ------------*/
250
251/**
252 * struct rkisp1_cif_isp_window - measurement window.
253 *
254 * Measurements are calculated per window inside the frame.
255 * This struct represents a window for a measurement.
256 *
257 * @h_offs: the horizontal offset of the window from the left of the frame in pixels.
258 * @v_offs: the vertical offset of the window from the top of the frame in pixels.
259 * @h_size: the horizontal size of the window in pixels
260 * @v_size: the vertical size of the window in pixels.
261 */
262struct rkisp1_cif_isp_window {
263 __u16 h_offs;
264 __u16 v_offs;
265 __u16 h_size;
266 __u16 v_size;
267};
268
269/**
270 * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
271 *
272 * The values will be subtracted from the sensor
273 * values. Therefore a negative value means addition instead of subtraction!
274 *
275 * @r: Fixed (signed!) subtraction value for Bayer pattern R
276 * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
277 * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
278 * @b: Fixed (signed!) subtraction value for Bayer pattern B
279 */
280struct rkisp1_cif_isp_bls_fixed_val {
281 __s16 r;
282 __s16 gr;
283 __s16 gb;
284 __s16 b;
285};
286
287/**
288 * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
289 *
290 * @enable_auto: Automatic mode activated means that the measured values
291 * are subtracted. Otherwise the fixed subtraction
292 * values will be subtracted.
293 * @en_windows: enabled window
294 * @bls_window1: Measurement window 1 size
295 * @bls_window2: Measurement window 2 size
296 * @bls_samples: Set amount of measured pixels for each Bayer position
297 * (A, B,C and D) to 2^bls_samples.
298 * @fixed_val: Fixed subtraction values
299 */
300struct rkisp1_cif_isp_bls_config {
301 __u8 enable_auto;
302 __u8 en_windows;
303 struct rkisp1_cif_isp_window bls_window1;
304 struct rkisp1_cif_isp_window bls_window2;
305 __u8 bls_samples;
306 struct rkisp1_cif_isp_bls_fixed_val fixed_val;
307};
308
309/**
310 * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration
311 *
312 * This structure stores the configuration of one set of methods for the DPCC
313 * algorithm. Multiple methods can be selected in each set (independently for
314 * the Green and Red/Blue components) through the @method field, the result is
315 * the logical AND of all enabled methods. The remaining fields set thresholds
316 * and factors for each method.
317 *
318 * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)
319 * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)
320 * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)
321 * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)
322 * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)
323 * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
324 */
325struct rkisp1_cif_isp_dpcc_methods_config {
326 __u32 method;
327 __u32 line_thresh;
328 __u32 line_mad_fac;
329 __u32 pg_fac;
330 __u32 rnd_thresh;
331 __u32 rg_fac;
332};
333
334/**
335 * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
336 *
337 * Configuration used by Defect Pixel Cluster Correction. Three sets of methods
338 * can be configured and selected through the @set_use field. The result is the
339 * logical OR of all enabled sets.
340 *
341 * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)
342 * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)
343 * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)
344 * @methods: Methods sets configuration
345 * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)
346 * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
347 */
348struct rkisp1_cif_isp_dpcc_config {
349 __u32 mode;
350 __u32 output_mode;
351 __u32 set_use;
352 struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
353 __u32 ro_limits;
354 __u32 rnd_offs;
355};
356
357/**
358 * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output).
359 *
360 * The reset values define a linear curve which has the same effect as bypass. Reset values are:
361 * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
362 *
363 * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
364 */
365struct rkisp1_cif_isp_gamma_corr_curve {
366 __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
367};
368
369/**
370 * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments
371 * (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the
372 * higher samples (9-16). The reset values for both fields is 0x44444444. This means
373 * that each sample is 4 units away from the previous one on the x-axis.
374 *
375 * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused.
376 * Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused
377 * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused.
378 * Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
379 */
380struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
381 __u32 gamma_dx0;
382 __u32 gamma_dx1;
383};
384
385/**
386 * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
387 *
388 * @curve_r: gamma curve point definition axis for red
389 * @curve_g: gamma curve point definition axis for green
390 * @curve_b: gamma curve point definition axis for blue
391 * @xa_pnts: x axis increments
392 */
393struct rkisp1_cif_isp_sdg_config {
394 struct rkisp1_cif_isp_gamma_corr_curve curve_r;
395 struct rkisp1_cif_isp_gamma_corr_curve curve_g;
396 struct rkisp1_cif_isp_gamma_corr_curve curve_b;
397 struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
398};
399
400/**
401 * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
402 *
403 * @r_data_tbl: sample table red
404 * @gr_data_tbl: sample table green (red)
405 * @gb_data_tbl: sample table green (blue)
406 * @b_data_tbl: sample table blue
407 * @x_grad_tbl: gradient table x
408 * @y_grad_tbl: gradient table y
409 * @x_size_tbl: size table x
410 * @y_size_tbl: size table y
411 * @config_width: not used at the moment
412 * @config_height: not used at the moment
413 */
414struct rkisp1_cif_isp_lsc_config {
415 __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
416 __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
417 __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
418 __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
419
420 __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
421 __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
422
423 __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
424 __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
425 __u16 config_width;
426 __u16 config_height;
427};
428
429/**
430 * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
431 *
432 * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA,
433 * V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS,
434 * V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVE
435 * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red).
436 * bits 8:15 - Threshold value of the RGB colors for the color selection effect.
437 * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
438 * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
439 * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
440 * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
441 * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
442 * @eff_tint: Chrominance increment values of tint (used for sepia effect)
443 */
444struct rkisp1_cif_isp_ie_config {
445 __u16 effect;
446 __u16 color_sel;
447 __u16 eff_mat_1;
448 __u16 eff_mat_2;
449 __u16 eff_mat_3;
450 __u16 eff_mat_4;
451 __u16 eff_mat_5;
452 __u16 eff_tint;
453};
454
455/**
456 * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
457 *
458 * @c_out_range: Chrominance pixel clipping range at output.
459 * (0 for limit, 1 for full)
460 * @y_in_range: Luminance pixel clipping range at output.
461 * @y_out_range: Luminance pixel clipping range at output.
462 * @contrast: 00~ff, 0.0~1.992
463 * @brightness: 80~7F, -128~+127
464 * @sat: saturation, 00~FF, 0.0~1.992
465 * @hue: 80~7F, -90~+87.188
466 */
467struct rkisp1_cif_isp_cproc_config {
468 __u8 c_out_range;
469 __u8 y_in_range;
470 __u8 y_out_range;
471 __u8 contrast;
472 __u8 brightness;
473 __u8 sat;
474 __u8 hue;
475};
476
477/**
478 * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
479 *
480 * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
481 * @awb_wnd: white balance measurement window (in pixels)
482 * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
483 * to disable this feature
484 * @min_y: only pixels values > min_y contribute to awb measurement
485 * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
486 * smaller than threshold for awb measurements
487 * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
488 * each greater than threshold value for awb measurements
489 * @frames: number of frames - 1 used for mean value calculation
490 * (ucFrames=0 means 1 Frame)
491 * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
492 * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
493 * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
494 */
495struct rkisp1_cif_isp_awb_meas_config {
496 /*
497 * Note: currently the h and v offsets are mapped to grid offsets
498 */
499 struct rkisp1_cif_isp_window awb_wnd;
500 __u32 awb_mode;
501 __u8 max_y;
502 __u8 min_y;
503 __u8 max_csum;
504 __u8 min_c;
505 __u8 frames;
506 __u8 awb_ref_cr;
507 __u8 awb_ref_cb;
508 __u8 enable_ymax_cmp;
509};
510
511/**
512 * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
513 *
514 * All fields in this struct are 10 bit, where:
515 * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
516 *
517 * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
518 *
519 * @gain_red: gain value for red component.
520 * @gain_green_r: gain value for green component in red line.
521 * @gain_blue: gain value for blue component.
522 * @gain_green_b: gain value for green component in blue line.
523 */
524struct rkisp1_cif_isp_awb_gain_config {
525 __u16 gain_red;
526 __u16 gain_green_r;
527 __u16 gain_blue;
528 __u16 gain_green_b;
529};
530
531/**
532 * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
533 *
534 * All 4 threshold fields (thresh_*) are 10 bits.
535 * All 6 factor fields (fac_*) are 6 bits.
536 *
537 * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
538 * @grn_stage1: Green filter stage 1 select (range 0x0...0x8)
539 * @chr_h_mode: Chroma filter horizontal mode
540 * @chr_v_mode: Chroma filter vertical mode
541 * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
542 * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
543 * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
544 * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
545 * @lum_weight: Parameters for luminance weight function.
546 * @fac_sh1: filter factor for sharp1 level
547 * @fac_sh0: filter factor for sharp0 level
548 * @fac_mid: filter factor for mid level and for static filter mode
549 * @fac_bl0: filter factor for blur 0 level
550 * @fac_bl1: filter factor for blur 1 level (max blur)
551 */
552struct rkisp1_cif_isp_flt_config {
553 __u32 mode;
554 __u8 grn_stage1;
555 __u8 chr_h_mode;
556 __u8 chr_v_mode;
557 __u32 thresh_bl0;
558 __u32 thresh_bl1;
559 __u32 thresh_sh0;
560 __u32 thresh_sh1;
561 __u32 lum_weight;
562 __u32 fac_sh1;
563 __u32 fac_sh0;
564 __u32 fac_mid;
565 __u32 fac_bl0;
566 __u32 fac_bl1;
567};
568
569/**
570 * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
571 *
572 * @demosaic_th: threshold for bayer demosaicing texture detection
573 */
574struct rkisp1_cif_isp_bdm_config {
575 __u8 demosaic_th;
576};
577
578/**
579 * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
580 *
581 * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer
582 * and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is
583 * represented by 0x000 and a coefficient value of 1 as 0x080.
584 * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
585 */
586struct rkisp1_cif_isp_ctk_config {
587 __u16 coeff[3][3];
588 __u16 ct_offset[3];
589};
590
591enum rkisp1_cif_isp_goc_mode {
592 RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
593 RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
594};
595
596/**
597 * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
598 *
599 * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
600 * @gamma_y: gamma out curve y-axis for all color components
601 *
602 * The number of entries of @gamma_y depends on the hardware revision
603 * as is reported by the hw_revision field of the struct media_device_info
604 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
605 *
606 * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
607 * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
608 * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
609 */
610struct rkisp1_cif_isp_goc_config {
611 __u32 mode;
612 __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
613};
614
615/**
616 * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
617 *
618 * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
619 * @histogram_predivider: process every stepsize pixel, all other pixels are
620 * skipped
621 * @meas_window: coordinates of the measure window
622 * @hist_weight: weighting factor for sub-windows
623 *
624 * The number of entries of @hist_weight depends on the hardware revision
625 * as is reported by the hw_revision field of the struct media_device_info
626 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
627 *
628 * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
629 * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
630 * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
631 * two.
632 */
633struct rkisp1_cif_isp_hst_config {
634 __u32 mode;
635 __u8 histogram_predivider;
636 struct rkisp1_cif_isp_window meas_window;
637 __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
638};
639
640/**
641 * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
642 *
643 * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
644 * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
645 * @meas_window: coordinates of the measure window
646 */
647struct rkisp1_cif_isp_aec_config {
648 __u32 mode;
649 __u32 autostop;
650 struct rkisp1_cif_isp_window meas_window;
651};
652
653/**
654 * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
655 *
656 * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
657 * @afm_win: coordinates of the meas window
658 * @thres: threshold used for minimizing the influence of noise
659 * @var_shift: the number of bits for the shift operation at the end of the
660 * calculation chain.
661 */
662struct rkisp1_cif_isp_afc_config {
663 __u8 num_afm_win;
664 struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
665 __u32 thres;
666 __u32 var_shift;
667};
668
669/**
670 * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
671 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
672 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
673 * registers DPF_NF_GAIN_R, ...
674 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module
675 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
676 * gains from LSC module
677 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
678 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
679 * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
680 */
681enum rkisp1_cif_isp_dpf_gain_usage {
682 RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
683 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
684 RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
685 RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
686 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
687 RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
688 RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
689};
690
691/**
692 * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
693 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
694 * (means 7x5 active pixel)
695 * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
696 * (means 5x5 active pixel)
697 */
698enum rkisp1_cif_isp_dpf_rb_filtersize {
699 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
700 RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
701};
702
703/**
704 * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
705 * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
706 * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
707 */
708enum rkisp1_cif_isp_dpf_nll_scale_mode {
709 RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
710 RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
711};
712
713/**
714 * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
715 *
716 * @coeff: Noise level Lookup coefficient
717 * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
718 */
719struct rkisp1_cif_isp_dpf_nll {
720 __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
721 __u32 scale_mode;
722};
723
724/**
725 * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
726 *
727 * @fltsize: The filter size for the red and blue pixels
728 * (from enum rkisp1_cif_isp_dpf_rb_filtersize)
729 * @spatial_coeff: Spatial weights
730 * @r_enable: enable filter processing for red pixels
731 * @b_enable: enable filter processing for blue pixels
732 */
733struct rkisp1_cif_isp_dpf_rb_flt {
734 __u32 fltsize;
735 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
736 __u8 r_enable;
737 __u8 b_enable;
738};
739
740/**
741 * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
742 *
743 * @spatial_coeff: Spatial weights
744 * @gr_enable: enable filter processing for green pixels in green/red lines
745 * @gb_enable: enable filter processing for green pixels in green/blue lines
746 */
747struct rkisp1_cif_isp_dpf_g_flt {
748 __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
749 __u8 gr_enable;
750 __u8 gb_enable;
751};
752
753/**
754 * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
755 *
756 * @mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage)
757 * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
758 * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
759 * @nf_gr_gain: Noise function Gain that replaces the AWB gain
760 * for green pixels in a red line
761 * @nf_gb_gain: Noise function Gain that replaces the AWB gain
762 * for green pixels in a blue line
763 */
764struct rkisp1_cif_isp_dpf_gain {
765 __u32 mode;
766 __u16 nf_r_gain;
767 __u16 nf_b_gain;
768 __u16 nf_gr_gain;
769 __u16 nf_gb_gain;
770};
771
772/**
773 * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
774 *
775 * @gain: noise function gain
776 * @g_flt: green filter config
777 * @rb_flt: red blue filter config
778 * @nll: noise level lookup
779 */
780struct rkisp1_cif_isp_dpf_config {
781 struct rkisp1_cif_isp_dpf_gain gain;
782 struct rkisp1_cif_isp_dpf_g_flt g_flt;
783 struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
784 struct rkisp1_cif_isp_dpf_nll nll;
785};
786
787/**
788 * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
789 *
790 * @r: filter strength of the RED filter
791 * @g: filter strength of the GREEN filter
792 * @b: filter strength of the BLUE filter
793 */
794struct rkisp1_cif_isp_dpf_strength_config {
795 __u8 r;
796 __u8 g;
797 __u8 b;
798};
799
800/**
801 * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
802 *
803 * @dpcc_config: Defect Pixel Cluster Correction config
804 * @bls_config: Black Level Subtraction config
805 * @sdg_config: sensor degamma config
806 * @lsc_config: Lens Shade config
807 * @awb_gain_config: Auto White balance gain config
808 * @flt_config: filter config
809 * @bdm_config: demosaic config
810 * @ctk_config: cross talk config
811 * @goc_config: gamma out config
812 * @bls_config: black level subtraction config
813 * @dpf_config: De-noising pre-filter config
814 * @dpf_strength_config: dpf strength config
815 * @cproc_config: color process config
816 * @ie_config: image effects config
817 */
818struct rkisp1_cif_isp_isp_other_cfg {
819 struct rkisp1_cif_isp_dpcc_config dpcc_config;
820 struct rkisp1_cif_isp_bls_config bls_config;
821 struct rkisp1_cif_isp_sdg_config sdg_config;
822 struct rkisp1_cif_isp_lsc_config lsc_config;
823 struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
824 struct rkisp1_cif_isp_flt_config flt_config;
825 struct rkisp1_cif_isp_bdm_config bdm_config;
826 struct rkisp1_cif_isp_ctk_config ctk_config;
827 struct rkisp1_cif_isp_goc_config goc_config;
828 struct rkisp1_cif_isp_dpf_config dpf_config;
829 struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
830 struct rkisp1_cif_isp_cproc_config cproc_config;
831 struct rkisp1_cif_isp_ie_config ie_config;
832};
833
834/**
835 * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
836 *
837 * @awb_meas_config: auto white balance config
838 * @hst_config: histogram config
839 * @aec_config: auto exposure config
840 * @afc_config: auto focus config
841 */
842struct rkisp1_cif_isp_isp_meas_cfg {
843 struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
844 struct rkisp1_cif_isp_hst_config hst_config;
845 struct rkisp1_cif_isp_aec_config aec_config;
846 struct rkisp1_cif_isp_afc_config afc_config;
847};
848
849/**
850 * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
851 *
852 * @module_en_update: mask the enable bits of which module should be updated
853 * @module_ens: mask the enable value of each module, only update the module
854 * which correspond bit was set in module_en_update
855 * @module_cfg_update: mask the config bits of which module should be updated
856 * @meas: measurement config
857 * @others: other config
858 */
859struct rkisp1_params_cfg {
860 __u32 module_en_update;
861 __u32 module_ens;
862 __u32 module_cfg_update;
863
864 struct rkisp1_cif_isp_isp_meas_cfg meas;
865 struct rkisp1_cif_isp_isp_other_cfg others;
866};
867
868/**
869 * struct rkisp1_cif_isp_compand_bls_config - Rockchip ISP1 Companding parameters (BLS)
870 * @r: Fixed subtraction value for Bayer pattern R
871 * @gr: Fixed subtraction value for Bayer pattern Gr
872 * @gb: Fixed subtraction value for Bayer pattern Gb
873 * @b: Fixed subtraction value for Bayer pattern B
874 *
875 * The values will be subtracted from the sensor values. Note that unlike the
876 * dedicated BLS block, the BLS values in the compander are 20-bit unsigned.
877 */
878struct rkisp1_cif_isp_compand_bls_config {
879 __u32 r;
880 __u32 gr;
881 __u32 gb;
882 __u32 b;
883};
884
885/**
886 * struct rkisp1_cif_isp_compand_curve_config - Rockchip ISP1 Companding
887 * parameters (expand and compression curves)
888 * @px: Compand curve x-values. Each value stores the distance from the
889 * previous x-value, expressed as log2 of the distance on 5 bits.
890 * @x: Compand curve x-values. The functionality of these parameters are
891 * unknown due to do a lack of hardware documentation, but these are left
892 * here for future compatibility purposes.
893 * @y: Compand curve y-values
894 */
895struct rkisp1_cif_isp_compand_curve_config {
896 __u8 px[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
897 __u32 x[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
898 __u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
899};
900
901/**
902 * struct rkisp1_cif_isp_wdr_tone_curve - Tone mapping curve definition for WDR.
903 *
904 * @dY: the dYn increments for horizontal (input) axis of the tone curve.
905 * each 3-bit dY value represents an increment of 2**(value+3).
906 * dY[0] bits 0:2 is increment dY1, bit 3 unused
907 * dY[0] bits 4:6 is increment dY2, bit 7 unused
908 * ...
909 * dY[0] bits 28:30 is increment dY8, bit 31 unused
910 * ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused.
911 * @ym: the Ym values for the vertical (output) axis of the tone curve.
912 * each value is 13 bit.
913 */
914struct rkisp1_cif_isp_wdr_tone_curve {
915 __u32 dY[RKISP1_CIF_ISP_WDR_CURVE_NUM_DY_REGS];
916 __u16 ym[RKISP1_CIF_ISP_WDR_CURVE_NUM_COEFF];
917};
918
919/**
920 * struct rkisp1_cif_isp_wdr_iref_config - Illumination reference config for WDR.
921 *
922 * Use illumination reference value as described below, instead of only the
923 * luminance (Y) value for tone mapping and gain calculations:
924 * IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8
925 *
926 * @rgb_factor: defines how much influence the RGBmax approach has in
927 * comparison to Y (valid values are 0..8).
928 * @use_y9_8: use Y*9/8 for maximum value calculation along with the
929 * default of R, G, B for noise reduction.
930 * @use_rgb7_8: decrease RGBMax by 7/8 for noise reduction.
931 * @disable_transient: disable transient calculation between Y and RGBY_max.
932 */
933struct rkisp1_cif_isp_wdr_iref_config {
934 __u8 rgb_factor;
935 __u8 use_y9_8;
936 __u8 use_rgb7_8;
937 __u8 disable_transient;
938};
939
940/**
941 * struct rkisp1_cif_isp_wdr_config - Configuration for wide dynamic range.
942 *
943 * @tone_curve: tone mapping curve.
944 * @iref_config: illumination reference configuration. (when use_iref is true)
945 * @rgb_offset: RGB offset value for RGB operation mode. (12 bits)
946 * @luma_offset: luminance offset value for RGB operation mode. (12 bits)
947 * @dmin_thresh: lower threshold for deltaMin value. (12 bits)
948 * @dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10)
949 * @use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace.
950 * @bypass_chroma_mapping: disable chrominance mapping (only valid if
951 * use_rgb_colorspace = 0)
952 * @use_iref: use illumination reference instead of Y for tone mapping
953 * and gain calculations.
954 */
955struct rkisp1_cif_isp_wdr_config {
956 struct rkisp1_cif_isp_wdr_tone_curve tone_curve;
957 struct rkisp1_cif_isp_wdr_iref_config iref_config;
958 __u16 rgb_offset;
959 __u16 luma_offset;
960 __u16 dmin_thresh;
961 __u8 dmin_strength;
962 __u8 use_rgb_colorspace;
963 __u8 bypass_chroma_mapping;
964 __u8 use_iref;
965};
966
967/*
968 * enum rkisp1_cif_isp_cac_h_clip_mode - horizontal clipping mode
969 *
970 * @RKISP1_CIF_ISP_CAC_H_CLIP_MODE_4PX: +/- 4 pixels
971 * @RKISP1_CIF_ISP_CAC_H_CLIP_MODE_4_5PX: +/- 4/5 pixels depending on bayer position
972 */
973enum rkisp1_cif_isp_cac_h_clip_mode {
974 RKISP1_CIF_ISP_CAC_H_CLIP_MODE_4PX = 0,
975 RKISP1_CIF_ISP_CAC_H_CLIP_MODE_4_5PX = 1,
976};
977
978/**
979 * enum rkisp1_cif_isp_cac_v_clip_mode - vertical clipping mode
980 *
981 * @RKISP1_CIF_ISP_CAC_V_CLIP_MODE_2PX: +/- 2 pixels
982 * @RKISP1_CIF_ISP_CAC_V_CLIP_MODE_3PX: +/- 3 pixels
983 * @RKISP1_CIF_ISP_CAC_V_CLIP_MODE_3_4PX: +/- 3/4 pixels depending on bayer position
984 */
985enum rkisp1_cif_isp_cac_v_clip_mode {
986 RKISP1_CIF_ISP_CAC_V_CLIP_MODE_2PX = 0,
987 RKISP1_CIF_ISP_CAC_V_CLIP_MODE_3PX = 1,
988 RKISP1_CIF_ISP_CAC_V_CLIP_MODE_3_4PX = 2,
989};
990
991/**
992 * struct rkisp1_cif_isp_cac_config - chromatic aberration correction configuration
993 *
994 * The correction is carried out by shifting the red and blue pixels relative
995 * to the green ones, depending on the distance from the optical center:
996 *
997 * @h_count_start: horizontal coordinate of the optical center (13-bit unsigned integer; [1,8191])
998 * @v_count_start: vertical coordinate of the optical center (13-bit unsigned integer; [1,8191])
999 *
1000 * For each pixel, the x/y distances from the optical center are calculated and
1001 * then transformed into the [0,255] range based on the following formula:
1002 *
1003 * (((d << 4) >> ns) * nf) >> 5
1004 *
1005 * where `d` is the distance, `ns` and `nf` are the normalization parameters:
1006 *
1007 * @x_nf: horizontal normalization scale parameter (5-bit unsigned integer; [0,31])
1008 * @x_ns: horizontal normalization shift parameter (4-bit unsigned integer; [0,15])
1009 *
1010 * @y_nf: vertical normalization scale parameter (5-bit unsigned integer; [0,31])
1011 * @y_ns: vertical normalization shift parameter (4-bit unsigned integer; [0,15])
1012 *
1013 * These parameters should be chosen based on the image resolution, the position
1014 * of the optical center, and the shape of pixels, so that no normalized distance
1015 * is larger than 255. If the pixels have square shape, the two sets of parameters
1016 * should be equal.
1017 *
1018 * The actual amount of correction is calculated with a third degree polynomial:
1019 *
1020 * c[0] * r + c[1] * r^2 + c[2] * r^3
1021 *
1022 * where `c` is the set of coefficients for the given color, and `r` is distance:
1023 *
1024 * @red: red coefficients (5.4 two's complement; [-16,15.9375])
1025 * @blue: blue coefficients (5.4 two's complement; [-16,15.9375])
1026 *
1027 * Finally, the amount is clipped as requested:
1028 *
1029 * @h_clip_mode: maximum horizontal shift (from enum rkisp1_cif_isp_cac_h_clip_mode)
1030 * @v_clip_mode: maximum vertical shift (from enum rkisp1_cif_isp_cac_v_clip_mode)
1031 *
1032 * A positive result will shift away from the optical center, while a negative
1033 * one will shift towards the optical center. In the latter case, the pixel
1034 * values at the edges are duplicated.
1035 */
1036struct rkisp1_cif_isp_cac_config {
1037 __u8 h_clip_mode;
1038 __u8 v_clip_mode;
1039
1040 __u16 h_count_start;
1041 __u16 v_count_start;
1042
1043 __u16 red[3];
1044 __u16 blue[3];
1045
1046 __u8 x_nf;
1047 __u8 x_ns;
1048
1049 __u8 y_nf;
1050 __u8 y_ns;
1051};
1052
1053/*---------- PART2: Measurement Statistics ------------*/
1054
1055/**
1056 * struct rkisp1_cif_isp_awb_meas - AWB measured values
1057 *
1058 * @cnt: White pixel count, number of "white pixels" found during last
1059 * measurement
1060 * @mean_y_or_g: Mean value of Y within window and frames,
1061 * Green if RGB is selected.
1062 * @mean_cb_or_b: Mean value of Cb within window and frames,
1063 * Blue if RGB is selected.
1064 * @mean_cr_or_r: Mean value of Cr within window and frames,
1065 * Red if RGB is selected.
1066 */
1067struct rkisp1_cif_isp_awb_meas {
1068 __u32 cnt;
1069 __u8 mean_y_or_g;
1070 __u8 mean_cb_or_b;
1071 __u8 mean_cr_or_r;
1072};
1073
1074/**
1075 * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
1076 *
1077 * @awb_mean: Mean measured data
1078 */
1079struct rkisp1_cif_isp_awb_stat {
1080 struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
1081};
1082
1083/**
1084 * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
1085 *
1086 * @meas_r: Mean measured value for Bayer pattern R
1087 * @meas_gr: Mean measured value for Bayer pattern Gr
1088 * @meas_gb: Mean measured value for Bayer pattern Gb
1089 * @meas_b: Mean measured value for Bayer pattern B
1090 */
1091struct rkisp1_cif_isp_bls_meas_val {
1092 __u16 meas_r;
1093 __u16 meas_gr;
1094 __u16 meas_gb;
1095 __u16 meas_b;
1096};
1097
1098/**
1099 * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
1100 *
1101 * @exp_mean: Mean luminance value of block xx
1102 * @bls_val: BLS measured values
1103 *
1104 * The number of entries of @exp_mean depends on the hardware revision
1105 * as is reported by the hw_revision field of the struct media_device_info
1106 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
1107 *
1108 * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
1109 * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
1110 * to the maximum of the two.
1111 *
1112 * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
1113 */
1114struct rkisp1_cif_isp_ae_stat {
1115 __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
1116 struct rkisp1_cif_isp_bls_meas_val bls_val;
1117};
1118
1119/**
1120 * struct rkisp1_cif_isp_af_meas_val - AF measured values
1121 *
1122 * @sum: sharpness value
1123 * @lum: luminance value
1124 */
1125struct rkisp1_cif_isp_af_meas_val {
1126 __u32 sum;
1127 __u32 lum;
1128};
1129
1130/**
1131 * struct rkisp1_cif_isp_af_stat - statistics auto focus data
1132 *
1133 * @window: AF measured value of window x
1134 *
1135 * The module measures the sharpness in 3 windows of selectable size via
1136 * register settings(ISP_AFM_*_A/B/C)
1137 */
1138struct rkisp1_cif_isp_af_stat {
1139 struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
1140};
1141
1142/**
1143 * struct rkisp1_cif_isp_hist_stat - statistics histogram data
1144 *
1145 * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point
1146 * type. Bits 0-4 are the fractional part and bits 5-19 are the
1147 * integer part.
1148 *
1149 * The window of the measurements area is divided to 5x5 sub-windows for
1150 * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
1151 * sub-window independently and the final result is a weighted average of the
1152 * histogram measurements on all sub-windows. The window of the measurements
1153 * area and the weight of each sub-window are configurable using
1154 * struct @rkisp1_cif_isp_hst_config.
1155 *
1156 * The histogram contains 16 bins in V10 and 32 bins in V12.
1157 *
1158 * The number of entries of @hist_bins depends on the hardware revision
1159 * as is reported by the hw_revision field of the struct media_device_info
1160 * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
1161 *
1162 * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
1163 * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
1164 * equal to the maximum of the two.
1165 */
1166struct rkisp1_cif_isp_hist_stat {
1167 __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
1168};
1169
1170/**
1171 * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data
1172 *
1173 * @awb: statistics data for automatic white balance
1174 * @ae: statistics data for auto exposure
1175 * @af: statistics data for auto focus
1176 * @hist: statistics histogram data
1177 */
1178struct rkisp1_cif_isp_stat {
1179 struct rkisp1_cif_isp_awb_stat awb;
1180 struct rkisp1_cif_isp_ae_stat ae;
1181 struct rkisp1_cif_isp_af_stat af;
1182 struct rkisp1_cif_isp_hist_stat hist;
1183};
1184
1185/**
1186 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
1187 *
1188 * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)
1189 * @frame_id: frame ID for sync
1190 * @params: statistics data
1191 */
1192struct rkisp1_stat_buffer {
1193 __u32 meas_type;
1194 __u32 frame_id;
1195 struct rkisp1_cif_isp_stat params;
1196};
1197
1198/*---------- PART3: Extensible Configuration Parameters ------------*/
1199
1200/**
1201 * enum rkisp1_ext_params_block_type - RkISP1 extensible params block type
1202 *
1203 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS: Black level subtraction
1204 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC: Defect pixel cluster correction
1205 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG: Sensor de-gamma
1206 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN: Auto white balance gains
1207 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT: ISP filtering
1208 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM: Bayer de-mosaic
1209 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK: Cross-talk correction
1210 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC: Gamma out correction
1211 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF: De-noise pre-filter
1212 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH: De-noise pre-filter strength
1213 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC: Color processing
1214 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_IE: Image effects
1215 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC: Lens shading correction
1216 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS: Auto white balance statistics
1217 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS: Histogram statistics
1218 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS: Auto exposure statistics
1219 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS: Auto-focus statistics
1220 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block
1221 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve
1222 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve
1223 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range
1224 * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CAC: Chromatic aberration correction
1225 */
1226enum rkisp1_ext_params_block_type {
1227 RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS,
1228 RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC,
1229 RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG,
1230 RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN,
1231 RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT,
1232 RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM,
1233 RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK,
1234 RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC,
1235 RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF,
1236 RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH,
1237 RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC,
1238 RKISP1_EXT_PARAMS_BLOCK_TYPE_IE,
1239 RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC,
1240 RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS,
1241 RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS,
1242 RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS,
1243 RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS,
1244 RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS,
1245 RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND,
1246 RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS,
1247 RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR,
1248 RKISP1_EXT_PARAMS_BLOCK_TYPE_CAC,
1249};
1250
1251/* For backward compatibility */
1252#define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE V4L2_ISP_PARAMS_FL_BLOCK_DISABLE
1253#define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE V4L2_ISP_PARAMS_FL_BLOCK_ENABLE
1254
1255/* A bitmask of parameters blocks supported on the current hardware. */
1256#define RKISP1_CID_SUPPORTED_PARAMS_BLOCKS (V4L2_CID_USER_RKISP1_BASE + 0x01)
1257
1258/**
1259 * rkisp1_ext_params_block_header - RkISP1 extensible parameters block header
1260 *
1261 * This structure represents the common part of all the ISP configuration
1262 * blocks and is identical to :c:type:`v4l2_isp_params_block_header`.
1263 *
1264 * The type field is one of the values enumerated by
1265 * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be
1266 * interpreted by the driver.
1267 *
1268 * The flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
1269 */
1270#define rkisp1_ext_params_block_header v4l2_isp_params_block_header
1271
1272/**
1273 * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config
1274 *
1275 * RkISP1 extensible parameters Black Level Subtraction configuration block.
1276 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS`.
1277 *
1278 * @header: The RkISP1 extensible parameters header, see
1279 * :c:type:`rkisp1_ext_params_block_header`
1280 * @config: Black Level Subtraction configuration, see
1281 * :c:type:`rkisp1_cif_isp_bls_config`
1282 */
1283struct rkisp1_ext_params_bls_config {
1284 struct rkisp1_ext_params_block_header header;
1285 struct rkisp1_cif_isp_bls_config config;
1286} __attribute__((aligned(8)));
1287
1288/**
1289 * struct rkisp1_ext_params_dpcc_config - RkISP1 extensible params DPCC config
1290 *
1291 * RkISP1 extensible parameters Defective Pixel Cluster Correction configuration
1292 * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC`.
1293 *
1294 * @header: The RkISP1 extensible parameters header, see
1295 * :c:type:`rkisp1_ext_params_block_header`
1296 * @config: Defective Pixel Cluster Correction configuration, see
1297 * :c:type:`rkisp1_cif_isp_dpcc_config`
1298 */
1299struct rkisp1_ext_params_dpcc_config {
1300 struct rkisp1_ext_params_block_header header;
1301 struct rkisp1_cif_isp_dpcc_config config;
1302} __attribute__((aligned(8)));
1303
1304/**
1305 * struct rkisp1_ext_params_sdg_config - RkISP1 extensible params SDG config
1306 *
1307 * RkISP1 extensible parameters Sensor Degamma configuration block. Identified
1308 * by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG`.
1309 *
1310 * @header: The RkISP1 extensible parameters header, see
1311 * :c:type:`rkisp1_ext_params_block_header`
1312 * @config: Sensor Degamma configuration, see
1313 * :c:type:`rkisp1_cif_isp_sdg_config`
1314 */
1315struct rkisp1_ext_params_sdg_config {
1316 struct rkisp1_ext_params_block_header header;
1317 struct rkisp1_cif_isp_sdg_config config;
1318} __attribute__((aligned(8)));
1319
1320/**
1321 * struct rkisp1_ext_params_lsc_config - RkISP1 extensible params LSC config
1322 *
1323 * RkISP1 extensible parameters Lens Shading Correction configuration block.
1324 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC`.
1325 *
1326 * @header: The RkISP1 extensible parameters header, see
1327 * :c:type:`rkisp1_ext_params_block_header`
1328 * @config: Lens Shading Correction configuration, see
1329 * :c:type:`rkisp1_cif_isp_lsc_config`
1330 */
1331struct rkisp1_ext_params_lsc_config {
1332 struct rkisp1_ext_params_block_header header;
1333 struct rkisp1_cif_isp_lsc_config config;
1334} __attribute__((aligned(8)));
1335
1336/**
1337 * struct rkisp1_ext_params_awb_gain_config - RkISP1 extensible params AWB
1338 * gain config
1339 *
1340 * RkISP1 extensible parameters Auto-White Balance Gains configuration block.
1341 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN`.
1342 *
1343 * @header: The RkISP1 extensible parameters header, see
1344 * :c:type:`rkisp1_ext_params_block_header`
1345 * @config: Auto-White Balance Gains configuration, see
1346 * :c:type:`rkisp1_cif_isp_awb_gain_config`
1347 */
1348struct rkisp1_ext_params_awb_gain_config {
1349 struct rkisp1_ext_params_block_header header;
1350 struct rkisp1_cif_isp_awb_gain_config config;
1351} __attribute__((aligned(8)));
1352
1353/**
1354 * struct rkisp1_ext_params_flt_config - RkISP1 extensible params FLT config
1355 *
1356 * RkISP1 extensible parameters Filter configuration block. Identified by
1357 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT`.
1358 *
1359 * @header: The RkISP1 extensible parameters header, see
1360 * :c:type:`rkisp1_ext_params_block_header`
1361 * @config: Filter configuration, see :c:type:`rkisp1_cif_isp_flt_config`
1362 */
1363struct rkisp1_ext_params_flt_config {
1364 struct rkisp1_ext_params_block_header header;
1365 struct rkisp1_cif_isp_flt_config config;
1366} __attribute__((aligned(8)));
1367
1368/**
1369 * struct rkisp1_ext_params_bdm_config - RkISP1 extensible params BDM config
1370 *
1371 * RkISP1 extensible parameters Demosaicing configuration block. Identified by
1372 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM`.
1373 *
1374 * @header: The RkISP1 extensible parameters header, see
1375 * :c:type:`rkisp1_ext_params_block_header`
1376 * @config: Demosaicing configuration, see :c:type:`rkisp1_cif_isp_bdm_config`
1377 */
1378struct rkisp1_ext_params_bdm_config {
1379 struct rkisp1_ext_params_block_header header;
1380 struct rkisp1_cif_isp_bdm_config config;
1381} __attribute__((aligned(8)));
1382
1383/**
1384 * struct rkisp1_ext_params_ctk_config - RkISP1 extensible params CTK config
1385 *
1386 * RkISP1 extensible parameters Cross-Talk configuration block. Identified by
1387 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK`.
1388 *
1389 * @header: The RkISP1 extensible parameters header, see
1390 * :c:type:`rkisp1_ext_params_block_header`
1391 * @config: Cross-Talk configuration, see :c:type:`rkisp1_cif_isp_ctk_config`
1392 */
1393struct rkisp1_ext_params_ctk_config {
1394 struct rkisp1_ext_params_block_header header;
1395 struct rkisp1_cif_isp_ctk_config config;
1396} __attribute__((aligned(8)));
1397
1398/**
1399 * struct rkisp1_ext_params_goc_config - RkISP1 extensible params GOC config
1400 *
1401 * RkISP1 extensible parameters Gamma-Out configuration block. Identified by
1402 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC`.
1403 *
1404 * @header: The RkISP1 extensible parameters header, see
1405 * :c:type:`rkisp1_ext_params_block_header`
1406 * @config: Gamma-Out configuration, see :c:type:`rkisp1_cif_isp_goc_config`
1407 */
1408struct rkisp1_ext_params_goc_config {
1409 struct rkisp1_ext_params_block_header header;
1410 struct rkisp1_cif_isp_goc_config config;
1411} __attribute__((aligned(8)));
1412
1413/**
1414 * struct rkisp1_ext_params_dpf_config - RkISP1 extensible params DPF config
1415 *
1416 * RkISP1 extensible parameters De-noise Pre-Filter configuration block.
1417 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF`.
1418 *
1419 * @header: The RkISP1 extensible parameters header, see
1420 * :c:type:`rkisp1_ext_params_block_header`
1421 * @config: De-noise Pre-Filter configuration, see
1422 * :c:type:`rkisp1_cif_isp_dpf_config`
1423 */
1424struct rkisp1_ext_params_dpf_config {
1425 struct rkisp1_ext_params_block_header header;
1426 struct rkisp1_cif_isp_dpf_config config;
1427} __attribute__((aligned(8)));
1428
1429/**
1430 * struct rkisp1_ext_params_dpf_strength_config - RkISP1 extensible params DPF
1431 * strength config
1432 *
1433 * RkISP1 extensible parameters De-noise Pre-Filter strength configuration
1434 * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH`.
1435 *
1436 * @header: The RkISP1 extensible parameters header, see
1437 * :c:type:`rkisp1_ext_params_block_header`
1438 * @config: De-noise Pre-Filter strength configuration, see
1439 * :c:type:`rkisp1_cif_isp_dpf_strength_config`
1440 */
1441struct rkisp1_ext_params_dpf_strength_config {
1442 struct rkisp1_ext_params_block_header header;
1443 struct rkisp1_cif_isp_dpf_strength_config config;
1444} __attribute__((aligned(8)));
1445
1446/**
1447 * struct rkisp1_ext_params_cproc_config - RkISP1 extensible params CPROC config
1448 *
1449 * RkISP1 extensible parameters Color Processing configuration block.
1450 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC`.
1451 *
1452 * @header: The RkISP1 extensible parameters header, see
1453 * :c:type:`rkisp1_ext_params_block_header`
1454 * @config: Color processing configuration, see
1455 * :c:type:`rkisp1_cif_isp_cproc_config`
1456 */
1457struct rkisp1_ext_params_cproc_config {
1458 struct rkisp1_ext_params_block_header header;
1459 struct rkisp1_cif_isp_cproc_config config;
1460} __attribute__((aligned(8)));
1461
1462/**
1463 * struct rkisp1_ext_params_ie_config - RkISP1 extensible params IE config
1464 *
1465 * RkISP1 extensible parameters Image Effect configuration block. Identified by
1466 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_IE`.
1467 *
1468 * @header: The RkISP1 extensible parameters header, see
1469 * :c:type:`rkisp1_ext_params_block_header`
1470 * @config: Image Effect configuration, see :c:type:`rkisp1_cif_isp_ie_config`
1471 */
1472struct rkisp1_ext_params_ie_config {
1473 struct rkisp1_ext_params_block_header header;
1474 struct rkisp1_cif_isp_ie_config config;
1475} __attribute__((aligned(8)));
1476
1477/**
1478 * struct rkisp1_ext_params_awb_meas_config - RkISP1 extensible params AWB
1479 * Meas config
1480 *
1481 * RkISP1 extensible parameters Auto-White Balance Measurement configuration
1482 * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS`.
1483 *
1484 * @header: The RkISP1 extensible parameters header, see
1485 * :c:type:`rkisp1_ext_params_block_header`
1486 * @config: Auto-White Balance measure configuration, see
1487 * :c:type:`rkisp1_cif_isp_awb_meas_config`
1488 */
1489struct rkisp1_ext_params_awb_meas_config {
1490 struct rkisp1_ext_params_block_header header;
1491 struct rkisp1_cif_isp_awb_meas_config config;
1492} __attribute__((aligned(8)));
1493
1494/**
1495 * struct rkisp1_ext_params_hst_config - RkISP1 extensible params Histogram config
1496 *
1497 * RkISP1 extensible parameters Histogram statistics configuration block.
1498 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS`.
1499 *
1500 * @header: The RkISP1 extensible parameters header, see
1501 * :c:type:`rkisp1_ext_params_block_header`
1502 * @config: Histogram statistics configuration, see
1503 * :c:type:`rkisp1_cif_isp_hst_config`
1504 */
1505struct rkisp1_ext_params_hst_config {
1506 struct rkisp1_ext_params_block_header header;
1507 struct rkisp1_cif_isp_hst_config config;
1508} __attribute__((aligned(8)));
1509
1510/**
1511 * struct rkisp1_ext_params_aec_config - RkISP1 extensible params AEC config
1512 *
1513 * RkISP1 extensible parameters Auto-Exposure statistics configuration block.
1514 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS`.
1515 *
1516 * @header: The RkISP1 extensible parameters header, see
1517 * :c:type:`rkisp1_ext_params_block_header`
1518 * @config: Auto-Exposure statistics configuration, see
1519 * :c:type:`rkisp1_cif_isp_aec_config`
1520 */
1521struct rkisp1_ext_params_aec_config {
1522 struct rkisp1_ext_params_block_header header;
1523 struct rkisp1_cif_isp_aec_config config;
1524} __attribute__((aligned(8)));
1525
1526/**
1527 * struct rkisp1_ext_params_afc_config - RkISP1 extensible params AFC config
1528 *
1529 * RkISP1 extensible parameters Auto-Focus statistics configuration block.
1530 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS`.
1531 *
1532 * @header: The RkISP1 extensible parameters header, see
1533 * :c:type:`rkisp1_ext_params_block_header`
1534 * @config: Auto-Focus statistics configuration, see
1535 * :c:type:`rkisp1_cif_isp_afc_config`
1536 */
1537struct rkisp1_ext_params_afc_config {
1538 struct rkisp1_ext_params_block_header header;
1539 struct rkisp1_cif_isp_afc_config config;
1540} __attribute__((aligned(8)));
1541
1542/**
1543 * struct rkisp1_ext_params_compand_bls_config - RkISP1 extensible params
1544 * Compand BLS config
1545 *
1546 * RkISP1 extensible parameters Companding configuration block (black level
1547 * subtraction). Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS`.
1548 *
1549 * @header: The RkISP1 extensible parameters header, see
1550 * :c:type:`rkisp1_ext_params_block_header`
1551 * @config: Companding BLS configuration, see
1552 * :c:type:`rkisp1_cif_isp_compand_bls_config`
1553 */
1554struct rkisp1_ext_params_compand_bls_config {
1555 struct rkisp1_ext_params_block_header header;
1556 struct rkisp1_cif_isp_compand_bls_config config;
1557} __attribute__((aligned(8)));
1558
1559/**
1560 * struct rkisp1_ext_params_compand_curve_config - RkISP1 extensible params
1561 * Compand curve config
1562 *
1563 * RkISP1 extensible parameters Companding configuration block (expand and
1564 * compression curves). Identified by
1565 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND` or
1566 * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS`.
1567 *
1568 * @header: The RkISP1 extensible parameters header, see
1569 * :c:type:`rkisp1_ext_params_block_header`
1570 * @config: Companding curve configuration, see
1571 * :c:type:`rkisp1_cif_isp_compand_curve_config`
1572 */
1573struct rkisp1_ext_params_compand_curve_config {
1574 struct rkisp1_ext_params_block_header header;
1575 struct rkisp1_cif_isp_compand_curve_config config;
1576} __attribute__((aligned(8)));
1577
1578/**
1579 * struct rkisp1_ext_params_wdr_config - RkISP1 extensible params
1580 * Wide dynamic range config
1581 *
1582 * RkISP1 extensible parameters WDR block.
1583 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR`
1584 *
1585 * @header: The RkISP1 extensible parameters header, see
1586 * :c:type:`rkisp1_ext_params_block_header`
1587 * @config: WDR configuration, see
1588 * :c:type:`rkisp1_cif_isp_wdr_config`
1589 */
1590struct rkisp1_ext_params_wdr_config {
1591 struct rkisp1_ext_params_block_header header;
1592 struct rkisp1_cif_isp_wdr_config config;
1593} __attribute__((aligned(8)));
1594
1595/**
1596 * struct rkisp1_ext_params_cac_config - RkISP1 extensible params CAC config
1597 *
1598 * RkISP1 extensible parameters CAC block.
1599 * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CAC`.
1600 *
1601 * @header: The RkISP1 extensible parameters header, see
1602 * :c:type:`rkisp1_ext_params_block_header`
1603 * @config: CAC configuration, see
1604 * :c:type:`rkisp1_cif_isp_cac_config`
1605 */
1606struct rkisp1_ext_params_cac_config {
1607 struct rkisp1_ext_params_block_header header;
1608 struct rkisp1_cif_isp_cac_config config;
1609} __attribute__((aligned(8)));
1610
1611/*
1612 * The rkisp1_ext_params_compand_curve_config structure is counted twice as it
1613 * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types.
1614 */
1615#define RKISP1_EXT_PARAMS_MAX_SIZE \
1616 (sizeof(struct rkisp1_ext_params_bls_config) +\
1617 sizeof(struct rkisp1_ext_params_dpcc_config) +\
1618 sizeof(struct rkisp1_ext_params_sdg_config) +\
1619 sizeof(struct rkisp1_ext_params_lsc_config) +\
1620 sizeof(struct rkisp1_ext_params_awb_gain_config) +\
1621 sizeof(struct rkisp1_ext_params_flt_config) +\
1622 sizeof(struct rkisp1_ext_params_bdm_config) +\
1623 sizeof(struct rkisp1_ext_params_ctk_config) +\
1624 sizeof(struct rkisp1_ext_params_goc_config) +\
1625 sizeof(struct rkisp1_ext_params_dpf_config) +\
1626 sizeof(struct rkisp1_ext_params_dpf_strength_config) +\
1627 sizeof(struct rkisp1_ext_params_cproc_config) +\
1628 sizeof(struct rkisp1_ext_params_ie_config) +\
1629 sizeof(struct rkisp1_ext_params_awb_meas_config) +\
1630 sizeof(struct rkisp1_ext_params_hst_config) +\
1631 sizeof(struct rkisp1_ext_params_aec_config) +\
1632 sizeof(struct rkisp1_ext_params_afc_config) +\
1633 sizeof(struct rkisp1_ext_params_compand_bls_config) +\
1634 sizeof(struct rkisp1_ext_params_compand_curve_config) +\
1635 sizeof(struct rkisp1_ext_params_compand_curve_config) +\
1636 sizeof(struct rkisp1_ext_params_wdr_config) +\
1637 sizeof(struct rkisp1_ext_params_cac_config))
1638
1639/**
1640 * enum rkisp1_ext_param_buffer_version - RkISP1 extensible parameters version
1641 *
1642 * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters
1643 */
1644enum rkisp1_ext_param_buffer_version {
1645 RKISP1_EXT_PARAM_BUFFER_V1 = V4L2_ISP_PARAMS_VERSION_V1,
1646};
1647
1648/**
1649 * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration
1650 *
1651 * This is the driver-specific implementation of
1652 * :c:type:`v4l2_isp_params_buffer`.
1653 *
1654 * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported.
1655 * When a new format version will be added, a mechanism for userspace to query
1656 * the supported format versions will be implemented in the form of a read-only
1657 * V4L2 control. If such control is not available, userspace should assume only
1658 * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
1659 *
1660 * The read-only V4L2 control ``RKISP1_CID_SUPPORTED_PARAMS_BLOCKS`` can be used
1661 * to query the blocks supported by the device. It contains a bitmask where each
1662 * bit represents the availability of the corresponding entry from the
1663 * :c:type:`rkisp1_ext_params_block_type` enum. The current and default values
1664 * of the control represents the blocks supported by the device instance, while
1665 * the maximum value represents the blocks supported by the kernel driver,
1666 * independently of the device instance.
1667 *
1668 * The expected memory layout of the parameters buffer is::
1669 *
1670 * +-------------------- struct rkisp1_ext_params_cfg -------------------+
1671 * | version = RKISP1_EXT_PARAM_BUFFER_V1; |
1672 * | data_size = sizeof(struct rkisp1_ext_params_bls_config) |
1673 * | + sizeof(struct rkisp1_ext_params_dpcc_config); |
1674 * | +------------------------- data ---------------------------------+ |
1675 * | | +------------- struct rkisp1_ext_params_bls_config -----------+ | |
1676 * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
1677 * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS; | | | |
1678 * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
1679 * | | | | size = sizeof(struct rkisp1_ext_params_bls_config); | | | |
1680 * | | | +---------------------------------------------------------+ | | |
1681 * | | | +---------- struct rkisp1_cif_isp_bls_config -------------+ | | |
1682 * | | | | enable_auto = 0; | | | |
1683 * | | | | fixed_val.r = 256; | | | |
1684 * | | | | fixed_val.gr = 256; | | | |
1685 * | | | | fixed_val.gb = 256; | | | |
1686 * | | | | fixed_val.b = 256; | | | |
1687 * | | | +---------------------------------------------------------+ | | |
1688 * | | +------------ struct rkisp1_ext_params_dpcc_config -----------+ | |
1689 * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
1690 * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC; | | | |
1691 * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
1692 * | | | | size = sizeof(struct rkisp1_ext_params_dpcc_config); | | | |
1693 * | | | +---------------------------------------------------------+ | | |
1694 * | | | +---------- struct rkisp1_cif_isp_dpcc_config ------------+ | | |
1695 * | | | | mode = RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE; | | | |
1696 * | | | | output_mode = | | | |
1697 * | | | | RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER; | | | |
1698 * | | | | set_use = ... ; | | | |
1699 * | | | | ... = ... ; | | | |
1700 * | | | +---------------------------------------------------------+ | | |
1701 * | | +-------------------------------------------------------------+ | |
1702 * | +-----------------------------------------------------------------+ |
1703 * +---------------------------------------------------------------------+
1704 *
1705 * @version: The RkISP1 extensible parameters buffer version, see
1706 * :c:type:`rkisp1_ext_param_buffer_version`
1707 * @data_size: The RkISP1 configuration data effective size, excluding this
1708 * header
1709 * @data: The RkISP1 extensible configuration data blocks
1710 */
1711struct rkisp1_ext_params_cfg {
1712 __u32 version;
1713 __u32 data_size;
1714 __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE];
1715};
1716
1717
1718#endif /* _RKISP1_CONFIG_H */