Manjunath Hadli | 9182540 | 2012-11-28 02:02:02 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Texas Instruments Inc |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation version 2. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | * |
| 17 | * Contributors: |
| 18 | * Manjunath Hadli <manjunath.hadli@ti.com> |
| 19 | * Prabhakar Lad <prabhakar.lad@ti.com> |
| 20 | */ |
| 21 | |
| 22 | #ifndef _DAVINCI_VPFE_USER_H |
| 23 | #define _DAVINCI_VPFE_USER_H |
| 24 | |
| 25 | #include <linux/types.h> |
| 26 | #include <linux/videodev2.h> |
| 27 | |
| 28 | /* |
| 29 | * Private IOCTL |
| 30 | * |
| 31 | * VIDIOC_VPFE_ISIF_S_RAW_PARAMS: Set raw params in isif |
| 32 | * VIDIOC_VPFE_ISIF_G_RAW_PARAMS: Get raw params from isif |
| 33 | * VIDIOC_VPFE_PRV_S_CONFIG: Set ipipe engine configuration |
| 34 | * VIDIOC_VPFE_PRV_G_CONFIG: Get ipipe engine configuration |
| 35 | * VIDIOC_VPFE_RSZ_S_CONFIG: Set resizer engine configuration |
| 36 | * VIDIOC_VPFE_RSZ_G_CONFIG: Get resizer engine configuration |
| 37 | */ |
| 38 | |
| 39 | #define VIDIOC_VPFE_ISIF_S_RAW_PARAMS \ |
| 40 | _IOW('V', BASE_VIDIOC_PRIVATE + 1, struct vpfe_isif_raw_config) |
| 41 | #define VIDIOC_VPFE_ISIF_G_RAW_PARAMS \ |
| 42 | _IOR('V', BASE_VIDIOC_PRIVATE + 2, struct vpfe_isif_raw_config) |
| 43 | #define VIDIOC_VPFE_IPIPE_S_CONFIG \ |
| 44 | _IOWR('P', BASE_VIDIOC_PRIVATE + 3, struct vpfe_ipipe_config) |
| 45 | #define VIDIOC_VPFE_IPIPE_G_CONFIG \ |
| 46 | _IOWR('P', BASE_VIDIOC_PRIVATE + 4, struct vpfe_ipipe_config) |
| 47 | #define VIDIOC_VPFE_RSZ_S_CONFIG \ |
| 48 | _IOWR('R', BASE_VIDIOC_PRIVATE + 5, struct vpfe_rsz_config) |
| 49 | #define VIDIOC_VPFE_RSZ_G_CONFIG \ |
| 50 | _IOWR('R', BASE_VIDIOC_PRIVATE + 6, struct vpfe_rsz_config) |
| 51 | |
| 52 | /* |
| 53 | * Private Control's for ISIF |
| 54 | */ |
| 55 | #define VPFE_ISIF_CID_CRGAIN (V4L2_CID_USER_BASE | 0xa001) |
| 56 | #define VPFE_ISIF_CID_CGRGAIN (V4L2_CID_USER_BASE | 0xa002) |
| 57 | #define VPFE_ISIF_CID_CGBGAIN (V4L2_CID_USER_BASE | 0xa003) |
| 58 | #define VPFE_ISIF_CID_CBGAIN (V4L2_CID_USER_BASE | 0xa004) |
| 59 | #define VPFE_ISIF_CID_GAIN_OFFSET (V4L2_CID_USER_BASE | 0xa005) |
| 60 | |
| 61 | /* |
| 62 | * Private Control's for ISIF and IPIPEIF |
| 63 | */ |
| 64 | #define VPFE_CID_DPCM_PREDICTOR (V4L2_CID_USER_BASE | 0xa006) |
| 65 | |
| 66 | /************************************************************************ |
| 67 | * Vertical Defect Correction parameters |
| 68 | ***********************************************************************/ |
| 69 | |
| 70 | /** |
| 71 | * vertical defect correction methods |
| 72 | */ |
| 73 | enum vpfe_isif_vdfc_corr_mode { |
| 74 | /* Defect level subtraction. Just fed through if saturating */ |
| 75 | VPFE_ISIF_VDFC_NORMAL, |
| 76 | /** |
| 77 | * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2 |
| 78 | * if data saturating |
| 79 | */ |
| 80 | VPFE_ISIF_VDFC_HORZ_INTERPOL_IF_SAT, |
| 81 | /* Horizontal interpolation (((i-2)+(i+2))/2) */ |
| 82 | VPFE_ISIF_VDFC_HORZ_INTERPOL |
| 83 | }; |
| 84 | |
| 85 | /** |
| 86 | * Max Size of the Vertical Defect Correction table |
| 87 | */ |
| 88 | #define VPFE_ISIF_VDFC_TABLE_SIZE 8 |
| 89 | |
| 90 | /** |
| 91 | * Values used for shifting up the vdfc defect level |
| 92 | */ |
| 93 | enum vpfe_isif_vdfc_shift { |
| 94 | /* No Shift */ |
| 95 | VPFE_ISIF_VDFC_NO_SHIFT, |
| 96 | /* Shift by 1 bit */ |
| 97 | VPFE_ISIF_VDFC_SHIFT_1, |
| 98 | /* Shift by 2 bit */ |
| 99 | VPFE_ISIF_VDFC_SHIFT_2, |
| 100 | /* Shift by 3 bit */ |
| 101 | VPFE_ISIF_VDFC_SHIFT_3, |
| 102 | /* Shift by 4 bit */ |
| 103 | VPFE_ISIF_VDFC_SHIFT_4 |
| 104 | }; |
| 105 | |
| 106 | /** |
| 107 | * Defect Correction (DFC) table entry |
| 108 | */ |
| 109 | struct vpfe_isif_vdfc_entry { |
| 110 | /* vertical position of defect */ |
| 111 | unsigned short pos_vert; |
| 112 | /* horizontal position of defect */ |
| 113 | unsigned short pos_horz; |
| 114 | /** |
| 115 | * Defect level of Vertical line defect position. This is subtracted |
| 116 | * from the data at the defect position |
| 117 | */ |
| 118 | unsigned char level_at_pos; |
| 119 | /** |
| 120 | * Defect level of the pixels upper than the vertical line defect. |
| 121 | * This is subtracted from the data |
| 122 | */ |
| 123 | unsigned char level_up_pixels; |
| 124 | /** |
| 125 | * Defect level of the pixels lower than the vertical line defect. |
| 126 | * This is subtracted from the data |
| 127 | */ |
| 128 | unsigned char level_low_pixels; |
| 129 | }; |
| 130 | |
| 131 | /** |
| 132 | * Structure for Defect Correction (DFC) parameter |
| 133 | */ |
| 134 | struct vpfe_isif_dfc { |
| 135 | /* enable vertical defect correction */ |
| 136 | unsigned char en; |
| 137 | /* Correction methods */ |
| 138 | enum vpfe_isif_vdfc_corr_mode corr_mode; |
| 139 | /** |
| 140 | * 0 - whole line corrected, 1 - not |
| 141 | * pixels upper than the defect |
| 142 | */ |
| 143 | unsigned char corr_whole_line; |
| 144 | /** |
| 145 | * defect level shift value. level_at_pos, level_upper_pos, |
| 146 | * and level_lower_pos can be shifted up by this value |
| 147 | */ |
| 148 | enum vpfe_isif_vdfc_shift def_level_shift; |
| 149 | /* defect saturation level */ |
| 150 | unsigned short def_sat_level; |
| 151 | /* number of vertical defects. Max is VPFE_ISIF_VDFC_TABLE_SIZE */ |
| 152 | short num_vdefects; |
| 153 | /* VDFC table ptr */ |
| 154 | struct vpfe_isif_vdfc_entry table[VPFE_ISIF_VDFC_TABLE_SIZE]; |
| 155 | }; |
| 156 | |
| 157 | /************************************************************************ |
| 158 | * Digital/Black clamp or DC Subtract parameters |
| 159 | ************************************************************************/ |
| 160 | /** |
| 161 | * Horizontal Black Clamp modes |
| 162 | */ |
| 163 | enum vpfe_isif_horz_bc_mode { |
| 164 | /** |
| 165 | * Horizontal clamp disabled. Only vertical clamp |
| 166 | * value is subtracted |
| 167 | */ |
| 168 | VPFE_ISIF_HORZ_BC_DISABLE, |
| 169 | /** |
| 170 | * Horizontal clamp value is calculated and subtracted |
| 171 | * from image data along with vertical clamp value |
| 172 | */ |
| 173 | VPFE_ISIF_HORZ_BC_CLAMP_CALC_ENABLED, |
| 174 | /** |
| 175 | * Horizontal clamp value calculated from previous image |
| 176 | * is subtracted from image data along with vertical clamp |
| 177 | * value. How the horizontal clamp value for the first image |
| 178 | * is calculated in this case ??? |
| 179 | */ |
| 180 | VPFE_ISIF_HORZ_BC_CLAMP_NOT_UPDATED |
| 181 | }; |
| 182 | |
| 183 | /** |
| 184 | * Base window selection for Horizontal Black Clamp calculations |
| 185 | */ |
| 186 | enum vpfe_isif_horz_bc_base_win_sel { |
| 187 | /* Select Most left window for bc calculation */ |
| 188 | VPFE_ISIF_SEL_MOST_LEFT_WIN, |
| 189 | |
| 190 | /* Select Most right window for bc calculation */ |
| 191 | VPFE_ISIF_SEL_MOST_RIGHT_WIN, |
| 192 | }; |
| 193 | |
| 194 | /* Size of window in horizontal direction for horizontal bc */ |
| 195 | enum vpfe_isif_horz_bc_sz_h { |
| 196 | VPFE_ISIF_HORZ_BC_SZ_H_2PIXELS, |
| 197 | VPFE_ISIF_HORZ_BC_SZ_H_4PIXELS, |
| 198 | VPFE_ISIF_HORZ_BC_SZ_H_8PIXELS, |
| 199 | VPFE_ISIF_HORZ_BC_SZ_H_16PIXELS |
| 200 | }; |
| 201 | |
| 202 | /* Size of window in vertcal direction for vertical bc */ |
| 203 | enum vpfe_isif_horz_bc_sz_v { |
| 204 | VPFE_ISIF_HORZ_BC_SZ_H_32PIXELS, |
| 205 | VPFE_ISIF_HORZ_BC_SZ_H_64PIXELS, |
| 206 | VPFE_ISIF_HORZ_BC_SZ_H_128PIXELS, |
| 207 | VPFE_ISIF_HORZ_BC_SZ_H_256PIXELS |
| 208 | }; |
| 209 | |
| 210 | /** |
| 211 | * Structure for Horizontal Black Clamp config params |
| 212 | */ |
| 213 | struct vpfe_isif_horz_bclamp { |
| 214 | /* horizontal clamp mode */ |
| 215 | enum vpfe_isif_horz_bc_mode mode; |
| 216 | /** |
| 217 | * pixel value limit enable. |
| 218 | * 0 - limit disabled |
| 219 | * 1 - pixel value limited to 1023 |
| 220 | */ |
| 221 | unsigned char clamp_pix_limit; |
| 222 | /** |
| 223 | * Select most left or right window for clamp val |
| 224 | * calculation |
| 225 | */ |
| 226 | enum vpfe_isif_horz_bc_base_win_sel base_win_sel_calc; |
| 227 | /* Window count per color for calculation. range 1-32 */ |
| 228 | unsigned char win_count_calc; |
| 229 | /* Window start position - horizontal for calculation. 0 - 8191 */ |
| 230 | unsigned short win_start_h_calc; |
| 231 | /* Window start position - vertical for calculation 0 - 8191 */ |
| 232 | unsigned short win_start_v_calc; |
| 233 | /* Width of the sample window in pixels for calculation */ |
| 234 | enum vpfe_isif_horz_bc_sz_h win_h_sz_calc; |
| 235 | /* Height of the sample window in pixels for calculation */ |
| 236 | enum vpfe_isif_horz_bc_sz_v win_v_sz_calc; |
| 237 | }; |
| 238 | |
| 239 | /** |
| 240 | * Black Clamp vertical reset values |
| 241 | */ |
| 242 | enum vpfe_isif_vert_bc_reset_val_sel { |
| 243 | /* Reset value used is the clamp value calculated */ |
| 244 | VPFE_ISIF_VERT_BC_USE_HORZ_CLAMP_VAL, |
| 245 | /* Reset value used is reset_clamp_val configured */ |
| 246 | VPFE_ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL, |
| 247 | /* No update, previous image value is used */ |
| 248 | VPFE_ISIF_VERT_BC_NO_UPDATE |
| 249 | }; |
| 250 | |
| 251 | enum vpfe_isif_vert_bc_sz_h { |
| 252 | VPFE_ISIF_VERT_BC_SZ_H_2PIXELS, |
| 253 | VPFE_ISIF_VERT_BC_SZ_H_4PIXELS, |
| 254 | VPFE_ISIF_VERT_BC_SZ_H_8PIXELS, |
| 255 | VPFE_ISIF_VERT_BC_SZ_H_16PIXELS, |
| 256 | VPFE_ISIF_VERT_BC_SZ_H_32PIXELS, |
| 257 | VPFE_ISIF_VERT_BC_SZ_H_64PIXELS |
| 258 | }; |
| 259 | |
| 260 | /** |
| 261 | * Structure for Vertical Black Clamp configuration params |
| 262 | */ |
| 263 | struct vpfe_isif_vert_bclamp { |
| 264 | /* Reset value selection for vertical clamp calculation */ |
| 265 | enum vpfe_isif_vert_bc_reset_val_sel reset_val_sel; |
| 266 | /* U12 value if reset_sel = ISIF_BC_VERT_USE_CONFIG_CLAMP_VAL */ |
| 267 | unsigned short reset_clamp_val; |
| 268 | /** |
| 269 | * U8Q8. Line average coefficient used in vertical clamp |
| 270 | * calculation |
| 271 | */ |
| 272 | unsigned char line_ave_coef; |
| 273 | /* Width in pixels of the optical black region used for calculation. */ |
| 274 | enum vpfe_isif_vert_bc_sz_h ob_h_sz_calc; |
| 275 | /* Height of the optical black region for calculation */ |
| 276 | unsigned short ob_v_sz_calc; |
| 277 | /* Optical black region start position - horizontal. 0 - 8191 */ |
| 278 | unsigned short ob_start_h; |
| 279 | /* Optical black region start position - vertical 0 - 8191 */ |
| 280 | unsigned short ob_start_v; |
| 281 | }; |
| 282 | |
| 283 | /** |
| 284 | * Structure for Black Clamp configuration params |
| 285 | */ |
| 286 | struct vpfe_isif_black_clamp { |
| 287 | /** |
| 288 | * this offset value is added irrespective of the clamp |
| 289 | * enable status. S13 |
| 290 | */ |
| 291 | unsigned short dc_offset; |
| 292 | /** |
| 293 | * Enable black/digital clamp value to be subtracted |
| 294 | * from the image data |
| 295 | */ |
| 296 | unsigned char en; |
| 297 | /** |
| 298 | * black clamp mode. same/separate clamp for 4 colors |
| 299 | * 0 - disable - same clamp value for all colors |
| 300 | * 1 - clamp value calculated separately for all colors |
| 301 | */ |
| 302 | unsigned char bc_mode_color; |
| 303 | /* Vertical start position for bc subtraction */ |
| 304 | unsigned short vert_start_sub; |
| 305 | /* Black clamp for horizontal direction */ |
| 306 | struct vpfe_isif_horz_bclamp horz; |
| 307 | /* Black clamp for vertical direction */ |
| 308 | struct vpfe_isif_vert_bclamp vert; |
| 309 | }; |
| 310 | |
| 311 | /************************************************************************* |
| 312 | ** Color Space Conversion (CSC) |
| 313 | *************************************************************************/ |
| 314 | /** |
| 315 | * Number of Coefficient values used for CSC |
| 316 | */ |
| 317 | #define VPFE_ISIF_CSC_NUM_COEFF 16 |
| 318 | |
| 319 | struct float_8_bit { |
| 320 | /* 8 bit integer part */ |
| 321 | __u8 integer; |
| 322 | /* 8 bit decimal part */ |
| 323 | __u8 decimal; |
| 324 | }; |
| 325 | |
| 326 | struct float_16_bit { |
| 327 | /* 16 bit integer part */ |
| 328 | __u16 integer; |
| 329 | /* 16 bit decimal part */ |
| 330 | __u16 decimal; |
| 331 | }; |
| 332 | |
| 333 | /************************************************************************* |
| 334 | ** Color Space Conversion parameters |
| 335 | *************************************************************************/ |
| 336 | /** |
| 337 | * Structure used for CSC config params |
| 338 | */ |
| 339 | struct vpfe_isif_color_space_conv { |
| 340 | /* Enable color space conversion */ |
| 341 | unsigned char en; |
| 342 | /** |
| 343 | * csc coefficient table. S8Q5, M00 at index 0, M01 at index 1, and |
| 344 | * so forth |
| 345 | */ |
| 346 | struct float_8_bit coeff[VPFE_ISIF_CSC_NUM_COEFF]; |
| 347 | }; |
| 348 | |
| 349 | enum vpfe_isif_datasft { |
| 350 | /* No Shift */ |
| 351 | VPFE_ISIF_NO_SHIFT, |
| 352 | /* 1 bit Shift */ |
| 353 | VPFE_ISIF_1BIT_SHIFT, |
| 354 | /* 2 bit Shift */ |
| 355 | VPFE_ISIF_2BIT_SHIFT, |
| 356 | /* 3 bit Shift */ |
| 357 | VPFE_ISIF_3BIT_SHIFT, |
| 358 | /* 4 bit Shift */ |
| 359 | VPFE_ISIF_4BIT_SHIFT, |
| 360 | /* 5 bit Shift */ |
| 361 | VPFE_ISIF_5BIT_SHIFT, |
| 362 | /* 6 bit Shift */ |
| 363 | VPFE_ISIF_6BIT_SHIFT |
| 364 | }; |
| 365 | |
| 366 | #define VPFE_ISIF_LINEAR_TAB_SIZE 192 |
| 367 | /************************************************************************* |
| 368 | ** Linearization parameters |
| 369 | *************************************************************************/ |
| 370 | /** |
| 371 | * Structure for Sensor data linearization |
| 372 | */ |
| 373 | struct vpfe_isif_linearize { |
| 374 | /* Enable or Disable linearization of data */ |
| 375 | unsigned char en; |
| 376 | /* Shift value applied */ |
| 377 | enum vpfe_isif_datasft corr_shft; |
| 378 | /* scale factor applied U11Q10 */ |
| 379 | struct float_16_bit scale_fact; |
| 380 | /* Size of the linear table */ |
| 381 | unsigned short table[VPFE_ISIF_LINEAR_TAB_SIZE]; |
| 382 | }; |
| 383 | |
| 384 | /************************************************************************* |
| 385 | ** ISIF Raw configuration parameters |
| 386 | *************************************************************************/ |
| 387 | enum vpfe_isif_fmt_mode { |
| 388 | VPFE_ISIF_SPLIT, |
| 389 | VPFE_ISIF_COMBINE |
| 390 | }; |
| 391 | |
| 392 | enum vpfe_isif_lnum { |
| 393 | VPFE_ISIF_1LINE, |
| 394 | VPFE_ISIF_2LINES, |
| 395 | VPFE_ISIF_3LINES, |
| 396 | VPFE_ISIF_4LINES |
| 397 | }; |
| 398 | |
| 399 | enum vpfe_isif_line { |
| 400 | VPFE_ISIF_1STLINE, |
| 401 | VPFE_ISIF_2NDLINE, |
| 402 | VPFE_ISIF_3RDLINE, |
| 403 | VPFE_ISIF_4THLINE |
| 404 | }; |
| 405 | |
| 406 | struct vpfe_isif_fmtplen { |
| 407 | /** |
| 408 | * number of program entries for SET0, range 1 - 16 |
| 409 | * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is |
| 410 | * ISIF_COMBINE |
| 411 | */ |
| 412 | unsigned short plen0; |
| 413 | /** |
| 414 | * number of program entries for SET1, range 1 - 16 |
| 415 | * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is |
| 416 | * ISIF_COMBINE |
| 417 | */ |
| 418 | unsigned short plen1; |
| 419 | /** |
| 420 | * number of program entries for SET2, range 1 - 16 |
| 421 | * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is |
| 422 | * ISIF_COMBINE |
| 423 | */ |
| 424 | unsigned short plen2; |
| 425 | /** |
| 426 | * number of program entries for SET3, range 1 - 16 |
| 427 | * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is |
| 428 | * ISIF_COMBINE |
| 429 | */ |
| 430 | unsigned short plen3; |
| 431 | }; |
| 432 | |
| 433 | struct vpfe_isif_fmt_cfg { |
| 434 | /* Split or combine or line alternate */ |
| 435 | enum vpfe_isif_fmt_mode fmtmode; |
| 436 | /* enable or disable line alternating mode */ |
| 437 | unsigned char ln_alter_en; |
| 438 | /* Split/combine line number */ |
| 439 | enum vpfe_isif_lnum lnum; |
| 440 | /* Address increment Range 1 - 16 */ |
| 441 | unsigned int addrinc; |
| 442 | }; |
| 443 | |
| 444 | struct vpfe_isif_fmt_addr_ptr { |
| 445 | /* Initial address */ |
| 446 | unsigned int init_addr; |
| 447 | /* output line number */ |
| 448 | enum vpfe_isif_line out_line; |
| 449 | }; |
| 450 | |
| 451 | struct vpfe_isif_fmtpgm_ap { |
| 452 | /* program address pointer */ |
| 453 | unsigned char pgm_aptr; |
| 454 | /* program address increment or decrement */ |
| 455 | unsigned char pgmupdt; |
| 456 | }; |
| 457 | |
| 458 | struct vpfe_isif_data_formatter { |
| 459 | /* Enable/Disable data formatter */ |
| 460 | unsigned char en; |
| 461 | /* data formatter configuration */ |
| 462 | struct vpfe_isif_fmt_cfg cfg; |
| 463 | /* Formatter program entries length */ |
| 464 | struct vpfe_isif_fmtplen plen; |
| 465 | /* first pixel in a line fed to formatter */ |
| 466 | unsigned short fmtrlen; |
| 467 | /* HD interval for output line. Only valid when split line */ |
| 468 | unsigned short fmthcnt; |
| 469 | /* formatter address pointers */ |
| 470 | struct vpfe_isif_fmt_addr_ptr fmtaddr_ptr[16]; |
| 471 | /* program enable/disable */ |
| 472 | unsigned char pgm_en[32]; |
| 473 | /* program address pointers */ |
| 474 | struct vpfe_isif_fmtpgm_ap fmtpgm_ap[32]; |
| 475 | }; |
| 476 | |
| 477 | struct vpfe_isif_df_csc { |
| 478 | /* Color Space Conversion configuration, 0 - csc, 1 - df */ |
| 479 | unsigned int df_or_csc; |
| 480 | /* csc configuration valid if df_or_csc is 0 */ |
| 481 | struct vpfe_isif_color_space_conv csc; |
| 482 | /* data formatter configuration valid if df_or_csc is 1 */ |
| 483 | struct vpfe_isif_data_formatter df; |
| 484 | /* start pixel in a line at the input */ |
| 485 | unsigned int start_pix; |
| 486 | /* number of pixels in input line */ |
| 487 | unsigned int num_pixels; |
| 488 | /* start line at the input */ |
| 489 | unsigned int start_line; |
| 490 | /* number of lines at the input */ |
| 491 | unsigned int num_lines; |
| 492 | }; |
| 493 | |
| 494 | struct vpfe_isif_gain_offsets_adj { |
| 495 | /* Enable or Disable Gain adjustment for SDRAM data */ |
| 496 | unsigned char gain_sdram_en; |
| 497 | /* Enable or Disable Gain adjustment for IPIPE data */ |
| 498 | unsigned char gain_ipipe_en; |
| 499 | /* Enable or Disable Gain adjustment for H3A data */ |
| 500 | unsigned char gain_h3a_en; |
| 501 | /* Enable or Disable Gain adjustment for SDRAM data */ |
| 502 | unsigned char offset_sdram_en; |
| 503 | /* Enable or Disable Gain adjustment for IPIPE data */ |
| 504 | unsigned char offset_ipipe_en; |
| 505 | /* Enable or Disable Gain adjustment for H3A data */ |
| 506 | unsigned char offset_h3a_en; |
| 507 | }; |
| 508 | |
| 509 | struct vpfe_isif_cul { |
| 510 | /* Horizontal Cull pattern for odd lines */ |
| 511 | unsigned char hcpat_odd; |
| 512 | /* Horizontal Cull pattern for even lines */ |
| 513 | unsigned char hcpat_even; |
| 514 | /* Vertical Cull pattern */ |
| 515 | unsigned char vcpat; |
| 516 | /* Enable or disable lpf. Apply when cull is enabled */ |
| 517 | unsigned char en_lpf; |
| 518 | }; |
| 519 | |
| 520 | /* all the stuff in this struct will be provided by userland */ |
| 521 | struct vpfe_isif_raw_config { |
| 522 | /* Linearization parameters for image sensor data input */ |
| 523 | struct vpfe_isif_linearize linearize; |
| 524 | /* Data formatter or CSC */ |
| 525 | struct vpfe_isif_df_csc df_csc; |
| 526 | /* Defect Pixel Correction (DFC) confguration */ |
| 527 | struct vpfe_isif_dfc dfc; |
| 528 | /* Black/Digital Clamp configuration */ |
| 529 | struct vpfe_isif_black_clamp bclamp; |
| 530 | /* Gain, offset adjustments */ |
| 531 | struct vpfe_isif_gain_offsets_adj gain_offset; |
| 532 | /* Culling */ |
| 533 | struct vpfe_isif_cul culling; |
| 534 | /* horizontal offset for Gain/LSC/DFC */ |
| 535 | unsigned short horz_offset; |
| 536 | /* vertical offset for Gain/LSC/DFC */ |
| 537 | unsigned short vert_offset; |
| 538 | }; |
| 539 | |
| 540 | /********************************************************************** |
Joseph Marrero | 7d3ccfe | 2015-11-25 20:38:43 -0200 | [diff] [blame] | 541 | * IPIPE API Structures |
Manjunath Hadli | 9182540 | 2012-11-28 02:02:02 -0300 | [diff] [blame] | 542 | **********************************************************************/ |
| 543 | |
| 544 | /* IPIPE module configurations */ |
| 545 | |
| 546 | /* IPIPE input configuration */ |
| 547 | #define VPFE_IPIPE_INPUT_CONFIG (1 << 0) |
| 548 | /* LUT based Defect Pixel Correction */ |
| 549 | #define VPFE_IPIPE_LUTDPC (1 << 1) |
| 550 | /* On the fly (OTF) Defect Pixel Correction */ |
| 551 | #define VPFE_IPIPE_OTFDPC (1 << 2) |
| 552 | /* Noise Filter - 1 */ |
| 553 | #define VPFE_IPIPE_NF1 (1 << 3) |
| 554 | /* Noise Filter - 2 */ |
| 555 | #define VPFE_IPIPE_NF2 (1 << 4) |
| 556 | /* White Balance. Also a control ID */ |
| 557 | #define VPFE_IPIPE_WB (1 << 5) |
| 558 | /* 1st RGB to RBG Blend module */ |
| 559 | #define VPFE_IPIPE_RGB2RGB_1 (1 << 6) |
| 560 | /* 2nd RGB to RBG Blend module */ |
| 561 | #define VPFE_IPIPE_RGB2RGB_2 (1 << 7) |
| 562 | /* Gamma Correction */ |
| 563 | #define VPFE_IPIPE_GAMMA (1 << 8) |
| 564 | /* 3D LUT color conversion */ |
| 565 | #define VPFE_IPIPE_3D_LUT (1 << 9) |
| 566 | /* RGB to YCbCr module */ |
| 567 | #define VPFE_IPIPE_RGB2YUV (1 << 10) |
| 568 | /* YUV 422 conversion module */ |
| 569 | #define VPFE_IPIPE_YUV422_CONV (1 << 11) |
| 570 | /* Edge Enhancement */ |
| 571 | #define VPFE_IPIPE_YEE (1 << 12) |
| 572 | /* Green Imbalance Correction */ |
| 573 | #define VPFE_IPIPE_GIC (1 << 13) |
| 574 | /* CFA Interpolation */ |
| 575 | #define VPFE_IPIPE_CFA (1 << 14) |
| 576 | /* Chroma Artifact Reduction */ |
| 577 | #define VPFE_IPIPE_CAR (1 << 15) |
| 578 | /* Chroma Gain Suppression */ |
| 579 | #define VPFE_IPIPE_CGS (1 << 16) |
| 580 | /* Global brightness and contrast control */ |
| 581 | #define VPFE_IPIPE_GBCE (1 << 17) |
| 582 | |
| 583 | #define VPFE_IPIPE_MAX_MODULES 18 |
| 584 | |
| 585 | struct ipipe_float_u16 { |
| 586 | unsigned short integer; |
| 587 | unsigned short decimal; |
| 588 | }; |
| 589 | |
| 590 | struct ipipe_float_s16 { |
| 591 | short integer; |
| 592 | unsigned short decimal; |
| 593 | }; |
| 594 | |
| 595 | struct ipipe_float_u8 { |
| 596 | unsigned char integer; |
| 597 | unsigned char decimal; |
| 598 | }; |
| 599 | |
| 600 | /* Copy method selection for vertical correction |
| 601 | * Used when ipipe_dfc_corr_meth is IPIPE_DPC_CTORB_AFTER_HINT |
| 602 | */ |
| 603 | enum vpfe_ipipe_dpc_corr_meth { |
| 604 | /* replace by black or white dot specified by repl_white */ |
| 605 | VPFE_IPIPE_DPC_REPL_BY_DOT = 0, |
| 606 | /* Copy from left */ |
| 607 | VPFE_IPIPE_DPC_CL = 1, |
| 608 | /* Copy from right */ |
| 609 | VPFE_IPIPE_DPC_CR = 2, |
| 610 | /* Horizontal interpolation */ |
| 611 | VPFE_IPIPE_DPC_H_INTP = 3, |
| 612 | /* Vertical interpolation */ |
| 613 | VPFE_IPIPE_DPC_V_INTP = 4, |
| 614 | /* Copy from top */ |
| 615 | VPFE_IPIPE_DPC_CT = 5, |
| 616 | /* Copy from bottom */ |
| 617 | VPFE_IPIPE_DPC_CB = 6, |
| 618 | /* 2D interpolation */ |
| 619 | VPFE_IPIPE_DPC_2D_INTP = 7, |
| 620 | }; |
| 621 | |
| 622 | struct vpfe_ipipe_lutdpc_entry { |
| 623 | /* Horizontal position */ |
| 624 | unsigned short horz_pos; |
| 625 | /* vertical position */ |
| 626 | unsigned short vert_pos; |
| 627 | enum vpfe_ipipe_dpc_corr_meth method; |
| 628 | }; |
| 629 | |
| 630 | #define VPFE_IPIPE_MAX_SIZE_DPC 256 |
| 631 | |
| 632 | /* Structure for configuring DPC module */ |
| 633 | struct vpfe_ipipe_lutdpc { |
| 634 | /* 0 - disable, 1 - enable */ |
| 635 | unsigned char en; |
| 636 | /* 0 - replace with black dot, 1 - white dot when correction |
| 637 | * method is IPIPE_DFC_REPL_BY_DOT=0, |
| 638 | */ |
| 639 | unsigned char repl_white; |
| 640 | /* number of entries in the correction table. Currently only |
| 641 | * support up-to 256 entries. infinite mode is not supported |
| 642 | */ |
| 643 | unsigned short dpc_size; |
| 644 | struct vpfe_ipipe_lutdpc_entry table[VPFE_IPIPE_MAX_SIZE_DPC]; |
| 645 | }; |
| 646 | |
| 647 | enum vpfe_ipipe_otfdpc_det_meth { |
| 648 | VPFE_IPIPE_DPC_OTF_MIN_MAX, |
| 649 | VPFE_IPIPE_DPC_OTF_MIN_MAX2 |
| 650 | }; |
| 651 | |
| 652 | struct vpfe_ipipe_otfdpc_thr { |
| 653 | unsigned short r; |
| 654 | unsigned short gr; |
| 655 | unsigned short gb; |
| 656 | unsigned short b; |
| 657 | }; |
| 658 | |
| 659 | enum vpfe_ipipe_otfdpc_alg { |
| 660 | VPFE_IPIPE_OTFDPC_2_0, |
| 661 | VPFE_IPIPE_OTFDPC_3_0 |
| 662 | }; |
| 663 | |
| 664 | struct vpfe_ipipe_otfdpc_2_0_cfg { |
| 665 | /* defect detection threshold for MIN_MAX2 method (DPC 2.0 alg) */ |
| 666 | struct vpfe_ipipe_otfdpc_thr det_thr; |
| 667 | /* defect correction threshold for MIN_MAX2 method (DPC 2.0 alg) or |
| 668 | * maximum value for MIN_MAX method |
| 669 | */ |
| 670 | struct vpfe_ipipe_otfdpc_thr corr_thr; |
| 671 | }; |
| 672 | |
| 673 | struct vpfe_ipipe_otfdpc_3_0_cfg { |
| 674 | /* DPC3.0 activity adj shf. activity = (max2-min2) >> (6 -shf) |
| 675 | */ |
| 676 | unsigned char act_adj_shf; |
| 677 | /* DPC3.0 detection threshold, THR */ |
| 678 | unsigned short det_thr; |
| 679 | /* DPC3.0 detection threshold slope, SLP */ |
| 680 | unsigned short det_slp; |
| 681 | /* DPC3.0 detection threshold min, MIN */ |
| 682 | unsigned short det_thr_min; |
| 683 | /* DPC3.0 detection threshold max, MAX */ |
| 684 | unsigned short det_thr_max; |
| 685 | /* DPC3.0 correction threshold, THR */ |
| 686 | unsigned short corr_thr; |
| 687 | /* DPC3.0 correction threshold slope, SLP */ |
| 688 | unsigned short corr_slp; |
| 689 | /* DPC3.0 correction threshold min, MIN */ |
| 690 | unsigned short corr_thr_min; |
| 691 | /* DPC3.0 correction threshold max, MAX */ |
| 692 | unsigned short corr_thr_max; |
| 693 | }; |
| 694 | |
| 695 | struct vpfe_ipipe_otfdpc { |
| 696 | /* 0 - disable, 1 - enable */ |
| 697 | unsigned char en; |
| 698 | /* defect detection method */ |
| 699 | enum vpfe_ipipe_otfdpc_det_meth det_method; |
| 700 | /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is |
| 701 | * used |
| 702 | */ |
| 703 | enum vpfe_ipipe_otfdpc_alg alg; |
| 704 | union { |
| 705 | /* if alg is IPIPE_OTFDPC_2_0 */ |
| 706 | struct vpfe_ipipe_otfdpc_2_0_cfg dpc_2_0; |
| 707 | /* if alg is IPIPE_OTFDPC_3_0 */ |
| 708 | struct vpfe_ipipe_otfdpc_3_0_cfg dpc_3_0; |
| 709 | } alg_cfg; |
| 710 | }; |
| 711 | |
| 712 | /* Threshold values table size */ |
| 713 | #define VPFE_IPIPE_NF_THR_TABLE_SIZE 8 |
| 714 | /* Intensity values table size */ |
| 715 | #define VPFE_IPIPE_NF_STR_TABLE_SIZE 8 |
| 716 | |
| 717 | /* NF, sampling method for green pixels */ |
| 718 | enum vpfe_ipipe_nf_sampl_meth { |
| 719 | /* Same as R or B */ |
| 720 | VPFE_IPIPE_NF_BOX, |
| 721 | /* Diamond mode */ |
| 722 | VPFE_IPIPE_NF_DIAMOND |
| 723 | }; |
| 724 | |
| 725 | /* Structure for configuring NF module */ |
| 726 | struct vpfe_ipipe_nf { |
| 727 | /* 0 - disable, 1 - enable */ |
| 728 | unsigned char en; |
| 729 | /* Sampling method for green pixels */ |
| 730 | enum vpfe_ipipe_nf_sampl_meth gr_sample_meth; |
| 731 | /* Down shift value in LUT reference address |
| 732 | */ |
| 733 | unsigned char shft_val; |
| 734 | /* Spread value in NF algorithm |
| 735 | */ |
| 736 | unsigned char spread_val; |
| 737 | /* Apply LSC gain to threshold. Enable this only if |
| 738 | * LSC is enabled in ISIF |
| 739 | */ |
| 740 | unsigned char apply_lsc_gain; |
| 741 | /* Threshold values table */ |
| 742 | unsigned short thr[VPFE_IPIPE_NF_THR_TABLE_SIZE]; |
| 743 | /* intensity values table */ |
| 744 | unsigned char str[VPFE_IPIPE_NF_STR_TABLE_SIZE]; |
| 745 | /* Edge detection minimum threshold */ |
| 746 | unsigned short edge_det_min_thr; |
| 747 | /* Edge detection maximum threshold */ |
| 748 | unsigned short edge_det_max_thr; |
| 749 | }; |
| 750 | |
| 751 | enum vpfe_ipipe_gic_alg { |
| 752 | VPFE_IPIPE_GIC_ALG_CONST_GAIN, |
| 753 | VPFE_IPIPE_GIC_ALG_ADAPT_GAIN |
| 754 | }; |
| 755 | |
| 756 | enum vpfe_ipipe_gic_thr_sel { |
| 757 | VPFE_IPIPE_GIC_THR_REG, |
| 758 | VPFE_IPIPE_GIC_THR_NF |
| 759 | }; |
| 760 | |
| 761 | enum vpfe_ipipe_gic_wt_fn_type { |
| 762 | /* Use difference as index */ |
| 763 | VPFE_IPIPE_GIC_WT_FN_TYP_DIF, |
| 764 | /* Use weight function as index */ |
| 765 | VPFE_IPIPE_GIC_WT_FN_TYP_HP_VAL |
| 766 | }; |
| 767 | |
| 768 | /* structure for Green Imbalance Correction */ |
| 769 | struct vpfe_ipipe_gic { |
| 770 | /* 0 - disable, 1 - enable */ |
| 771 | unsigned char en; |
| 772 | /* 0 - Constant gain , 1 - Adaptive gain algorithm */ |
| 773 | enum vpfe_ipipe_gic_alg gic_alg; |
| 774 | /* GIC gain or weight. Used for Constant gain and Adaptive algorithms |
| 775 | */ |
| 776 | unsigned short gain; |
| 777 | /* Threshold selection. GIC register values or NF2 thr table */ |
| 778 | enum vpfe_ipipe_gic_thr_sel thr_sel; |
| 779 | /* thr1. Used when thr_sel is IPIPE_GIC_THR_REG */ |
| 780 | unsigned short thr; |
| 781 | /* this value is used for thr2-thr1, thr3-thr2 or |
| 782 | * thr4-thr3 when wt_fn_type is index. Otherwise it |
| 783 | * is the |
| 784 | */ |
| 785 | unsigned short slope; |
| 786 | /* Apply LSC gain to threshold. Enable this only if |
| 787 | * LSC is enabled in ISIF & thr_sel is IPIPE_GIC_THR_REG |
| 788 | */ |
| 789 | unsigned char apply_lsc_gain; |
| 790 | /* Multiply Nf2 threshold by this gain. Use this when thr_sel |
| 791 | * is IPIPE_GIC_THR_NF |
| 792 | */ |
| 793 | struct ipipe_float_u8 nf2_thr_gain; |
| 794 | /* Weight function uses difference as index or high pass value. |
| 795 | * Used for adaptive gain algorithm |
| 796 | */ |
| 797 | enum vpfe_ipipe_gic_wt_fn_type wt_fn_type; |
| 798 | }; |
| 799 | |
| 800 | /* Structure for configuring WB module */ |
| 801 | struct vpfe_ipipe_wb { |
| 802 | /* Offset (S12) for R */ |
| 803 | short ofst_r; |
| 804 | /* Offset (S12) for Gr */ |
| 805 | short ofst_gr; |
| 806 | /* Offset (S12) for Gb */ |
| 807 | short ofst_gb; |
| 808 | /* Offset (S12) for B */ |
| 809 | short ofst_b; |
| 810 | /* Gain (U13Q9) for Red */ |
| 811 | struct ipipe_float_u16 gain_r; |
| 812 | /* Gain (U13Q9) for Gr */ |
| 813 | struct ipipe_float_u16 gain_gr; |
| 814 | /* Gain (U13Q9) for Gb */ |
| 815 | struct ipipe_float_u16 gain_gb; |
| 816 | /* Gain (U13Q9) for Blue */ |
| 817 | struct ipipe_float_u16 gain_b; |
| 818 | }; |
| 819 | |
| 820 | enum vpfe_ipipe_cfa_alg { |
| 821 | /* Algorithm is 2DirAC */ |
| 822 | VPFE_IPIPE_CFA_ALG_2DIRAC, |
| 823 | /* Algorithm is 2DirAC + Digital Antialiasing (DAA) */ |
| 824 | VPFE_IPIPE_CFA_ALG_2DIRAC_DAA, |
| 825 | /* Algorithm is DAA */ |
| 826 | VPFE_IPIPE_CFA_ALG_DAA |
| 827 | }; |
| 828 | |
| 829 | /* Structure for CFA Interpolation */ |
| 830 | struct vpfe_ipipe_cfa { |
| 831 | /* 2DirAC or 2DirAC + DAA */ |
| 832 | enum vpfe_ipipe_cfa_alg alg; |
| 833 | /* 2Dir CFA HP value Low Threshold */ |
| 834 | unsigned short hpf_thr_2dir; |
| 835 | /* 2Dir CFA HP value slope */ |
| 836 | unsigned short hpf_slp_2dir; |
| 837 | /* 2Dir CFA HP mix threshold */ |
| 838 | unsigned short hp_mix_thr_2dir; |
| 839 | /* 2Dir CFA HP mix slope */ |
| 840 | unsigned short hp_mix_slope_2dir; |
| 841 | /* 2Dir Direction threshold */ |
| 842 | unsigned short dir_thr_2dir; |
| 843 | /* 2Dir Direction slope */ |
| 844 | unsigned short dir_slope_2dir; |
| 845 | /* 2Dir Non Directional Weight */ |
| 846 | unsigned short nd_wt_2dir; |
| 847 | /* DAA Mono Hue Fraction */ |
| 848 | unsigned short hue_fract_daa; |
| 849 | /* DAA Mono Edge threshold */ |
| 850 | unsigned short edge_thr_daa; |
| 851 | /* DAA Mono threshold minimum */ |
| 852 | unsigned short thr_min_daa; |
| 853 | /* DAA Mono threshold slope */ |
| 854 | unsigned short thr_slope_daa; |
| 855 | /* DAA Mono slope minimum */ |
| 856 | unsigned short slope_min_daa; |
| 857 | /* DAA Mono slope slope */ |
| 858 | unsigned short slope_slope_daa; |
| 859 | /* DAA Mono LP wight */ |
| 860 | unsigned short lp_wt_daa; |
| 861 | }; |
| 862 | |
| 863 | /* Struct for configuring RGB2RGB blending module */ |
| 864 | struct vpfe_ipipe_rgb2rgb { |
| 865 | /* Matrix coefficient for RR S12Q8 for ID = 1 and S11Q8 for ID = 2 */ |
| 866 | struct ipipe_float_s16 coef_rr; |
| 867 | /* Matrix coefficient for GR S12Q8/S11Q8 */ |
| 868 | struct ipipe_float_s16 coef_gr; |
| 869 | /* Matrix coefficient for BR S12Q8/S11Q8 */ |
| 870 | struct ipipe_float_s16 coef_br; |
| 871 | /* Matrix coefficient for RG S12Q8/S11Q8 */ |
| 872 | struct ipipe_float_s16 coef_rg; |
| 873 | /* Matrix coefficient for GG S12Q8/S11Q8 */ |
| 874 | struct ipipe_float_s16 coef_gg; |
| 875 | /* Matrix coefficient for BG S12Q8/S11Q8 */ |
| 876 | struct ipipe_float_s16 coef_bg; |
| 877 | /* Matrix coefficient for RB S12Q8/S11Q8 */ |
| 878 | struct ipipe_float_s16 coef_rb; |
| 879 | /* Matrix coefficient for GB S12Q8/S11Q8 */ |
| 880 | struct ipipe_float_s16 coef_gb; |
| 881 | /* Matrix coefficient for BB S12Q8/S11Q8 */ |
| 882 | struct ipipe_float_s16 coef_bb; |
| 883 | /* Output offset for R S13/S11 */ |
| 884 | int out_ofst_r; |
| 885 | /* Output offset for G S13/S11 */ |
| 886 | int out_ofst_g; |
| 887 | /* Output offset for B S13/S11 */ |
| 888 | int out_ofst_b; |
| 889 | }; |
| 890 | |
| 891 | #define VPFE_IPIPE_MAX_SIZE_GAMMA 512 |
| 892 | |
| 893 | enum vpfe_ipipe_gamma_tbl_size { |
| 894 | VPFE_IPIPE_GAMMA_TBL_SZ_64 = 64, |
| 895 | VPFE_IPIPE_GAMMA_TBL_SZ_128 = 128, |
| 896 | VPFE_IPIPE_GAMMA_TBL_SZ_256 = 256, |
| 897 | VPFE_IPIPE_GAMMA_TBL_SZ_512 = 512, |
| 898 | }; |
| 899 | |
| 900 | enum vpfe_ipipe_gamma_tbl_sel { |
| 901 | VPFE_IPIPE_GAMMA_TBL_RAM = 0, |
| 902 | VPFE_IPIPE_GAMMA_TBL_ROM = 1, |
| 903 | }; |
| 904 | |
| 905 | struct vpfe_ipipe_gamma_entry { |
| 906 | /* 10 bit slope */ |
| 907 | short slope; |
| 908 | /* 10 bit offset */ |
| 909 | unsigned short offset; |
| 910 | }; |
| 911 | |
| 912 | /* Structure for configuring Gamma correction module */ |
| 913 | struct vpfe_ipipe_gamma { |
| 914 | /* 0 - Enable Gamma correction for Red |
| 915 | * 1 - bypass Gamma correction. Data is divided by 16 |
| 916 | */ |
| 917 | unsigned char bypass_r; |
| 918 | /* 0 - Enable Gamma correction for Blue |
| 919 | * 1 - bypass Gamma correction. Data is divided by 16 |
| 920 | */ |
| 921 | unsigned char bypass_b; |
| 922 | /* 0 - Enable Gamma correction for Green |
| 923 | * 1 - bypass Gamma correction. Data is divided by 16 |
| 924 | */ |
| 925 | unsigned char bypass_g; |
| 926 | /* IPIPE_GAMMA_TBL_RAM or IPIPE_GAMMA_TBL_ROM */ |
| 927 | enum vpfe_ipipe_gamma_tbl_sel tbl_sel; |
| 928 | /* Table size for RAM gamma table. |
| 929 | */ |
| 930 | enum vpfe_ipipe_gamma_tbl_size tbl_size; |
| 931 | /* R table */ |
| 932 | struct vpfe_ipipe_gamma_entry table_r[VPFE_IPIPE_MAX_SIZE_GAMMA]; |
| 933 | /* Blue table */ |
| 934 | struct vpfe_ipipe_gamma_entry table_b[VPFE_IPIPE_MAX_SIZE_GAMMA]; |
| 935 | /* Green table */ |
| 936 | struct vpfe_ipipe_gamma_entry table_g[VPFE_IPIPE_MAX_SIZE_GAMMA]; |
| 937 | }; |
| 938 | |
| 939 | #define VPFE_IPIPE_MAX_SIZE_3D_LUT 729 |
| 940 | |
| 941 | struct vpfe_ipipe_3d_lut_entry { |
| 942 | /* 10 bit entry for red */ |
| 943 | unsigned short r; |
| 944 | /* 10 bit entry for green */ |
| 945 | unsigned short g; |
| 946 | /* 10 bit entry for blue */ |
| 947 | unsigned short b; |
| 948 | }; |
| 949 | |
| 950 | /* structure for 3D-LUT */ |
| 951 | struct vpfe_ipipe_3d_lut { |
| 952 | /* enable/disable 3D lut */ |
| 953 | unsigned char en; |
| 954 | /* 3D - LUT table entry */ |
| 955 | struct vpfe_ipipe_3d_lut_entry table[VPFE_IPIPE_MAX_SIZE_3D_LUT]; |
| 956 | }; |
| 957 | |
| 958 | /* Struct for configuring rgb2ycbcr module */ |
| 959 | struct vpfe_ipipe_rgb2yuv { |
| 960 | /* Matrix coefficient for RY S12Q8 */ |
| 961 | struct ipipe_float_s16 coef_ry; |
| 962 | /* Matrix coefficient for GY S12Q8 */ |
| 963 | struct ipipe_float_s16 coef_gy; |
| 964 | /* Matrix coefficient for BY S12Q8 */ |
| 965 | struct ipipe_float_s16 coef_by; |
| 966 | /* Matrix coefficient for RCb S12Q8 */ |
| 967 | struct ipipe_float_s16 coef_rcb; |
| 968 | /* Matrix coefficient for GCb S12Q8 */ |
| 969 | struct ipipe_float_s16 coef_gcb; |
| 970 | /* Matrix coefficient for BCb S12Q8 */ |
| 971 | struct ipipe_float_s16 coef_bcb; |
| 972 | /* Matrix coefficient for RCr S12Q8 */ |
| 973 | struct ipipe_float_s16 coef_rcr; |
| 974 | /* Matrix coefficient for GCr S12Q8 */ |
| 975 | struct ipipe_float_s16 coef_gcr; |
| 976 | /* Matrix coefficient for BCr S12Q8 */ |
| 977 | struct ipipe_float_s16 coef_bcr; |
| 978 | /* Output offset for R S11 */ |
| 979 | int out_ofst_y; |
| 980 | /* Output offset for Cb S11 */ |
| 981 | int out_ofst_cb; |
| 982 | /* Output offset for Cr S11 */ |
| 983 | int out_ofst_cr; |
| 984 | }; |
| 985 | |
| 986 | enum vpfe_ipipe_gbce_type { |
| 987 | VPFE_IPIPE_GBCE_Y_VAL_TBL = 0, |
| 988 | VPFE_IPIPE_GBCE_GAIN_TBL = 1, |
| 989 | }; |
| 990 | |
| 991 | #define VPFE_IPIPE_MAX_SIZE_GBCE_LUT 1024 |
| 992 | |
| 993 | /* structure for Global brightness and Contrast */ |
| 994 | struct vpfe_ipipe_gbce { |
| 995 | /* enable/disable GBCE */ |
| 996 | unsigned char en; |
| 997 | /* Y - value table or Gain table */ |
| 998 | enum vpfe_ipipe_gbce_type type; |
| 999 | /* ptr to LUT for GBCE with 1024 entries */ |
| 1000 | unsigned short table[VPFE_IPIPE_MAX_SIZE_GBCE_LUT]; |
| 1001 | }; |
| 1002 | |
| 1003 | /* Chrominance position. Applicable only for YCbCr input |
| 1004 | * Applied after edge enhancement |
| 1005 | */ |
| 1006 | enum vpfe_chr_pos { |
| 1007 | /* Co-siting, same position with luminance */ |
| 1008 | VPFE_IPIPE_YUV422_CHR_POS_COSITE = 0, |
| 1009 | /* Centering, In the middle of luminance */ |
| 1010 | VPFE_IPIPE_YUV422_CHR_POS_CENTRE = 1, |
| 1011 | }; |
| 1012 | |
| 1013 | /* Structure for configuring yuv422 conversion module */ |
| 1014 | struct vpfe_ipipe_yuv422_conv { |
| 1015 | /* Max Chrominance value */ |
| 1016 | unsigned char en_chrom_lpf; |
| 1017 | /* 1 - enable LPF for chrminance, 0 - disable */ |
| 1018 | enum vpfe_chr_pos chrom_pos; |
| 1019 | }; |
| 1020 | |
| 1021 | #define VPFE_IPIPE_MAX_SIZE_YEE_LUT 1024 |
| 1022 | |
| 1023 | enum vpfe_ipipe_yee_merge_meth { |
| 1024 | VPFE_IPIPE_YEE_ABS_MAX = 0, |
| 1025 | VPFE_IPIPE_YEE_EE_ES = 1, |
| 1026 | }; |
| 1027 | |
| 1028 | /* Structure for configuring YUV Edge Enhancement module */ |
| 1029 | struct vpfe_ipipe_yee { |
| 1030 | /* 1 - enable enhancement, 0 - disable */ |
| 1031 | unsigned char en; |
| 1032 | /* enable/disable halo reduction in edge sharpner */ |
| 1033 | unsigned char en_halo_red; |
| 1034 | /* Merge method between Edge Enhancer and Edge sharpner */ |
| 1035 | enum vpfe_ipipe_yee_merge_meth merge_meth; |
| 1036 | /* HPF Shift length */ |
| 1037 | unsigned char hpf_shft; |
| 1038 | /* HPF Coefficient 00, S10 */ |
| 1039 | short hpf_coef_00; |
| 1040 | /* HPF Coefficient 01, S10 */ |
| 1041 | short hpf_coef_01; |
| 1042 | /* HPF Coefficient 02, S10 */ |
| 1043 | short hpf_coef_02; |
| 1044 | /* HPF Coefficient 10, S10 */ |
| 1045 | short hpf_coef_10; |
| 1046 | /* HPF Coefficient 11, S10 */ |
| 1047 | short hpf_coef_11; |
| 1048 | /* HPF Coefficient 12, S10 */ |
| 1049 | short hpf_coef_12; |
| 1050 | /* HPF Coefficient 20, S10 */ |
| 1051 | short hpf_coef_20; |
| 1052 | /* HPF Coefficient 21, S10 */ |
| 1053 | short hpf_coef_21; |
| 1054 | /* HPF Coefficient 22, S10 */ |
| 1055 | short hpf_coef_22; |
| 1056 | /* Lower threshold before referring to LUT */ |
| 1057 | unsigned short yee_thr; |
| 1058 | /* Edge sharpener Gain */ |
| 1059 | unsigned short es_gain; |
| 1060 | /* Edge sharpener lower threshold */ |
| 1061 | unsigned short es_thr1; |
| 1062 | /* Edge sharpener upper threshold */ |
| 1063 | unsigned short es_thr2; |
| 1064 | /* Edge sharpener gain on gradient */ |
| 1065 | unsigned short es_gain_grad; |
| 1066 | /* Edge sharpener offset on gradient */ |
| 1067 | unsigned short es_ofst_grad; |
| 1068 | /* Ptr to EE table. Must have 1024 entries */ |
| 1069 | short table[VPFE_IPIPE_MAX_SIZE_YEE_LUT]; |
| 1070 | }; |
| 1071 | |
| 1072 | enum vpfe_ipipe_car_meth { |
| 1073 | /* Chromatic Gain Control */ |
| 1074 | VPFE_IPIPE_CAR_CHR_GAIN_CTRL = 0, |
| 1075 | /* Dynamic switching between CHR_GAIN_CTRL |
| 1076 | * and MED_FLTR |
| 1077 | */ |
| 1078 | VPFE_IPIPE_CAR_DYN_SWITCH = 1, |
| 1079 | /* Median Filter */ |
| 1080 | VPFE_IPIPE_CAR_MED_FLTR = 2, |
| 1081 | }; |
| 1082 | |
| 1083 | enum vpfe_ipipe_car_hpf_type { |
| 1084 | VPFE_IPIPE_CAR_HPF_Y = 0, |
| 1085 | VPFE_IPIPE_CAR_HPF_H = 1, |
| 1086 | VPFE_IPIPE_CAR_HPF_V = 2, |
| 1087 | VPFE_IPIPE_CAR_HPF_2D = 3, |
| 1088 | /* 2D HPF from YUV Edge Enhancement */ |
| 1089 | VPFE_IPIPE_CAR_HPF_2D_YEE = 4, |
| 1090 | }; |
| 1091 | |
| 1092 | struct vpfe_ipipe_car_gain { |
| 1093 | /* csup_gain */ |
| 1094 | unsigned char gain; |
| 1095 | /* csup_shf. */ |
| 1096 | unsigned char shft; |
| 1097 | /* gain minimum */ |
| 1098 | unsigned short gain_min; |
| 1099 | }; |
| 1100 | |
| 1101 | /* Structure for Chromatic Artifact Reduction */ |
| 1102 | struct vpfe_ipipe_car { |
| 1103 | /* enable/disable */ |
| 1104 | unsigned char en; |
| 1105 | /* Gain control or Dynamic switching */ |
| 1106 | enum vpfe_ipipe_car_meth meth; |
| 1107 | /* Gain1 function configuration for Gain control */ |
| 1108 | struct vpfe_ipipe_car_gain gain1; |
| 1109 | /* Gain2 function configuration for Gain control */ |
| 1110 | struct vpfe_ipipe_car_gain gain2; |
| 1111 | /* HPF type used for CAR */ |
| 1112 | enum vpfe_ipipe_car_hpf_type hpf; |
| 1113 | /* csup_thr: HPF threshold for Gain control */ |
| 1114 | unsigned char hpf_thr; |
| 1115 | /* Down shift value for hpf. 2 bits */ |
| 1116 | unsigned char hpf_shft; |
| 1117 | /* switch limit for median filter */ |
| 1118 | unsigned char sw0; |
| 1119 | /* switch coefficient for Gain control */ |
| 1120 | unsigned char sw1; |
| 1121 | }; |
| 1122 | |
| 1123 | /* structure for Chromatic Gain Suppression */ |
| 1124 | struct vpfe_ipipe_cgs { |
| 1125 | /* enable/disable */ |
| 1126 | unsigned char en; |
| 1127 | /* gain1 bright side threshold */ |
| 1128 | unsigned char h_thr; |
| 1129 | /* gain1 bright side slope */ |
| 1130 | unsigned char h_slope; |
| 1131 | /* gain1 down shift value for bright side */ |
| 1132 | unsigned char h_shft; |
| 1133 | /* gain1 bright side minimum gain */ |
| 1134 | unsigned char h_min; |
| 1135 | }; |
| 1136 | |
| 1137 | /* Max pixels allowed in the input. If above this either decimation |
| 1138 | * or frame division mode to be enabled |
| 1139 | */ |
| 1140 | #define VPFE_IPIPE_MAX_INPUT_WIDTH 2600 |
| 1141 | |
| 1142 | struct vpfe_ipipe_input_config { |
| 1143 | unsigned int vst; |
| 1144 | unsigned int hst; |
| 1145 | }; |
| 1146 | |
| 1147 | /** |
| 1148 | * struct vpfe_ipipe_config - IPIPE engine configuration (user) |
| 1149 | * @input_config: Pointer to structure for ipipe configuration. |
| 1150 | * @flag: Specifies which ISP IPIPE functions should be enabled. |
| 1151 | * @lutdpc: Pointer to luma enhancement structure. |
| 1152 | * @otfdpc: Pointer to structure for defect correction. |
| 1153 | * @nf1: Pointer to structure for Noise Filter. |
| 1154 | * @nf2: Pointer to structure for Noise Filter. |
| 1155 | * @gic: Pointer to structure for Green Imbalance. |
| 1156 | * @wbal: Pointer to structure for White Balance. |
| 1157 | * @cfa: Pointer to structure containing the CFA interpolation. |
| 1158 | * @rgb2rgb1: Pointer to structure for RGB to RGB Blending. |
| 1159 | * @rgb2rgb2: Pointer to structure for RGB to RGB Blending. |
| 1160 | * @gamma: Pointer to gamma structure. |
| 1161 | * @lut: Pointer to structure for 3D LUT. |
| 1162 | * @rgb2yuv: Pointer to structure for RGB-YCbCr conversion. |
| 1163 | * @gbce: Pointer to structure for Global Brightness,Contrast Control. |
| 1164 | * @yuv422_conv: Pointer to structure for YUV 422 conversion. |
| 1165 | * @yee: Pointer to structure for Edge Enhancer. |
| 1166 | * @car: Pointer to structure for Chromatic Artifact Reduction. |
| 1167 | * @cgs: Pointer to structure for Chromatic Gain Suppression. |
| 1168 | */ |
| 1169 | struct vpfe_ipipe_config { |
| 1170 | __u32 flag; |
| 1171 | struct vpfe_ipipe_input_config __user *input_config; |
| 1172 | struct vpfe_ipipe_lutdpc __user *lutdpc; |
| 1173 | struct vpfe_ipipe_otfdpc __user *otfdpc; |
| 1174 | struct vpfe_ipipe_nf __user *nf1; |
| 1175 | struct vpfe_ipipe_nf __user *nf2; |
| 1176 | struct vpfe_ipipe_gic __user *gic; |
| 1177 | struct vpfe_ipipe_wb __user *wbal; |
| 1178 | struct vpfe_ipipe_cfa __user *cfa; |
| 1179 | struct vpfe_ipipe_rgb2rgb __user *rgb2rgb1; |
| 1180 | struct vpfe_ipipe_rgb2rgb __user *rgb2rgb2; |
| 1181 | struct vpfe_ipipe_gamma __user *gamma; |
| 1182 | struct vpfe_ipipe_3d_lut __user *lut; |
| 1183 | struct vpfe_ipipe_rgb2yuv __user *rgb2yuv; |
| 1184 | struct vpfe_ipipe_gbce __user *gbce; |
| 1185 | struct vpfe_ipipe_yuv422_conv __user *yuv422_conv; |
| 1186 | struct vpfe_ipipe_yee __user *yee; |
| 1187 | struct vpfe_ipipe_car __user *car; |
| 1188 | struct vpfe_ipipe_cgs __user *cgs; |
| 1189 | }; |
| 1190 | |
| 1191 | /******************************************************************* |
| 1192 | ** Resizer API structures |
| 1193 | *******************************************************************/ |
| 1194 | /* Interpolation types used for horizontal rescale */ |
| 1195 | enum vpfe_rsz_intp_t { |
| 1196 | VPFE_RSZ_INTP_CUBIC, |
| 1197 | VPFE_RSZ_INTP_LINEAR |
| 1198 | }; |
| 1199 | |
| 1200 | /* Horizontal LPF intensity selection */ |
| 1201 | enum vpfe_rsz_h_lpf_lse_t { |
| 1202 | VPFE_RSZ_H_LPF_LSE_INTERN, |
| 1203 | VPFE_RSZ_H_LPF_LSE_USER_VAL |
| 1204 | }; |
| 1205 | |
| 1206 | enum vpfe_rsz_down_scale_ave_sz { |
| 1207 | VPFE_IPIPE_DWN_SCALE_1_OVER_2, |
| 1208 | VPFE_IPIPE_DWN_SCALE_1_OVER_4, |
| 1209 | VPFE_IPIPE_DWN_SCALE_1_OVER_8, |
| 1210 | VPFE_IPIPE_DWN_SCALE_1_OVER_16, |
| 1211 | VPFE_IPIPE_DWN_SCALE_1_OVER_32, |
| 1212 | VPFE_IPIPE_DWN_SCALE_1_OVER_64, |
| 1213 | VPFE_IPIPE_DWN_SCALE_1_OVER_128, |
| 1214 | VPFE_IPIPE_DWN_SCALE_1_OVER_256 |
| 1215 | }; |
| 1216 | |
| 1217 | struct vpfe_rsz_output_spec { |
| 1218 | /* enable horizontal flip */ |
| 1219 | unsigned char h_flip; |
| 1220 | /* enable vertical flip */ |
| 1221 | unsigned char v_flip; |
| 1222 | /* line start offset for y. */ |
| 1223 | unsigned int vst_y; |
| 1224 | /* line start offset for c. Only for 420 */ |
| 1225 | unsigned int vst_c; |
| 1226 | /* vertical rescale interpolation type, YCbCr or Luminance */ |
| 1227 | enum vpfe_rsz_intp_t v_typ_y; |
| 1228 | /* vertical rescale interpolation type for Chrominance */ |
| 1229 | enum vpfe_rsz_intp_t v_typ_c; |
| 1230 | /* vertical lpf intensity - Luminance */ |
| 1231 | unsigned char v_lpf_int_y; |
| 1232 | /* vertical lpf intensity - Chrominance */ |
| 1233 | unsigned char v_lpf_int_c; |
| 1234 | /* horizontal rescale interpolation types, YCbCr or Luminance */ |
| 1235 | enum vpfe_rsz_intp_t h_typ_y; |
| 1236 | /* horizontal rescale interpolation types, Chrominance */ |
| 1237 | enum vpfe_rsz_intp_t h_typ_c; |
| 1238 | /* horizontal lpf intensity - Luminance */ |
| 1239 | unsigned char h_lpf_int_y; |
| 1240 | /* horizontal lpf intensity - Chrominance */ |
| 1241 | unsigned char h_lpf_int_c; |
| 1242 | /* Use down scale mode for scale down */ |
| 1243 | unsigned char en_down_scale; |
| 1244 | /* if downscale, set the downscale more average size for horizontal |
| 1245 | * direction. Used only if output width and height is less than |
| 1246 | * input sizes |
| 1247 | */ |
| 1248 | enum vpfe_rsz_down_scale_ave_sz h_dscale_ave_sz; |
| 1249 | /* if downscale, set the downscale more average size for vertical |
| 1250 | * direction. Used only if output width and height is less than |
| 1251 | * input sizes |
| 1252 | */ |
| 1253 | enum vpfe_rsz_down_scale_ave_sz v_dscale_ave_sz; |
| 1254 | /* Y offset. If set, the offset would be added to the base address |
| 1255 | */ |
| 1256 | unsigned int user_y_ofst; |
| 1257 | /* C offset. If set, the offset would be added to the base address |
| 1258 | */ |
| 1259 | unsigned int user_c_ofst; |
| 1260 | }; |
| 1261 | |
| 1262 | struct vpfe_rsz_config_params { |
| 1263 | unsigned int vst; |
| 1264 | /* horizontal start position of the image |
| 1265 | * data to IPIPE |
| 1266 | */ |
| 1267 | unsigned int hst; |
| 1268 | /* output spec of the image data coming out of resizer - 0(UYVY). |
| 1269 | */ |
| 1270 | struct vpfe_rsz_output_spec output1; |
| 1271 | /* output spec of the image data coming out of resizer - 1(UYVY). |
| 1272 | */ |
| 1273 | struct vpfe_rsz_output_spec output2; |
| 1274 | /* 0 , chroma sample at odd pixel, 1 - even pixel */ |
| 1275 | unsigned char chroma_sample_even; |
| 1276 | unsigned char frame_div_mode_en; |
| 1277 | unsigned char yuv_y_min; |
| 1278 | unsigned char yuv_y_max; |
| 1279 | unsigned char yuv_c_min; |
| 1280 | unsigned char yuv_c_max; |
| 1281 | enum vpfe_chr_pos out_chr_pos; |
| 1282 | unsigned char bypass; |
| 1283 | }; |
| 1284 | |
| 1285 | /* Structure for VIDIOC_VPFE_RSZ_[S/G]_CONFIG IOCTLs */ |
| 1286 | struct vpfe_rsz_config { |
| 1287 | struct vpfe_rsz_config_params *config; |
| 1288 | }; |
| 1289 | |
| 1290 | #endif /* _DAVINCI_VPFE_USER_H */ |