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.
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
23 #include <media/davinci/ccdc_types.h>
24 #include <media/davinci/vpfe_types.h>
26 /* isif float type S8Q8/U8Q8 */
28 /* 8 bit integer part */
30 /* 8 bit decimal part */
34 /* isif float type U16Q16/S16Q16 */
35 struct isif_float_16
{
36 /* 16 bit integer part */
38 /* 16 bit decimal part */
42 /************************************************************************
43 * Vertical Defect Correction parameters
44 ***********************************************************************/
45 /* Defect Correction (DFC) table entry */
46 struct isif_vdfc_entry
{
47 /* vertical position of defect */
49 /* horizontal position of defect */
52 * Defect level of Vertical line defect position. This is subtracted
53 * from the data at the defect position
57 * Defect level of the pixels upper than the vertical line defect.
58 * This is subtracted from the data
62 * Defect level of the pixels lower than the vertical line defect.
63 * This is subtracted from the data
65 __u8 level_low_pixels
;
68 #define ISIF_VDFC_TABLE_SIZE 8
70 /* enable vertical defect correction */
72 /* Defect level subtraction. Just fed through if saturating */
73 #define ISIF_VDFC_NORMAL 0
75 * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
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
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
96 /* defect saturation level */
98 /* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
101 struct isif_vdfc_entry table
[ISIF_VDFC_TABLE_SIZE
];
104 struct isif_horz_bclamp
{
106 /* Horizontal clamp disabled. Only vertical clamp value is subtracted */
107 #define ISIF_HORZ_BC_DISABLE 0
109 * Horizontal clamp value is calculated and subtracted from image data
110 * along with vertical clamp value
112 #define ISIF_HORZ_BC_CLAMP_CALC_ENABLED 1
114 * Horizontal clamp value calculated from previous image is subtracted
115 * from image data along with vertical clamp value.
117 #define ISIF_HORZ_BC_CLAMP_NOT_UPDATED 2
118 /* horizontal clamp mode. One of the values above */
121 * pixel value limit enable.
123 * 1 - pixel value limited to 1023
125 __u8 clamp_pix_limit
;
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 */
131 __u8 base_win_sel_calc
;
132 /* Window count per color for calculation. range 1-32 */
134 /* Window start position - horizontal for calculation. 0 - 8191 */
135 __u16 win_start_h_calc
;
136 /* Window start position - vertical for calculation 0 - 8191 */
137 __u16 win_start_v_calc
;
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 */
152 /************************************************************************
153 * Black Clamp parameters
154 ***********************************************************************/
155 struct isif_vert_bclamp
{
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
163 * Reset value selector for vertical clamp calculation. Use one of
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 */
177 struct isif_black_clamp
{
179 * This offset value is added irrespective of the clamp enable status.
184 * Enable black/digital clamp value to be subtracted from the image data
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
193 /* Vrtical start position for bc subtraction */
194 __u16 vert_start_sub
;
195 /* Black clamp for horizontal direction */
196 struct isif_horz_bclamp horz
;
197 /* Black clamp for vertical direction */
198 struct isif_vert_bclamp vert
;
201 /*************************************************************************
202 ** Color Space Conversion (CSC)
203 *************************************************************************/
204 #define ISIF_CSC_NUM_COEFF 16
205 struct isif_color_space_conv
{
206 /* Enable color space conversion */
209 * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
212 struct isif_float_8 coeff
[ISIF_CSC_NUM_COEFF
];
216 /*************************************************************************
217 ** Black Compensation parameters
218 *************************************************************************/
219 struct isif_black_comp
{
230 /*************************************************************************
232 *************************************************************************/
234 /* Gain for Red or ye */
235 struct isif_float_16 r_ye
;
236 /* Gain for Gr or cy */
237 struct isif_float_16 gr_cy
;
238 /* Gain for Gb or g */
239 struct isif_float_16 gb_g
;
240 /* Gain for Blue or mg */
241 struct isif_float_16 b_mg
;
244 #define ISIF_LINEAR_TAB_SIZE 192
245 /*************************************************************************
246 ** Linearization parameters
247 *************************************************************************/
248 struct isif_linearize
{
249 /* Enable or Disable linearization of data */
251 /* Shift value applied */
253 /* scale factor applied U11Q10 */
254 struct isif_float_16 scale_fact
;
255 /* Size of the linear table */
256 __u16 table
[ISIF_LINEAR_TAB_SIZE
];
261 #define ISIF_GREEN_RED 1
262 #define ISIF_GREEN_BLUE 2
264 struct isif_col_pat
{
271 /*************************************************************************
272 ** Data formatter parameters
273 *************************************************************************/
274 struct isif_fmtplen
{
276 * number of program entries for SET0, range 1 - 16
277 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
282 * number of program entries for SET1, range 1 - 16
283 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
288 * number of program entries for SET2, range 1 - 16
289 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
294 * number of program entries for SET3, range 1 - 16
295 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
301 struct isif_fmt_cfg
{
303 #define ISIF_COMBINE 1
304 /* Split or combine or line alternate */
306 /* enable or disable line alternating mode */
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 */
318 struct isif_fmt_addr_ptr
{
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
329 struct isif_fmtpgm_ap
{
330 /* program address pointer */
332 /* program address increment or decrement */
336 struct isif_data_formatter
{
337 /* Enable/Disable data formatter */
339 /* data formatter configuration */
340 struct isif_fmt_cfg cfg
;
341 /* Formatter program entries length */
342 struct isif_fmtplen plen
;
343 /* first pixel in a line fed to formatter */
345 /* HD interval for output line. Only valid when split line */
347 /* formatter address pointers */
348 struct isif_fmt_addr_ptr fmtaddr_ptr
[16];
349 /* program enable/disable */
351 /* program address pointers */
352 struct isif_fmtpgm_ap fmtpgm_ap
[32];
356 /* Color Space Conversion confguration, 0 - csc, 1 - df */
358 /* csc configuration valid if df_or_csc is 0 */
359 struct isif_color_space_conv csc
;
360 /* data formatter configuration valid if df_or_csc is 1 */
361 struct isif_data_formatter df
;
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 */
372 struct isif_gain_offsets_adj
{
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 */
384 __u8 offset_sdram_en
;
385 /* Enable or Disable Gain adjustment for IPIPE data */
386 __u8 offset_ipipe_en
;
387 /* Enable or Disable Gain adjustment for H3A data */
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 */
402 struct isif_compress
{
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 */
416 /* all the stuff in this struct will be provided by userland */
417 struct isif_config_params_raw
{
418 /* Linearization parameters for image sensor data input */
419 struct isif_linearize linearize
;
420 /* Data formatter or CSC */
421 struct isif_df_csc df_csc
;
422 /* Defect Pixel Correction (DFC) confguration */
424 /* Black/Digital Clamp configuration */
425 struct isif_black_clamp bclamp
;
426 /* Gain, offset adjustments */
427 struct isif_gain_offsets_adj gain_offset
;
429 struct isif_cul culling
;
430 /* A-Law and DPCM compression options */
431 struct isif_compress compress
;
432 /* horizontal offset for Gain/LSC/DFC */
434 /* vertical offset for Gain/LSC/DFC */
436 /* color pattern for field 0 */
437 struct isif_col_pat col_pat_field0
;
438 /* color pattern for field 1 */
439 struct isif_col_pat col_pat_field1
;
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 */
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
;
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
;
473 /* MSB of image data connected to sensor port */
486 enum isif_cfa_pattern
{
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
;
497 struct v4l2_rect win
;
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
;
507 struct isif_gain gain
;
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
;
517 /* all the userland defined stuff*/
518 struct isif_config_params_raw config_params
;
521 enum isif_data_pack
{
527 #define ISIF_WIN_NTSC {0, 0, 720, 480}
528 #define ISIF_WIN_VGA {0, 0, 640, 480}