1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Medifield PNW Camera Imaging ISP subsystem. 4 * 5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved. 6 */ 7 8 #ifndef _ATOM_ISP_H 9 #define _ATOM_ISP_H 10 11 #include <linux/types.h> 12 13 /* struct media_device_info.hw_revision */ 14 #define ATOMISP_HW_REVISION_MASK 0x0000ff00 15 #define ATOMISP_HW_REVISION_SHIFT 8 16 #define ATOMISP_HW_REVISION_ISP2300 0x00 17 #define ATOMISP_HW_REVISION_ISP2400 0x10 18 #define ATOMISP_HW_REVISION_ISP2401_LEGACY 0x11 19 #define ATOMISP_HW_REVISION_ISP2401 0x20 20 21 #define ATOMISP_HW_STEPPING_MASK 0x000000ff 22 #define ATOMISP_HW_STEPPING_A0 0x00 23 #define ATOMISP_HW_STEPPING_B0 0x10 24 25 /* ISP binary running mode */ 26 #define CI_MODE_PREVIEW 0x8000 27 #define CI_MODE_VIDEO 0x4000 28 #define CI_MODE_STILL_CAPTURE 0x2000 29 #define CI_MODE_NONE 0x0000 30 31 #define OUTPUT_MODE_FILE 0x0100 32 #define OUTPUT_MODE_TEXT 0x0200 33 34 /* 35 * Camera HAL sets this flag in v4l2_buffer reserved2 to indicate this 36 * buffer has a per-frame parameter. 37 */ 38 #define ATOMISP_BUFFER_HAS_PER_FRAME_SETTING 0x80000000 39 40 /* Custom format for RAW capture from M10MO 0x3130314d */ 41 #define V4L2_PIX_FMT_CUSTOM_M10MO_RAW v4l2_fourcc('M', '1', '0', '1') 42 43 /* Custom media bus formats being used in atomisp */ 44 #define V4L2_MBUS_FMT_CUSTOM_YUV420 0x8001 45 #define V4L2_MBUS_FMT_CUSTOM_YVU420 0x8002 46 #define V4L2_MBUS_FMT_CUSTOM_YUV422P 0x8003 47 #define V4L2_MBUS_FMT_CUSTOM_YUV444 0x8004 48 #define V4L2_MBUS_FMT_CUSTOM_NV12 0x8005 49 #define V4L2_MBUS_FMT_CUSTOM_NV21 0x8006 50 #define V4L2_MBUS_FMT_CUSTOM_NV16 0x8007 51 #define V4L2_MBUS_FMT_CUSTOM_YUYV 0x8008 52 #define V4L2_MBUS_FMT_CUSTOM_SBGGR16 0x8009 53 #define V4L2_MBUS_FMT_CUSTOM_RGB32 0x800a 54 55 /* Custom media bus format for M10MO RAW capture */ 56 #if 0 57 #define V4L2_MBUS_FMT_CUSTOM_M10MO_RAW 0x800b 58 #endif 59 60 /* Configuration used by Bayer noise reduction and YCC noise reduction */ 61 struct atomisp_nr_config { 62 /* [gain] Strength of noise reduction for Bayer NR */ 63 unsigned int bnr_gain; 64 /* [gain] Strength of noise reduction for YCC NR */ 65 unsigned int ynr_gain; 66 /* [intensity] Sensitivity of Edge (Used by Bayer NR) */ 67 unsigned int direction; 68 /* [intensity] coring threshold for Cb (Used by YCC NR) */ 69 unsigned int threshold_cb; 70 /* [intensity] coring threshold for Cr (Used by YCC NR) */ 71 unsigned int threshold_cr; 72 }; 73 74 /* Temporal noise reduction configuration */ 75 struct atomisp_tnr_config { 76 unsigned int gain; /* [gain] Strength of NR */ 77 unsigned int threshold_y;/* [intensity] Motion sensitivity for Y */ 78 unsigned int threshold_uv;/* [intensity] Motion sensitivity for U/V */ 79 }; 80 81 /* 82 * Contains num_elements values of type unsigned int. 83 * The data pointer is a DDR pointer (virtual address). 84 */ 85 struct atomisp_histogram { 86 unsigned int num_elements; 87 void __user *data; 88 }; 89 90 enum atomisp_ob_mode { 91 atomisp_ob_mode_none, 92 atomisp_ob_mode_fixed, 93 atomisp_ob_mode_raster 94 }; 95 96 /* Optical black level configuration */ 97 struct atomisp_ob_config { 98 /* Optical black level mode (Fixed / Raster) */ 99 enum atomisp_ob_mode mode; 100 /* [intensity] optical black level for GR (relevant for fixed mode) */ 101 unsigned int level_gr; 102 /* [intensity] optical black level for R (relevant for fixed mode) */ 103 unsigned int level_r; 104 /* [intensity] optical black level for B (relevant for fixed mode) */ 105 unsigned int level_b; 106 /* [intensity] optical black level for GB (relevant for fixed mode) */ 107 unsigned int level_gb; 108 /* [BQ] 0..63 start position of OB area (relevant for raster mode) */ 109 unsigned short start_position; 110 /* [BQ] start..63 end position of OB area (relevant for raster mode) */ 111 unsigned short end_position; 112 }; 113 114 /* Edge enhancement (sharpen) configuration */ 115 struct atomisp_ee_config { 116 /* [gain] The strength of sharpness. u5_11 */ 117 unsigned int gain; 118 /* [intensity] The threshold that divides noises from edge. u8_8 */ 119 unsigned int threshold; 120 /* [gain] The strength of sharpness in pell-mell area. u5_11 */ 121 unsigned int detail_gain; 122 }; 123 124 struct atomisp_3a_output { 125 int ae_y; 126 int awb_cnt; 127 int awb_gr; 128 int awb_r; 129 int awb_b; 130 int awb_gb; 131 int af_hpf1; 132 int af_hpf2; 133 }; 134 135 enum atomisp_calibration_type { 136 calibration_type1, 137 calibration_type2, 138 calibration_type3 139 }; 140 141 struct atomisp_gc_config { 142 __u16 gain_k1; 143 __u16 gain_k2; 144 }; 145 146 struct atomisp_3a_config { 147 unsigned int ae_y_coef_r; /* [gain] Weight of R for Y */ 148 unsigned int ae_y_coef_g; /* [gain] Weight of G for Y */ 149 unsigned int ae_y_coef_b; /* [gain] Weight of B for Y */ 150 unsigned int awb_lg_high_raw; /* [intensity] AWB level gate high for raw */ 151 unsigned int awb_lg_low; /* [intensity] AWB level gate low */ 152 unsigned int awb_lg_high; /* [intensity] AWB level gate high */ 153 int af_fir1_coef[7]; /* [factor] AF FIR coefficients of fir1 */ 154 int af_fir2_coef[7]; /* [factor] AF FIR coefficients of fir2 */ 155 }; 156 157 struct atomisp_dvs_grid_info { 158 u32 enable; 159 u32 width; 160 u32 aligned_width; 161 u32 height; 162 u32 aligned_height; 163 u32 bqs_per_grid_cell; 164 u32 num_hor_coefs; 165 u32 num_ver_coefs; 166 }; 167 168 struct atomisp_dvs_envelop { 169 unsigned int width; 170 unsigned int height; 171 }; 172 173 struct atomisp_grid_info { 174 u32 enable; 175 u32 use_dmem; 176 u32 has_histogram; 177 u32 s3a_width; 178 u32 s3a_height; 179 u32 aligned_width; 180 u32 aligned_height; 181 u32 s3a_bqs_per_grid_cell; 182 u32 deci_factor_log2; 183 u32 elem_bit_depth; 184 }; 185 186 struct atomisp_dis_vector { 187 int x; 188 int y; 189 }; 190 191 /* 192 * DVS 2.0 Coefficient types. This structure contains 4 pointers to 193 * arrays that contain the coefficients for each type. 194 */ 195 struct atomisp_dvs2_coef_types { 196 short __user *odd_real; /* Real part of the odd coefficients */ 197 short __user *odd_imag; /* Imaginary part of the odd coefficients */ 198 short __user *even_real;/* Real part of the even coefficients */ 199 short __user *even_imag;/* Imaginary part of the even coefficients */ 200 }; 201 202 /* 203 * DVS 2.0 Statistic types. This structure contains 4 pointers to 204 * arrays that contain the statistics for each type. 205 */ 206 struct atomisp_dvs2_stat_types { 207 int __user *odd_real; /* Real part of the odd statistics */ 208 int __user *odd_imag; /* Imaginary part of the odd statistics */ 209 int __user *even_real;/* Real part of the even statistics */ 210 int __user *even_imag;/* Imaginary part of the even statistics */ 211 }; 212 213 struct atomisp_dis_coefficients { 214 struct atomisp_dvs_grid_info grid_info; 215 struct atomisp_dvs2_coef_types hor_coefs; 216 struct atomisp_dvs2_coef_types ver_coefs; 217 }; 218 219 struct atomisp_dvs2_statistics { 220 struct atomisp_dvs_grid_info grid_info; 221 struct atomisp_dvs2_stat_types hor_prod; 222 struct atomisp_dvs2_stat_types ver_prod; 223 }; 224 225 struct atomisp_dis_statistics { 226 struct atomisp_dvs2_statistics dvs2_stat; 227 u32 exp_id; 228 }; 229 230 struct atomisp_3a_rgby_output { 231 u32 r; 232 u32 g; 233 u32 b; 234 u32 y; 235 }; 236 237 /* 238 * As the driver can output metadata on two pipes at max, 239 * ATOMISP_MAIN_METADATA is used for the pipe that streams continuously. 240 * ATOMISP_SEC_METADATA is used for the pipe that streams on demand, e.g., 241 * the capture pipe in ZSL or SDV modes. 242 * In use cases with a single streaming pipe (like online capture), 243 * only ATOMISP_MAIN_METADATA is used. 244 */ 245 enum atomisp_metadata_type { 246 ATOMISP_MAIN_METADATA = 0, 247 ATOMISP_SEC_METADATA, 248 ATOMISP_METADATA_TYPE_NUM, 249 }; 250 251 struct atomisp_ext_isp_ctrl { 252 u32 id; 253 u32 data; 254 }; 255 256 struct atomisp_3a_statistics { 257 struct atomisp_grid_info grid_info; 258 struct atomisp_3a_output __user *data; 259 struct atomisp_3a_rgby_output __user *rgby_data; 260 u32 exp_id; /* exposure ID */ 261 u32 isp_config_id; 262 }; 263 264 /* White Balance (Gain Adjust) */ 265 struct atomisp_wb_config { 266 unsigned int integer_bits; 267 unsigned int gr; /* unsigned <integer_bits>.<16-integer_bits> */ 268 unsigned int r; /* unsigned <integer_bits>.<16-integer_bits> */ 269 unsigned int b; /* unsigned <integer_bits>.<16-integer_bits> */ 270 unsigned int gb; /* unsigned <integer_bits>.<16-integer_bits> */ 271 }; 272 273 /* Color Space Conversion settings */ 274 struct atomisp_cc_config { 275 unsigned int fraction_bits; 276 /* RGB2YUV Color matrix, signed <13-fraction_bits>.<fraction_bits> */ 277 int matrix[3 * 3]; 278 }; 279 280 /* De pixel noise configuration */ 281 struct atomisp_de_config { 282 unsigned int pixelnoise; 283 unsigned int c1_coring_threshold; 284 unsigned int c2_coring_threshold; 285 }; 286 287 /* Chroma enhancement */ 288 struct atomisp_ce_config { 289 unsigned char uv_level_min; 290 unsigned char uv_level_max; 291 }; 292 293 /* Defect pixel correction configuration */ 294 struct atomisp_dp_config { 295 /* 296 * [intensity] The threshold of defect Pixel Correction, representing 297 * the permissible difference of intensity between one pixel and its 298 * surrounding pixels. Smaller values result in more frequent pixel 299 * corrections. u0_16 300 */ 301 unsigned int threshold; 302 /* 303 * [gain] The sensitivity of mis-correction. ISP will miss a lot of 304 * defects if the value is set too large. u8_8 305 */ 306 unsigned int gain; 307 unsigned int gr; 308 unsigned int r; 309 unsigned int b; 310 unsigned int gb; 311 }; 312 313 /* XNR threshold */ 314 struct atomisp_xnr_config { 315 __u16 threshold; 316 }; 317 318 /* Metadata config */ 319 struct atomisp_metadata_config { 320 u32 metadata_height; 321 u32 metadata_stride; 322 }; 323 324 /* 325 * Generic resolution structure. 326 */ 327 struct atomisp_resolution { 328 u32 width; 329 u32 height; 330 }; 331 332 /* 333 * Specifies the zoom point coordinates (x,y) 334 */ 335 struct atomisp_zoom_point { 336 s32 x; 337 s32 y; 338 }; 339 340 /* 341 * Specifies the zoom region 342 */ 343 struct atomisp_zoom_region { 344 struct atomisp_zoom_point origin; /* Starting point coordinates for the region */ 345 struct atomisp_resolution resolution; /* Region resolution */ 346 }; 347 348 struct atomisp_dz_config { 349 u32 dx; /* Horizontal zoom factor */ 350 u32 dy; /* Vertical zoom factor */ 351 struct atomisp_zoom_region zoom_region; 352 }; 353 354 struct atomisp_parm { 355 struct atomisp_grid_info info; 356 struct atomisp_dvs_grid_info dvs_grid; 357 struct atomisp_dvs_envelop dvs_envelop; 358 struct atomisp_wb_config wb_config; 359 struct atomisp_cc_config cc_config; 360 struct atomisp_ob_config ob_config; 361 struct atomisp_de_config de_config; 362 struct atomisp_dz_config dz_config; 363 struct atomisp_ce_config ce_config; 364 struct atomisp_dp_config dp_config; 365 struct atomisp_nr_config nr_config; 366 struct atomisp_ee_config ee_config; 367 struct atomisp_tnr_config tnr_config; 368 struct atomisp_metadata_config metadata_config; 369 }; 370 371 struct dvs2_bq_resolution { 372 int width_bq; 373 int height_bq; 374 }; 375 376 struct atomisp_dvs2_bq_resolutions { 377 /* GDC source image size [BQ] */ 378 struct dvs2_bq_resolution source_bq; 379 /* GDC output image size [BQ] */ 380 struct dvs2_bq_resolution output_bq; 381 /* GDC effective envelope size [BQ] */ 382 struct dvs2_bq_resolution envelope_bq; 383 /* ISP pipe filter size [BQ] */ 384 struct dvs2_bq_resolution ispfilter_bq; 385 /* GDC shift size [BQ] */ 386 struct dvs2_bq_resolution gdc_shift_bq; 387 }; 388 389 struct atomisp_dvs_6axis_config { 390 u32 exp_id; 391 u32 width_y; 392 u32 height_y; 393 u32 width_uv; 394 u32 height_uv; 395 u32 *xcoords_y; 396 u32 *ycoords_y; 397 u32 *xcoords_uv; 398 u32 *ycoords_uv; 399 }; 400 401 struct atomisp_formats_config { 402 u32 video_full_range_flag; 403 }; 404 405 struct atomisp_parameters { 406 struct atomisp_wb_config *wb_config; /* White Balance config */ 407 struct atomisp_cc_config *cc_config; /* Color Correction config */ 408 struct atomisp_tnr_config *tnr_config; /* Temporal Noise Reduction */ 409 struct atomisp_ecd_config *ecd_config; /* Eigen Color Demosaicing */ 410 struct atomisp_ynr_config *ynr_config; /* Y(Luma) Noise Reduction */ 411 struct atomisp_fc_config *fc_config; /* Fringe Control */ 412 struct atomisp_formats_config *formats_config; /* Formats Control */ 413 struct atomisp_cnr_config *cnr_config; /* Chroma Noise Reduction */ 414 struct atomisp_macc_config *macc_config; /* MACC */ 415 struct atomisp_ctc_config *ctc_config; /* Chroma Tone Control */ 416 struct atomisp_aa_config *aa_config; /* Anti-Aliasing */ 417 struct atomisp_aa_config *baa_config; /* Anti-Aliasing */ 418 struct atomisp_ce_config *ce_config; 419 struct atomisp_dvs_6axis_config *dvs_6axis_config; 420 struct atomisp_ob_config *ob_config; /* Objective Black config */ 421 struct atomisp_dp_config *dp_config; /* Dead Pixel config */ 422 struct atomisp_nr_config *nr_config; /* Noise Reduction config */ 423 struct atomisp_ee_config *ee_config; /* Edge Enhancement config */ 424 struct atomisp_de_config *de_config; /* Demosaic config */ 425 struct atomisp_gc_config *gc_config; /* Gamma Correction config */ 426 struct atomisp_anr_config *anr_config; /* Advanced Noise Reduction */ 427 struct atomisp_3a_config *a3a_config; /* 3A Statistics config */ 428 struct atomisp_xnr_config *xnr_config; /* eXtra Noise Reduction */ 429 struct atomisp_dz_config *dz_config; /* Digital Zoom */ 430 struct atomisp_cc_config *yuv2rgb_cc_config; /* Color Correction config */ 431 struct atomisp_cc_config *rgb2yuv_cc_config; /* Color Correction config */ 432 struct atomisp_macc_table *macc_table; 433 struct atomisp_gamma_table *gamma_table; 434 struct atomisp_ctc_table *ctc_table; 435 struct atomisp_xnr_table *xnr_table; 436 struct atomisp_rgb_gamma_table *r_gamma_table; 437 struct atomisp_rgb_gamma_table *g_gamma_table; 438 struct atomisp_rgb_gamma_table *b_gamma_table; 439 struct atomisp_vector *motion_vector; /* For 2-axis DVS */ 440 struct atomisp_shading_table *shading_table; 441 struct atomisp_morph_table *morph_table; 442 struct atomisp_dvs_coefficients *dvs_coefs; /* DVS 1.0 coefficients */ 443 struct atomisp_dis_coefficients *dvs2_coefs; /* DVS 2.0 coefficients */ 444 struct atomisp_capture_config *capture_config; 445 struct atomisp_anr_thres *anr_thres; 446 447 void *lin_2500_config; /* Skylake: Linearization config */ 448 void *obgrid_2500_config; /* Skylake: OBGRID config */ 449 void *bnr_2500_config; /* Skylake: bayer denoise config */ 450 void *shd_2500_config; /* Skylake: shading config */ 451 void *dm_2500_config; /* Skylake: demosaic config */ 452 void *rgbpp_2500_config; /* Skylake: RGBPP config */ 453 void *dvs_stat_2500_config; /* Skylake: DVS STAT config */ 454 void *lace_stat_2500_config; /* Skylake: LACE STAT config */ 455 void *yuvp1_2500_config; /* Skylake: yuvp1 config */ 456 void *yuvp2_2500_config; /* Skylake: yuvp2 config */ 457 void *tnr_2500_config; /* Skylake: TNR config */ 458 void *dpc_2500_config; /* Skylake: DPC config */ 459 void *awb_2500_config; /* Skylake: auto white balance config */ 460 void *awb_fr_2500_config; /* Skylake: auto white balance filter response config */ 461 void *anr_2500_config; /* Skylake: ANR config */ 462 void *af_2500_config; /* Skylake: auto focus config */ 463 void *ae_2500_config; /* Skylake: auto exposure config */ 464 void *bds_2500_config; /* Skylake: bayer downscaler config */ 465 void *dvs_2500_config; /* Skylake: digital video stabilization config */ 466 void *res_mgr_2500_config; 467 468 /* 469 * Output frame pointer to which the config will be applied to (optional), 470 * Set to NULL to make this config be applied as global. 471 */ 472 void *output_frame; 473 /* 474 * Unique ID to track which config was actually applied to a particular 475 * frame, driver will send this id back with output frame together. 476 */ 477 u32 isp_config_id; 478 479 /* 480 * Switch to control per_frame setting: 481 * 0: this is a global setting 482 * 1: this is a per_frame setting 483 * PLEASE KEEP THIS AT THE END OF THE STRUCTURE!! 484 */ 485 u32 per_frame_setting; 486 }; 487 488 #define ATOMISP_GAMMA_TABLE_SIZE 1024 489 struct atomisp_gamma_table { 490 unsigned short data[ATOMISP_GAMMA_TABLE_SIZE]; 491 }; 492 493 /* 494 * Morphing table for advanced ISP. 495 * Each line of width elements takes up COORD_TABLE_EXT_WIDTH elements in memory. 496 */ 497 #define ATOMISP_MORPH_TABLE_NUM_PLANES 6 498 struct atomisp_morph_table { 499 unsigned int enabled; 500 501 unsigned int height; 502 unsigned int width; /* number of valid elements per line */ 503 unsigned short __user *coordinates_x[ATOMISP_MORPH_TABLE_NUM_PLANES]; 504 unsigned short __user *coordinates_y[ATOMISP_MORPH_TABLE_NUM_PLANES]; 505 }; 506 507 #define ATOMISP_NUM_SC_COLORS 4 508 #define ATOMISP_SC_FLAG_QUERY BIT(0) 509 510 struct atomisp_shading_table { 511 __u32 enable; 512 513 __u32 sensor_width; 514 __u32 sensor_height; 515 __u32 width; 516 __u32 height; 517 __u32 fraction_bits; 518 519 __u16 *data[ATOMISP_NUM_SC_COLORS]; 520 }; 521 522 /* Parameter for MACC */ 523 #define ATOMISP_NUM_MACC_AXES 16 524 struct atomisp_macc_table { 525 short data[4 * ATOMISP_NUM_MACC_AXES]; 526 }; 527 528 struct atomisp_macc_config { 529 int color_effect; 530 struct atomisp_macc_table table; 531 }; 532 533 /* CTC parameter control */ 534 #define ATOMISP_CTC_TABLE_SIZE 1024 535 struct atomisp_ctc_table { 536 unsigned short data[ATOMISP_CTC_TABLE_SIZE]; 537 }; 538 539 /* Parameter for overlay image loading */ 540 struct atomisp_overlay { 541 /* 542 * The frame containing the overlay data. The overlay frame width should 543 * be a multiple of 2 * ISP_VEC_NELEMS. The overlay frame height 544 * should be a multiple of 2. 545 */ 546 struct v4l2_framebuffer *frame; 547 /* Y value of overlay background */ 548 unsigned char bg_y; 549 /* U value of overlay background */ 550 char bg_u; 551 /* V value of overlay background */ 552 char bg_v; 553 /* The blending percentage of input data for Y subpixels */ 554 unsigned char blend_input_perc_y; 555 /* The blending percentage of input data for U subpixels */ 556 unsigned char blend_input_perc_u; 557 /* The blending percentage of input data for V subpixels */ 558 unsigned char blend_input_perc_v; 559 /* The blending percentage of overlay data for Y subpixels */ 560 unsigned char blend_overlay_perc_y; 561 /* The blending percentage of overlay data for U subpixels */ 562 unsigned char blend_overlay_perc_u; 563 /* The blending percentage of overlay data for V subpixels */ 564 unsigned char blend_overlay_perc_v; 565 /* 566 * The overlay "start x" pixel position on the output frame. It should be a 567 * multiple of 2 * ISP_VEC_NELEMS. 568 */ 569 unsigned int overlay_start_x; 570 /* 571 * The overlay "start y" pixel position on the output frame. It should be a 572 * multiple of 2. 573 */ 574 unsigned int overlay_start_y; 575 }; 576 577 struct atomisp_exposure { 578 unsigned int integration_time[8]; 579 unsigned int shutter_speed[8]; 580 unsigned int gain[4]; 581 unsigned int aperture; 582 }; 583 584 /* For texture streaming. */ 585 struct atomisp_bc_video_package { 586 int ioctl_cmd; 587 int device_id; 588 int inputparam; 589 int outputparam; 590 }; 591 592 enum atomisp_focus_hp { 593 ATOMISP_FOCUS_HP_IN_PROGRESS = (1U << 2), 594 ATOMISP_FOCUS_HP_COMPLETE = (2U << 2), 595 ATOMISP_FOCUS_HP_FAILED = (3U << 2) 596 }; 597 598 /* Masks */ 599 #define ATOMISP_FOCUS_STATUS_MOVING BIT(0) 600 #define ATOMISP_FOCUS_STATUS_ACCEPTS_NEW_MOVE BIT(1) 601 #define ATOMISP_FOCUS_STATUS_HOME_POSITION (3U << 2) 602 603 enum atomisp_camera_port { 604 ATOMISP_CAMERA_PORT_SECONDARY, 605 ATOMISP_CAMERA_PORT_PRIMARY, 606 ATOMISP_CAMERA_PORT_TERTIARY, 607 ATOMISP_CAMERA_NR_PORTS 608 }; 609 610 enum atomisp_ext_isp_id { 611 EXT_ISP_CID_ISO = 0, 612 EXT_ISP_CID_CAPTURE_HDR, 613 EXT_ISP_CID_CAPTURE_LLS, 614 EXT_ISP_CID_FOCUS_MODE, 615 EXT_ISP_CID_FOCUS_EXECUTION, 616 EXT_ISP_CID_TOUCH_POSX, 617 EXT_ISP_CID_TOUCH_POSY, 618 EXT_ISP_CID_CAF_STATUS, 619 EXT_ISP_CID_AF_STATUS, 620 EXT_ISP_CID_GET_AF_MODE, 621 EXT_ISP_CID_CAPTURE_BURST, 622 EXT_ISP_CID_ZOOM, 623 EXT_ISP_CID_SHOT_MODE 624 }; 625 626 #define EXT_ISP_FOCUS_MODE_NORMAL 0 627 #define EXT_ISP_FOCUS_MODE_MACRO 1 628 #define EXT_ISP_FOCUS_MODE_TOUCH_AF 2 629 #define EXT_ISP_FOCUS_MODE_PREVIEW_CAF 3 630 #define EXT_ISP_FOCUS_MODE_MOVIE_CAF 4 631 #define EXT_ISP_FOCUS_MODE_FACE_CAF 5 632 #define EXT_ISP_FOCUS_MODE_TOUCH_MACRO 6 633 #define EXT_ISP_FOCUS_MODE_TOUCH_CAF 7 634 635 #define EXT_ISP_FOCUS_STOP 0 636 #define EXT_ISP_FOCUS_SEARCH 1 637 #define EXT_ISP_PAN_FOCUSING 2 638 639 #define EXT_ISP_CAF_RESTART_CHECK 1 640 #define EXT_ISP_CAF_STATUS_FOCUSING 2 641 #define EXT_ISP_CAF_STATUS_SUCCESS 3 642 #define EXT_ISP_CAF_STATUS_FAIL 4 643 644 #define EXT_ISP_AF_STATUS_INVALID 1 645 #define EXT_ISP_AF_STATUS_FOCUSING 2 646 #define EXT_ISP_AF_STATUS_SUCCESS 3 647 #define EXT_ISP_AF_STATUS_FAIL 4 648 649 enum atomisp_burst_capture_options { 650 EXT_ISP_BURST_CAPTURE_CTRL_START = 0, 651 EXT_ISP_BURST_CAPTURE_CTRL_STOP 652 }; 653 654 #define EXT_ISP_SHOT_MODE_AUTO 0 655 #define EXT_ISP_SHOT_MODE_BEAUTY_FACE 1 656 #define EXT_ISP_SHOT_MODE_BEST_PHOTO 2 657 #define EXT_ISP_SHOT_MODE_DRAMA 3 658 #define EXT_ISP_SHOT_MODE_BEST_FACE 4 659 #define EXT_ISP_SHOT_MODE_ERASER 5 660 #define EXT_ISP_SHOT_MODE_PANORAMA 6 661 #define EXT_ISP_SHOT_MODE_RICH_TONE_HDR 7 662 #define EXT_ISP_SHOT_MODE_NIGHT 8 663 #define EXT_ISP_SHOT_MODE_SOUND_SHOT 9 664 #define EXT_ISP_SHOT_MODE_ANIMATED_PHOTO 10 665 #define EXT_ISP_SHOT_MODE_SPORTS 11 666 667 /* Private IOCTLs for ISP */ 668 #define ATOMISP_IOC_G_XNR \ 669 _IOR('v', BASE_VIDIOC_PRIVATE + 0, int) 670 #define ATOMISP_IOC_S_XNR \ 671 _IOW('v', BASE_VIDIOC_PRIVATE + 0, int) 672 #define ATOMISP_IOC_G_NR \ 673 _IOR('v', BASE_VIDIOC_PRIVATE + 1, struct atomisp_nr_config) 674 #define ATOMISP_IOC_S_NR \ 675 _IOW('v', BASE_VIDIOC_PRIVATE + 1, struct atomisp_nr_config) 676 #define ATOMISP_IOC_G_TNR \ 677 _IOR('v', BASE_VIDIOC_PRIVATE + 2, struct atomisp_tnr_config) 678 #define ATOMISP_IOC_S_TNR \ 679 _IOW('v', BASE_VIDIOC_PRIVATE + 2, struct atomisp_tnr_config) 680 #define ATOMISP_IOC_G_HISTOGRAM \ 681 _IOWR('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram) 682 #define ATOMISP_IOC_S_HISTOGRAM \ 683 _IOW('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram) 684 #define ATOMISP_IOC_G_BLACK_LEVEL_COMP \ 685 _IOR('v', BASE_VIDIOC_PRIVATE + 4, struct atomisp_ob_config) 686 #define ATOMISP_IOC_S_BLACK_LEVEL_COMP \ 687 _IOW('v', BASE_VIDIOC_PRIVATE + 4, struct atomisp_ob_config) 688 #define ATOMISP_IOC_G_EE \ 689 _IOR('v', BASE_VIDIOC_PRIVATE + 5, struct atomisp_ee_config) 690 #define ATOMISP_IOC_S_EE \ 691 _IOW('v', BASE_VIDIOC_PRIVATE + 5, struct atomisp_ee_config) 692 /* 693 * Digital Image Stabilization: 694 * 1. get dis statistics: reads DIS statistics from ISP (every frame) 695 * 2. set dis coefficients: set DIS filter coefficients (one time) 696 * 3. set dis motion vector: set motion vector (result of DIS, every frame) 697 */ 698 #define ATOMISP_IOC_G_DIS_STAT \ 699 _IOWR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_statistics) 700 701 #define ATOMISP_IOC_G_DVS2_BQ_RESOLUTIONS \ 702 _IOR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs2_bq_resolutions) 703 704 #define ATOMISP_IOC_S_DIS_COEFS \ 705 _IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_coefficients) 706 707 #define ATOMISP_IOC_S_DIS_VECTOR \ 708 _IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs_6axis_config) 709 710 #define ATOMISP_IOC_G_3A_STAT \ 711 _IOWR('v', BASE_VIDIOC_PRIVATE + 7, struct atomisp_3a_statistics) 712 #define ATOMISP_IOC_G_ISP_PARM \ 713 _IOR('v', BASE_VIDIOC_PRIVATE + 8, struct atomisp_parm) 714 #define ATOMISP_IOC_S_ISP_PARM \ 715 _IOW('v', BASE_VIDIOC_PRIVATE + 8, struct atomisp_parm) 716 #define ATOMISP_IOC_G_ISP_GAMMA \ 717 _IOR('v', BASE_VIDIOC_PRIVATE + 9, struct atomisp_gamma_table) 718 #define ATOMISP_IOC_S_ISP_GAMMA \ 719 _IOW('v', BASE_VIDIOC_PRIVATE + 9, struct atomisp_gamma_table) 720 #define ATOMISP_IOC_G_ISP_GDC_TAB \ 721 _IOR('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table) 722 #define ATOMISP_IOC_S_ISP_GDC_TAB \ 723 _IOW('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table) 724 725 /* MACC parameter control */ 726 #define ATOMISP_IOC_G_ISP_MACC \ 727 _IOR('v', BASE_VIDIOC_PRIVATE + 12, struct atomisp_macc_config) 728 #define ATOMISP_IOC_S_ISP_MACC \ 729 _IOW('v', BASE_VIDIOC_PRIVATE + 12, struct atomisp_macc_config) 730 731 /* Defect pixel detection & correction */ 732 #define ATOMISP_IOC_G_ISP_BAD_PIXEL_DETECTION \ 733 _IOR('v', BASE_VIDIOC_PRIVATE + 13, struct atomisp_dp_config) 734 #define ATOMISP_IOC_S_ISP_BAD_PIXEL_DETECTION \ 735 _IOW('v', BASE_VIDIOC_PRIVATE + 13, struct atomisp_dp_config) 736 737 /* False color correction */ 738 #define ATOMISP_IOC_G_ISP_FALSE_COLOR_CORRECTION \ 739 _IOR('v', BASE_VIDIOC_PRIVATE + 14, struct atomisp_de_config) 740 #define ATOMISP_IOC_S_ISP_FALSE_COLOR_CORRECTION \ 741 _IOW('v', BASE_VIDIOC_PRIVATE + 14, struct atomisp_de_config) 742 743 /* CTC parameter control */ 744 #define ATOMISP_IOC_G_ISP_CTC \ 745 _IOR('v', BASE_VIDIOC_PRIVATE + 15, struct atomisp_ctc_table) 746 #define ATOMISP_IOC_S_ISP_CTC \ 747 _IOW('v', BASE_VIDIOC_PRIVATE + 15, struct atomisp_ctc_table) 748 749 /* White balance correction */ 750 #define ATOMISP_IOC_G_ISP_WHITE_BALANCE \ 751 _IOR('v', BASE_VIDIOC_PRIVATE + 16, struct atomisp_wb_config) 752 #define ATOMISP_IOC_S_ISP_WHITE_BALANCE \ 753 _IOW('v', BASE_VIDIOC_PRIVATE + 16, struct atomisp_wb_config) 754 755 /* FPN table loading */ 756 #define ATOMISP_IOC_S_ISP_FPN_TABLE \ 757 _IOW('v', BASE_VIDIOC_PRIVATE + 17, struct v4l2_framebuffer) 758 759 /* Overlay image loading */ 760 #define ATOMISP_IOC_G_ISP_OVERLAY \ 761 _IOWR('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay) 762 #define ATOMISP_IOC_S_ISP_OVERLAY \ 763 _IOW('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay) 764 765 /* BCD driver bridge */ 766 #define ATOMISP_IOC_CAMERA_BRIDGE \ 767 _IOWR('v', BASE_VIDIOC_PRIVATE + 19, struct atomisp_bc_video_package) 768 769 #define ATOMISP_IOC_S_EXPOSURE \ 770 _IOW('v', BASE_VIDIOC_PRIVATE + 21, struct atomisp_exposure) 771 772 /* White balance correction */ 773 #define ATOMISP_IOC_G_3A_CONFIG \ 774 _IOR('v', BASE_VIDIOC_PRIVATE + 23, struct atomisp_3a_config) 775 #define ATOMISP_IOC_S_3A_CONFIG \ 776 _IOW('v', BASE_VIDIOC_PRIVATE + 23, struct atomisp_3a_config) 777 778 /* LCS (shading) table write */ 779 #define ATOMISP_IOC_S_ISP_SHD_TAB \ 780 _IOWR('v', BASE_VIDIOC_PRIVATE + 27, struct atomisp_shading_table) 781 782 /* Gamma correction */ 783 #define ATOMISP_IOC_G_ISP_GAMMA_CORRECTION \ 784 _IOR('v', BASE_VIDIOC_PRIVATE + 28, struct atomisp_gc_config) 785 786 #define ATOMISP_IOC_S_ISP_GAMMA_CORRECTION \ 787 _IOW('v', BASE_VIDIOC_PRIVATE + 28, struct atomisp_gc_config) 788 789 #define ATOMISP_IOC_S_PARAMETERS \ 790 _IOW('v', BASE_VIDIOC_PRIVATE + 32, struct atomisp_parameters) 791 792 #define ATOMISP_IOC_EXP_ID_UNLOCK \ 793 _IOW('v', BASE_VIDIOC_PRIVATE + 36, int) 794 795 #define ATOMISP_IOC_EXP_ID_CAPTURE \ 796 _IOW('v', BASE_VIDIOC_PRIVATE + 37, int) 797 798 #define ATOMISP_IOC_S_ENABLE_DZ_CAPT_PIPE \ 799 _IOWR('v', BASE_VIDIOC_PRIVATE + 38, unsigned int) 800 801 #define ATOMISP_IOC_G_FORMATS_CONFIG \ 802 _IOR('v', BASE_VIDIOC_PRIVATE + 39, struct atomisp_formats_config) 803 804 #define ATOMISP_IOC_S_FORMATS_CONFIG \ 805 _IOW('v', BASE_VIDIOC_PRIVATE + 39, struct atomisp_formats_config) 806 807 #define ATOMISP_IOC_INJECT_A_FAKE_EVENT \ 808 _IOW('v', BASE_VIDIOC_PRIVATE + 42, int) 809 810 #define ATOMISP_IOC_S_ARRAY_RESOLUTION \ 811 _IOW('v', BASE_VIDIOC_PRIVATE + 45, struct atomisp_resolution) 812 813 /* For depth mode sensor frame sync compensation */ 814 #define ATOMISP_IOC_G_DEPTH_SYNC_COMP \ 815 _IOR('v', BASE_VIDIOC_PRIVATE + 46, unsigned int) 816 817 #define ATOMISP_IOC_S_SENSOR_EE_CONFIG \ 818 _IOW('v', BASE_VIDIOC_PRIVATE + 47, unsigned int) 819 820 /* 821 * Reserved ioctls. We have customer implementing it internally. 822 * We can't use both numbers to not cause ABI conflict. 823 * Anyway, those ioctls are hacks and not implemented by us: 824 * 825 * #define ATOMISP_IOC_G_SENSOR_REG \ 826 * _IOW('v', BASE_VIDIOC_PRIVATE + 55, struct atomisp_sensor_regs) 827 * #define ATOMISP_IOC_S_SENSOR_REG \ 828 * _IOW('v', BASE_VIDIOC_PRIVATE + 56, struct atomisp_sensor_regs) 829 */ 830 831 /* ISP Private control IDs */ 832 #define V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION \ 833 (V4L2_CID_PRIVATE_BASE + 0) 834 #define V4L2_CID_ATOMISP_POSTPROCESS_GDC_CAC \ 835 (V4L2_CID_PRIVATE_BASE + 1) 836 #define V4L2_CID_ATOMISP_VIDEO_STABLIZATION \ 837 (V4L2_CID_PRIVATE_BASE + 2) 838 #define V4L2_CID_ATOMISP_FIXED_PATTERN_NR \ 839 (V4L2_CID_PRIVATE_BASE + 3) 840 #define V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION \ 841 (V4L2_CID_PRIVATE_BASE + 4) 842 #define V4L2_CID_ATOMISP_LOW_LIGHT \ 843 (V4L2_CID_PRIVATE_BASE + 5) 844 845 /* 846 * Camera class: 847 * Exposure, Flash and privacy (indicator) light controls, to be upstreamed 848 */ 849 #define V4L2_CID_CAMERA_LASTP1 (V4L2_CID_CAMERA_CLASS_BASE + 1024) 850 851 #define V4L2_CID_RUN_MODE (V4L2_CID_CAMERA_LASTP1 + 20) 852 #define ATOMISP_RUN_MODE_VIDEO 1 853 #define ATOMISP_RUN_MODE_STILL_CAPTURE 2 854 #define ATOMISP_RUN_MODE_PREVIEW 3 855 #define ATOMISP_RUN_MODE_MIN 1 856 #define ATOMISP_RUN_MODE_MAX 3 857 858 #define V4L2_CID_ENABLE_VFPP (V4L2_CID_CAMERA_LASTP1 + 21) 859 #define V4L2_CID_ATOMISP_CONTINUOUS_MODE (V4L2_CID_CAMERA_LASTP1 + 22) 860 #define V4L2_CID_ATOMISP_CONTINUOUS_RAW_BUFFER_SIZE \ 861 (V4L2_CID_CAMERA_LASTP1 + 23) 862 #define V4L2_CID_ATOMISP_CONTINUOUS_VIEWFINDER \ 863 (V4L2_CID_CAMERA_LASTP1 + 24) 864 865 #define V4L2_CID_VFPP (V4L2_CID_CAMERA_LASTP1 + 25) 866 #define ATOMISP_VFPP_ENABLE 0 867 #define ATOMISP_VFPP_DISABLE_SCALER 1 868 #define ATOMISP_VFPP_DISABLE_LOWLAT 2 869 870 #define V4L2_CID_START_ZSL_CAPTURE (V4L2_CID_CAMERA_LASTP1 + 28) 871 /* Lock and unlock raw buffer */ 872 #define V4L2_CID_ENABLE_RAW_BUFFER_LOCK (V4L2_CID_CAMERA_LASTP1 + 29) 873 874 #define V4L2_CID_EXPOSURE_ZONE_NUM (V4L2_CID_CAMERA_LASTP1 + 31) 875 /* Disable digital zoom */ 876 #define V4L2_CID_DISABLE_DZ (V4L2_CID_CAMERA_LASTP1 + 32) 877 878 #define V4L2_CID_ATOMISP_SELECT_ISP_VERSION (V4L2_CID_CAMERA_LASTP1 + 38) 879 880 #define V4L2_BUF_FLAG_BUFFER_INVALID 0x0400 881 #define V4L2_BUF_FLAG_BUFFER_VALID 0x0800 882 883 #define V4L2_BUF_TYPE_VIDEO_CAPTURE_ION (V4L2_BUF_TYPE_PRIVATE + 1024) 884 885 #define V4L2_EVENT_ATOMISP_3A_STATS_READY (V4L2_EVENT_PRIVATE_START + 1) 886 #define V4L2_EVENT_ATOMISP_METADATA_READY (V4L2_EVENT_PRIVATE_START + 2) 887 #define V4L2_EVENT_ATOMISP_ACC_COMPLETE (V4L2_EVENT_PRIVATE_START + 4) 888 #define V4L2_EVENT_ATOMISP_PAUSE_BUFFER (V4L2_EVENT_PRIVATE_START + 5) 889 #define V4L2_EVENT_ATOMISP_CSS_RESET (V4L2_EVENT_PRIVATE_START + 6) 890 /* Non-standard color effects for V4L2_CID_COLORFX */ 891 enum { 892 V4L2_COLORFX_SKIN_WHITEN_LOW = 1001, 893 V4L2_COLORFX_SKIN_WHITEN_HIGH = 1002, 894 V4L2_COLORFX_WARM = 1003, 895 V4L2_COLORFX_COLD = 1004, 896 V4L2_COLORFX_WASHED = 1005, 897 V4L2_COLORFX_RED = 1006, 898 V4L2_COLORFX_GREEN = 1007, 899 V4L2_COLORFX_BLUE = 1008, 900 V4L2_COLORFX_PINK = 1009, 901 V4L2_COLORFX_YELLOW = 1010, 902 V4L2_COLORFX_PURPLE = 1011, 903 }; 904 905 #endif /* _ATOM_ISP_H */ 906