Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
isif.h
Go to the documentation of this file.
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  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * isif header file
19  */
20 #ifndef _ISIF_H
21 #define _ISIF_H
22 
25 
26 /* isif float type S8Q8/U8Q8 */
27 struct isif_float_8 {
28  /* 8 bit integer part */
30  /* 8 bit decimal part */
32 };
33 
34 /* isif float type U16Q16/S16Q16 */
35 struct isif_float_16 {
36  /* 16 bit integer part */
38  /* 16 bit decimal part */
40 };
41 
42 /************************************************************************
43  * Vertical Defect Correction parameters
44  ***********************************************************************/
45 /* Defect Correction (DFC) table entry */
47  /* vertical position of defect */
49  /* horizontal position of defect */
51  /*
52  * Defect level of Vertical line defect position. This is subtracted
53  * from the data at the defect position
54  */
56  /*
57  * Defect level of the pixels upper than the vertical line defect.
58  * This is subtracted from the data
59  */
61  /*
62  * Defect level of the pixels lower than the vertical line defect.
63  * This is subtracted from the data
64  */
66 };
67 
68 #define ISIF_VDFC_TABLE_SIZE 8
69 struct isif_dfc {
70  /* enable vertical defect correction */
72  /* Defect level subtraction. Just fed through if saturating */
73 #define ISIF_VDFC_NORMAL 0
74  /*
75  * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
76  * if data saturating
77  */
78 #define ISIF_VDFC_HORZ_INTERPOL_IF_SAT 1
79  /* Horizontal interpolation (((i-2)+(i+2))/2) */
80 #define ISIF_VDFC_HORZ_INTERPOL 2
81  /* one of the vertical defect correction modes above */
83  /* 0 - whole line corrected, 1 - not pixels upper than the defect */
85 #define ISIF_VDFC_NO_SHIFT 0
86 #define ISIF_VDFC_SHIFT_1 1
87 #define ISIF_VDFC_SHIFT_2 2
88 #define ISIF_VDFC_SHIFT_3 3
89 #define ISIF_VDFC_SHIFT_4 4
90  /*
91  * defect level shift value. level_at_pos, level_upper_pos,
92  * and level_lower_pos can be shifted up by this value. Choose
93  * one of the values above
94  */
96  /* defect saturation level */
98  /* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
100  /* VDFC table ptr */
102 };
103 
105 
106  /* Horizontal clamp disabled. Only vertical clamp value is subtracted */
107 #define ISIF_HORZ_BC_DISABLE 0
108  /*
109  * Horizontal clamp value is calculated and subtracted from image data
110  * along with vertical clamp value
111  */
112 #define ISIF_HORZ_BC_CLAMP_CALC_ENABLED 1
113  /*
114  * Horizontal clamp value calculated from previous image is subtracted
115  * from image data along with vertical clamp value.
116  */
117 #define ISIF_HORZ_BC_CLAMP_NOT_UPDATED 2
118  /* horizontal clamp mode. One of the values above */
120  /*
121  * pixel value limit enable.
122  * 0 - limit disabled
123  * 1 - pixel value limited to 1023
124  */
126  /* Select Most left window for bc calculation */
127 #define ISIF_SEL_MOST_LEFT_WIN 0
128  /* Select Most right window for bc calculation */
129 #define ISIF_SEL_MOST_RIGHT_WIN 1
130  /* Select most left or right window for clamp val calculation */
132  /* Window count per color for calculation. range 1-32 */
134  /* Window start position - horizontal for calculation. 0 - 8191 */
136  /* Window start position - vertical for calculation 0 - 8191 */
138 #define ISIF_HORZ_BC_SZ_H_2PIXELS 0
139 #define ISIF_HORZ_BC_SZ_H_4PIXELS 1
140 #define ISIF_HORZ_BC_SZ_H_8PIXELS 2
141 #define ISIF_HORZ_BC_SZ_H_16PIXELS 3
142  /* Width of the sample window in pixels for calculation */
144 #define ISIF_HORZ_BC_SZ_V_32PIXELS 0
145 #define ISIF_HORZ_BC_SZ_V_64PIXELS 1
146 #define ISIF_HORZ_BC_SZ_V_128PIXELS 2
147 #define ISIF_HORZ_BC_SZ_V_256PIXELS 3
148  /* Height of the sample window in pixels for calculation */
150 };
151 
152 /************************************************************************
153  * Black Clamp parameters
154  ***********************************************************************/
156  /* Reset value used is the clamp value calculated */
157 #define ISIF_VERT_BC_USE_HORZ_CLAMP_VAL 0
158  /* Reset value used is reset_clamp_val configured */
159 #define ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL 1
160  /* No update, previous image value is used */
161 #define ISIF_VERT_BC_NO_UPDATE 2
162  /*
163  * Reset value selector for vertical clamp calculation. Use one of
164  * the above values
165  */
167  /* U8Q8. Line average coefficient used in vertical clamp calculation */
169  /* Height of the optical black region for calculation */
171  /* Optical black region start position - horizontal. 0 - 8191 */
173  /* Optical black region start position - vertical 0 - 8191 */
175 };
176 
178  /*
179  * This offset value is added irrespective of the clamp enable status.
180  * S13
181  */
183  /*
184  * Enable black/digital clamp value to be subtracted from the image data
185  */
187  /*
188  * black clamp mode. same/separate clamp for 4 colors
189  * 0 - disable - same clamp value for all colors
190  * 1 - clamp value calculated separately for all colors
191  */
193  /* Vrtical start position for bc subtraction */
195  /* Black clamp for horizontal direction */
197  /* Black clamp for vertical direction */
199 };
200 
201 /*************************************************************************
202 ** Color Space Conversion (CSC)
203 *************************************************************************/
204 #define ISIF_CSC_NUM_COEFF 16
206  /* Enable color space conversion */
208  /*
209  * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
210  * so forth
211  */
213 };
214 
215 
216 /*************************************************************************
217 ** Black Compensation parameters
218 *************************************************************************/
220  /* Comp for Red */
222  /* Comp for Gr */
224  /* Comp for Blue */
226  /* Comp for Gb */
228 };
229 
230 /*************************************************************************
231 ** Gain parameters
232 *************************************************************************/
233 struct isif_gain {
234  /* Gain for Red or ye */
236  /* Gain for Gr or cy */
238  /* Gain for Gb or g */
240  /* Gain for Blue or mg */
242 };
243 
244 #define ISIF_LINEAR_TAB_SIZE 192
245 /*************************************************************************
246 ** Linearization parameters
247 *************************************************************************/
249  /* Enable or Disable linearization of data */
251  /* Shift value applied */
253  /* scale factor applied U11Q10 */
255  /* Size of the linear table */
257 };
258 
259 /* Color patterns */
260 #define ISIF_RED 0
261 #define ISIF_GREEN_RED 1
262 #define ISIF_GREEN_BLUE 2
263 #define ISIF_BLUE 3
264 struct isif_col_pat {
269 };
270 
271 /*************************************************************************
272 ** Data formatter parameters
273 *************************************************************************/
274 struct isif_fmtplen {
275  /*
276  * number of program entries for SET0, range 1 - 16
277  * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
278  * ISIF_COMBINE
279  */
281  /*
282  * number of program entries for SET1, range 1 - 16
283  * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
284  * ISIF_COMBINE
285  */
299 };
300 
301 struct isif_fmt_cfg {
302 #define ISIF_SPLIT 0
303 #define ISIF_COMBINE 1
304  /* Split or combine or line alternate */
306  /* enable or disable line alternating mode */
308 #define ISIF_1LINE 0
309 #define ISIF_2LINES 1
310 #define ISIF_3LINES 2
311 #define ISIF_4LINES 3
312  /* Split/combine line number */
314  /* Address increment Range 1 - 16 */
316 };
317 
319  /* Initial address */
321  /* output line number */
322 #define ISIF_1STLINE 0
323 #define ISIF_2NDLINE 1
324 #define ISIF_3RDLINE 2
325 #define ISIF_4THLINE 3
327 };
328 
330  /* program address pointer */
332  /* program address increment or decrement */
334 };
335 
337  /* Enable/Disable data formatter */
339  /* data formatter configuration */
341  /* Formatter program entries length */
343  /* first pixel in a line fed to formatter */
345  /* HD interval for output line. Only valid when split line */
347  /* formatter address pointers */
349  /* program enable/disable */
351  /* program address pointers */
353 };
354 
355 struct isif_df_csc {
356  /* Color Space Conversion confguration, 0 - csc, 1 - df */
358  /* csc configuration valid if df_or_csc is 0 */
360  /* data formatter configuration valid if df_or_csc is 1 */
362  /* start pixel in a line at the input */
364  /* number of pixels in input line */
366  /* start line at the input */
368  /* number of lines at the input */
370 };
371 
373  /* Gain adjustment per color */
374  struct isif_gain gain;
375  /* Offset adjustment */
377  /* Enable or Disable Gain adjustment for SDRAM data */
379  /* Enable or Disable Gain adjustment for IPIPE data */
381  /* Enable or Disable Gain adjustment for H3A data */
383  /* Enable or Disable Gain adjustment for SDRAM data */
385  /* Enable or Disable Gain adjustment for IPIPE data */
387  /* Enable or Disable Gain adjustment for H3A data */
389 };
390 
391 struct isif_cul {
392  /* Horizontal Cull pattern for odd lines */
394  /* Horizontal Cull pattern for even lines */
396  /* Vertical Cull pattern */
398  /* Enable or disable lpf. Apply when cull is enabled */
400 };
401 
403 #define ISIF_ALAW 0
404 #define ISIF_DPCM 1
405 #define ISIF_NO_COMPRESSION 2
406  /* Compression Algorithm used */
408  /* Choose Predictor1 for DPCM compression */
409 #define ISIF_DPCM_PRED1 0
410  /* Choose Predictor2 for DPCM compression */
411 #define ISIF_DPCM_PRED2 1
412  /* Predictor for DPCM compression */
414 };
415 
416 /* all the stuff in this struct will be provided by userland */
418  /* Linearization parameters for image sensor data input */
420  /* Data formatter or CSC */
422  /* Defect Pixel Correction (DFC) confguration */
423  struct isif_dfc dfc;
424  /* Black/Digital Clamp configuration */
426  /* Gain, offset adjustments */
428  /* Culling */
430  /* A-Law and DPCM compression options */
432  /* horizontal offset for Gain/LSC/DFC */
434  /* vertical offset for Gain/LSC/DFC */
436  /* color pattern for field 0 */
438  /* color pattern for field 1 */
440 #define ISIF_NO_SHIFT 0
441 #define ISIF_1BIT_SHIFT 1
442 #define ISIF_2BIT_SHIFT 2
443 #define ISIF_3BIT_SHIFT 3
444 #define ISIF_4BIT_SHIFT 4
445 #define ISIF_5BIT_SHIFT 5
446 #define ISIF_6BIT_SHIFT 6
447  /* Data shift applied before storing to SDRAM */
449  /* enable input test pattern generation */
451 };
452 
453 #ifdef __KERNEL__
454 struct isif_ycbcr_config {
455  /* isif pixel format */
456  enum ccdc_pixfmt pix_fmt;
457  /* isif frame format */
458  enum ccdc_frmfmt frm_fmt;
459  /* ISIF crop window */
460  struct v4l2_rect win;
461  /* field polarity */
462  enum vpfe_pin_pol fid_pol;
463  /* interface VD polarity */
464  enum vpfe_pin_pol vd_pol;
465  /* interface HD polarity */
466  enum vpfe_pin_pol hd_pol;
467  /* isif pix order. Only used for ycbcr capture */
468  enum ccdc_pixorder pix_order;
469  /* isif buffer type. Only used for ycbcr capture */
470  enum ccdc_buftype buf_type;
471 };
472 
473 /* MSB of image data connected to sensor port */
474 enum isif_data_msb {
475  ISIF_BIT_MSB_15,
476  ISIF_BIT_MSB_14,
477  ISIF_BIT_MSB_13,
478  ISIF_BIT_MSB_12,
479  ISIF_BIT_MSB_11,
480  ISIF_BIT_MSB_10,
481  ISIF_BIT_MSB_9,
482  ISIF_BIT_MSB_8,
483  ISIF_BIT_MSB_7
484 };
485 
486 enum isif_cfa_pattern {
487  ISIF_CFA_PAT_MOSAIC,
488  ISIF_CFA_PAT_STRIPE
489 };
490 
491 struct isif_params_raw {
492  /* isif pixel format */
493  enum ccdc_pixfmt pix_fmt;
494  /* isif frame format */
495  enum ccdc_frmfmt frm_fmt;
496  /* video window */
497  struct v4l2_rect win;
498  /* field polarity */
499  enum vpfe_pin_pol fid_pol;
500  /* interface VD polarity */
501  enum vpfe_pin_pol vd_pol;
502  /* interface HD polarity */
503  enum vpfe_pin_pol hd_pol;
504  /* buffer type. Applicable for interlaced mode */
505  enum ccdc_buftype buf_type;
506  /* Gain values */
507  struct isif_gain gain;
508  /* cfa pattern */
509  enum isif_cfa_pattern cfa_pat;
510  /* Data MSB position */
511  enum isif_data_msb data_msb;
512  /* Enable horizontal flip */
513  unsigned char horz_flip_en;
514  /* Enable image invert vertically */
515  unsigned char image_invert_en;
516 
517  /* all the userland defined stuff*/
518  struct isif_config_params_raw config_params;
519 };
520 
521 enum isif_data_pack {
522  ISIF_PACK_16BIT,
523  ISIF_PACK_12BIT,
524  ISIF_PACK_8BIT
525 };
526 
527 #define ISIF_WIN_NTSC {0, 0, 720, 480}
528 #define ISIF_WIN_VGA {0, 0, 640, 480}
529 
530 #endif
531 #endif