linux/include/media/davinci/isif.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2008-2009 Texas Instruments Inc
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License as published by
   6 * the Free Software Foundation; either version 2 of the License, or
   7 * (at your option) any later version.
   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 * isif header file
  15 */
  16#ifndef _ISIF_H
  17#define _ISIF_H
  18
  19#include <media/davinci/ccdc_types.h>
  20#include <media/davinci/vpfe_types.h>
  21
  22/* isif float type S8Q8/U8Q8 */
  23struct isif_float_8 {
  24        /* 8 bit integer part */
  25        __u8 integer;
  26        /* 8 bit decimal part */
  27        __u8 decimal;
  28};
  29
  30/* isif float type U16Q16/S16Q16 */
  31struct isif_float_16 {
  32        /* 16 bit integer part */
  33        __u16 integer;
  34        /* 16 bit decimal part */
  35        __u16 decimal;
  36};
  37
  38/************************************************************************
  39 *   Vertical Defect Correction parameters
  40 ***********************************************************************/
  41/* Defect Correction (DFC) table entry */
  42struct isif_vdfc_entry {
  43        /* vertical position of defect */
  44        __u16 pos_vert;
  45        /* horizontal position of defect */
  46        __u16 pos_horz;
  47        /*
  48         * Defect level of Vertical line defect position. This is subtracted
  49         * from the data at the defect position
  50         */
  51        __u8 level_at_pos;
  52        /*
  53         * Defect level of the pixels upper than the vertical line defect.
  54         * This is subtracted from the data
  55         */
  56        __u8 level_up_pixels;
  57        /*
  58         * Defect level of the pixels lower than the vertical line defect.
  59         * This is subtracted from the data
  60         */
  61        __u8 level_low_pixels;
  62};
  63
  64#define ISIF_VDFC_TABLE_SIZE            8
  65struct isif_dfc {
  66        /* enable vertical defect correction */
  67        __u8 en;
  68        /* Defect level subtraction. Just fed through if saturating */
  69#define ISIF_VDFC_NORMAL                0
  70        /*
  71         * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
  72         * if data saturating
  73         */
  74#define ISIF_VDFC_HORZ_INTERPOL_IF_SAT  1
  75        /* Horizontal interpolation (((i-2)+(i+2))/2) */
  76#define ISIF_VDFC_HORZ_INTERPOL         2
  77        /* one of the vertical defect correction modes above */
  78        __u8 corr_mode;
  79        /* 0 - whole line corrected, 1 - not pixels upper than the defect */
  80        __u8 corr_whole_line;
  81#define ISIF_VDFC_NO_SHIFT              0
  82#define ISIF_VDFC_SHIFT_1               1
  83#define ISIF_VDFC_SHIFT_2               2
  84#define ISIF_VDFC_SHIFT_3               3
  85#define ISIF_VDFC_SHIFT_4               4
  86        /*
  87         * defect level shift value. level_at_pos, level_upper_pos,
  88         * and level_lower_pos can be shifted up by this value. Choose
  89         * one of the values above
  90         */
  91        __u8 def_level_shift;
  92        /* defect saturation level */
  93        __u16 def_sat_level;
  94        /* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
  95        __u16 num_vdefects;
  96        /* VDFC table ptr */
  97        struct isif_vdfc_entry table[ISIF_VDFC_TABLE_SIZE];
  98};
  99
 100struct isif_horz_bclamp {
 101
 102        /* Horizontal clamp disabled. Only vertical clamp value is subtracted */
 103#define ISIF_HORZ_BC_DISABLE            0
 104        /*
 105         * Horizontal clamp value is calculated and subtracted from image data
 106         * along with vertical clamp value
 107         */
 108#define ISIF_HORZ_BC_CLAMP_CALC_ENABLED 1
 109        /*
 110         * Horizontal clamp value calculated from previous image is subtracted
 111         * from image data along with vertical clamp value.
 112         */
 113#define ISIF_HORZ_BC_CLAMP_NOT_UPDATED  2
 114        /* horizontal clamp mode. One of the values above */
 115        __u8 mode;
 116        /*
 117         * pixel value limit enable.
 118         *  0 - limit disabled
 119         *  1 - pixel value limited to 1023
 120         */
 121        __u8 clamp_pix_limit;
 122        /* Select Most left window for bc calculation */
 123#define ISIF_SEL_MOST_LEFT_WIN          0
 124        /* Select Most right window for bc calculation */
 125#define ISIF_SEL_MOST_RIGHT_WIN         1
 126        /* Select most left or right window for clamp val calculation */
 127        __u8 base_win_sel_calc;
 128        /* Window count per color for calculation. range 1-32 */
 129        __u8 win_count_calc;
 130        /* Window start position - horizontal for calculation. 0 - 8191 */
 131        __u16 win_start_h_calc;
 132        /* Window start position - vertical for calculation 0 - 8191 */
 133        __u16 win_start_v_calc;
 134#define ISIF_HORZ_BC_SZ_H_2PIXELS       0
 135#define ISIF_HORZ_BC_SZ_H_4PIXELS       1
 136#define ISIF_HORZ_BC_SZ_H_8PIXELS       2
 137#define ISIF_HORZ_BC_SZ_H_16PIXELS      3
 138        /* Width of the sample window in pixels for calculation */
 139        __u8 win_h_sz_calc;
 140#define ISIF_HORZ_BC_SZ_V_32PIXELS      0
 141#define ISIF_HORZ_BC_SZ_V_64PIXELS      1
 142#define ISIF_HORZ_BC_SZ_V_128PIXELS     2
 143#define ISIF_HORZ_BC_SZ_V_256PIXELS     3
 144        /* Height of the sample window in pixels for calculation */
 145        __u8 win_v_sz_calc;
 146};
 147
 148/************************************************************************
 149 *  Black Clamp parameters
 150 ***********************************************************************/
 151struct isif_vert_bclamp {
 152        /* Reset value used is the clamp value calculated */
 153#define ISIF_VERT_BC_USE_HORZ_CLAMP_VAL         0
 154        /* Reset value used is reset_clamp_val configured */
 155#define ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL       1
 156        /* No update, previous image value is used */
 157#define ISIF_VERT_BC_NO_UPDATE                  2
 158        /*
 159         * Reset value selector for vertical clamp calculation. Use one of
 160         * the above values
 161         */
 162        __u8 reset_val_sel;
 163        /* U8Q8. Line average coefficient used in vertical clamp calculation */
 164        __u8 line_ave_coef;
 165        /* Height of the optical black region for calculation */
 166        __u16 ob_v_sz_calc;
 167        /* Optical black region start position - horizontal. 0 - 8191 */
 168        __u16 ob_start_h;
 169        /* Optical black region start position - vertical 0 - 8191 */
 170        __u16 ob_start_v;
 171};
 172
 173struct isif_black_clamp {
 174        /*
 175         * This offset value is added irrespective of the clamp enable status.
 176         * S13
 177         */
 178        __u16 dc_offset;
 179        /*
 180         * Enable black/digital clamp value to be subtracted from the image data
 181         */
 182        __u8 en;
 183        /*
 184         * black clamp mode. same/separate clamp for 4 colors
 185         * 0 - disable - same clamp value for all colors
 186         * 1 - clamp value calculated separately for all colors
 187         */
 188        __u8 bc_mode_color;
 189        /* Vrtical start position for bc subtraction */
 190        __u16 vert_start_sub;
 191        /* Black clamp for horizontal direction */
 192        struct isif_horz_bclamp horz;
 193        /* Black clamp for vertical direction */
 194        struct isif_vert_bclamp vert;
 195};
 196
 197/*************************************************************************
 198** Color Space Conversion (CSC)
 199*************************************************************************/
 200#define ISIF_CSC_NUM_COEFF      16
 201struct isif_color_space_conv {
 202        /* Enable color space conversion */
 203        __u8 en;
 204        /*
 205         * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
 206         * so forth
 207         */
 208        struct isif_float_8 coeff[ISIF_CSC_NUM_COEFF];
 209};
 210
 211
 212/*************************************************************************
 213**  Black  Compensation parameters
 214*************************************************************************/
 215struct isif_black_comp {
 216        /* Comp for Red */
 217        __s8 r_comp;
 218        /* Comp for Gr */
 219        __s8 gr_comp;
 220        /* Comp for Blue */
 221        __s8 b_comp;
 222        /* Comp for Gb */
 223        __s8 gb_comp;
 224};
 225
 226/*************************************************************************
 227**  Gain parameters
 228*************************************************************************/
 229struct isif_gain {
 230        /* Gain for Red or ye */
 231        struct isif_float_16 r_ye;
 232        /* Gain for Gr or cy */
 233        struct isif_float_16 gr_cy;
 234        /* Gain for Gb or g */
 235        struct isif_float_16 gb_g;
 236        /* Gain for Blue or mg */
 237        struct isif_float_16 b_mg;
 238};
 239
 240#define ISIF_LINEAR_TAB_SIZE    192
 241/*************************************************************************
 242**  Linearization parameters
 243*************************************************************************/
 244struct isif_linearize {
 245        /* Enable or Disable linearization of data */
 246        __u8 en;
 247        /* Shift value applied */
 248        __u8 corr_shft;
 249        /* scale factor applied U11Q10 */
 250        struct isif_float_16 scale_fact;
 251        /* Size of the linear table */
 252        __u16 table[ISIF_LINEAR_TAB_SIZE];
 253};
 254
 255/* Color patterns */
 256#define ISIF_RED        0
 257#define ISIF_GREEN_RED  1
 258#define ISIF_GREEN_BLUE 2
 259#define ISIF_BLUE       3
 260struct isif_col_pat {
 261        __u8 olop;
 262        __u8 olep;
 263        __u8 elop;
 264        __u8 elep;
 265};
 266
 267/*************************************************************************
 268**  Data formatter parameters
 269*************************************************************************/
 270struct isif_fmtplen {
 271        /*
 272         * number of program entries for SET0, range 1 - 16
 273         * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
 274         * ISIF_COMBINE
 275         */
 276        __u16 plen0;
 277        /*
 278         * number of program entries for SET1, range 1 - 16
 279         * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
 280         * ISIF_COMBINE
 281         */
 282        __u16 plen1;
 283        /**
 284         * number of program entries for SET2, range 1 - 16
 285         * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
 286         * ISIF_COMBINE
 287         */
 288        __u16 plen2;
 289        /**
 290         * number of program entries for SET3, range 1 - 16
 291         * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
 292         * ISIF_COMBINE
 293         */
 294        __u16 plen3;
 295};
 296
 297struct isif_fmt_cfg {
 298#define ISIF_SPLIT              0
 299#define ISIF_COMBINE            1
 300        /* Split or combine or line alternate */
 301        __u8 fmtmode;
 302        /* enable or disable line alternating mode */
 303        __u8 ln_alter_en;
 304#define ISIF_1LINE              0
 305#define ISIF_2LINES             1
 306#define ISIF_3LINES             2
 307#define ISIF_4LINES             3
 308        /* Split/combine line number */
 309        __u8 lnum;
 310        /* Address increment Range 1 - 16 */
 311        __u8 addrinc;
 312};
 313
 314struct isif_fmt_addr_ptr {
 315        /* Initial address */
 316        __u32 init_addr;
 317        /* output line number */
 318#define ISIF_1STLINE            0
 319#define ISIF_2NDLINE            1
 320#define ISIF_3RDLINE            2
 321#define ISIF_4THLINE            3
 322        __u8 out_line;
 323};
 324
 325struct isif_fmtpgm_ap {
 326        /* program address pointer */
 327        __u8 pgm_aptr;
 328        /* program address increment or decrement */
 329        __u8 pgmupdt;
 330};
 331
 332struct isif_data_formatter {
 333        /* Enable/Disable data formatter */
 334        __u8 en;
 335        /* data formatter configuration */
 336        struct isif_fmt_cfg cfg;
 337        /* Formatter program entries length */
 338        struct isif_fmtplen plen;
 339        /* first pixel in a line fed to formatter */
 340        __u16 fmtrlen;
 341        /* HD interval for output line. Only valid when split line */
 342        __u16 fmthcnt;
 343        /* formatter address pointers */
 344        struct isif_fmt_addr_ptr fmtaddr_ptr[16];
 345        /* program enable/disable */
 346        __u8 pgm_en[32];
 347        /* program address pointers */
 348        struct isif_fmtpgm_ap fmtpgm_ap[32];
 349};
 350
 351struct isif_df_csc {
 352        /* Color Space Conversion confguration, 0 - csc, 1 - df */
 353        __u8 df_or_csc;
 354        /* csc configuration valid if df_or_csc is 0 */
 355        struct isif_color_space_conv csc;
 356        /* data formatter configuration valid if df_or_csc is 1 */
 357        struct isif_data_formatter df;
 358        /* start pixel in a line at the input */
 359        __u32 start_pix;
 360        /* number of pixels in input line */
 361        __u32 num_pixels;
 362        /* start line at the input */
 363        __u32 start_line;
 364        /* number of lines at the input */
 365        __u32 num_lines;
 366};
 367
 368struct isif_gain_offsets_adj {
 369        /* Gain adjustment per color */
 370        struct isif_gain gain;
 371        /* Offset adjustment */
 372        __u16 offset;
 373        /* Enable or Disable Gain adjustment for SDRAM data */
 374        __u8 gain_sdram_en;
 375        /* Enable or Disable Gain adjustment for IPIPE data */
 376        __u8 gain_ipipe_en;
 377        /* Enable or Disable Gain adjustment for H3A data */
 378        __u8 gain_h3a_en;
 379        /* Enable or Disable Gain adjustment for SDRAM data */
 380        __u8 offset_sdram_en;
 381        /* Enable or Disable Gain adjustment for IPIPE data */
 382        __u8 offset_ipipe_en;
 383        /* Enable or Disable Gain adjustment for H3A data */
 384        __u8 offset_h3a_en;
 385};
 386
 387struct isif_cul {
 388        /* Horizontal Cull pattern for odd lines */
 389        __u8 hcpat_odd;
 390        /* Horizontal Cull pattern for even lines */
 391        __u8 hcpat_even;
 392        /* Vertical Cull pattern */
 393        __u8 vcpat;
 394        /* Enable or disable lpf. Apply when cull is enabled */
 395        __u8 en_lpf;
 396};
 397
 398struct isif_compress {
 399#define ISIF_ALAW               0
 400#define ISIF_DPCM               1
 401#define ISIF_NO_COMPRESSION     2
 402        /* Compression Algorithm used */
 403        __u8 alg;
 404        /* Choose Predictor1 for DPCM compression */
 405#define ISIF_DPCM_PRED1         0
 406        /* Choose Predictor2 for DPCM compression */
 407#define ISIF_DPCM_PRED2         1
 408        /* Predictor for DPCM compression */
 409        __u8 pred;
 410};
 411
 412/* all the stuff in this struct will be provided by userland */
 413struct isif_config_params_raw {
 414        /* Linearization parameters for image sensor data input */
 415        struct isif_linearize linearize;
 416        /* Data formatter or CSC */
 417        struct isif_df_csc df_csc;
 418        /* Defect Pixel Correction (DFC) confguration */
 419        struct isif_dfc dfc;
 420        /* Black/Digital Clamp configuration */
 421        struct isif_black_clamp bclamp;
 422        /* Gain, offset adjustments */
 423        struct isif_gain_offsets_adj gain_offset;
 424        /* Culling */
 425        struct isif_cul culling;
 426        /* A-Law and DPCM compression options */
 427        struct isif_compress compress;
 428        /* horizontal offset for Gain/LSC/DFC */
 429        __u16 horz_offset;
 430        /* vertical offset for Gain/LSC/DFC */
 431        __u16 vert_offset;
 432        /* color pattern for field 0 */
 433        struct isif_col_pat col_pat_field0;
 434        /* color pattern for field 1 */
 435        struct isif_col_pat col_pat_field1;
 436#define ISIF_NO_SHIFT           0
 437#define ISIF_1BIT_SHIFT         1
 438#define ISIF_2BIT_SHIFT         2
 439#define ISIF_3BIT_SHIFT         3
 440#define ISIF_4BIT_SHIFT         4
 441#define ISIF_5BIT_SHIFT         5
 442#define ISIF_6BIT_SHIFT         6
 443        /* Data shift applied before storing to SDRAM */
 444        __u8 data_shift;
 445        /* enable input test pattern generation */
 446        __u8 test_pat_gen;
 447};
 448
 449#ifdef __KERNEL__
 450struct isif_ycbcr_config {
 451        /* isif pixel format */
 452        enum ccdc_pixfmt pix_fmt;
 453        /* isif frame format */
 454        enum ccdc_frmfmt frm_fmt;
 455        /* ISIF crop window */
 456        struct v4l2_rect win;
 457        /* field polarity */
 458        enum vpfe_pin_pol fid_pol;
 459        /* interface VD polarity */
 460        enum vpfe_pin_pol vd_pol;
 461        /* interface HD polarity */
 462        enum vpfe_pin_pol hd_pol;
 463        /* isif pix order. Only used for ycbcr capture */
 464        enum ccdc_pixorder pix_order;
 465        /* isif buffer type. Only used for ycbcr capture */
 466        enum ccdc_buftype buf_type;
 467};
 468
 469/* MSB of image data connected to sensor port */
 470enum isif_data_msb {
 471        ISIF_BIT_MSB_15,
 472        ISIF_BIT_MSB_14,
 473        ISIF_BIT_MSB_13,
 474        ISIF_BIT_MSB_12,
 475        ISIF_BIT_MSB_11,
 476        ISIF_BIT_MSB_10,
 477        ISIF_BIT_MSB_9,
 478        ISIF_BIT_MSB_8,
 479        ISIF_BIT_MSB_7
 480};
 481
 482enum isif_cfa_pattern {
 483        ISIF_CFA_PAT_MOSAIC,
 484        ISIF_CFA_PAT_STRIPE
 485};
 486
 487struct isif_params_raw {
 488        /* isif pixel format */
 489        enum ccdc_pixfmt pix_fmt;
 490        /* isif frame format */
 491        enum ccdc_frmfmt frm_fmt;
 492        /* video window */
 493        struct v4l2_rect win;
 494        /* field polarity */
 495        enum vpfe_pin_pol fid_pol;
 496        /* interface VD polarity */
 497        enum vpfe_pin_pol vd_pol;
 498        /* interface HD polarity */
 499        enum vpfe_pin_pol hd_pol;
 500        /* buffer type. Applicable for interlaced mode */
 501        enum ccdc_buftype buf_type;
 502        /* Gain values */
 503        struct isif_gain gain;
 504        /* cfa pattern */
 505        enum isif_cfa_pattern cfa_pat;
 506        /* Data MSB position */
 507        enum isif_data_msb data_msb;
 508        /* Enable horizontal flip */
 509        unsigned char horz_flip_en;
 510        /* Enable image invert vertically */
 511        unsigned char image_invert_en;
 512
 513        /* all the userland defined stuff*/
 514        struct isif_config_params_raw config_params;
 515};
 516
 517enum isif_data_pack {
 518        ISIF_PACK_16BIT,
 519        ISIF_PACK_12BIT,
 520        ISIF_PACK_8BIT
 521};
 522
 523#define ISIF_WIN_NTSC                           {0, 0, 720, 480}
 524#define ISIF_WIN_VGA                            {0, 0, 640, 480}
 525
 526#endif
 527#endif
 528