GNU Linux-libre 4.14.254-gnu1
[releases.git] / drivers / staging / media / atomisp / include / linux / atomisp.h
1 /*
2  * Support for Medifield PNW Camera Imaging ISP subsystem.
3  *
4  * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version
8  * 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  *
20  */
21 #ifdef CSS15
22 #include <linux/atomisp_css15.h>
23 #else
24
25 #ifndef _ATOM_ISP_H
26 #define _ATOM_ISP_H
27
28 #include <linux/types.h>
29 #include <linux/version.h>
30
31 /* struct media_device_info.hw_revision */
32 #define ATOMISP_HW_REVISION_MASK        0x0000ff00
33 #define ATOMISP_HW_REVISION_SHIFT       8
34 #define ATOMISP_HW_REVISION_ISP2300     0x00
35 #define ATOMISP_HW_REVISION_ISP2400     0x10
36 #define ATOMISP_HW_REVISION_ISP2401_LEGACY 0x11
37 #define ATOMISP_HW_REVISION_ISP2401     0x20
38
39 #define ATOMISP_HW_STEPPING_MASK        0x000000ff
40 #define ATOMISP_HW_STEPPING_A0          0x00
41 #define ATOMISP_HW_STEPPING_B0          0x10
42
43 /*ISP binary running mode*/
44 #define CI_MODE_PREVIEW         0x8000
45 #define CI_MODE_VIDEO           0x4000
46 #define CI_MODE_STILL_CAPTURE   0x2000
47 #define CI_MODE_CONTINUOUS      0x1000
48 #define CI_MODE_NONE            0x0000
49
50 #define OUTPUT_MODE_FILE 0x0100
51 #define OUTPUT_MODE_TEXT 0x0200
52
53 /*
54  * Camera HAL sets this flag in v4l2_buffer reserved2 to indicate this
55  * buffer has a per-frame parameter.
56  */
57 #define ATOMISP_BUFFER_HAS_PER_FRAME_SETTING    0x80000000
58
59 /* Custom format for RAW capture from M10MO 0x3130314d */
60 #define V4L2_PIX_FMT_CUSTOM_M10MO_RAW   v4l2_fourcc('M', '1', '0', '1')
61
62 /* Custom media bus formats being used in atomisp */
63 #define V4L2_MBUS_FMT_CUSTOM_YUV420     0x8001
64 #define V4L2_MBUS_FMT_CUSTOM_YVU420     0x8002
65 #define V4L2_MBUS_FMT_CUSTOM_YUV422P    0x8003
66 #define V4L2_MBUS_FMT_CUSTOM_YUV444     0x8004
67 #define V4L2_MBUS_FMT_CUSTOM_NV12       0x8005
68 #define V4L2_MBUS_FMT_CUSTOM_NV21       0x8006
69 #define V4L2_MBUS_FMT_CUSTOM_NV16       0x8007
70 #define V4L2_MBUS_FMT_CUSTOM_YUYV       0x8008
71 #define V4L2_MBUS_FMT_CUSTOM_SBGGR16    0x8009
72 #define V4L2_MBUS_FMT_CUSTOM_RGB32      0x800a
73
74 /* Custom media bus format for M10MO RAW capture */
75 #define V4L2_MBUS_FMT_CUSTOM_M10MO_RAW  0x800b
76
77 /* Configuration used by Bayer noise reduction and YCC noise reduction */
78 struct atomisp_nr_config {
79         /* [gain] Strength of noise reduction for Bayer NR (Used by Bayer NR) */
80         unsigned int bnr_gain;
81         /* [gain] Strength of noise reduction for YCC NR (Used by YCC NR) */
82         unsigned int ynr_gain;
83         /* [intensity] Sensitivity of Edge (Used by Bayer NR) */
84         unsigned int direction;
85         /* [intensity] coring threshold for Cb (Used by YCC NR) */
86         unsigned int threshold_cb;
87         /* [intensity] coring threshold for Cr (Used by YCC NR) */
88         unsigned int threshold_cr;
89 };
90
91 /* Temporal noise reduction configuration */
92 struct atomisp_tnr_config {
93         unsigned int gain;       /* [gain] Strength of NR */
94         unsigned int threshold_y;/* [intensity] Motion sensitivity for Y */
95         unsigned int threshold_uv;/* [intensity] Motion sensitivity for U/V */
96 };
97
98 /* Histogram. This contains num_elements values of type unsigned int.
99  * The data pointer is a DDR pointer (virtual address).
100  */
101 struct atomisp_histogram {
102         unsigned int num_elements;
103         void __user *data;
104 };
105
106 enum atomisp_ob_mode {
107         atomisp_ob_mode_none,
108         atomisp_ob_mode_fixed,
109         atomisp_ob_mode_raster
110 };
111
112 /* Optical black level configuration */
113 struct atomisp_ob_config {
114         /* Obtical black level mode (Fixed / Raster) */
115         enum atomisp_ob_mode mode;
116         /* [intensity] optical black level for GR (relevant for fixed mode) */
117         unsigned int level_gr;
118         /* [intensity] optical black level for R (relevant for fixed mode) */
119         unsigned int level_r;
120         /* [intensity] optical black level for B (relevant for fixed mode) */
121         unsigned int level_b;
122         /* [intensity] optical black level for GB (relevant for fixed mode) */
123         unsigned int level_gb;
124         /* [BQ] 0..63 start position of OB area (relevant for raster mode) */
125         unsigned short start_position;
126         /* [BQ] start..63 end position of OB area (relevant for raster mode) */
127         unsigned short end_position;
128 };
129
130 /* Edge enhancement (sharpen) configuration */
131 struct atomisp_ee_config {
132         /* [gain] The strength of sharpness. u5_11 */
133         unsigned int gain;
134         /* [intensity] The threshold that divides noises from edge. u8_8 */
135         unsigned int threshold;
136         /* [gain] The strength of sharpness in pell-mell area. u5_11 */
137         unsigned int detail_gain;
138 };
139
140 struct atomisp_3a_output {
141         int ae_y;
142         int awb_cnt;
143         int awb_gr;
144         int awb_r;
145         int awb_b;
146         int awb_gb;
147         int af_hpf1;
148         int af_hpf2;
149 };
150
151 enum atomisp_calibration_type {
152         calibration_type1,
153         calibration_type2,
154         calibration_type3
155 };
156
157 struct atomisp_calibration_group {
158         unsigned int size;
159         unsigned int type;
160         unsigned short *calb_grp_values;
161 };
162
163 struct atomisp_gc_config {
164         __u16 gain_k1;
165         __u16 gain_k2;
166 };
167
168 struct atomisp_3a_config {
169         unsigned int ae_y_coef_r;       /* [gain] Weight of R for Y */
170         unsigned int ae_y_coef_g;       /* [gain] Weight of G for Y */
171         unsigned int ae_y_coef_b;       /* [gain] Weight of B for Y */
172         unsigned int awb_lg_high_raw;   /* [intensity]
173                                            AWB level gate high for raw */
174         unsigned int awb_lg_low;        /* [intensity] AWB level gate low */
175         unsigned int awb_lg_high;       /* [intensity] AWB level gate high */
176         int af_fir1_coef[7];    /* [factor] AF FIR coefficients of fir1 */
177         int af_fir2_coef[7];    /* [factor] AF FIR coefficients of fir2 */
178 };
179
180 struct atomisp_dvs_grid_info {
181         uint32_t enable;
182         uint32_t width;
183         uint32_t aligned_width;
184         uint32_t height;
185         uint32_t aligned_height;
186         uint32_t bqs_per_grid_cell;
187         uint32_t num_hor_coefs;
188         uint32_t num_ver_coefs;
189 };
190
191 struct atomisp_dvs_envelop {
192         unsigned int width;
193         unsigned int height;
194 };
195
196 struct atomisp_grid_info {
197         uint32_t enable;
198         uint32_t use_dmem;
199         uint32_t has_histogram;
200         uint32_t s3a_width;
201         uint32_t s3a_height;
202         uint32_t aligned_width;
203         uint32_t aligned_height;
204         uint32_t s3a_bqs_per_grid_cell;
205         uint32_t deci_factor_log2;
206         uint32_t elem_bit_depth;
207 };
208
209 struct atomisp_dis_vector {
210         int x;
211         int y;
212 };
213
214
215 /** DVS 2.0 Coefficient types. This structure contains 4 pointers to
216  *  arrays that contain the coeffients for each type.
217  */
218 struct atomisp_dvs2_coef_types {
219         short __user *odd_real; /**< real part of the odd coefficients*/
220         short __user *odd_imag; /**< imaginary part of the odd coefficients*/
221         short __user *even_real;/**< real part of the even coefficients*/
222         short __user *even_imag;/**< imaginary part of the even coefficients*/
223 };
224
225 /*
226  * DVS 2.0 Statistic types. This structure contains 4 pointers to
227  * arrays that contain the statistics for each type.
228  */
229 struct atomisp_dvs2_stat_types {
230         int __user *odd_real; /**< real part of the odd statistics*/
231         int __user *odd_imag; /**< imaginary part of the odd statistics*/
232         int __user *even_real;/**< real part of the even statistics*/
233         int __user *even_imag;/**< imaginary part of the even statistics*/
234 };
235
236 struct atomisp_dis_coefficients {
237         struct atomisp_dvs_grid_info grid_info;
238         struct atomisp_dvs2_coef_types hor_coefs;
239         struct atomisp_dvs2_coef_types ver_coefs;
240 };
241
242 struct atomisp_dvs2_statistics {
243         struct atomisp_dvs_grid_info grid_info;
244         struct atomisp_dvs2_stat_types hor_prod;
245         struct atomisp_dvs2_stat_types ver_prod;
246 };
247
248 struct atomisp_dis_statistics {
249         struct atomisp_dvs2_statistics dvs2_stat;
250         uint32_t exp_id;
251 };
252
253 struct atomisp_3a_rgby_output {
254         uint32_t r;
255         uint32_t g;
256         uint32_t b;
257         uint32_t y;
258 };
259
260 /*
261  * Because we have 2 pipes at max to output metadata, therefore driver will use
262  * ATOMISP_MAIN_METADATA to specify the metadata from the pipe which keeps
263  * streaming always and use ATOMISP_SEC_METADATA to specify the metadata from
264  * the pipe which is streaming by request like capture pipe of ZSL or SDV mode
265  * as secondary metadata. And for the use case which has only one pipe
266  * streaming like online capture, ATOMISP_MAIN_METADATA will be used.
267  */
268 enum atomisp_metadata_type {
269         ATOMISP_MAIN_METADATA = 0,
270         ATOMISP_SEC_METADATA,
271         ATOMISP_METADATA_TYPE_NUM,
272 };
273
274 struct atomisp_metadata_with_type {
275         /* to specify which type of metadata to get */
276         enum atomisp_metadata_type type;
277         void __user *data;
278         uint32_t width;
279         uint32_t height;
280         uint32_t stride; /* in bytes */
281         uint32_t exp_id; /* exposure ID */
282         uint32_t *effective_width; /* mipi packets valid data size */
283 };
284
285 struct atomisp_metadata {
286         void __user *data;
287         uint32_t width;
288         uint32_t height;
289         uint32_t stride; /* in bytes */
290         uint32_t exp_id; /* exposure ID */
291         uint32_t *effective_width; /* mipi packets valid data size */
292 };
293
294 struct atomisp_ext_isp_ctrl {
295         uint32_t id;
296         uint32_t data;
297 };
298
299 struct atomisp_3a_statistics {
300         struct atomisp_grid_info  grid_info;
301         struct atomisp_3a_output __user *data;
302         struct atomisp_3a_rgby_output __user *rgby_data;
303         uint32_t exp_id; /* exposure ID */
304         uint32_t isp_config_id; /* isp config ID */
305 };
306
307 /**
308  * struct atomisp_cont_capture_conf - continuous capture parameters
309  * @num_captures: number of still images to capture
310  * @skip_frames: number of frames to skip between 2 captures
311  * @offset: offset in ring buffer to start capture
312  *
313  * For example, to capture 1 frame from past, current, and 1 from future
314  * and skip one frame between each capture, parameters would be:
315  * num_captures:3
316  * skip_frames:1
317  * offset:-2
318  */
319
320 struct atomisp_cont_capture_conf {
321         int num_captures;
322         unsigned int skip_frames;
323         int offset;
324         __u32 reserved[5];
325 };
326
327 struct atomisp_ae_window {
328         int x_left;
329         int x_right;
330         int y_top;
331         int y_bottom;
332         int weight;
333 };
334
335 /* White Balance (Gain Adjust) */
336 struct atomisp_wb_config {
337         unsigned int integer_bits;
338         unsigned int gr;        /* unsigned <integer_bits>.<16-integer_bits> */
339         unsigned int r;         /* unsigned <integer_bits>.<16-integer_bits> */
340         unsigned int b;         /* unsigned <integer_bits>.<16-integer_bits> */
341         unsigned int gb;        /* unsigned <integer_bits>.<16-integer_bits> */
342 };
343
344 /* Color Space Conversion settings */
345 struct atomisp_cc_config {
346         unsigned int fraction_bits;
347         int matrix[3 * 3];      /* RGB2YUV Color matrix, signed
348                                    <13-fraction_bits>.<fraction_bits> */
349 };
350
351 /* De pixel noise configuration */
352 struct atomisp_de_config {
353         unsigned int pixelnoise;
354         unsigned int c1_coring_threshold;
355         unsigned int c2_coring_threshold;
356 };
357
358 /* Chroma enhancement */
359 struct atomisp_ce_config {
360         unsigned char uv_level_min;
361         unsigned char uv_level_max;
362 };
363
364 /* Defect pixel correction configuration */
365 struct atomisp_dp_config {
366         /* [intensity] The threshold of defect Pixel Correction, representing
367          * the permissible difference of intensity between one pixel and its
368          * surrounding pixels. Smaller values result in more frequent pixel
369          * corrections. u0_16
370          */
371         unsigned int threshold;
372         /* [gain] The sensitivity of mis-correction. ISP will miss a lot of
373          * defects if the value is set too large. u8_8
374          */
375         unsigned int gain;
376         unsigned int gr;
377         unsigned int r;
378         unsigned int b;
379         unsigned int gb;
380 };
381
382 /* XNR threshold */
383 struct atomisp_xnr_config {
384         __u16 threshold;
385 };
386
387 /* metadata config */
388 struct atomisp_metadata_config {
389         uint32_t metadata_height;
390         uint32_t metadata_stride;
391 };
392
393 /*
394  * Generic resolution structure.
395  */
396 struct atomisp_resolution {
397         uint32_t width;  /**< Width */
398         uint32_t height; /**< Height */
399 };
400
401 /*
402  * This specifies the coordinates (x,y)
403  */
404 struct atomisp_zoom_point {
405         int32_t x; /**< x coordinate */
406         int32_t y; /**< y coordinate */
407 };
408
409 /*
410  * This specifies the region
411  */
412 struct atomisp_zoom_region {
413         struct atomisp_zoom_point origin; /* Starting point coordinates for the region */
414         struct atomisp_resolution resolution; /* Region resolution */
415 };
416
417 struct atomisp_dz_config {
418         uint32_t dx; /**< Horizontal zoom factor */
419         uint32_t dy; /**< Vertical zoom factor */
420         struct atomisp_zoom_region zoom_region; /**< region for zoom */
421 };
422
423 struct atomisp_parm {
424         struct atomisp_grid_info info;
425         struct atomisp_dvs_grid_info dvs_grid;
426         struct atomisp_dvs_envelop dvs_envelop;
427         struct atomisp_wb_config wb_config;
428         struct atomisp_cc_config cc_config;
429         struct atomisp_ob_config ob_config;
430         struct atomisp_de_config de_config;
431         struct atomisp_dz_config dz_config;
432         struct atomisp_ce_config ce_config;
433         struct atomisp_dp_config dp_config;
434         struct atomisp_nr_config nr_config;
435         struct atomisp_ee_config ee_config;
436         struct atomisp_tnr_config tnr_config;
437         struct atomisp_metadata_config metadata_config;
438 };
439
440 struct dvs2_bq_resolution {
441         int width_bq;         /* width [BQ] */
442         int height_bq;        /* height [BQ] */
443 };
444
445 struct atomisp_dvs2_bq_resolutions {
446         /* GDC source image size [BQ] */
447         struct dvs2_bq_resolution source_bq;
448         /* GDC output image size [BQ] */
449         struct dvs2_bq_resolution output_bq;
450         /* GDC effective envelope size [BQ] */
451         struct dvs2_bq_resolution envelope_bq;
452         /* isp pipe filter size [BQ] */
453         struct dvs2_bq_resolution ispfilter_bq;
454         /* GDC shit size [BQ] */
455         struct dvs2_bq_resolution gdc_shift_bq;
456 };
457
458 struct atomisp_dvs_6axis_config {
459         uint32_t exp_id;
460         uint32_t width_y;
461         uint32_t height_y;
462         uint32_t width_uv;
463         uint32_t height_uv;
464         uint32_t *xcoords_y;
465         uint32_t *ycoords_y;
466         uint32_t *xcoords_uv;
467         uint32_t *ycoords_uv;
468 };
469
470 struct atomisp_formats_config {
471         uint32_t video_full_range_flag;
472 };
473
474 struct atomisp_parameters {
475         struct atomisp_wb_config   *wb_config;  /* White Balance config */
476         struct atomisp_cc_config   *cc_config;  /* Color Correction config */
477         struct atomisp_tnr_config  *tnr_config; /* Temporal Noise Reduction */
478         struct atomisp_ecd_config  *ecd_config; /* Eigen Color Demosaicing */
479         struct atomisp_ynr_config  *ynr_config; /* Y(Luma) Noise Reduction */
480         struct atomisp_fc_config   *fc_config;  /* Fringe Control */
481         struct atomisp_formats_config *formats_config; /* Formats Control */
482         struct atomisp_cnr_config  *cnr_config; /* Chroma Noise Reduction */
483         struct atomisp_macc_config *macc_config;  /* MACC */
484         struct atomisp_ctc_config  *ctc_config; /* Chroma Tone Control */
485         struct atomisp_aa_config   *aa_config;  /* Anti-Aliasing */
486         struct atomisp_aa_config   *baa_config;  /* Anti-Aliasing */
487         struct atomisp_ce_config   *ce_config;
488         struct atomisp_dvs_6axis_config *dvs_6axis_config;
489         struct atomisp_ob_config   *ob_config;  /* Objective Black config */
490         struct atomisp_dp_config   *dp_config;  /* Dead Pixel config */
491         struct atomisp_nr_config   *nr_config;  /* Noise Reduction config */
492         struct atomisp_ee_config   *ee_config;  /* Edge Enhancement config */
493         struct atomisp_de_config   *de_config;  /* Demosaic config */
494         struct atomisp_gc_config   *gc_config;  /* Gamma Correction config */
495         struct atomisp_anr_config  *anr_config; /* Advanced Noise Reduction */
496         struct atomisp_3a_config   *a3a_config; /* 3A Statistics config */
497         struct atomisp_xnr_config  *xnr_config; /* eXtra Noise Reduction */
498         struct atomisp_dz_config   *dz_config;  /* Digital Zoom */
499         struct atomisp_cc_config *yuv2rgb_cc_config; /* Color
500                                                         Correction config */
501         struct atomisp_cc_config *rgb2yuv_cc_config; /* Color
502                                                         Correction config */
503         struct atomisp_macc_table  *macc_table;
504         struct atomisp_gamma_table *gamma_table;
505         struct atomisp_ctc_table   *ctc_table;
506         struct atomisp_xnr_table   *xnr_table;
507         struct atomisp_rgb_gamma_table *r_gamma_table;
508         struct atomisp_rgb_gamma_table *g_gamma_table;
509         struct atomisp_rgb_gamma_table *b_gamma_table;
510         struct atomisp_vector      *motion_vector; /* For 2-axis DVS */
511         struct atomisp_shading_table *shading_table;
512         struct atomisp_morph_table   *morph_table;
513         struct atomisp_dvs_coefficients *dvs_coefs; /* DVS 1.0 coefficients */
514         struct atomisp_dvs2_coefficients *dvs2_coefs; /* DVS 2.0 coefficients */
515         struct atomisp_capture_config   *capture_config;
516         struct atomisp_anr_thres   *anr_thres;
517
518         void    *lin_2500_config;       /* Skylake: Linearization config */
519         void    *obgrid_2500_config;    /* Skylake: OBGRID config */
520         void    *bnr_2500_config;       /* Skylake: bayer denoise config */
521         void    *shd_2500_config;       /* Skylake: shading config */
522         void    *dm_2500_config;        /* Skylake: demosaic config */
523         void    *rgbpp_2500_config;     /* Skylake: RGBPP config */
524         void    *dvs_stat_2500_config;  /* Skylake: DVS STAT config */
525         void    *lace_stat_2500_config; /* Skylake: LACE STAT config */
526         void    *yuvp1_2500_config;     /* Skylake: yuvp1 config */
527         void    *yuvp2_2500_config;     /* Skylake: yuvp2 config */
528         void    *tnr_2500_config;       /* Skylake: TNR config */
529         void    *dpc_2500_config;       /* Skylake: DPC config */
530         void    *awb_2500_config;       /* Skylake: auto white balance config */
531         void    *awb_fr_2500_config;    /* Skylake: auto white balance filter response config */
532         void    *anr_2500_config;       /* Skylake: ANR config */
533         void    *af_2500_config;        /* Skylake: auto focus config */
534         void    *ae_2500_config;        /* Skylake: auto exposure config */
535         void    *bds_2500_config;       /* Skylake: bayer downscaler config */
536         void    *dvs_2500_config;       /* Skylake: digital video stabilization config */
537         void    *res_mgr_2500_config;
538
539         /*
540          * Output frame pointer the config is to be applied to (optional),
541          * set to NULL to make this config is applied as global.
542          */
543         void    *output_frame;
544         /*
545          * Unique ID to track which config was actually applied to a particular
546          * frame, driver will send this id back with output frame together.
547          */
548         uint32_t        isp_config_id;
549
550         /*
551          * Switch to control per_frame setting:
552          * 0: this is a global setting
553          * 1: this is a per_frame setting
554          * PLEASE KEEP THIS AT THE END OF THE STRUCTURE!!
555          */
556         uint32_t        per_frame_setting;
557 };
558
559 #define ATOMISP_GAMMA_TABLE_SIZE        1024
560 struct atomisp_gamma_table {
561         unsigned short data[ATOMISP_GAMMA_TABLE_SIZE];
562 };
563
564 /* Morphing table for advanced ISP.
565  * Each line of width elements takes up COORD_TABLE_EXT_WIDTH elements
566  * in memory.
567  */
568 #define ATOMISP_MORPH_TABLE_NUM_PLANES  6
569 struct atomisp_morph_table {
570         unsigned int enabled;
571
572         unsigned int height;
573         unsigned int width;     /* number of valid elements per line */
574         unsigned short __user *coordinates_x[ATOMISP_MORPH_TABLE_NUM_PLANES];
575         unsigned short __user *coordinates_y[ATOMISP_MORPH_TABLE_NUM_PLANES];
576 };
577
578 #define ATOMISP_NUM_SC_COLORS   4
579 #define ATOMISP_SC_FLAG_QUERY   (1 << 0)
580
581 struct atomisp_shading_table {
582         __u32 enable;
583
584         __u32 sensor_width;
585         __u32 sensor_height;
586         __u32 width;
587         __u32 height;
588         __u32 fraction_bits;
589
590         __u16 *data[ATOMISP_NUM_SC_COLORS];
591 };
592
593 struct atomisp_makernote_info {
594         /* bits 31-16: numerator, bits 15-0: denominator */
595         unsigned int focal_length;
596         /* bits 31-16: numerator, bits 15-0: denominator*/
597         unsigned int f_number_curr;
598         /*
599         * bits 31-24: max f-number numerator
600         * bits 23-16: max f-number denominator
601         * bits 15-8: min f-number numerator
602         * bits 7-0: min f-number denominator
603         */
604         unsigned int f_number_range;
605 };
606
607 /* parameter for MACC */
608 #define ATOMISP_NUM_MACC_AXES           16
609 struct atomisp_macc_table {
610         short data[4 * ATOMISP_NUM_MACC_AXES];
611 };
612
613 struct atomisp_macc_config {
614         int color_effect;
615         struct atomisp_macc_table table;
616 };
617
618 /* Parameter for ctc parameter control */
619 #define ATOMISP_CTC_TABLE_SIZE          1024
620 struct atomisp_ctc_table {
621         unsigned short data[ATOMISP_CTC_TABLE_SIZE];
622 };
623
624 /* Parameter for overlay image loading */
625 struct atomisp_overlay {
626         /* the frame containing the overlay data The overlay frame width should
627          * be the multiples of 2*ISP_VEC_NELEMS. The overlay frame height
628          * should be the multiples of 2.
629          */
630         struct v4l2_framebuffer *frame;
631         /* Y value of overlay background */
632         unsigned char bg_y;
633         /* U value of overlay background */
634         char bg_u;
635         /* V value of overlay background */
636         char bg_v;
637         /* the blending percent of input data for Y subpixels */
638         unsigned char blend_input_perc_y;
639         /* the blending percent of input data for U subpixels */
640         unsigned char blend_input_perc_u;
641         /* the blending percent of input data for V subpixels */
642         unsigned char blend_input_perc_v;
643         /* the blending percent of overlay data for Y subpixels */
644         unsigned char blend_overlay_perc_y;
645         /* the blending percent of overlay data for U subpixels */
646         unsigned char blend_overlay_perc_u;
647         /* the blending percent of overlay data for V subpixels */
648         unsigned char blend_overlay_perc_v;
649         /* the overlay start x pixel position on output frame It should be the
650            multiples of 2*ISP_VEC_NELEMS. */
651         unsigned int overlay_start_x;
652         /* the overlay start y pixel position on output frame It should be the
653            multiples of 2. */
654         unsigned int overlay_start_y;
655 };
656
657 /* Sensor resolution specific data for AE calculation.*/
658 struct atomisp_sensor_mode_data {
659         unsigned int coarse_integration_time_min;
660         unsigned int coarse_integration_time_max_margin;
661         unsigned int fine_integration_time_min;
662         unsigned int fine_integration_time_max_margin;
663         unsigned int fine_integration_time_def;
664         unsigned int frame_length_lines;
665         unsigned int line_length_pck;
666         unsigned int read_mode;
667         unsigned int vt_pix_clk_freq_mhz;
668         unsigned int crop_horizontal_start; /* Sensor crop start cord. (x0,y0)*/
669         unsigned int crop_vertical_start;
670         unsigned int crop_horizontal_end; /* Sensor crop end cord. (x1,y1)*/
671         unsigned int crop_vertical_end;
672         unsigned int output_width; /* input size to ISP after binning/scaling */
673         unsigned int output_height;
674         uint8_t binning_factor_x; /* horizontal binning factor used */
675         uint8_t binning_factor_y; /* vertical binning factor used */
676         uint16_t hts;
677 };
678
679 struct atomisp_exposure {
680         unsigned int integration_time[8];
681         unsigned int shutter_speed[8];
682         unsigned int gain[4];
683         unsigned int aperture;
684 };
685
686 /* For texture streaming. */
687 struct atomisp_bc_video_package {
688         int ioctl_cmd;
689         int device_id;
690         int inputparam;
691         int outputparam;
692 };
693
694 enum atomisp_focus_hp {
695         ATOMISP_FOCUS_HP_IN_PROGRESS = (1U << 2),
696         ATOMISP_FOCUS_HP_COMPLETE    = (2U << 2),
697         ATOMISP_FOCUS_HP_FAILED      = (3U << 2)
698 };
699
700 /* Masks */
701 #define ATOMISP_FOCUS_STATUS_MOVING           (1U << 0)
702 #define ATOMISP_FOCUS_STATUS_ACCEPTS_NEW_MOVE (1U << 1)
703 #define ATOMISP_FOCUS_STATUS_HOME_POSITION    (3U << 2)
704
705 enum atomisp_camera_port {
706         ATOMISP_CAMERA_PORT_SECONDARY,
707         ATOMISP_CAMERA_PORT_PRIMARY,
708         ATOMISP_CAMERA_PORT_TERTIARY,
709         ATOMISP_CAMERA_NR_PORTS
710 };
711
712 /* Flash modes. Default is off.
713  * Setting a flash to TORCH or INDICATOR mode will automatically
714  * turn it on. Setting it to FLASH mode will not turn on the flash
715  * until the FLASH_STROBE command is sent. */
716 enum atomisp_flash_mode {
717         ATOMISP_FLASH_MODE_OFF,
718         ATOMISP_FLASH_MODE_FLASH,
719         ATOMISP_FLASH_MODE_TORCH,
720         ATOMISP_FLASH_MODE_INDICATOR,
721 };
722
723 /* Flash statuses, used by atomisp driver to check before starting
724  * flash and after having started flash. */
725 enum atomisp_flash_status {
726         ATOMISP_FLASH_STATUS_OK,
727         ATOMISP_FLASH_STATUS_HW_ERROR,
728         ATOMISP_FLASH_STATUS_INTERRUPTED,
729         ATOMISP_FLASH_STATUS_TIMEOUT,
730 };
731
732 /* Frame status. This is used to detect corrupted frames and flash
733  * exposed frames. Usually, the first 2 frames coming out of the sensor
734  * are corrupted. When using flash, the frame before and the frame after
735  * the flash exposed frame may be partially exposed by flash. The ISP
736  * statistics for these frames should not be used by the 3A library.
737  * The frame status value can be found in the "reserved" field in the
738  * v4l2_buffer struct. */
739 enum atomisp_frame_status {
740         ATOMISP_FRAME_STATUS_OK,
741         ATOMISP_FRAME_STATUS_CORRUPTED,
742         ATOMISP_FRAME_STATUS_FLASH_EXPOSED,
743         ATOMISP_FRAME_STATUS_FLASH_PARTIAL,
744         ATOMISP_FRAME_STATUS_FLASH_FAILED,
745 };
746
747 enum atomisp_acc_type {
748         ATOMISP_ACC_STANDALONE, /* Stand-alone acceleration */
749         ATOMISP_ACC_OUTPUT,     /* Accelerator stage on output frame */
750         ATOMISP_ACC_VIEWFINDER  /* Accelerator stage on viewfinder frame */
751 };
752
753 enum atomisp_acc_arg_type {
754         ATOMISP_ACC_ARG_SCALAR_IN,    /* Scalar input argument */
755         ATOMISP_ACC_ARG_SCALAR_OUT,   /* Scalar output argument */
756         ATOMISP_ACC_ARG_SCALAR_IO,    /* Scalar in/output argument */
757         ATOMISP_ACC_ARG_PTR_IN,      /* Pointer input argument */
758         ATOMISP_ACC_ARG_PTR_OUT,             /* Pointer output argument */
759         ATOMISP_ACC_ARG_PTR_IO,      /* Pointer in/output argument */
760         ATOMISP_ARG_PTR_NOFLUSH,  /* Pointer argument will not be flushed */
761         ATOMISP_ARG_PTR_STABLE,   /* Pointer input argument that is stable */
762         ATOMISP_ACC_ARG_FRAME        /* Frame argument */
763 };
764
765 /** ISP memories, isp2400 */
766 enum atomisp_acc_memory {
767         ATOMISP_ACC_MEMORY_PMEM0 = 0,
768         ATOMISP_ACC_MEMORY_DMEM0,
769         /* for backward compatibility */
770         ATOMISP_ACC_MEMORY_DMEM = ATOMISP_ACC_MEMORY_DMEM0,
771         ATOMISP_ACC_MEMORY_VMEM0,
772         ATOMISP_ACC_MEMORY_VAMEM0,
773         ATOMISP_ACC_MEMORY_VAMEM1,
774         ATOMISP_ACC_MEMORY_VAMEM2,
775         ATOMISP_ACC_MEMORY_HMEM0,
776         ATOMISP_ACC_NR_MEMORY
777 };
778
779 enum atomisp_ext_isp_id {
780         EXT_ISP_CID_ISO = 0,
781         EXT_ISP_CID_CAPTURE_HDR,
782         EXT_ISP_CID_CAPTURE_LLS,
783         EXT_ISP_CID_FOCUS_MODE,
784         EXT_ISP_CID_FOCUS_EXECUTION,
785         EXT_ISP_CID_TOUCH_POSX,
786         EXT_ISP_CID_TOUCH_POSY,
787         EXT_ISP_CID_CAF_STATUS,
788         EXT_ISP_CID_AF_STATUS,
789         EXT_ISP_CID_GET_AF_MODE,
790         EXT_ISP_CID_CAPTURE_BURST,
791         EXT_ISP_CID_FLASH_MODE,
792         EXT_ISP_CID_ZOOM,
793         EXT_ISP_CID_SHOT_MODE
794 };
795
796 #define EXT_ISP_FOCUS_MODE_NORMAL       0
797 #define EXT_ISP_FOCUS_MODE_MACRO        1
798 #define EXT_ISP_FOCUS_MODE_TOUCH_AF     2
799 #define EXT_ISP_FOCUS_MODE_PREVIEW_CAF  3
800 #define EXT_ISP_FOCUS_MODE_MOVIE_CAF    4
801 #define EXT_ISP_FOCUS_MODE_FACE_CAF     5
802 #define EXT_ISP_FOCUS_MODE_TOUCH_MACRO  6
803 #define EXT_ISP_FOCUS_MODE_TOUCH_CAF    7
804
805 #define EXT_ISP_FOCUS_STOP              0
806 #define EXT_ISP_FOCUS_SEARCH            1
807 #define EXT_ISP_PAN_FOCUSING            2
808
809 #define EXT_ISP_CAF_RESTART_CHECK       1
810 #define EXT_ISP_CAF_STATUS_FOCUSING     2
811 #define EXT_ISP_CAF_STATUS_SUCCESS      3
812 #define EXT_ISP_CAF_STATUS_FAIL         4
813
814 #define EXT_ISP_AF_STATUS_INVALID       1
815 #define EXT_ISP_AF_STATUS_FOCUSING      2
816 #define EXT_ISP_AF_STATUS_SUCCESS       3
817 #define EXT_ISP_AF_STATUS_FAIL          4
818
819 enum atomisp_burst_capture_options {
820         EXT_ISP_BURST_CAPTURE_CTRL_START = 0,
821         EXT_ISP_BURST_CAPTURE_CTRL_STOP
822 };
823
824 #define EXT_ISP_FLASH_MODE_OFF          0
825 #define EXT_ISP_FLASH_MODE_ON           1
826 #define EXT_ISP_FLASH_MODE_AUTO         2
827 #define EXT_ISP_LED_TORCH_OFF           3
828 #define EXT_ISP_LED_TORCH_ON            4
829
830 #define EXT_ISP_SHOT_MODE_AUTO          0
831 #define EXT_ISP_SHOT_MODE_BEAUTY_FACE   1
832 #define EXT_ISP_SHOT_MODE_BEST_PHOTO    2
833 #define EXT_ISP_SHOT_MODE_DRAMA         3
834 #define EXT_ISP_SHOT_MODE_BEST_FACE     4
835 #define EXT_ISP_SHOT_MODE_ERASER        5
836 #define EXT_ISP_SHOT_MODE_PANORAMA      6
837 #define EXT_ISP_SHOT_MODE_RICH_TONE_HDR 7
838 #define EXT_ISP_SHOT_MODE_NIGHT         8
839 #define EXT_ISP_SHOT_MODE_SOUND_SHOT    9
840 #define EXT_ISP_SHOT_MODE_ANIMATED_PHOTO        10
841 #define EXT_ISP_SHOT_MODE_SPORTS        11
842
843 struct atomisp_sp_arg {
844         enum atomisp_acc_arg_type type; /* Type  of SP argument */
845         void                    *value; /* Value of SP argument */
846         unsigned int             size;  /* Size  of SP argument */
847 };
848
849 /* Acceleration API */
850
851 /* For CSS 1.0 only */
852 struct atomisp_acc_fw_arg {
853         unsigned int fw_handle;
854         unsigned int index;
855         void __user *value;
856         size_t size;
857 };
858
859 /*
860  * Set arguments after first mapping with ATOMISP_IOC_ACC_S_MAPPED_ARG.
861  */
862 struct atomisp_acc_s_mapped_arg {
863         unsigned int fw_handle;
864         __u32 memory;                   /* one of enum atomisp_acc_memory */
865         size_t length;
866         unsigned long css_ptr;
867 };
868
869 struct atomisp_acc_fw_abort {
870         unsigned int fw_handle;
871         /* Timeout in us */
872         unsigned int timeout;
873 };
874
875 struct atomisp_acc_fw_load {
876         unsigned int size;
877         unsigned int fw_handle;
878         void __user *data;
879 };
880
881 /*
882  * Load firmware to specified pipeline.
883  */
884 struct atomisp_acc_fw_load_to_pipe {
885         __u32 flags;                    /* Flags, see below for valid values */
886         unsigned int fw_handle;         /* Handle, filled by kernel. */
887         __u32 size;                     /* Firmware binary size */
888         void __user *data;              /* Pointer to firmware */
889         __u32 type;                     /* Binary type */
890         __u32 reserved[3];              /* Set to zero */
891 };
892 /*
893  * Set Senor run mode
894  */
895 struct atomisp_s_runmode {
896         __u32 mode;
897 };
898
899 #define ATOMISP_ACC_FW_LOAD_FL_PREVIEW          (1 << 0)
900 #define ATOMISP_ACC_FW_LOAD_FL_COPY             (1 << 1)
901 #define ATOMISP_ACC_FW_LOAD_FL_VIDEO            (1 << 2)
902 #define ATOMISP_ACC_FW_LOAD_FL_CAPTURE          (1 << 3)
903 #define ATOMISP_ACC_FW_LOAD_FL_ACC              (1 << 4)
904 #define ATOMISP_ACC_FW_LOAD_FL_ENABLE           (1 << 16)
905
906 #define ATOMISP_ACC_FW_LOAD_TYPE_NONE           0 /* Normal binary: don't use */
907 #define ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT         1 /* Stage on output */
908 #define ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER     2 /* Stage on viewfinder */
909 #define ATOMISP_ACC_FW_LOAD_TYPE_STANDALONE     3 /* Stand-alone acceleration */
910
911 struct atomisp_acc_map {
912         __u32 flags;                    /* Flags, see list below */
913         __u32 length;                   /* Length of data in bytes */
914         void __user *user_ptr;          /* Pointer into user space */
915         unsigned long css_ptr;          /* Pointer into CSS address space */
916         __u32 reserved[4];              /* Set to zero */
917 };
918
919 #define ATOMISP_MAP_FLAG_NOFLUSH        0x0001  /* Do not flush cache */
920 #define ATOMISP_MAP_FLAG_CACHED         0x0002  /* Enable cache */
921
922 struct atomisp_acc_state {
923         __u32 flags;                    /* Flags, see list below */
924 #define ATOMISP_STATE_FLAG_ENABLE       ATOMISP_ACC_FW_LOAD_FL_ENABLE
925         unsigned int fw_handle;
926 };
927
928 struct atomisp_update_exposure {
929         unsigned int gain;
930         unsigned int digi_gain;
931         unsigned int update_gain;
932         unsigned int update_digi_gain;
933 };
934
935 /*
936  * V4L2 private internal data interface.
937  * -----------------------------------------------------------------------------
938  * struct v4l2_private_int_data - request private data stored in video device
939  * internal memory.
940  * @size: sanity check to ensure userspace's buffer fits whole private data.
941  *        If not, kernel will make partial copy (or nothing if @size == 0).
942  *        @size is always corrected for the minimum necessary if IOCTL returns
943  *        no error.
944  * @data: pointer to userspace buffer.
945  */
946 struct v4l2_private_int_data {
947         __u32 size;
948         void __user *data;
949         __u32 reserved[2];
950 };
951
952 enum atomisp_sensor_ae_bracketing_mode {
953         SENSOR_AE_BRACKETING_MODE_OFF = 0,
954         SENSOR_AE_BRACKETING_MODE_SINGLE, /* back to SW standby after bracketing */
955         SENSOR_AE_BRACKETING_MODE_SINGLE_TO_STREAMING, /* back to normal streaming after bracketing */
956         SENSOR_AE_BRACKETING_MODE_LOOP, /* continue AE bracketing in loop mode */
957 };
958
959 struct atomisp_sensor_ae_bracketing_info {
960         unsigned int modes; /* bit mask to indicate supported modes  */
961         unsigned int lut_depth;
962 };
963
964 struct atomisp_sensor_ae_bracketing_lut_entry {
965         __u16 coarse_integration_time;
966         __u16 analog_gain;
967         __u16 digital_gain;
968 };
969
970 struct atomisp_sensor_ae_bracketing_lut {
971         struct atomisp_sensor_ae_bracketing_lut_entry *lut;
972         unsigned int lut_size;
973 };
974
975 /*Private IOCTLs for ISP */
976 #define ATOMISP_IOC_G_XNR \
977         _IOR('v', BASE_VIDIOC_PRIVATE + 0, int)
978 #define ATOMISP_IOC_S_XNR \
979         _IOW('v', BASE_VIDIOC_PRIVATE + 0, int)
980 #define ATOMISP_IOC_G_NR \
981         _IOR('v', BASE_VIDIOC_PRIVATE + 1, struct atomisp_nr_config)
982 #define ATOMISP_IOC_S_NR \
983         _IOW('v', BASE_VIDIOC_PRIVATE + 1, struct atomisp_nr_config)
984 #define ATOMISP_IOC_G_TNR \
985         _IOR('v', BASE_VIDIOC_PRIVATE + 2, struct atomisp_tnr_config)
986 #define ATOMISP_IOC_S_TNR \
987         _IOW('v', BASE_VIDIOC_PRIVATE + 2, struct atomisp_tnr_config)
988 #define ATOMISP_IOC_G_HISTOGRAM \
989         _IOWR('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram)
990 #define ATOMISP_IOC_S_HISTOGRAM \
991         _IOW('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram)
992 #define ATOMISP_IOC_G_BLACK_LEVEL_COMP \
993         _IOR('v', BASE_VIDIOC_PRIVATE + 4, struct atomisp_ob_config)
994 #define ATOMISP_IOC_S_BLACK_LEVEL_COMP \
995         _IOW('v', BASE_VIDIOC_PRIVATE + 4, struct atomisp_ob_config)
996 #define ATOMISP_IOC_G_EE \
997         _IOR('v', BASE_VIDIOC_PRIVATE + 5, struct atomisp_ee_config)
998 #define ATOMISP_IOC_S_EE \
999         _IOW('v', BASE_VIDIOC_PRIVATE + 5, struct atomisp_ee_config)
1000 /* Digital Image Stabilization:
1001  * 1. get dis statistics: reads DIS statistics from ISP (every frame)
1002  * 2. set dis coefficients: set DIS filter coefficients (one time)
1003  * 3. set dis motion vecotr: set motion vector (result of DIS, every frame)
1004  */
1005 #define ATOMISP_IOC_G_DIS_STAT \
1006         _IOWR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_statistics)
1007
1008 #define ATOMISP_IOC_G_DVS2_BQ_RESOLUTIONS \
1009         _IOR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs2_bq_resolutions)
1010
1011 #define ATOMISP_IOC_S_DIS_COEFS \
1012         _IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_coefficients)
1013
1014 #define ATOMISP_IOC_S_DIS_VECTOR \
1015         _IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs_6axis_config)
1016
1017 #define ATOMISP_IOC_G_3A_STAT \
1018         _IOWR('v', BASE_VIDIOC_PRIVATE + 7, struct atomisp_3a_statistics)
1019 #define ATOMISP_IOC_G_ISP_PARM \
1020         _IOR('v', BASE_VIDIOC_PRIVATE + 8, struct atomisp_parm)
1021 #define ATOMISP_IOC_S_ISP_PARM \
1022         _IOW('v', BASE_VIDIOC_PRIVATE + 8, struct atomisp_parm)
1023 #define ATOMISP_IOC_G_ISP_GAMMA \
1024         _IOR('v', BASE_VIDIOC_PRIVATE + 9, struct atomisp_gamma_table)
1025 #define ATOMISP_IOC_S_ISP_GAMMA \
1026         _IOW('v', BASE_VIDIOC_PRIVATE + 9, struct atomisp_gamma_table)
1027 #define ATOMISP_IOC_G_ISP_GDC_TAB \
1028         _IOR('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table)
1029 #define ATOMISP_IOC_S_ISP_GDC_TAB \
1030         _IOW('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table)
1031 #define ATOMISP_IOC_ISP_MAKERNOTE \
1032         _IOWR('v', BASE_VIDIOC_PRIVATE + 11, struct atomisp_makernote_info)
1033
1034 /* macc parameter control*/
1035 #define ATOMISP_IOC_G_ISP_MACC \
1036         _IOR('v', BASE_VIDIOC_PRIVATE + 12, struct atomisp_macc_config)
1037 #define ATOMISP_IOC_S_ISP_MACC \
1038         _IOW('v', BASE_VIDIOC_PRIVATE + 12, struct atomisp_macc_config)
1039
1040 /* Defect pixel detection & Correction */
1041 #define ATOMISP_IOC_G_ISP_BAD_PIXEL_DETECTION \
1042         _IOR('v', BASE_VIDIOC_PRIVATE + 13, struct atomisp_dp_config)
1043 #define ATOMISP_IOC_S_ISP_BAD_PIXEL_DETECTION \
1044         _IOW('v', BASE_VIDIOC_PRIVATE + 13, struct atomisp_dp_config)
1045
1046 /* False Color Correction */
1047 #define ATOMISP_IOC_G_ISP_FALSE_COLOR_CORRECTION \
1048         _IOR('v', BASE_VIDIOC_PRIVATE + 14, struct atomisp_de_config)
1049 #define ATOMISP_IOC_S_ISP_FALSE_COLOR_CORRECTION \
1050         _IOW('v', BASE_VIDIOC_PRIVATE + 14, struct atomisp_de_config)
1051
1052 /* ctc parameter control */
1053 #define ATOMISP_IOC_G_ISP_CTC \
1054         _IOR('v', BASE_VIDIOC_PRIVATE + 15, struct atomisp_ctc_table)
1055 #define ATOMISP_IOC_S_ISP_CTC \
1056         _IOW('v', BASE_VIDIOC_PRIVATE + 15, struct atomisp_ctc_table)
1057
1058 /* white balance Correction */
1059 #define ATOMISP_IOC_G_ISP_WHITE_BALANCE \
1060         _IOR('v', BASE_VIDIOC_PRIVATE + 16, struct atomisp_wb_config)
1061 #define ATOMISP_IOC_S_ISP_WHITE_BALANCE \
1062         _IOW('v', BASE_VIDIOC_PRIVATE + 16, struct atomisp_wb_config)
1063
1064 /* fpn table loading */
1065 #define ATOMISP_IOC_S_ISP_FPN_TABLE \
1066         _IOW('v', BASE_VIDIOC_PRIVATE + 17, struct v4l2_framebuffer)
1067
1068 /* overlay image loading */
1069 #define ATOMISP_IOC_G_ISP_OVERLAY \
1070         _IOWR('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay)
1071 #define ATOMISP_IOC_S_ISP_OVERLAY \
1072         _IOW('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay)
1073
1074 /* bcd driver bridge */
1075 #define ATOMISP_IOC_CAMERA_BRIDGE \
1076         _IOWR('v', BASE_VIDIOC_PRIVATE + 19, struct atomisp_bc_video_package)
1077
1078 /* Sensor resolution specific info for AE */
1079 #define ATOMISP_IOC_G_SENSOR_MODE_DATA \
1080         _IOR('v', BASE_VIDIOC_PRIVATE + 20, struct atomisp_sensor_mode_data)
1081
1082 #define ATOMISP_IOC_S_EXPOSURE \
1083         _IOW('v', BASE_VIDIOC_PRIVATE + 21, struct atomisp_exposure)
1084
1085 /* sensor calibration registers group */
1086 #define ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP \
1087         _IOWR('v', BASE_VIDIOC_PRIVATE + 22, struct atomisp_calibration_group)
1088
1089 /* white balance Correction */
1090 #define ATOMISP_IOC_G_3A_CONFIG \
1091         _IOR('v', BASE_VIDIOC_PRIVATE + 23, struct atomisp_3a_config)
1092 #define ATOMISP_IOC_S_3A_CONFIG \
1093         _IOW('v', BASE_VIDIOC_PRIVATE + 23, struct atomisp_3a_config)
1094
1095 /* Accelerate ioctls */
1096 #define ATOMISP_IOC_ACC_LOAD \
1097         _IOWR('v', BASE_VIDIOC_PRIVATE + 24, struct atomisp_acc_fw_load)
1098
1099 #define ATOMISP_IOC_ACC_UNLOAD \
1100         _IOWR('v', BASE_VIDIOC_PRIVATE + 24, unsigned int)
1101
1102 /* For CSS 1.0 only */
1103 #define ATOMISP_IOC_ACC_S_ARG \
1104         _IOW('v', BASE_VIDIOC_PRIVATE + 24, struct atomisp_acc_fw_arg)
1105
1106 #define ATOMISP_IOC_ACC_START \
1107         _IOW('v', BASE_VIDIOC_PRIVATE + 24, unsigned int)
1108
1109 #define ATOMISP_IOC_ACC_WAIT \
1110         _IOW('v', BASE_VIDIOC_PRIVATE + 25, unsigned int)
1111
1112 #define ATOMISP_IOC_ACC_ABORT \
1113         _IOW('v', BASE_VIDIOC_PRIVATE + 25, struct atomisp_acc_fw_abort)
1114
1115 #define ATOMISP_IOC_ACC_DESTAB \
1116         _IOW('v', BASE_VIDIOC_PRIVATE + 25, struct atomisp_acc_fw_arg)
1117
1118 /* sensor OTP memory read */
1119 #define ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA \
1120         _IOWR('v', BASE_VIDIOC_PRIVATE + 26, struct v4l2_private_int_data)
1121
1122 /* LCS (shading) table write */
1123 #define ATOMISP_IOC_S_ISP_SHD_TAB \
1124         _IOWR('v', BASE_VIDIOC_PRIVATE + 27, struct atomisp_shading_table)
1125
1126 /* Gamma Correction */
1127 #define ATOMISP_IOC_G_ISP_GAMMA_CORRECTION \
1128         _IOR('v', BASE_VIDIOC_PRIVATE + 28, struct atomisp_gc_config)
1129
1130 #define ATOMISP_IOC_S_ISP_GAMMA_CORRECTION \
1131         _IOW('v', BASE_VIDIOC_PRIVATE + 28, struct atomisp_gc_config)
1132
1133 /* motor internal memory read */
1134 #define ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA \
1135         _IOWR('v', BASE_VIDIOC_PRIVATE + 29, struct v4l2_private_int_data)
1136
1137 /*
1138  * Ioctls to map and unmap user buffers to CSS address space for acceleration.
1139  * User fills fields length and user_ptr and sets other fields to zero,
1140  * kernel may modify the flags and sets css_ptr.
1141  */
1142 #define ATOMISP_IOC_ACC_MAP \
1143         _IOWR('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_map)
1144
1145 /* User fills fields length, user_ptr, and css_ptr and zeroes other fields. */
1146 #define ATOMISP_IOC_ACC_UNMAP \
1147         _IOW('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_map)
1148
1149 #define ATOMISP_IOC_ACC_S_MAPPED_ARG \
1150         _IOW('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_s_mapped_arg)
1151
1152 #define ATOMISP_IOC_ACC_LOAD_TO_PIPE \
1153         _IOWR('v', BASE_VIDIOC_PRIVATE + 31, struct atomisp_acc_fw_load_to_pipe)
1154
1155 #define ATOMISP_IOC_S_PARAMETERS \
1156         _IOW('v', BASE_VIDIOC_PRIVATE + 32, struct atomisp_parameters)
1157
1158 #define ATOMISP_IOC_S_CONT_CAPTURE_CONFIG \
1159         _IOWR('v', BASE_VIDIOC_PRIVATE + 33, struct atomisp_cont_capture_conf)
1160
1161 #define ATOMISP_IOC_G_METADATA \
1162         _IOWR('v', BASE_VIDIOC_PRIVATE + 34, struct atomisp_metadata)
1163
1164 #define ATOMISP_IOC_G_METADATA_BY_TYPE \
1165         _IOWR('v', BASE_VIDIOC_PRIVATE + 34, struct atomisp_metadata_with_type)
1166
1167 #define ATOMISP_IOC_EXT_ISP_CTRL \
1168         _IOWR('v', BASE_VIDIOC_PRIVATE + 35, struct atomisp_ext_isp_ctrl)
1169
1170 #define ATOMISP_IOC_EXP_ID_UNLOCK \
1171         _IOW('v', BASE_VIDIOC_PRIVATE + 36, int)
1172
1173 #define ATOMISP_IOC_EXP_ID_CAPTURE \
1174         _IOW('v', BASE_VIDIOC_PRIVATE + 37, int)
1175
1176 #define ATOMISP_IOC_S_ENABLE_DZ_CAPT_PIPE \
1177         _IOWR('v', BASE_VIDIOC_PRIVATE + 38, unsigned int)
1178
1179 #define ATOMISP_IOC_G_FORMATS_CONFIG \
1180         _IOR('v', BASE_VIDIOC_PRIVATE + 39, struct atomisp_formats_config)
1181
1182 #define ATOMISP_IOC_S_FORMATS_CONFIG \
1183         _IOW('v', BASE_VIDIOC_PRIVATE + 39, struct atomisp_formats_config)
1184
1185 #define ATOMISP_IOC_S_EXPOSURE_WINDOW \
1186         _IOW('v', BASE_VIDIOC_PRIVATE + 40, struct atomisp_ae_window)
1187
1188 #define ATOMISP_IOC_S_ACC_STATE \
1189         _IOW('v', BASE_VIDIOC_PRIVATE + 41, struct atomisp_acc_state)
1190
1191 #define ATOMISP_IOC_G_ACC_STATE \
1192         _IOR('v', BASE_VIDIOC_PRIVATE + 41, struct atomisp_acc_state)
1193
1194 #define ATOMISP_IOC_INJECT_A_FAKE_EVENT \
1195         _IOW('v', BASE_VIDIOC_PRIVATE + 42, int)
1196
1197 #define ATOMISP_IOC_G_SENSOR_AE_BRACKETING_INFO \
1198         _IOR('v', BASE_VIDIOC_PRIVATE + 43, struct atomisp_sensor_ae_bracketing_info)
1199
1200 #define ATOMISP_IOC_S_SENSOR_AE_BRACKETING_MODE \
1201         _IOW('v', BASE_VIDIOC_PRIVATE + 43, unsigned int)
1202
1203 #define ATOMISP_IOC_G_SENSOR_AE_BRACKETING_MODE \
1204         _IOR('v', BASE_VIDIOC_PRIVATE + 43, unsigned int)
1205
1206 #define ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT \
1207         _IOW('v', BASE_VIDIOC_PRIVATE + 43, struct atomisp_sensor_ae_bracketing_lut)
1208
1209 #define ATOMISP_IOC_G_INVALID_FRAME_NUM \
1210         _IOR('v', BASE_VIDIOC_PRIVATE + 44, unsigned int)
1211
1212 #define ATOMISP_IOC_S_ARRAY_RESOLUTION \
1213         _IOW('v', BASE_VIDIOC_PRIVATE + 45, struct atomisp_resolution)
1214
1215 /* for depth mode sensor frame sync compensation */
1216 #define ATOMISP_IOC_G_DEPTH_SYNC_COMP \
1217         _IOR('v', BASE_VIDIOC_PRIVATE + 46, unsigned int)
1218
1219 #define ATOMISP_IOC_S_SENSOR_EE_CONFIG \
1220         _IOW('v', BASE_VIDIOC_PRIVATE + 47, unsigned int)
1221
1222 #define ATOMISP_IOC_S_SENSOR_RUNMODE \
1223         _IOW('v', BASE_VIDIOC_PRIVATE + 48, struct atomisp_s_runmode)
1224
1225 #define ATOMISP_IOC_G_UPDATE_EXPOSURE \
1226         _IOWR('v', BASE_VIDIOC_PRIVATE + 49, struct atomisp_update_exposure)
1227
1228 /*
1229  * Reserved ioctls. We have customer implementing it internally.
1230  * We can't use both numbers to not cause ABI conflict.
1231  * Anyway, those ioctls are hacks and not implemented by us:
1232  *
1233  * #define ATOMISP_IOC_G_SENSOR_REG \
1234  *      _IOW('v', BASE_VIDIOC_PRIVATE + 55, struct atomisp_sensor_regs)
1235  * #define ATOMISP_IOC_S_SENSOR_REG \
1236  *      _IOW('v', BASE_VIDIOC_PRIVATE + 56, struct atomisp_sensor_regs)
1237  */
1238
1239 /*  ISP Private control IDs */
1240 #define V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION \
1241         (V4L2_CID_PRIVATE_BASE + 0)
1242 #define V4L2_CID_ATOMISP_POSTPROCESS_GDC_CAC \
1243         (V4L2_CID_PRIVATE_BASE + 1)
1244 #define V4L2_CID_ATOMISP_VIDEO_STABLIZATION \
1245         (V4L2_CID_PRIVATE_BASE + 2)
1246 #define V4L2_CID_ATOMISP_FIXED_PATTERN_NR \
1247         (V4L2_CID_PRIVATE_BASE + 3)
1248 #define V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION \
1249         (V4L2_CID_PRIVATE_BASE + 4)
1250 #define V4L2_CID_ATOMISP_LOW_LIGHT \
1251         (V4L2_CID_PRIVATE_BASE + 5)
1252
1253 /* Camera class:
1254  * Exposure, Flash and privacy (indicator) light controls, to be upstreamed */
1255 #define V4L2_CID_CAMERA_LASTP1             (V4L2_CID_CAMERA_CLASS_BASE + 1024)
1256
1257 #define V4L2_CID_FOCAL_ABSOLUTE            (V4L2_CID_CAMERA_LASTP1 + 0)
1258 #define V4L2_CID_FNUMBER_ABSOLUTE          (V4L2_CID_CAMERA_LASTP1 + 1)
1259 #define V4L2_CID_FNUMBER_RANGE             (V4L2_CID_CAMERA_LASTP1 + 2)
1260
1261 /* Flash related CIDs, see also:
1262  * http://linuxtv.org/downloads/v4l-dvb-apis/extended-controls.html\
1263  * #flash-controls */
1264
1265 /* Request a number of flash-exposed frames. The frame status can be
1266  * found in the reserved field in the v4l2_buffer struct. */
1267 #define V4L2_CID_REQUEST_FLASH             (V4L2_CID_CAMERA_LASTP1 + 3)
1268 /* Query flash driver status. See enum atomisp_flash_status above. */
1269 #define V4L2_CID_FLASH_STATUS              (V4L2_CID_CAMERA_LASTP1 + 5)
1270 /* Set the flash mode (see enum atomisp_flash_mode) */
1271 #define V4L2_CID_FLASH_MODE                (V4L2_CID_CAMERA_LASTP1 + 10)
1272
1273 /* VCM slew control */
1274 #define V4L2_CID_VCM_SLEW                  (V4L2_CID_CAMERA_LASTP1 + 11)
1275 /* VCM step time */
1276 #define V4L2_CID_VCM_TIMEING               (V4L2_CID_CAMERA_LASTP1 + 12)
1277
1278 /* Query Focus Status */
1279 #define V4L2_CID_FOCUS_STATUS              (V4L2_CID_CAMERA_LASTP1 + 14)
1280
1281 /* Query sensor's binning factor */
1282 #define V4L2_CID_BIN_FACTOR_HORZ           (V4L2_CID_CAMERA_LASTP1 + 15)
1283 #define V4L2_CID_BIN_FACTOR_VERT           (V4L2_CID_CAMERA_LASTP1 + 16)
1284
1285 /* number of frames to skip at stream start */
1286 #define V4L2_CID_G_SKIP_FRAMES             (V4L2_CID_CAMERA_LASTP1 + 17)
1287
1288 /* Query sensor's 2A status */
1289 #define V4L2_CID_2A_STATUS                 (V4L2_CID_CAMERA_LASTP1 + 18)
1290 #define V4L2_2A_STATUS_AE_READY            (1 << 0)
1291 #define V4L2_2A_STATUS_AWB_READY           (1 << 1)
1292
1293 #define V4L2_CID_FMT_AUTO                       (V4L2_CID_CAMERA_LASTP1 + 19)
1294
1295 #define V4L2_CID_RUN_MODE                       (V4L2_CID_CAMERA_LASTP1 + 20)
1296 #define ATOMISP_RUN_MODE_VIDEO                  1
1297 #define ATOMISP_RUN_MODE_STILL_CAPTURE          2
1298 #define ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE     3
1299 #define ATOMISP_RUN_MODE_PREVIEW                4
1300 #define ATOMISP_RUN_MODE_SDV                    5
1301
1302 #define V4L2_CID_ENABLE_VFPP                    (V4L2_CID_CAMERA_LASTP1 + 21)
1303 #define V4L2_CID_ATOMISP_CONTINUOUS_MODE        (V4L2_CID_CAMERA_LASTP1 + 22)
1304 #define V4L2_CID_ATOMISP_CONTINUOUS_RAW_BUFFER_SIZE \
1305                                                 (V4L2_CID_CAMERA_LASTP1 + 23)
1306 #define V4L2_CID_ATOMISP_CONTINUOUS_VIEWFINDER \
1307                                                 (V4L2_CID_CAMERA_LASTP1 + 24)
1308
1309 #define V4L2_CID_VFPP                           (V4L2_CID_CAMERA_LASTP1 + 25)
1310 #define ATOMISP_VFPP_ENABLE                     0
1311 #define ATOMISP_VFPP_DISABLE_SCALER             1
1312 #define ATOMISP_VFPP_DISABLE_LOWLAT             2
1313
1314 /* Query real flash status register value */
1315 #define V4L2_CID_FLASH_STATUS_REGISTER  (V4L2_CID_CAMERA_LASTP1 + 26)
1316
1317 #define V4L2_CID_START_ZSL_CAPTURE      (V4L2_CID_CAMERA_LASTP1 + 28)
1318 /* Lock and unlock raw buffer */
1319 #define V4L2_CID_ENABLE_RAW_BUFFER_LOCK (V4L2_CID_CAMERA_LASTP1 + 29)
1320
1321 #define V4L2_CID_DEPTH_MODE             (V4L2_CID_CAMERA_LASTP1 + 30)
1322
1323 #define V4L2_CID_EXPOSURE_ZONE_NUM      (V4L2_CID_CAMERA_LASTP1 + 31)
1324 /* Disable digital zoom */
1325 #define V4L2_CID_DISABLE_DZ             (V4L2_CID_CAMERA_LASTP1 + 32)
1326
1327 #define V4L2_CID_TEST_PATTERN_COLOR_R   (V4L2_CID_CAMERA_LASTP1 + 33)
1328 #define V4L2_CID_TEST_PATTERN_COLOR_GR  (V4L2_CID_CAMERA_LASTP1 + 34)
1329 #define V4L2_CID_TEST_PATTERN_COLOR_GB  (V4L2_CID_CAMERA_LASTP1 + 35)
1330 #define V4L2_CID_TEST_PATTERN_COLOR_B   (V4L2_CID_CAMERA_LASTP1 + 36)
1331
1332 #define V4L2_CID_ATOMISP_SELECT_ISP_VERSION     (V4L2_CID_CAMERA_LASTP1 + 38)
1333
1334 #define V4L2_BUF_FLAG_BUFFER_INVALID       0x0400
1335 #define V4L2_BUF_FLAG_BUFFER_VALID         0x0800
1336
1337 #define V4L2_BUF_TYPE_VIDEO_CAPTURE_ION  (V4L2_BUF_TYPE_PRIVATE + 1024)
1338
1339 #define V4L2_EVENT_ATOMISP_3A_STATS_READY   (V4L2_EVENT_PRIVATE_START + 1)
1340 #define V4L2_EVENT_ATOMISP_METADATA_READY   (V4L2_EVENT_PRIVATE_START + 2)
1341 #define V4L2_EVENT_ATOMISP_RAW_BUFFERS_ALLOC_DONE   (V4L2_EVENT_PRIVATE_START + 3)
1342 #define V4L2_EVENT_ATOMISP_ACC_COMPLETE     (V4L2_EVENT_PRIVATE_START + 4)
1343 #define V4L2_EVENT_ATOMISP_PAUSE_BUFFER     (V4L2_EVENT_PRIVATE_START + 5)
1344 #define V4L2_EVENT_ATOMISP_CSS_RESET        (V4L2_EVENT_PRIVATE_START + 6)
1345 /* Nonstandard color effects for V4L2_CID_COLORFX */
1346 enum {
1347         V4L2_COLORFX_SKIN_WHITEN_LOW = 1001,
1348         V4L2_COLORFX_SKIN_WHITEN_HIGH = 1002,
1349         V4L2_COLORFX_WARM = 1003,
1350         V4L2_COLORFX_COLD = 1004,
1351         V4L2_COLORFX_WASHED = 1005,
1352         V4L2_COLORFX_RED = 1006,
1353         V4L2_COLORFX_GREEN = 1007,
1354         V4L2_COLORFX_BLUE = 1008,
1355         V4L2_COLORFX_PINK = 1009,
1356         V4L2_COLORFX_YELLOW = 1010,
1357         V4L2_COLORFX_PURPLE = 1011,
1358 };
1359
1360 #endif /* _ATOM_ISP_H */
1361 #endif /* CSS15*/