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