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