Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2008-2009 Texas Instruments Inc
0004  *
0005  * isif header file
0006  */
0007 #ifndef _ISIF_H
0008 #define _ISIF_H
0009 
0010 #include <media/davinci/ccdc_types.h>
0011 #include <media/davinci/vpfe_types.h>
0012 
0013 /* isif float type S8Q8/U8Q8 */
0014 struct isif_float_8 {
0015     /* 8 bit integer part */
0016     __u8 integer;
0017     /* 8 bit decimal part */
0018     __u8 decimal;
0019 };
0020 
0021 /* isif float type U16Q16/S16Q16 */
0022 struct isif_float_16 {
0023     /* 16 bit integer part */
0024     __u16 integer;
0025     /* 16 bit decimal part */
0026     __u16 decimal;
0027 };
0028 
0029 /************************************************************************
0030  *   Vertical Defect Correction parameters
0031  ***********************************************************************/
0032 /* Defect Correction (DFC) table entry */
0033 struct isif_vdfc_entry {
0034     /* vertical position of defect */
0035     __u16 pos_vert;
0036     /* horizontal position of defect */
0037     __u16 pos_horz;
0038     /*
0039      * Defect level of Vertical line defect position. This is subtracted
0040      * from the data at the defect position
0041      */
0042     __u8 level_at_pos;
0043     /*
0044      * Defect level of the pixels upper than the vertical line defect.
0045      * This is subtracted from the data
0046      */
0047     __u8 level_up_pixels;
0048     /*
0049      * Defect level of the pixels lower than the vertical line defect.
0050      * This is subtracted from the data
0051      */
0052     __u8 level_low_pixels;
0053 };
0054 
0055 #define ISIF_VDFC_TABLE_SIZE        8
0056 struct isif_dfc {
0057     /* enable vertical defect correction */
0058     __u8 en;
0059     /* Defect level subtraction. Just fed through if saturating */
0060 #define ISIF_VDFC_NORMAL        0
0061     /*
0062      * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
0063      * if data saturating
0064      */
0065 #define ISIF_VDFC_HORZ_INTERPOL_IF_SAT  1
0066     /* Horizontal interpolation (((i-2)+(i+2))/2) */
0067 #define ISIF_VDFC_HORZ_INTERPOL     2
0068     /* one of the vertical defect correction modes above */
0069     __u8 corr_mode;
0070     /* 0 - whole line corrected, 1 - not pixels upper than the defect */
0071     __u8 corr_whole_line;
0072 #define ISIF_VDFC_NO_SHIFT      0
0073 #define ISIF_VDFC_SHIFT_1       1
0074 #define ISIF_VDFC_SHIFT_2       2
0075 #define ISIF_VDFC_SHIFT_3       3
0076 #define ISIF_VDFC_SHIFT_4       4
0077     /*
0078      * defect level shift value. level_at_pos, level_upper_pos,
0079      * and level_lower_pos can be shifted up by this value. Choose
0080      * one of the values above
0081      */
0082     __u8 def_level_shift;
0083     /* defect saturation level */
0084     __u16 def_sat_level;
0085     /* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
0086     __u16 num_vdefects;
0087     /* VDFC table ptr */
0088     struct isif_vdfc_entry table[ISIF_VDFC_TABLE_SIZE];
0089 };
0090 
0091 struct isif_horz_bclamp {
0092 
0093     /* Horizontal clamp disabled. Only vertical clamp value is subtracted */
0094 #define ISIF_HORZ_BC_DISABLE        0
0095     /*
0096      * Horizontal clamp value is calculated and subtracted from image data
0097      * along with vertical clamp value
0098      */
0099 #define ISIF_HORZ_BC_CLAMP_CALC_ENABLED 1
0100     /*
0101      * Horizontal clamp value calculated from previous image is subtracted
0102      * from image data along with vertical clamp value.
0103      */
0104 #define ISIF_HORZ_BC_CLAMP_NOT_UPDATED  2
0105     /* horizontal clamp mode. One of the values above */
0106     __u8 mode;
0107     /*
0108      * pixel value limit enable.
0109      *  0 - limit disabled
0110      *  1 - pixel value limited to 1023
0111      */
0112     __u8 clamp_pix_limit;
0113     /* Select Most left window for bc calculation */
0114 #define ISIF_SEL_MOST_LEFT_WIN      0
0115     /* Select Most right window for bc calculation */
0116 #define ISIF_SEL_MOST_RIGHT_WIN     1
0117     /* Select most left or right window for clamp val calculation */
0118     __u8 base_win_sel_calc;
0119     /* Window count per color for calculation. range 1-32 */
0120     __u8 win_count_calc;
0121     /* Window start position - horizontal for calculation. 0 - 8191 */
0122     __u16 win_start_h_calc;
0123     /* Window start position - vertical for calculation 0 - 8191 */
0124     __u16 win_start_v_calc;
0125 #define ISIF_HORZ_BC_SZ_H_2PIXELS   0
0126 #define ISIF_HORZ_BC_SZ_H_4PIXELS   1
0127 #define ISIF_HORZ_BC_SZ_H_8PIXELS   2
0128 #define ISIF_HORZ_BC_SZ_H_16PIXELS  3
0129     /* Width of the sample window in pixels for calculation */
0130     __u8 win_h_sz_calc;
0131 #define ISIF_HORZ_BC_SZ_V_32PIXELS  0
0132 #define ISIF_HORZ_BC_SZ_V_64PIXELS  1
0133 #define ISIF_HORZ_BC_SZ_V_128PIXELS 2
0134 #define ISIF_HORZ_BC_SZ_V_256PIXELS 3
0135     /* Height of the sample window in pixels for calculation */
0136     __u8 win_v_sz_calc;
0137 };
0138 
0139 /************************************************************************
0140  *  Black Clamp parameters
0141  ***********************************************************************/
0142 struct isif_vert_bclamp {
0143     /* Reset value used is the clamp value calculated */
0144 #define ISIF_VERT_BC_USE_HORZ_CLAMP_VAL     0
0145     /* Reset value used is reset_clamp_val configured */
0146 #define ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL   1
0147     /* No update, previous image value is used */
0148 #define ISIF_VERT_BC_NO_UPDATE          2
0149     /*
0150      * Reset value selector for vertical clamp calculation. Use one of
0151      * the above values
0152      */
0153     __u8 reset_val_sel;
0154     /* U8Q8. Line average coefficient used in vertical clamp calculation */
0155     __u8 line_ave_coef;
0156     /* Height of the optical black region for calculation */
0157     __u16 ob_v_sz_calc;
0158     /* Optical black region start position - horizontal. 0 - 8191 */
0159     __u16 ob_start_h;
0160     /* Optical black region start position - vertical 0 - 8191 */
0161     __u16 ob_start_v;
0162 };
0163 
0164 struct isif_black_clamp {
0165     /*
0166      * This offset value is added irrespective of the clamp enable status.
0167      * S13
0168      */
0169     __u16 dc_offset;
0170     /*
0171      * Enable black/digital clamp value to be subtracted from the image data
0172      */
0173     __u8 en;
0174     /*
0175      * black clamp mode. same/separate clamp for 4 colors
0176      * 0 - disable - same clamp value for all colors
0177      * 1 - clamp value calculated separately for all colors
0178      */
0179     __u8 bc_mode_color;
0180     /* Vertical start position for bc subtraction */
0181     __u16 vert_start_sub;
0182     /* Black clamp for horizontal direction */
0183     struct isif_horz_bclamp horz;
0184     /* Black clamp for vertical direction */
0185     struct isif_vert_bclamp vert;
0186 };
0187 
0188 /*************************************************************************
0189 ** Color Space Conversion (CSC)
0190 *************************************************************************/
0191 #define ISIF_CSC_NUM_COEFF  16
0192 struct isif_color_space_conv {
0193     /* Enable color space conversion */
0194     __u8 en;
0195     /*
0196      * csc coefficient table. S8Q5, M00 at index 0, M01 at index 1, and
0197      * so forth
0198      */
0199     struct isif_float_8 coeff[ISIF_CSC_NUM_COEFF];
0200 };
0201 
0202 
0203 /*************************************************************************
0204 **  Black  Compensation parameters
0205 *************************************************************************/
0206 struct isif_black_comp {
0207     /* Comp for Red */
0208     __s8 r_comp;
0209     /* Comp for Gr */
0210     __s8 gr_comp;
0211     /* Comp for Blue */
0212     __s8 b_comp;
0213     /* Comp for Gb */
0214     __s8 gb_comp;
0215 };
0216 
0217 /*************************************************************************
0218 **  Gain parameters
0219 *************************************************************************/
0220 struct isif_gain {
0221     /* Gain for Red or ye */
0222     struct isif_float_16 r_ye;
0223     /* Gain for Gr or cy */
0224     struct isif_float_16 gr_cy;
0225     /* Gain for Gb or g */
0226     struct isif_float_16 gb_g;
0227     /* Gain for Blue or mg */
0228     struct isif_float_16 b_mg;
0229 };
0230 
0231 #define ISIF_LINEAR_TAB_SIZE    192
0232 /*************************************************************************
0233 **  Linearization parameters
0234 *************************************************************************/
0235 struct isif_linearize {
0236     /* Enable or Disable linearization of data */
0237     __u8 en;
0238     /* Shift value applied */
0239     __u8 corr_shft;
0240     /* scale factor applied U11Q10 */
0241     struct isif_float_16 scale_fact;
0242     /* Size of the linear table */
0243     __u16 table[ISIF_LINEAR_TAB_SIZE];
0244 };
0245 
0246 /* Color patterns */
0247 #define ISIF_RED    0
0248 #define ISIF_GREEN_RED  1
0249 #define ISIF_GREEN_BLUE 2
0250 #define ISIF_BLUE   3
0251 struct isif_col_pat {
0252     __u8 olop;
0253     __u8 olep;
0254     __u8 elop;
0255     __u8 elep;
0256 };
0257 
0258 /*************************************************************************
0259 **  Data formatter parameters
0260 *************************************************************************/
0261 struct isif_fmtplen {
0262     /*
0263      * number of program entries for SET0, range 1 - 16
0264      * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
0265      * ISIF_COMBINE
0266      */
0267     __u16 plen0;
0268     /*
0269      * number of program entries for SET1, range 1 - 16
0270      * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
0271      * ISIF_COMBINE
0272      */
0273     __u16 plen1;
0274     /**
0275      * number of program entries for SET2, range 1 - 16
0276      * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
0277      * ISIF_COMBINE
0278      */
0279     __u16 plen2;
0280     /**
0281      * number of program entries for SET3, range 1 - 16
0282      * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
0283      * ISIF_COMBINE
0284      */
0285     __u16 plen3;
0286 };
0287 
0288 struct isif_fmt_cfg {
0289 #define ISIF_SPLIT      0
0290 #define ISIF_COMBINE        1
0291     /* Split or combine or line alternate */
0292     __u8 fmtmode;
0293     /* enable or disable line alternating mode */
0294     __u8 ln_alter_en;
0295 #define ISIF_1LINE      0
0296 #define ISIF_2LINES     1
0297 #define ISIF_3LINES     2
0298 #define ISIF_4LINES     3
0299     /* Split/combine line number */
0300     __u8 lnum;
0301     /* Address increment Range 1 - 16 */
0302     __u8 addrinc;
0303 };
0304 
0305 struct isif_fmt_addr_ptr {
0306     /* Initial address */
0307     __u32 init_addr;
0308     /* output line number */
0309 #define ISIF_1STLINE        0
0310 #define ISIF_2NDLINE        1
0311 #define ISIF_3RDLINE        2
0312 #define ISIF_4THLINE        3
0313     __u8 out_line;
0314 };
0315 
0316 struct isif_fmtpgm_ap {
0317     /* program address pointer */
0318     __u8 pgm_aptr;
0319     /* program address increment or decrement */
0320     __u8 pgmupdt;
0321 };
0322 
0323 struct isif_data_formatter {
0324     /* Enable/Disable data formatter */
0325     __u8 en;
0326     /* data formatter configuration */
0327     struct isif_fmt_cfg cfg;
0328     /* Formatter program entries length */
0329     struct isif_fmtplen plen;
0330     /* first pixel in a line fed to formatter */
0331     __u16 fmtrlen;
0332     /* HD interval for output line. Only valid when split line */
0333     __u16 fmthcnt;
0334     /* formatter address pointers */
0335     struct isif_fmt_addr_ptr fmtaddr_ptr[16];
0336     /* program enable/disable */
0337     __u8 pgm_en[32];
0338     /* program address pointers */
0339     struct isif_fmtpgm_ap fmtpgm_ap[32];
0340 };
0341 
0342 struct isif_df_csc {
0343     /* Color Space Conversion configuration, 0 - csc, 1 - df */
0344     __u8 df_or_csc;
0345     /* csc configuration valid if df_or_csc is 0 */
0346     struct isif_color_space_conv csc;
0347     /* data formatter configuration valid if df_or_csc is 1 */
0348     struct isif_data_formatter df;
0349     /* start pixel in a line at the input */
0350     __u32 start_pix;
0351     /* number of pixels in input line */
0352     __u32 num_pixels;
0353     /* start line at the input */
0354     __u32 start_line;
0355     /* number of lines at the input */
0356     __u32 num_lines;
0357 };
0358 
0359 struct isif_gain_offsets_adj {
0360     /* Gain adjustment per color */
0361     struct isif_gain gain;
0362     /* Offset adjustment */
0363     __u16 offset;
0364     /* Enable or Disable Gain adjustment for SDRAM data */
0365     __u8 gain_sdram_en;
0366     /* Enable or Disable Gain adjustment for IPIPE data */
0367     __u8 gain_ipipe_en;
0368     /* Enable or Disable Gain adjustment for H3A data */
0369     __u8 gain_h3a_en;
0370     /* Enable or Disable Gain adjustment for SDRAM data */
0371     __u8 offset_sdram_en;
0372     /* Enable or Disable Gain adjustment for IPIPE data */
0373     __u8 offset_ipipe_en;
0374     /* Enable or Disable Gain adjustment for H3A data */
0375     __u8 offset_h3a_en;
0376 };
0377 
0378 struct isif_cul {
0379     /* Horizontal Cull pattern for odd lines */
0380     __u8 hcpat_odd;
0381     /* Horizontal Cull pattern for even lines */
0382     __u8 hcpat_even;
0383     /* Vertical Cull pattern */
0384     __u8 vcpat;
0385     /* Enable or disable lpf. Apply when cull is enabled */
0386     __u8 en_lpf;
0387 };
0388 
0389 struct isif_compress {
0390 #define ISIF_ALAW       0
0391 #define ISIF_DPCM       1
0392 #define ISIF_NO_COMPRESSION 2
0393     /* Compression Algorithm used */
0394     __u8 alg;
0395     /* Choose Predictor1 for DPCM compression */
0396 #define ISIF_DPCM_PRED1     0
0397     /* Choose Predictor2 for DPCM compression */
0398 #define ISIF_DPCM_PRED2     1
0399     /* Predictor for DPCM compression */
0400     __u8 pred;
0401 };
0402 
0403 /* all the stuff in this struct will be provided by userland */
0404 struct isif_config_params_raw {
0405     /* Linearization parameters for image sensor data input */
0406     struct isif_linearize linearize;
0407     /* Data formatter or CSC */
0408     struct isif_df_csc df_csc;
0409     /* Defect Pixel Correction (DFC) configuration */
0410     struct isif_dfc dfc;
0411     /* Black/Digital Clamp configuration */
0412     struct isif_black_clamp bclamp;
0413     /* Gain, offset adjustments */
0414     struct isif_gain_offsets_adj gain_offset;
0415     /* Culling */
0416     struct isif_cul culling;
0417     /* A-Law and DPCM compression options */
0418     struct isif_compress compress;
0419     /* horizontal offset for Gain/LSC/DFC */
0420     __u16 horz_offset;
0421     /* vertical offset for Gain/LSC/DFC */
0422     __u16 vert_offset;
0423     /* color pattern for field 0 */
0424     struct isif_col_pat col_pat_field0;
0425     /* color pattern for field 1 */
0426     struct isif_col_pat col_pat_field1;
0427 #define ISIF_NO_SHIFT       0
0428 #define ISIF_1BIT_SHIFT     1
0429 #define ISIF_2BIT_SHIFT     2
0430 #define ISIF_3BIT_SHIFT     3
0431 #define ISIF_4BIT_SHIFT     4
0432 #define ISIF_5BIT_SHIFT     5
0433 #define ISIF_6BIT_SHIFT     6
0434     /* Data shift applied before storing to SDRAM */
0435     __u8 data_shift;
0436     /* enable input test pattern generation */
0437     __u8 test_pat_gen;
0438 };
0439 
0440 #ifdef __KERNEL__
0441 struct isif_ycbcr_config {
0442     /* isif pixel format */
0443     enum ccdc_pixfmt pix_fmt;
0444     /* isif frame format */
0445     enum ccdc_frmfmt frm_fmt;
0446     /* ISIF crop window */
0447     struct v4l2_rect win;
0448     /* field polarity */
0449     enum vpfe_pin_pol fid_pol;
0450     /* interface VD polarity */
0451     enum vpfe_pin_pol vd_pol;
0452     /* interface HD polarity */
0453     enum vpfe_pin_pol hd_pol;
0454     /* isif pix order. Only used for ycbcr capture */
0455     enum ccdc_pixorder pix_order;
0456     /* isif buffer type. Only used for ycbcr capture */
0457     enum ccdc_buftype buf_type;
0458 };
0459 
0460 /* MSB of image data connected to sensor port */
0461 enum isif_data_msb {
0462     ISIF_BIT_MSB_15,
0463     ISIF_BIT_MSB_14,
0464     ISIF_BIT_MSB_13,
0465     ISIF_BIT_MSB_12,
0466     ISIF_BIT_MSB_11,
0467     ISIF_BIT_MSB_10,
0468     ISIF_BIT_MSB_9,
0469     ISIF_BIT_MSB_8,
0470     ISIF_BIT_MSB_7
0471 };
0472 
0473 enum isif_cfa_pattern {
0474     ISIF_CFA_PAT_MOSAIC,
0475     ISIF_CFA_PAT_STRIPE
0476 };
0477 
0478 struct isif_params_raw {
0479     /* isif pixel format */
0480     enum ccdc_pixfmt pix_fmt;
0481     /* isif frame format */
0482     enum ccdc_frmfmt frm_fmt;
0483     /* video window */
0484     struct v4l2_rect win;
0485     /* field polarity */
0486     enum vpfe_pin_pol fid_pol;
0487     /* interface VD polarity */
0488     enum vpfe_pin_pol vd_pol;
0489     /* interface HD polarity */
0490     enum vpfe_pin_pol hd_pol;
0491     /* buffer type. Applicable for interlaced mode */
0492     enum ccdc_buftype buf_type;
0493     /* Gain values */
0494     struct isif_gain gain;
0495     /* cfa pattern */
0496     enum isif_cfa_pattern cfa_pat;
0497     /* Data MSB position */
0498     enum isif_data_msb data_msb;
0499     /* Enable horizontal flip */
0500     unsigned char horz_flip_en;
0501     /* Enable image invert vertically */
0502     unsigned char image_invert_en;
0503 
0504     /* all the userland defined stuff*/
0505     struct isif_config_params_raw config_params;
0506 };
0507 
0508 enum isif_data_pack {
0509     ISIF_PACK_16BIT,
0510     ISIF_PACK_12BIT,
0511     ISIF_PACK_8BIT
0512 };
0513 
0514 #define ISIF_WIN_NTSC               {0, 0, 720, 480}
0515 #define ISIF_WIN_VGA                {0, 0, 640, 480}
0516 
0517 #endif
0518 #endif