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