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