1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2008-2009 Texas Instruments Inc
10 #include <media/davinci/ccdc_types.h>
11 #include <media/davinci/vpfe_types.h>
13 /* isif float type S8Q8/U8Q8 */
15 /* 8 bit integer part */
17 /* 8 bit decimal part */
21 /* isif float type U16Q16/S16Q16 */
22 struct isif_float_16
{
23 /* 16 bit integer part */
25 /* 16 bit decimal part */
29 /************************************************************************
30 * Vertical Defect Correction parameters
31 ***********************************************************************/
32 /* Defect Correction (DFC) table entry */
33 struct isif_vdfc_entry
{
34 /* vertical position of defect */
36 /* horizontal position of defect */
39 * Defect level of Vertical line defect position. This is subtracted
40 * from the data at the defect position
44 * Defect level of the pixels upper than the vertical line defect.
45 * This is subtracted from the data
49 * Defect level of the pixels lower than the vertical line defect.
50 * This is subtracted from the data
52 __u8 level_low_pixels
;
55 #define ISIF_VDFC_TABLE_SIZE 8
57 /* enable vertical defect correction */
59 /* Defect level subtraction. Just fed through if saturating */
60 #define ISIF_VDFC_NORMAL 0
62 * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
65 #define ISIF_VDFC_HORZ_INTERPOL_IF_SAT 1
66 /* Horizontal interpolation (((i-2)+(i+2))/2) */
67 #define ISIF_VDFC_HORZ_INTERPOL 2
68 /* one of the vertical defect correction modes above */
70 /* 0 - whole line corrected, 1 - not pixels upper than the defect */
72 #define ISIF_VDFC_NO_SHIFT 0
73 #define ISIF_VDFC_SHIFT_1 1
74 #define ISIF_VDFC_SHIFT_2 2
75 #define ISIF_VDFC_SHIFT_3 3
76 #define ISIF_VDFC_SHIFT_4 4
78 * defect level shift value. level_at_pos, level_upper_pos,
79 * and level_lower_pos can be shifted up by this value. Choose
80 * one of the values above
83 /* defect saturation level */
85 /* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
88 struct isif_vdfc_entry table
[ISIF_VDFC_TABLE_SIZE
];
91 struct isif_horz_bclamp
{
93 /* Horizontal clamp disabled. Only vertical clamp value is subtracted */
94 #define ISIF_HORZ_BC_DISABLE 0
96 * Horizontal clamp value is calculated and subtracted from image data
97 * along with vertical clamp value
99 #define ISIF_HORZ_BC_CLAMP_CALC_ENABLED 1
101 * Horizontal clamp value calculated from previous image is subtracted
102 * from image data along with vertical clamp value.
104 #define ISIF_HORZ_BC_CLAMP_NOT_UPDATED 2
105 /* horizontal clamp mode. One of the values above */
108 * pixel value limit enable.
110 * 1 - pixel value limited to 1023
112 __u8 clamp_pix_limit
;
113 /* Select Most left window for bc calculation */
114 #define ISIF_SEL_MOST_LEFT_WIN 0
115 /* Select Most right window for bc calculation */
116 #define ISIF_SEL_MOST_RIGHT_WIN 1
117 /* Select most left or right window for clamp val calculation */
118 __u8 base_win_sel_calc
;
119 /* Window count per color for calculation. range 1-32 */
121 /* Window start position - horizontal for calculation. 0 - 8191 */
122 __u16 win_start_h_calc
;
123 /* Window start position - vertical for calculation 0 - 8191 */
124 __u16 win_start_v_calc
;
125 #define ISIF_HORZ_BC_SZ_H_2PIXELS 0
126 #define ISIF_HORZ_BC_SZ_H_4PIXELS 1
127 #define ISIF_HORZ_BC_SZ_H_8PIXELS 2
128 #define ISIF_HORZ_BC_SZ_H_16PIXELS 3
129 /* Width of the sample window in pixels for calculation */
131 #define ISIF_HORZ_BC_SZ_V_32PIXELS 0
132 #define ISIF_HORZ_BC_SZ_V_64PIXELS 1
133 #define ISIF_HORZ_BC_SZ_V_128PIXELS 2
134 #define ISIF_HORZ_BC_SZ_V_256PIXELS 3
135 /* Height of the sample window in pixels for calculation */
139 /************************************************************************
140 * Black Clamp parameters
141 ***********************************************************************/
142 struct isif_vert_bclamp
{
143 /* Reset value used is the clamp value calculated */
144 #define ISIF_VERT_BC_USE_HORZ_CLAMP_VAL 0
145 /* Reset value used is reset_clamp_val configured */
146 #define ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL 1
147 /* No update, previous image value is used */
148 #define ISIF_VERT_BC_NO_UPDATE 2
150 * Reset value selector for vertical clamp calculation. Use one of
154 /* U8Q8. Line average coefficient used in vertical clamp calculation */
156 /* Height of the optical black region for calculation */
158 /* Optical black region start position - horizontal. 0 - 8191 */
160 /* Optical black region start position - vertical 0 - 8191 */
164 struct isif_black_clamp
{
166 * This offset value is added irrespective of the clamp enable status.
171 * Enable black/digital clamp value to be subtracted from the image data
175 * black clamp mode. same/separate clamp for 4 colors
176 * 0 - disable - same clamp value for all colors
177 * 1 - clamp value calculated separately for all colors
180 /* Vrtical start position for bc subtraction */
181 __u16 vert_start_sub
;
182 /* Black clamp for horizontal direction */
183 struct isif_horz_bclamp horz
;
184 /* Black clamp for vertical direction */
185 struct isif_vert_bclamp vert
;
188 /*************************************************************************
189 ** Color Space Conversion (CSC)
190 *************************************************************************/
191 #define ISIF_CSC_NUM_COEFF 16
192 struct isif_color_space_conv
{
193 /* Enable color space conversion */
196 * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
199 struct isif_float_8 coeff
[ISIF_CSC_NUM_COEFF
];
203 /*************************************************************************
204 ** Black Compensation parameters
205 *************************************************************************/
206 struct isif_black_comp
{
217 /*************************************************************************
219 *************************************************************************/
221 /* Gain for Red or ye */
222 struct isif_float_16 r_ye
;
223 /* Gain for Gr or cy */
224 struct isif_float_16 gr_cy
;
225 /* Gain for Gb or g */
226 struct isif_float_16 gb_g
;
227 /* Gain for Blue or mg */
228 struct isif_float_16 b_mg
;
231 #define ISIF_LINEAR_TAB_SIZE 192
232 /*************************************************************************
233 ** Linearization parameters
234 *************************************************************************/
235 struct isif_linearize
{
236 /* Enable or Disable linearization of data */
238 /* Shift value applied */
240 /* scale factor applied U11Q10 */
241 struct isif_float_16 scale_fact
;
242 /* Size of the linear table */
243 __u16 table
[ISIF_LINEAR_TAB_SIZE
];
248 #define ISIF_GREEN_RED 1
249 #define ISIF_GREEN_BLUE 2
251 struct isif_col_pat
{
258 /*************************************************************************
259 ** Data formatter parameters
260 *************************************************************************/
261 struct isif_fmtplen
{
263 * number of program entries for SET0, range 1 - 16
264 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
269 * number of program entries for SET1, range 1 - 16
270 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
275 * number of program entries for SET2, range 1 - 16
276 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
281 * number of program entries for SET3, range 1 - 16
282 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
288 struct isif_fmt_cfg
{
290 #define ISIF_COMBINE 1
291 /* Split or combine or line alternate */
293 /* enable or disable line alternating mode */
296 #define ISIF_2LINES 1
297 #define ISIF_3LINES 2
298 #define ISIF_4LINES 3
299 /* Split/combine line number */
301 /* Address increment Range 1 - 16 */
305 struct isif_fmt_addr_ptr
{
306 /* Initial address */
308 /* output line number */
309 #define ISIF_1STLINE 0
310 #define ISIF_2NDLINE 1
311 #define ISIF_3RDLINE 2
312 #define ISIF_4THLINE 3
316 struct isif_fmtpgm_ap
{
317 /* program address pointer */
319 /* program address increment or decrement */
323 struct isif_data_formatter
{
324 /* Enable/Disable data formatter */
326 /* data formatter configuration */
327 struct isif_fmt_cfg cfg
;
328 /* Formatter program entries length */
329 struct isif_fmtplen plen
;
330 /* first pixel in a line fed to formatter */
332 /* HD interval for output line. Only valid when split line */
334 /* formatter address pointers */
335 struct isif_fmt_addr_ptr fmtaddr_ptr
[16];
336 /* program enable/disable */
338 /* program address pointers */
339 struct isif_fmtpgm_ap fmtpgm_ap
[32];
343 /* Color Space Conversion confguration, 0 - csc, 1 - df */
345 /* csc configuration valid if df_or_csc is 0 */
346 struct isif_color_space_conv csc
;
347 /* data formatter configuration valid if df_or_csc is 1 */
348 struct isif_data_formatter df
;
349 /* start pixel in a line at the input */
351 /* number of pixels in input line */
353 /* start line at the input */
355 /* number of lines at the input */
359 struct isif_gain_offsets_adj
{
360 /* Gain adjustment per color */
361 struct isif_gain gain
;
362 /* Offset adjustment */
364 /* Enable or Disable Gain adjustment for SDRAM data */
366 /* Enable or Disable Gain adjustment for IPIPE data */
368 /* Enable or Disable Gain adjustment for H3A data */
370 /* Enable or Disable Gain adjustment for SDRAM data */
371 __u8 offset_sdram_en
;
372 /* Enable or Disable Gain adjustment for IPIPE data */
373 __u8 offset_ipipe_en
;
374 /* Enable or Disable Gain adjustment for H3A data */
379 /* Horizontal Cull pattern for odd lines */
381 /* Horizontal Cull pattern for even lines */
383 /* Vertical Cull pattern */
385 /* Enable or disable lpf. Apply when cull is enabled */
389 struct isif_compress
{
392 #define ISIF_NO_COMPRESSION 2
393 /* Compression Algorithm used */
395 /* Choose Predictor1 for DPCM compression */
396 #define ISIF_DPCM_PRED1 0
397 /* Choose Predictor2 for DPCM compression */
398 #define ISIF_DPCM_PRED2 1
399 /* Predictor for DPCM compression */
403 /* all the stuff in this struct will be provided by userland */
404 struct isif_config_params_raw
{
405 /* Linearization parameters for image sensor data input */
406 struct isif_linearize linearize
;
407 /* Data formatter or CSC */
408 struct isif_df_csc df_csc
;
409 /* Defect Pixel Correction (DFC) confguration */
411 /* Black/Digital Clamp configuration */
412 struct isif_black_clamp bclamp
;
413 /* Gain, offset adjustments */
414 struct isif_gain_offsets_adj gain_offset
;
416 struct isif_cul culling
;
417 /* A-Law and DPCM compression options */
418 struct isif_compress compress
;
419 /* horizontal offset for Gain/LSC/DFC */
421 /* vertical offset for Gain/LSC/DFC */
423 /* color pattern for field 0 */
424 struct isif_col_pat col_pat_field0
;
425 /* color pattern for field 1 */
426 struct isif_col_pat col_pat_field1
;
427 #define ISIF_NO_SHIFT 0
428 #define ISIF_1BIT_SHIFT 1
429 #define ISIF_2BIT_SHIFT 2
430 #define ISIF_3BIT_SHIFT 3
431 #define ISIF_4BIT_SHIFT 4
432 #define ISIF_5BIT_SHIFT 5
433 #define ISIF_6BIT_SHIFT 6
434 /* Data shift applied before storing to SDRAM */
436 /* enable input test pattern generation */
441 struct isif_ycbcr_config
{
442 /* isif pixel format */
443 enum ccdc_pixfmt pix_fmt
;
444 /* isif frame format */
445 enum ccdc_frmfmt frm_fmt
;
446 /* ISIF crop window */
447 struct v4l2_rect win
;
449 enum vpfe_pin_pol fid_pol
;
450 /* interface VD polarity */
451 enum vpfe_pin_pol vd_pol
;
452 /* interface HD polarity */
453 enum vpfe_pin_pol hd_pol
;
454 /* isif pix order. Only used for ycbcr capture */
455 enum ccdc_pixorder pix_order
;
456 /* isif buffer type. Only used for ycbcr capture */
457 enum ccdc_buftype buf_type
;
460 /* MSB of image data connected to sensor port */
473 enum isif_cfa_pattern
{
478 struct isif_params_raw
{
479 /* isif pixel format */
480 enum ccdc_pixfmt pix_fmt
;
481 /* isif frame format */
482 enum ccdc_frmfmt frm_fmt
;
484 struct v4l2_rect win
;
486 enum vpfe_pin_pol fid_pol
;
487 /* interface VD polarity */
488 enum vpfe_pin_pol vd_pol
;
489 /* interface HD polarity */
490 enum vpfe_pin_pol hd_pol
;
491 /* buffer type. Applicable for interlaced mode */
492 enum ccdc_buftype buf_type
;
494 struct isif_gain gain
;
496 enum isif_cfa_pattern cfa_pat
;
497 /* Data MSB position */
498 enum isif_data_msb data_msb
;
499 /* Enable horizontal flip */
500 unsigned char horz_flip_en
;
501 /* Enable image invert vertically */
502 unsigned char image_invert_en
;
504 /* all the userland defined stuff*/
505 struct isif_config_params_raw config_params
;
508 enum isif_data_pack
{
514 #define ISIF_WIN_NTSC {0, 0, 720, 480}
515 #define ISIF_WIN_VGA {0, 0, 640, 480}