• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */
2 /*
3  * Rockchip isp1 driver
4  * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
5  */
6 
7 #ifndef _UAPI_RKISP1_CONFIG_H
8 #define _UAPI_RKISP1_CONFIG_H
9 
10 #include <linux/types.h>
11 #include <linux/v4l2-controls.h>
12 #include "rkisp21-config.h"
13 
14 #define CIFISP_MODULE_DPCC (1 << 0)
15 #define CIFISP_MODULE_BLS (1 << 1)
16 #define CIFISP_MODULE_SDG (1 << 2)
17 #define CIFISP_MODULE_HST (1 << 3)
18 #define CIFISP_MODULE_LSC (1 << 4)
19 #define CIFISP_MODULE_AWB_GAIN (1 << 5)
20 #define CIFISP_MODULE_FLT (1 << 6)
21 #define CIFISP_MODULE_BDM (1 << 7)
22 #define CIFISP_MODULE_CTK (1 << 8)
23 #define CIFISP_MODULE_GOC (1 << 9)
24 #define CIFISP_MODULE_CPROC (1 << 10)
25 #define CIFISP_MODULE_AFC (1 << 11)
26 #define CIFISP_MODULE_AWB (1 << 12)
27 #define CIFISP_MODULE_IE (1 << 13)
28 #define CIFISP_MODULE_AEC (1 << 14)
29 #define CIFISP_MODULE_WDR (1 << 15)
30 #define CIFISP_MODULE_DPF (1 << 16)
31 #define CIFISP_MODULE_DPF_STRENGTH (1 << 17)
32 #define CIFISP_MODULE_DEMOSAICLP (1 << 18)
33 #define CIFISP_MODULE_RK_IESHARP (1 << 19)
34 
35 #define CIFISP_CTK_COEFF_MAX 0x100
36 #define CIFISP_CTK_OFFSET_MAX 0x800
37 
38 #define CIFISP_AE_MEAN_MAX 81
39 #define CIFISP_HIST_BIN_N_MAX 32
40 #define CIFISP_AFM_MAX_WINDOWS 3
41 #define CIFISP_DEGAMMA_CURVE_SIZE 17
42 
43 #define CIFISP_BDM_MAX_TH 0xFF
44 
45 /*
46  * Black level compensation
47  */
48 /* maximum value for horizontal start address */
49 #define CIFISP_BLS_START_H_MAX 0x00000FFF
50 /* maximum value for horizontal stop address */
51 #define CIFISP_BLS_STOP_H_MAX 0x00000FFF
52 /* maximum value for vertical start address */
53 #define CIFISP_BLS_START_V_MAX 0x00000FFF
54 /* maximum value for vertical stop address */
55 #define CIFISP_BLS_STOP_V_MAX 0x00000FFF
56 /* maximum is 2^18 = 262144 */
57 #define CIFISP_BLS_SAMPLES_MAX 0x00000012
58 /* maximum value for fixed black level */
59 #define CIFISP_BLS_FIX_SUB_MAX 0x00000FFF
60 /* minimum value for fixed black level */
61 #define CIFISP_BLS_FIX_SUB_MIN 0xFFFFF000
62 /* 13 bit range (signed) */
63 #define CIFISP_BLS_FIX_MASK 0x00001FFF
64 
65 /*
66  * Automatic white balance measurments
67  */
68 #define CIFISP_AWB_MAX_GRID 1
69 #define CIFISP_AWB_MAX_FRAMES 7
70 
71 /*
72  * Gamma out
73  */
74 /* Maximum number of color samples supported */
75 #define CIFISP_GAMMA_OUT_MAX_SAMPLES 34
76 
77 /*
78  * Lens shade correction
79  */
80 #define CIFISP_LSC_GRAD_TBL_SIZE 8
81 #define CIFISP_LSC_SIZE_TBL_SIZE 8
82 /*
83  * The following matches the tuning process,
84  * not the max capabilities of the chip.
85  * Last value unused.
86  */
87 #define CIFISP_LSC_DATA_TBL_SIZE 290
88 
89 /*
90  * Histogram calculation
91  */
92 /* Last 3 values unused. */
93 #define CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 81
94 
95 /*
96  * Defect Pixel Cluster Correction
97  */
98 #define CIFISP_DPCC_METHODS_MAX 3
99 
100 /*
101  * Denoising pre filter
102  */
103 #define CIFISP_DPF_MAX_NLF_COEFFS 17
104 #define CIFISP_DPF_MAX_SPATIAL_COEFFS 6
105 
106 /* WDR */
107 #define CIFISP_WDR_SIZE 48
108 
109 /*
110  * Measurement types
111  */
112 #define CIFISP_STAT_AWB (1 << 0)
113 #define CIFISP_STAT_AUTOEXP (1 << 1)
114 #define CIFISP_STAT_AFM_FIN (1 << 2)
115 #define CIFISP_STAT_HIST (1 << 3)
116 #define CIFISP_STAT_EMB_DATA (1 << 4)
117 
118 /* ADD DATA */
119 #define CIFISP_ADD_DATA_FIFO_SIZE (2048 * 4)
120 
121 /* Private v4l2 event */
122 #define CIFISP_V4L2_EVENT_STREAM_START (V4L2_EVENT_PRIVATE_START + 1)
123 #define CIFISP_V4L2_EVENT_STREAM_STOP (V4L2_EVENT_PRIVATE_START + 2)
124 
125 /*
126  * private control id
127  */
128 enum cifisp_ctrl_id { CIFISP_CID_EMB_VC = (V4L2_CTRL_CLASS_CAMERA | 0x1001), CIFISP_CID_EMB_DT, CIFISP_CID_LAST };
129 
130 enum cifisp_histogram_mode {
131     CIFISP_HISTOGRAM_MODE_DISABLE,
132     CIFISP_HISTOGRAM_MODE_RGB_COMBINED,
133     CIFISP_HISTOGRAM_MODE_R_HISTOGRAM,
134     CIFISP_HISTOGRAM_MODE_G_HISTOGRAM,
135     CIFISP_HISTOGRAM_MODE_B_HISTOGRAM,
136     CIFISP_HISTOGRAM_MODE_Y_HISTOGRAM
137 };
138 
139 enum cifisp_awb_mode_type { CIFISP_AWB_MODE_MANUAL, CIFISP_AWB_MODE_RGB, CIFISP_AWB_MODE_YCBCR };
140 
141 enum cifisp_flt_mode { CIFISP_FLT_STATIC_MODE, CIFISP_FLT_DYNAMIC_MODE };
142 
143 /**
144  * enum cifisp_exp_ctrl_auotostop - stop modes
145  * @CIFISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
146  * @CIFISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
147  */
148 enum cifisp_exp_ctrl_auotostop {
149     CIFISP_EXP_CTRL_AUTOSTOP_0 = 0,
150     CIFISP_EXP_CTRL_AUTOSTOP_1 = 1,
151 };
152 
153 /**
154  * enum cifisp_exp_meas_mode - Exposure measure mode
155  * @CIFISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
156  * @CIFISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
157  */
158 enum cifisp_exp_meas_mode {
159     CIFISP_EXP_MEASURING_MODE_0,
160     CIFISP_EXP_MEASURING_MODE_1,
161 };
162 
163 /*---------- PART1: Input Parameters ------------*/
164 
165 struct cifisp_window {
166     unsigned short h_offs;
167     unsigned short v_offs;
168     unsigned short h_size;
169     unsigned short v_size;
170 } __attribute__((packed));
171 
172 /**
173  * struct cifisp_bls_fixed_val - BLS fixed subtraction values
174  *
175  * The values will be subtracted from the sensor
176  * values. Therefore a negative value means addition instead of subtraction!
177  *
178  * @r: Fixed (signed!) subtraction value for Bayer pattern R
179  * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
180  * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
181  * @b: Fixed (signed!) subtraction value for Bayer pattern B
182  */
183 struct cifisp_bls_fixed_val {
184     signed short r;
185     signed short gr;
186     signed short gb;
187     signed short b;
188 } __attribute__((packed));
189 
190 /**
191  * struct cifisp_bls_config - Configuration used by black level subtraction
192  *
193  * @enable_auto: Automatic mode activated means that the measured values
194  * are subtracted.Otherwise the fixed subtraction
195  * values will be subtracted.
196  * @en_windows: enabled window
197  * @bls_window1: Measurement window 1 size
198  * @bls_window2: Measurement window 2 size
199  * @bls_samples: Set amount of measured pixels for each Bayer position
200  * (A, B,C and D) to 2^bls_samples.
201  * @cifisp_bls_fixed_val: Fixed subtraction values
202  */
203 struct cifisp_bls_config {
204     unsigned char enable_auto;
205     unsigned char en_windows;
206     struct cifisp_window bls_window1;
207     struct cifisp_window bls_window2;
208     unsigned char bls_samples;
209     struct cifisp_bls_fixed_val fixed_val;
210 } __attribute__((packed));
211 
212 /**
213  * struct cifisp_dpcc_methods_config - Methods Configuration used by Defect Pixel Cluster Correction
214  *
215  * @method:
216  * @line_thresh:
217  * @line_mad_fac:
218  * @pg_fac:
219  * @rnd_thresh:
220  * @rg_fac:
221  */
222 struct cifisp_dpcc_methods_config {
223     unsigned int method;
224     unsigned int line_thresh;
225     unsigned int line_mad_fac;
226     unsigned int pg_fac;
227     unsigned int rnd_thresh;
228     unsigned int rg_fac;
229 } __attribute__((packed));
230 
231 /**
232  * struct cifisp_dpcc_methods_config - Configuration used by Defect Pixel Cluster Correction
233  *
234  * @mode: dpcc output mode
235  * @output_mode: whether use hard coded methods
236  * @set_use: stage1 methods set
237  * @methods: methods config
238  * @ro_limits: rank order limits
239  * @rnd_offs: differential rank offsets for rank neighbor difference
240  */
241 struct cifisp_dpcc_config {
242     unsigned int mode;
243     unsigned int output_mode;
244     unsigned int set_use;
245     struct cifisp_dpcc_methods_config methods[CIFISP_DPCC_METHODS_MAX];
246     unsigned int ro_limits;
247     unsigned int rnd_offs;
248 } __attribute__((packed));
249 
250 struct cifisp_gamma_corr_curve {
251     unsigned short gamma_y[CIFISP_DEGAMMA_CURVE_SIZE];
252 } __attribute__((packed));
253 
254 struct cifisp_gamma_curve_x_axis_pnts {
255     unsigned int gamma_dx0;
256     unsigned int gamma_dx1;
257 } __attribute__((packed));
258 
259 /**
260  * struct cifisp_gamma_corr_curve - Configuration used by sensor degamma
261  *
262  * @curve_x: gamma curve point definition axis for x
263  * @xa_pnts: x increments
264  */
265 struct cifisp_sdg_config {
266     struct cifisp_gamma_corr_curve curve_r;
267     struct cifisp_gamma_corr_curve curve_g;
268     struct cifisp_gamma_corr_curve curve_b;
269     struct cifisp_gamma_curve_x_axis_pnts xa_pnts;
270 } __attribute__((packed));
271 
272 /**
273  * struct cifisp_lsc_config - Configuration used by Lens shading correction
274  *
275  * refer to datasheet for details
276  */
277 struct cifisp_lsc_config {
278     unsigned int r_data_tbl[CIFISP_LSC_DATA_TBL_SIZE];
279     unsigned int gr_data_tbl[CIFISP_LSC_DATA_TBL_SIZE];
280     unsigned int gb_data_tbl[CIFISP_LSC_DATA_TBL_SIZE];
281     unsigned int b_data_tbl[CIFISP_LSC_DATA_TBL_SIZE];
282 
283     unsigned int x_grad_tbl[CIFISP_LSC_GRAD_TBL_SIZE];
284     unsigned int y_grad_tbl[CIFISP_LSC_GRAD_TBL_SIZE];
285 
286     unsigned int x_size_tbl[CIFISP_LSC_SIZE_TBL_SIZE];
287     unsigned int y_size_tbl[CIFISP_LSC_SIZE_TBL_SIZE];
288     unsigned short config_width;
289     unsigned short config_height;
290 } __attribute__((packed));
291 
292 /**
293  * struct cifisp_ie_config - Configuration used by image effects
294  *
295  * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
296  * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
297  * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
298  * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
299  * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
300  * @eff_tint: Chrominance increment values of tint (used for sepia effect)
301  */
302 struct cifisp_ie_config {
303     unsigned short effect;
304     unsigned short color_sel;
305     unsigned short eff_mat_1;
306     unsigned short eff_mat_2;
307     unsigned short eff_mat_3;
308     unsigned short eff_mat_4;
309     unsigned short eff_mat_5;
310     unsigned short eff_tint;
311 } __attribute__((packed));
312 
313 /**
314  * struct cifisp_cproc_config - Configuration used by Color Processing
315  *
316  * @c_out_range: Chrominance pixel clipping range at output. (0 for limit, 1 for full)
317  * @y_in_range: Luminance pixel clipping range at output.
318  * @y_out_range: Luminance pixel clipping range at output.
319  * @contrast: 00~ff, 0.0~1.992
320  * @brightness: 80~7F, -128~+127
321  * @sat: saturation, 00~FF, 0.0~1.992
322  * @hue: 80~7F, -90~+87.188
323  */
324 struct cifisp_cproc_config {
325     unsigned char c_out_range;
326     unsigned char y_in_range;
327     unsigned char y_out_range;
328     unsigned char contrast;
329     unsigned char brightness;
330     unsigned char sat;
331     unsigned char hue;
332 } __attribute__((packed));
333 
334 /**
335  * struct cifisp_awb_meas_config - Configuration used by auto white balance
336  *
337  * @awb_wnd: white balance measurement window (in pixels)
338  * @max_y: only pixels values < max_y contribute to awb measurement, set to 0 to disable this feature
339  * @min_y: only pixels values > min_y contribute to awb measurement
340  * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr, smaller than threshold for awb
341  * measurements
342  * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr each greater than threshold value for awb
343  * measurements
344  * @frames: number of frames - 1 used for mean value calculation(ucFrames=0 means 1 Frame)
345  * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
346  * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
347  */
348 struct cifisp_awb_meas_config {
349     /*
350      * Note: currently the h and v offsets are mapped to grid offsets
351      */
352     struct cifisp_window awb_wnd;
353     enum cifisp_awb_mode_type awb_mode;
354     unsigned char max_y;
355     unsigned char min_y;
356     unsigned char max_csum;
357     unsigned char min_c;
358     unsigned char frames;
359     unsigned char awb_ref_cr;
360     unsigned char awb_ref_cb;
361     bool enable_ymax_cmp;
362 } __attribute__((packed));
363 
364 /**
365  * struct cifisp_awb_gain_config - Configuration used by auto white balance gain
366  *
367  * out_data_x = ( AWB_GEAIN_X * in_data + 128) >> 8
368  */
369 struct cifisp_awb_gain_config {
370     unsigned short gain_red;
371     unsigned short gain_green_r;
372     unsigned short gain_blue;
373     unsigned short gain_green_b;
374 } __attribute__((packed));
375 
376 /**
377  * struct cifisp_flt_config - Configuration used by ISP filtering
378  *
379  * @mode: ISP_FILT_MODE register fields
380  * @grn_stage1: ISP_FILT_MODE register fields
381  * @chr_h_mode: ISP_FILT_MODE register fields
382  * @chr_v_mode: ISP_FILT_MODE register fields
383  *
384  * refer to datasheet for details.
385  */
386 struct cifisp_flt_config {
387     enum cifisp_flt_mode mode;
388     unsigned char grn_stage1;
389     unsigned char chr_h_mode;
390     unsigned char chr_v_mode;
391     unsigned int thresh_bl0;
392     unsigned int thresh_bl1;
393     unsigned int thresh_sh0;
394     unsigned int thresh_sh1;
395     unsigned int lum_weight;
396     unsigned int fac_sh1;
397     unsigned int fac_sh0;
398     unsigned int fac_mid;
399     unsigned int fac_bl0;
400     unsigned int fac_bl1;
401 } __attribute__((packed));
402 
403 /**
404  * struct cifisp_bdm_config - Configuration used by Bayer DeMosaic
405  *
406  * @demosaic_th: threshod for bayer demosaicing texture detection
407  */
408 struct cifisp_bdm_config {
409     unsigned char demosaic_th;
410 } __attribute__((packed));
411 
412 /**
413  * struct cifisp_ctk_config - Configuration used by Cross Talk correction
414  *
415  * @coeff: color correction matrix
416  * @ct_offset_b: offset for the crosstalk correction matrix
417  */
418 struct cifisp_ctk_config {
419     unsigned short coeff0;
420     unsigned short coeff1;
421     unsigned short coeff2;
422     unsigned short coeff3;
423     unsigned short coeff4;
424     unsigned short coeff5;
425     unsigned short coeff6;
426     unsigned short coeff7;
427     unsigned short coeff8;
428     unsigned short ct_offset_r;
429     unsigned short ct_offset_g;
430     unsigned short ct_offset_b;
431 } __attribute__((packed));
432 
433 enum cifisp_goc_mode { CIFISP_GOC_MODE_LOGARITHMIC, CIFISP_GOC_MODE_EQUIDISTANT };
434 
435 /**
436  * struct cifisp_goc_config - Configuration used by Gamma Out correction
437  *
438  * @mode: goc mode
439  * @gamma_y: gamma out curve y-axis for all color components
440  */
441 struct cifisp_goc_config {
442     enum cifisp_goc_mode mode;
443     unsigned short gamma_y[CIFISP_GAMMA_OUT_MAX_SAMPLES];
444 } __attribute__((packed));
445 
446 /**
447  * struct cifisp_hst_config - Configuration used by Histogram
448  *
449  * @mode: histogram mode
450  * @histogram_predivider: process every stepsize pixel, all other pixels are skipped
451  * @meas_window: coordinates of the meas window
452  * @hist_weight: weighting factor for sub-windows
453  */
454 struct cifisp_hst_config {
455     enum cifisp_histogram_mode mode;
456     unsigned char histogram_predivider;
457     struct cifisp_window meas_window;
458     unsigned char hist_weight[CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
459 } __attribute__((packed));
460 
461 /**
462  * struct cifisp_aec_config - Configuration used by Auto Exposure Control
463  *
464  * @mode: Exposure measure mode
465  * @autostop: stop mode (from enum cifisp_exp_ctrl_auotostop)
466  * @meas_window: coordinates of the meas window
467  */
468 struct cifisp_aec_config {
469     enum cifisp_exp_meas_mode mode;
470     __u32 autostop;
471     struct cifisp_window meas_window;
472 } __attribute__((packed));
473 
474 /**
475  * struct cifisp_afc_config - Configuration used by Auto Focus Control
476  *
477  * @num_afm_win: max CIFISP_AFM_MAX_WINDOWS
478  * @afm_win: coordinates of the meas window
479  * @thres: threshold used for minimizing the influence of noise
480  * @var_shift: the number of bits for the shift operation at the end of the calculation chain.
481  */
482 struct cifisp_afc_config {
483     unsigned char num_afm_win;
484     struct cifisp_window afm_win[CIFISP_AFM_MAX_WINDOWS];
485     unsigned int thres;
486     unsigned int var_shift;
487 } __attribute__((packed));
488 
489 /**
490  * enum cifisp_dpf_gain_usage - dpf gain usage
491  * @CIFISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
492  * @CIFISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from registers DPF_NF_GAIN_R, ...
493  * @CIFISP_DPF_GAIN_USAGE_LSC_GAINS:  use only the gains from LSC module
494  * @CIFISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the gains from LSC module
495  * @CIFISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
496  * @CIFISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
497  * @CIFISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
498  */
499 enum cifisp_dpf_gain_usage {
500     CIFISP_DPF_GAIN_USAGE_DISABLED,
501     CIFISP_DPF_GAIN_USAGE_NF_GAINS,
502     CIFISP_DPF_GAIN_USAGE_LSC_GAINS,
503     CIFISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
504     CIFISP_DPF_GAIN_USAGE_AWB_GAINS,
505     CIFISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
506     CIFISP_DPF_GAIN_USAGE_MAX
507 };
508 
509 /**
510  * enum cifisp_dpf_gain_usage - dpf gain usage
511  * @CIFISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9 (means 7x5 active pixel)
512  * @CIFISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9 (means 5x5 active pixel)
513  */
514 enum cifisp_dpf_rb_filtersize {
515     CIFISP_DPF_RB_FILTERSIZE_13x9,
516     CIFISP_DPF_RB_FILTERSIZE_9x9,
517 };
518 
519 /**
520  * enum cifisp_dpf_nll_scale_mode - dpf noise level scale mode
521  * @CIFISP_NLL_SCALE_LINEAR: use a linear scaling
522  * @CIFISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
523  */
524 enum cifisp_dpf_nll_scale_mode {
525     CIFISP_NLL_SCALE_LINEAR,
526     CIFISP_NLL_SCALE_LOGARITHMIC,
527 };
528 
529 struct cifisp_dpf_nll {
530     unsigned short coeff[CIFISP_DPF_MAX_NLF_COEFFS];
531     enum cifisp_dpf_nll_scale_mode scale_mode;
532 } __attribute__((packed));
533 
534 struct cifisp_dpf_rb_flt {
535     enum cifisp_dpf_rb_filtersize fltsize;
536     unsigned char spatial_coeff[CIFISP_DPF_MAX_SPATIAL_COEFFS];
537     bool r_enable;
538     bool b_enable;
539 } __attribute__((packed));
540 
541 struct cifisp_dpf_g_flt {
542     unsigned char spatial_coeff[CIFISP_DPF_MAX_SPATIAL_COEFFS];
543     bool gr_enable;
544     bool gb_enable;
545 } __attribute__((packed));
546 
547 struct cifisp_dpf_gain {
548     enum cifisp_dpf_gain_usage mode;
549     unsigned short nf_r_gain;
550     unsigned short nf_b_gain;
551     unsigned short nf_gr_gain;
552     unsigned short nf_gb_gain;
553 } __attribute__((packed));
554 
555 /**
556  * struct cifisp_dpf_config - Configuration used by De-noising pre-filter
557  *
558  * @gain: noise function gain
559  * @g_flt: green filter config
560  * @rb_flt: red blue filter config
561  * @nll: noise level lookup
562  */
563 struct cifisp_dpf_config {
564     struct cifisp_dpf_gain gain;
565     struct cifisp_dpf_g_flt g_flt;
566     struct cifisp_dpf_rb_flt rb_flt;
567     struct cifisp_dpf_nll nll;
568 } __attribute__((packed));
569 
570 /**
571  * struct cifisp_dpf_strength_config - strength of the filter
572  *
573  * @r: filter strength of the RED filter
574  * @g: filter strength of the GREEN filter
575  * @b: filter strength of the BLUE filter
576  */
577 struct cifisp_dpf_strength_config {
578     unsigned char r;
579     unsigned char g;
580     unsigned char b;
581 } __attribute__((packed));
582 
583 /**
584  * enum cifisp_wdr_mode - wdr mode
585  * @CIFISP_WDR_MODE_BLOCK: use a linear scaling
586  * @CIFISP_WDR_MODE_GLOBAL: use a logarithmic scaling
587  */
588 enum cifisp_wdr_mode { CIFISP_WDR_MODE_BLOCK, CIFISP_WDR_MODE_GLOBAL };
589 
590 /**
591  * struct cifisp_wdr_config - Gamma Out correction
592  */
593 struct cifisp_wdr_config {
594     enum cifisp_wdr_mode mode;
595     unsigned int c_wdr[CIFISP_WDR_SIZE];
596 } __attribute__((packed));
597 
598 /**
599  * struct cifisp_demosaiclp_config - rk demosiac low pass
600  */
601 struct cifisp_demosaiclp_config {
602     unsigned char rb_filter_en;
603     unsigned char hp_filter_en;
604     unsigned char lu_divided[4];
605     unsigned char thgrad_divided[5];
606     unsigned char thdiff_divided[5];
607     unsigned char thcsc_divided[5];
608     unsigned short thvar_divided[5];
609     unsigned char th_grad;
610     unsigned char th_diff;
611     unsigned char th_csc;
612     unsigned short th_var;
613     unsigned char th_var_en;
614     unsigned char th_csc_en;
615     unsigned char th_diff_en;
616     unsigned char th_grad_en;
617     unsigned char use_old_lp;
618     unsigned char similarity_th;
619     unsigned char flat_level_sel;
620     unsigned char pattern_level_sel;
621     unsigned char edge_level_sel;
622     unsigned char thgrad_r_fct;
623     unsigned char thdiff_r_fct;
624     unsigned char thvar_r_fct;
625     unsigned char thgrad_b_fct;
626     unsigned char thdiff_b_fct;
627     unsigned char thvar_b_fct;
628 } __attribute__((packed));
629 
630 /**
631  * struct cifisp_rkiesharp_config - rk ie sharp
632  */
633 struct cifisp_rkiesharp_config {
634     unsigned char coring_thr;
635     unsigned char full_range;
636     unsigned char switch_avg;
637     unsigned char yavg_thr[4];
638     unsigned char delta1[5];
639     unsigned char delta2[5];
640     unsigned char maxnumber[5];
641     unsigned char minnumber[5];
642     unsigned char gauss_flat_coe[9];
643     unsigned char gauss_noise_coe[9];
644     unsigned char gauss_other_coe[9];
645     unsigned char line1_filter_coe[6];
646     unsigned char line2_filter_coe[9];
647     unsigned char line3_filter_coe[6];
648     unsigned short grad_seq[4];
649     unsigned char sharp_factor[5];
650     unsigned char uv_gauss_flat_coe[15];
651     unsigned char uv_gauss_noise_coe[15];
652     unsigned char uv_gauss_other_coe[15];
653     unsigned char lap_mat_coe[9];
654 } __attribute__((packed));
655 
656 /**
657  * struct cifisp_isp_other_cfg - Parameters for some blocks in rockchip isp1
658  *
659  * @dpcc_config: Defect Pixel Cluster Correction config
660  * @bls_config: Black Level Subtraction config
661  * @sdg_config: sensor degamma config
662  * @lsc_config: Lens Shade config
663  * @awb_gain_config: Auto White balance gain config
664  * @flt_config: filter config
665  * @bdm_config: demosaic config
666  * @ctk_config: cross talk config
667  * @goc_config: gamma out config
668  * @bls_config: black level suntraction config
669  * @dpf_config: De-noising pre-filter config
670  * @dpf_strength_config: dpf strength config
671  * @cproc_config: color process config
672  * @ie_config: image effects config
673  */
674 struct cifisp_isp_other_cfg {
675     struct cifisp_dpcc_config dpcc_config;
676     struct cifisp_bls_config bls_config;
677     struct cifisp_sdg_config sdg_config;
678     struct cifisp_lsc_config lsc_config;
679     struct cifisp_awb_gain_config awb_gain_config;
680     struct cifisp_flt_config flt_config;
681     struct cifisp_bdm_config bdm_config;
682     struct cifisp_ctk_config ctk_config;
683     struct cifisp_goc_config goc_config;
684     struct cifisp_dpf_config dpf_config;
685     struct cifisp_dpf_strength_config dpf_strength_config;
686     struct cifisp_cproc_config cproc_config;
687     struct cifisp_ie_config ie_config;
688     struct cifisp_wdr_config wdr_config;
689     struct cifisp_demosaiclp_config demosaiclp_config;
690     struct cifisp_rkiesharp_config rkiesharp_config;
691 } __attribute__((packed));
692 
693 /**
694  * struct cifisp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
695  *
696  * @awb_meas_config: auto white balance config
697  * @hst_config: histogram config
698  * @aec_config: auto exposure config
699  * @afc_config: auto focus config
700  */
701 struct cifisp_isp_meas_cfg {
702     struct cifisp_awb_meas_config awb_meas_config;
703     struct cifisp_hst_config hst_config;
704     struct cifisp_aec_config aec_config;
705     struct cifisp_afc_config afc_config;
706 } __attribute__((packed));
707 
708 /**
709  * struct rkisp1_isp_params_cfg - Rockchip ISP1 Input Parameters Meta Data
710  *
711  * @module_en_update: mask the enable bits of which module  should be updated
712  * @module_ens: mask the enable value of each module, only update the module
713  * which correspond bit was set in module_en_update
714  * @module_cfg_update: mask the config bits of which module  should be updated
715  * @meas: measurement config
716  * @others: other config
717  */
718 struct rkisp1_isp_params_cfg {
719     unsigned int module_en_update;
720     unsigned int module_ens;
721     unsigned int module_cfg_update;
722 
723     struct cifisp_isp_meas_cfg meas;
724     struct cifisp_isp_other_cfg others;
725 } __attribute__((packed));
726 
727 /*---------- PART2: Measurement Statistics ------------*/
728 
729 /**
730  * struct cifisp_bls_meas_val - AWB measured values
731  *
732  * @cnt: White pixel count, number of "white pixels" found during laster measurement
733  * @mean_y_or_g: Mean value of Y within window and frames, Green if RGB is selected.
734  * @mean_cb_or_b: Mean value of Cb within window and frames, Blue if RGB is selected.
735  * @mean_cr_or_r: Mean value of Cr within window and frames, Red if RGB is selected.
736  */
737 struct cifisp_awb_meas {
738     unsigned int cnt;
739     unsigned char mean_y_or_g;
740     unsigned char mean_cb_or_b;
741     unsigned char mean_cr_or_r;
742 } __attribute__((packed));
743 
744 /**
745  * struct cifisp_awb_stat - statistics automatic white balance data
746  *
747  * @awb_mean: Mean measured data
748  */
749 struct cifisp_awb_stat {
750     struct cifisp_awb_meas awb_mean[CIFISP_AWB_MAX_GRID];
751 } __attribute__((packed));
752 
753 /**
754  * struct cifisp_bls_meas_val - BLS measured values
755  *
756  * @meas_r: Mean measured value for Bayer pattern R
757  * @meas_gr: Mean measured value for Bayer pattern Gr
758  * @meas_gb: Mean measured value for Bayer pattern Gb
759  * @meas_b: Mean measured value for Bayer pattern B
760  */
761 struct cifisp_bls_meas_val {
762     unsigned short meas_r;
763     unsigned short meas_gr;
764     unsigned short meas_gb;
765     unsigned short meas_b;
766 } __attribute__((packed));
767 
768 /**
769  * struct cifisp_ae_stat - statistics auto exposure data
770  *
771  * @exp_mean: Mean luminance value of block xx
772  * @bls_val: available wit exposure results
773  *
774  * Image is divided into 5x5 blocks.
775  */
776 struct cifisp_ae_stat {
777     unsigned char exp_mean[CIFISP_AE_MEAN_MAX];
778     struct cifisp_bls_meas_val bls_val;
779 } __attribute__((packed));
780 
781 /**
782  * struct cifisp_af_meas_val - AF measured values
783  *
784  * @sum: sharpness, refer to datasheet for definition
785  * @lum: luminance, refer to datasheet for definition
786  */
787 struct cifisp_af_meas_val {
788     unsigned int sum;
789     unsigned int lum;
790 } __attribute__((packed));
791 
792 /**
793  * struct cifisp_af_stat - statistics auto focus data
794  *
795  * @window: AF measured value of window x
796  *
797  * The module measures the sharpness in 3 windows of selectable size via
798  * register settings(ISP_AFM_*_A/B/C)
799  */
800 struct cifisp_af_stat {
801     struct cifisp_af_meas_val window[CIFISP_AFM_MAX_WINDOWS];
802 } __attribute__((packed));
803 
804 /**
805  * struct cifisp_hist_stat - statistics histogram data
806  *
807  * @hist_bins: measured bin counters
808  *
809  * Measurement window divided into 25 sub-windows, set
810  * with ISP_HIST_XXX
811  */
812 struct cifisp_hist_stat {
813     unsigned int hist_bins[CIFISP_HIST_BIN_N_MAX];
814 } __attribute__((packed));
815 
816 /**
817  * struct cifisp_embedded_data - embedded data
818  *
819  * @data: embedded data
820  *
821  */
822 struct cifisp_embedded_data {
823     unsigned char data[CIFISP_ADD_DATA_FIFO_SIZE];
824 } __attribute__((packed));
825 
826 /**
827  * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Data
828  *
829  * @cifisp_awb_stat: statistics data for automatic white balance
830  * @cifisp_ae_stat: statistics data for auto exposure
831  * @cifisp_af_stat: statistics data for auto focus
832  * @cifisp_hist_stat: statistics histogram data
833  */
834 struct cifisp_stat {
835     struct cifisp_awb_stat awb;
836     struct cifisp_ae_stat ae;
837     struct cifisp_af_stat af;
838     struct cifisp_hist_stat hist;
839     struct cifisp_embedded_data emd;
840 } __attribute__((packed));
841 
842 /**
843  * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
844  *
845  * @meas_type: measurement types (CIFISP_STAT_ definitions)
846  * @frame_id: frame ID for sync
847  * @params: statistics data
848  */
849 struct rkisp1_stat_buffer {
850     unsigned int meas_type;
851     unsigned int frame_id;
852     struct cifisp_stat params;
853 } __attribute__((packed));
854 
855 #endif /* _UAPI_RKISP1_CONFIG_H */
856