2 * Copyright (C) 2008-2009 Texas Instruments Inc
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.
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.
19 #include <media/davinci/ccdc_types.h>
20 #include <media/davinci/vpfe_types.h>
22 /* isif float type S8Q8/U8Q8 */
24 /* 8 bit integer part */
26 /* 8 bit decimal part */
30 /* isif float type U16Q16/S16Q16 */
31 struct isif_float_16
{
32 /* 16 bit integer part */
34 /* 16 bit decimal part */
38 /************************************************************************
39 * Vertical Defect Correction parameters
40 ***********************************************************************/
41 /* Defect Correction (DFC) table entry */
42 struct isif_vdfc_entry
{
43 /* vertical position of defect */
45 /* horizontal position of defect */
48 * Defect level of Vertical line defect position. This is subtracted
49 * from the data at the defect position
53 * Defect level of the pixels upper than the vertical line defect.
54 * This is subtracted from the data
58 * Defect level of the pixels lower than the vertical line defect.
59 * This is subtracted from the data
61 __u8 level_low_pixels
;
64 #define ISIF_VDFC_TABLE_SIZE 8
66 /* enable vertical defect correction */
68 /* Defect level subtraction. Just fed through if saturating */
69 #define ISIF_VDFC_NORMAL 0
71 * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
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 */
79 /* 0 - whole line corrected, 1 - not pixels upper than the defect */
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
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
92 /* defect saturation level */
94 /* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
97 struct isif_vdfc_entry table
[ISIF_VDFC_TABLE_SIZE
];
100 struct isif_horz_bclamp
{
102 /* Horizontal clamp disabled. Only vertical clamp value is subtracted */
103 #define ISIF_HORZ_BC_DISABLE 0
105 * Horizontal clamp value is calculated and subtracted from image data
106 * along with vertical clamp value
108 #define ISIF_HORZ_BC_CLAMP_CALC_ENABLED 1
110 * Horizontal clamp value calculated from previous image is subtracted
111 * from image data along with vertical clamp value.
113 #define ISIF_HORZ_BC_CLAMP_NOT_UPDATED 2
114 /* horizontal clamp mode. One of the values above */
117 * pixel value limit enable.
119 * 1 - pixel value limited to 1023
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 */
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 */
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 */
148 /************************************************************************
149 * Black Clamp parameters
150 ***********************************************************************/
151 struct 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
159 * Reset value selector for vertical clamp calculation. Use one of
163 /* U8Q8. Line average coefficient used in vertical clamp calculation */
165 /* Height of the optical black region for calculation */
167 /* Optical black region start position - horizontal. 0 - 8191 */
169 /* Optical black region start position - vertical 0 - 8191 */
173 struct isif_black_clamp
{
175 * This offset value is added irrespective of the clamp enable status.
180 * Enable black/digital clamp value to be subtracted from the image data
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
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
;
197 /*************************************************************************
198 ** Color Space Conversion (CSC)
199 *************************************************************************/
200 #define ISIF_CSC_NUM_COEFF 16
201 struct isif_color_space_conv
{
202 /* Enable color space conversion */
205 * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
208 struct isif_float_8 coeff
[ISIF_CSC_NUM_COEFF
];
212 /*************************************************************************
213 ** Black Compensation parameters
214 *************************************************************************/
215 struct isif_black_comp
{
226 /*************************************************************************
228 *************************************************************************/
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
;
240 #define ISIF_LINEAR_TAB_SIZE 192
241 /*************************************************************************
242 ** Linearization parameters
243 *************************************************************************/
244 struct isif_linearize
{
245 /* Enable or Disable linearization of data */
247 /* Shift value applied */
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
];
257 #define ISIF_GREEN_RED 1
258 #define ISIF_GREEN_BLUE 2
260 struct isif_col_pat
{
267 /*************************************************************************
268 ** Data formatter parameters
269 *************************************************************************/
270 struct isif_fmtplen
{
272 * number of program entries for SET0, range 1 - 16
273 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
278 * number of program entries for SET1, range 1 - 16
279 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
284 * number of program entries for SET2, range 1 - 16
285 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
290 * number of program entries for SET3, range 1 - 16
291 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
297 struct isif_fmt_cfg
{
299 #define ISIF_COMBINE 1
300 /* Split or combine or line alternate */
302 /* enable or disable line alternating mode */
305 #define ISIF_2LINES 1
306 #define ISIF_3LINES 2
307 #define ISIF_4LINES 3
308 /* Split/combine line number */
310 /* Address increment Range 1 - 16 */
314 struct isif_fmt_addr_ptr
{
315 /* Initial address */
317 /* output line number */
318 #define ISIF_1STLINE 0
319 #define ISIF_2NDLINE 1
320 #define ISIF_3RDLINE 2
321 #define ISIF_4THLINE 3
325 struct isif_fmtpgm_ap
{
326 /* program address pointer */
328 /* program address increment or decrement */
332 struct isif_data_formatter
{
333 /* Enable/Disable data formatter */
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 */
341 /* HD interval for output line. Only valid when split line */
343 /* formatter address pointers */
344 struct isif_fmt_addr_ptr fmtaddr_ptr
[16];
345 /* program enable/disable */
347 /* program address pointers */
348 struct isif_fmtpgm_ap fmtpgm_ap
[32];
352 /* Color Space Conversion confguration, 0 - csc, 1 - df */
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 */
360 /* number of pixels in input line */
362 /* start line at the input */
364 /* number of lines at the input */
368 struct isif_gain_offsets_adj
{
369 /* Gain adjustment per color */
370 struct isif_gain gain
;
371 /* Offset adjustment */
373 /* Enable or Disable Gain adjustment for SDRAM data */
375 /* Enable or Disable Gain adjustment for IPIPE data */
377 /* Enable or Disable Gain adjustment for H3A data */
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 */
388 /* Horizontal Cull pattern for odd lines */
390 /* Horizontal Cull pattern for even lines */
392 /* Vertical Cull pattern */
394 /* Enable or disable lpf. Apply when cull is enabled */
398 struct isif_compress
{
401 #define ISIF_NO_COMPRESSION 2
402 /* Compression Algorithm used */
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 */
412 /* all the stuff in this struct will be provided by userland */
413 struct 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 */
420 /* Black/Digital Clamp configuration */
421 struct isif_black_clamp bclamp
;
422 /* Gain, offset adjustments */
423 struct isif_gain_offsets_adj gain_offset
;
425 struct isif_cul culling
;
426 /* A-Law and DPCM compression options */
427 struct isif_compress compress
;
428 /* horizontal offset for Gain/LSC/DFC */
430 /* vertical offset for Gain/LSC/DFC */
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 */
445 /* enable input test pattern generation */
450 struct 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
;
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
;
469 /* MSB of image data connected to sensor port */
482 enum isif_cfa_pattern
{
487 struct isif_params_raw
{
488 /* isif pixel format */
489 enum ccdc_pixfmt pix_fmt
;
490 /* isif frame format */
491 enum ccdc_frmfmt frm_fmt
;
493 struct v4l2_rect win
;
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
;
503 struct isif_gain gain
;
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
;
513 /* all the userland defined stuff*/
514 struct isif_config_params_raw config_params
;
517 enum isif_data_pack
{
523 #define ISIF_WIN_NTSC {0, 0, 720, 480}
524 #define ISIF_WIN_VGA {0, 0, 640, 480}