Linux Audio

Check our new training course

Loading...
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * Copyright (C) 2008-2009 Texas Instruments Inc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  4 *
  5 * isif header file
  6 */
  7#ifndef _ISIF_H
  8#define _ISIF_H
  9
 10#include <media/davinci/ccdc_types.h>
 11#include <media/davinci/vpfe_types.h>
 12
 13/* isif float type S8Q8/U8Q8 */
 14struct isif_float_8 {
 15	/* 8 bit integer part */
 16	__u8 integer;
 17	/* 8 bit decimal part */
 18	__u8 decimal;
 19};
 20
 21/* isif float type U16Q16/S16Q16 */
 22struct isif_float_16 {
 23	/* 16 bit integer part */
 24	__u16 integer;
 25	/* 16 bit decimal part */
 26	__u16 decimal;
 27};
 28
 29/************************************************************************
 30 *   Vertical Defect Correction parameters
 31 ***********************************************************************/
 32/* Defect Correction (DFC) table entry */
 33struct isif_vdfc_entry {
 34	/* vertical position of defect */
 35	__u16 pos_vert;
 36	/* horizontal position of defect */
 37	__u16 pos_horz;
 38	/*
 39	 * Defect level of Vertical line defect position. This is subtracted
 40	 * from the data at the defect position
 41	 */
 42	__u8 level_at_pos;
 43	/*
 44	 * Defect level of the pixels upper than the vertical line defect.
 45	 * This is subtracted from the data
 46	 */
 47	__u8 level_up_pixels;
 48	/*
 49	 * Defect level of the pixels lower than the vertical line defect.
 50	 * This is subtracted from the data
 51	 */
 52	__u8 level_low_pixels;
 53};
 54
 55#define ISIF_VDFC_TABLE_SIZE		8
 56struct isif_dfc {
 57	/* enable vertical defect correction */
 58	__u8 en;
 59	/* Defect level subtraction. Just fed through if saturating */
 60#define	ISIF_VDFC_NORMAL		0
 61	/*
 62	 * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
 63	 * if data saturating
 64	 */
 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 */
 69	__u8 corr_mode;
 70	/* 0 - whole line corrected, 1 - not pixels upper than the defect */
 71	__u8 corr_whole_line;
 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
 77	/*
 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
 81	 */
 82	__u8 def_level_shift;
 83	/* defect saturation level */
 84	__u16 def_sat_level;
 85	/* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
 86	__u16 num_vdefects;
 87	/* VDFC table ptr */
 88	struct isif_vdfc_entry table[ISIF_VDFC_TABLE_SIZE];
 89};
 90
 91struct isif_horz_bclamp {
 92
 93	/* Horizontal clamp disabled. Only vertical clamp value is subtracted */
 94#define	ISIF_HORZ_BC_DISABLE		0
 95	/*
 96	 * Horizontal clamp value is calculated and subtracted from image data
 97	 * along with vertical clamp value
 98	 */
 99#define ISIF_HORZ_BC_CLAMP_CALC_ENABLED	1
100	/*
101	 * Horizontal clamp value calculated from previous image is subtracted
102	 * from image data along with vertical clamp value.
103	 */
104#define ISIF_HORZ_BC_CLAMP_NOT_UPDATED	2
105	/* horizontal clamp mode. One of the values above */
106	__u8 mode;
107	/*
108	 * pixel value limit enable.
109	 *  0 - limit disabled
110	 *  1 - pixel value limited to 1023
111	 */
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 */
120	__u8 win_count_calc;
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 */
130	__u8 win_h_sz_calc;
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 */
136	__u8 win_v_sz_calc;
137};
138
139/************************************************************************
140 *  Black Clamp parameters
141 ***********************************************************************/
142struct 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
149	/*
150	 * Reset value selector for vertical clamp calculation. Use one of
151	 * the above values
152	 */
153	__u8 reset_val_sel;
154	/* U8Q8. Line average coefficient used in vertical clamp calculation */
155	__u8 line_ave_coef;
156	/* Height of the optical black region for calculation */
157	__u16 ob_v_sz_calc;
158	/* Optical black region start position - horizontal. 0 - 8191 */
159	__u16 ob_start_h;
160	/* Optical black region start position - vertical 0 - 8191 */
161	__u16 ob_start_v;
162};
163
164struct isif_black_clamp {
165	/*
166	 * This offset value is added irrespective of the clamp enable status.
167	 * S13
168	 */
169	__u16 dc_offset;
170	/*
171	 * Enable black/digital clamp value to be subtracted from the image data
172	 */
173	__u8 en;
174	/*
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
178	 */
179	__u8 bc_mode_color;
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;
186};
187
188/*************************************************************************
189** Color Space Conversion (CSC)
190*************************************************************************/
191#define ISIF_CSC_NUM_COEFF	16
192struct isif_color_space_conv {
193	/* Enable color space conversion */
194	__u8 en;
195	/*
196	 * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
197	 * so forth
198	 */
199	struct isif_float_8 coeff[ISIF_CSC_NUM_COEFF];
200};
201
202
203/*************************************************************************
204**  Black  Compensation parameters
205*************************************************************************/
206struct isif_black_comp {
207	/* Comp for Red */
208	__s8 r_comp;
209	/* Comp for Gr */
210	__s8 gr_comp;
211	/* Comp for Blue */
212	__s8 b_comp;
213	/* Comp for Gb */
214	__s8 gb_comp;
215};
216
217/*************************************************************************
218**  Gain parameters
219*************************************************************************/
220struct isif_gain {
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;
229};
230
231#define ISIF_LINEAR_TAB_SIZE	192
232/*************************************************************************
233**  Linearization parameters
234*************************************************************************/
235struct isif_linearize {
236	/* Enable or Disable linearization of data */
237	__u8 en;
238	/* Shift value applied */
239	__u8 corr_shft;
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];
244};
245
246/* Color patterns */
247#define ISIF_RED	0
248#define	ISIF_GREEN_RED	1
249#define ISIF_GREEN_BLUE	2
250#define ISIF_BLUE	3
251struct isif_col_pat {
252	__u8 olop;
253	__u8 olep;
254	__u8 elop;
255	__u8 elep;
256};
257
258/*************************************************************************
259**  Data formatter parameters
260*************************************************************************/
261struct isif_fmtplen {
262	/*
263	 * number of program entries for SET0, range 1 - 16
264	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
265	 * ISIF_COMBINE
266	 */
267	__u16 plen0;
268	/*
269	 * number of program entries for SET1, range 1 - 16
270	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
271	 * ISIF_COMBINE
272	 */
273	__u16 plen1;
274	/**
275	 * number of program entries for SET2, range 1 - 16
276	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
277	 * ISIF_COMBINE
278	 */
279	__u16 plen2;
280	/**
281	 * number of program entries for SET3, range 1 - 16
282	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
283	 * ISIF_COMBINE
284	 */
285	__u16 plen3;
286};
287
288struct isif_fmt_cfg {
289#define ISIF_SPLIT		0
290#define ISIF_COMBINE		1
291	/* Split or combine or line alternate */
292	__u8 fmtmode;
293	/* enable or disable line alternating mode */
294	__u8 ln_alter_en;
295#define ISIF_1LINE		0
296#define	ISIF_2LINES		1
297#define	ISIF_3LINES		2
298#define	ISIF_4LINES		3
299	/* Split/combine line number */
300	__u8 lnum;
301	/* Address increment Range 1 - 16 */
302	__u8 addrinc;
303};
304
305struct isif_fmt_addr_ptr {
306	/* Initial address */
307	__u32 init_addr;
308	/* output line number */
309#define ISIF_1STLINE		0
310#define	ISIF_2NDLINE		1
311#define	ISIF_3RDLINE		2
312#define	ISIF_4THLINE		3
313	__u8 out_line;
314};
315
316struct isif_fmtpgm_ap {
317	/* program address pointer */
318	__u8 pgm_aptr;
319	/* program address increment or decrement */
320	__u8 pgmupdt;
321};
322
323struct isif_data_formatter {
324	/* Enable/Disable data formatter */
325	__u8 en;
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 */
331	__u16 fmtrlen;
332	/* HD interval for output line. Only valid when split line */
333	__u16 fmthcnt;
334	/* formatter address pointers */
335	struct isif_fmt_addr_ptr fmtaddr_ptr[16];
336	/* program enable/disable */
337	__u8 pgm_en[32];
338	/* program address pointers */
339	struct isif_fmtpgm_ap fmtpgm_ap[32];
340};
341
342struct isif_df_csc {
343	/* Color Space Conversion confguration, 0 - csc, 1 - df */
344	__u8 df_or_csc;
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 */
350	__u32 start_pix;
351	/* number of pixels in input line */
352	__u32 num_pixels;
353	/* start line at the input */
354	__u32 start_line;
355	/* number of lines at the input */
356	__u32 num_lines;
357};
358
359struct isif_gain_offsets_adj {
360	/* Gain adjustment per color */
361	struct isif_gain gain;
362	/* Offset adjustment */
363	__u16 offset;
364	/* Enable or Disable Gain adjustment for SDRAM data */
365	__u8 gain_sdram_en;
366	/* Enable or Disable Gain adjustment for IPIPE data */
367	__u8 gain_ipipe_en;
368	/* Enable or Disable Gain adjustment for H3A data */
369	__u8 gain_h3a_en;
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 */
375	__u8 offset_h3a_en;
376};
377
378struct isif_cul {
379	/* Horizontal Cull pattern for odd lines */
380	__u8 hcpat_odd;
381	/* Horizontal Cull pattern for even lines */
382	__u8 hcpat_even;
383	/* Vertical Cull pattern */
384	__u8 vcpat;
385	/* Enable or disable lpf. Apply when cull is enabled */
386	__u8 en_lpf;
387};
388
389struct isif_compress {
390#define ISIF_ALAW		0
391#define ISIF_DPCM		1
392#define ISIF_NO_COMPRESSION	2
393	/* Compression Algorithm used */
394	__u8 alg;
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 */
400	__u8 pred;
401};
402
403/* all the stuff in this struct will be provided by userland */
404struct 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 */
410	struct isif_dfc dfc;
411	/* Black/Digital Clamp configuration */
412	struct isif_black_clamp bclamp;
413	/* Gain, offset adjustments */
414	struct isif_gain_offsets_adj gain_offset;
415	/* Culling */
416	struct isif_cul culling;
417	/* A-Law and DPCM compression options */
418	struct isif_compress compress;
419	/* horizontal offset for Gain/LSC/DFC */
420	__u16 horz_offset;
421	/* vertical offset for Gain/LSC/DFC */
422	__u16 vert_offset;
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 */
435	__u8 data_shift;
436	/* enable input test pattern generation */
437	__u8 test_pat_gen;
438};
439
440#ifdef __KERNEL__
441struct 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;
448	/* field polarity */
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;
458};
459
460/* MSB of image data connected to sensor port */
461enum isif_data_msb {
462	ISIF_BIT_MSB_15,
463	ISIF_BIT_MSB_14,
464	ISIF_BIT_MSB_13,
465	ISIF_BIT_MSB_12,
466	ISIF_BIT_MSB_11,
467	ISIF_BIT_MSB_10,
468	ISIF_BIT_MSB_9,
469	ISIF_BIT_MSB_8,
470	ISIF_BIT_MSB_7
471};
472
473enum isif_cfa_pattern {
474	ISIF_CFA_PAT_MOSAIC,
475	ISIF_CFA_PAT_STRIPE
476};
477
478struct isif_params_raw {
479	/* isif pixel format */
480	enum ccdc_pixfmt pix_fmt;
481	/* isif frame format */
482	enum ccdc_frmfmt frm_fmt;
483	/* video window */
484	struct v4l2_rect win;
485	/* field polarity */
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;
493	/* Gain values */
494	struct isif_gain gain;
495	/* cfa pattern */
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;
503
504	/* all the userland defined stuff*/
505	struct isif_config_params_raw config_params;
506};
507
508enum isif_data_pack {
509	ISIF_PACK_16BIT,
510	ISIF_PACK_12BIT,
511	ISIF_PACK_8BIT
512};
513
514#define ISIF_WIN_NTSC				{0, 0, 720, 480}
515#define ISIF_WIN_VGA				{0, 0, 640, 480}
516
517#endif
518#endif
v4.6
 
  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
 23#include <media/davinci/ccdc_types.h>
 24#include <media/davinci/vpfe_types.h>
 25
 26/* isif float type S8Q8/U8Q8 */
 27struct isif_float_8 {
 28	/* 8 bit integer part */
 29	__u8 integer;
 30	/* 8 bit decimal part */
 31	__u8 decimal;
 32};
 33
 34/* isif float type U16Q16/S16Q16 */
 35struct isif_float_16 {
 36	/* 16 bit integer part */
 37	__u16 integer;
 38	/* 16 bit decimal part */
 39	__u16 decimal;
 40};
 41
 42/************************************************************************
 43 *   Vertical Defect Correction parameters
 44 ***********************************************************************/
 45/* Defect Correction (DFC) table entry */
 46struct isif_vdfc_entry {
 47	/* vertical position of defect */
 48	__u16 pos_vert;
 49	/* horizontal position of defect */
 50	__u16 pos_horz;
 51	/*
 52	 * Defect level of Vertical line defect position. This is subtracted
 53	 * from the data at the defect position
 54	 */
 55	__u8 level_at_pos;
 56	/*
 57	 * Defect level of the pixels upper than the vertical line defect.
 58	 * This is subtracted from the data
 59	 */
 60	__u8 level_up_pixels;
 61	/*
 62	 * Defect level of the pixels lower than the vertical line defect.
 63	 * This is subtracted from the data
 64	 */
 65	__u8 level_low_pixels;
 66};
 67
 68#define ISIF_VDFC_TABLE_SIZE		8
 69struct isif_dfc {
 70	/* enable vertical defect correction */
 71	__u8 en;
 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 */
 82	__u8 corr_mode;
 83	/* 0 - whole line corrected, 1 - not pixels upper than the defect */
 84	__u8 corr_whole_line;
 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	 */
 95	__u8 def_level_shift;
 96	/* defect saturation level */
 97	__u16 def_sat_level;
 98	/* number of vertical defects. Max is ISIF_VDFC_TABLE_SIZE */
 99	__u16 num_vdefects;
100	/* VDFC table ptr */
101	struct isif_vdfc_entry table[ISIF_VDFC_TABLE_SIZE];
102};
103
104struct isif_horz_bclamp {
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 */
119	__u8 mode;
120	/*
121	 * pixel value limit enable.
122	 *  0 - limit disabled
123	 *  1 - pixel value limited to 1023
124	 */
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 */
133	__u8 win_count_calc;
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 */
143	__u8 win_h_sz_calc;
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 */
149	__u8 win_v_sz_calc;
150};
151
152/************************************************************************
153 *  Black Clamp parameters
154 ***********************************************************************/
155struct 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
162	/*
163	 * Reset value selector for vertical clamp calculation. Use one of
164	 * the above values
165	 */
166	__u8 reset_val_sel;
167	/* U8Q8. Line average coefficient used in vertical clamp calculation */
168	__u8 line_ave_coef;
169	/* Height of the optical black region for calculation */
170	__u16 ob_v_sz_calc;
171	/* Optical black region start position - horizontal. 0 - 8191 */
172	__u16 ob_start_h;
173	/* Optical black region start position - vertical 0 - 8191 */
174	__u16 ob_start_v;
175};
176
177struct isif_black_clamp {
178	/*
179	 * This offset value is added irrespective of the clamp enable status.
180	 * S13
181	 */
182	__u16 dc_offset;
183	/*
184	 * Enable black/digital clamp value to be subtracted from the image data
185	 */
186	__u8 en;
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	 */
192	__u8 bc_mode_color;
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;
199};
200
201/*************************************************************************
202** Color Space Conversion (CSC)
203*************************************************************************/
204#define ISIF_CSC_NUM_COEFF	16
205struct isif_color_space_conv {
206	/* Enable color space conversion */
207	__u8 en;
208	/*
209	 * csc coeffient table. S8Q5, M00 at index 0, M01 at index 1, and
210	 * so forth
211	 */
212	struct isif_float_8 coeff[ISIF_CSC_NUM_COEFF];
213};
214
215
216/*************************************************************************
217**  Black  Compensation parameters
218*************************************************************************/
219struct isif_black_comp {
220	/* Comp for Red */
221	__s8 r_comp;
222	/* Comp for Gr */
223	__s8 gr_comp;
224	/* Comp for Blue */
225	__s8 b_comp;
226	/* Comp for Gb */
227	__s8 gb_comp;
228};
229
230/*************************************************************************
231**  Gain parameters
232*************************************************************************/
233struct isif_gain {
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;
242};
243
244#define ISIF_LINEAR_TAB_SIZE	192
245/*************************************************************************
246**  Linearization parameters
247*************************************************************************/
248struct isif_linearize {
249	/* Enable or Disable linearization of data */
250	__u8 en;
251	/* Shift value applied */
252	__u8 corr_shft;
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];
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
264struct isif_col_pat {
265	__u8 olop;
266	__u8 olep;
267	__u8 elop;
268	__u8 elep;
269};
270
271/*************************************************************************
272**  Data formatter parameters
273*************************************************************************/
274struct 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	 */
280	__u16 plen0;
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	 */
286	__u16 plen1;
287	/**
288	 * number of program entries for SET2, range 1 - 16
289	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
290	 * ISIF_COMBINE
291	 */
292	__u16 plen2;
293	/**
294	 * number of program entries for SET3, range 1 - 16
295	 * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
296	 * ISIF_COMBINE
297	 */
298	__u16 plen3;
299};
300
301struct isif_fmt_cfg {
302#define ISIF_SPLIT		0
303#define ISIF_COMBINE		1
304	/* Split or combine or line alternate */
305	__u8 fmtmode;
306	/* enable or disable line alternating mode */
307	__u8 ln_alter_en;
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 */
313	__u8 lnum;
314	/* Address increment Range 1 - 16 */
315	__u8 addrinc;
316};
317
318struct isif_fmt_addr_ptr {
319	/* Initial address */
320	__u32 init_addr;
321	/* output line number */
322#define ISIF_1STLINE		0
323#define	ISIF_2NDLINE		1
324#define	ISIF_3RDLINE		2
325#define	ISIF_4THLINE		3
326	__u8 out_line;
327};
328
329struct isif_fmtpgm_ap {
330	/* program address pointer */
331	__u8 pgm_aptr;
332	/* program address increment or decrement */
333	__u8 pgmupdt;
334};
335
336struct isif_data_formatter {
337	/* Enable/Disable data formatter */
338	__u8 en;
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 */
344	__u16 fmtrlen;
345	/* HD interval for output line. Only valid when split line */
346	__u16 fmthcnt;
347	/* formatter address pointers */
348	struct isif_fmt_addr_ptr fmtaddr_ptr[16];
349	/* program enable/disable */
350	__u8 pgm_en[32];
351	/* program address pointers */
352	struct isif_fmtpgm_ap fmtpgm_ap[32];
353};
354
355struct isif_df_csc {
356	/* Color Space Conversion confguration, 0 - csc, 1 - df */
357	__u8 df_or_csc;
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 */
363	__u32 start_pix;
364	/* number of pixels in input line */
365	__u32 num_pixels;
366	/* start line at the input */
367	__u32 start_line;
368	/* number of lines at the input */
369	__u32 num_lines;
370};
371
372struct isif_gain_offsets_adj {
373	/* Gain adjustment per color */
374	struct isif_gain gain;
375	/* Offset adjustment */
376	__u16 offset;
377	/* Enable or Disable Gain adjustment for SDRAM data */
378	__u8 gain_sdram_en;
379	/* Enable or Disable Gain adjustment for IPIPE data */
380	__u8 gain_ipipe_en;
381	/* Enable or Disable Gain adjustment for H3A data */
382	__u8 gain_h3a_en;
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 */
388	__u8 offset_h3a_en;
389};
390
391struct isif_cul {
392	/* Horizontal Cull pattern for odd lines */
393	__u8 hcpat_odd;
394	/* Horizontal Cull pattern for even lines */
395	__u8 hcpat_even;
396	/* Vertical Cull pattern */
397	__u8 vcpat;
398	/* Enable or disable lpf. Apply when cull is enabled */
399	__u8 en_lpf;
400};
401
402struct isif_compress {
403#define ISIF_ALAW		0
404#define ISIF_DPCM		1
405#define ISIF_NO_COMPRESSION	2
406	/* Compression Algorithm used */
407	__u8 alg;
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 */
413	__u8 pred;
414};
415
416/* all the stuff in this struct will be provided by userland */
417struct 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 */
423	struct isif_dfc dfc;
424	/* Black/Digital Clamp configuration */
425	struct isif_black_clamp bclamp;
426	/* Gain, offset adjustments */
427	struct isif_gain_offsets_adj gain_offset;
428	/* Culling */
429	struct isif_cul culling;
430	/* A-Law and DPCM compression options */
431	struct isif_compress compress;
432	/* horizontal offset for Gain/LSC/DFC */
433	__u16 horz_offset;
434	/* vertical offset for Gain/LSC/DFC */
435	__u16 vert_offset;
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 */
448	__u8 data_shift;
449	/* enable input test pattern generation */
450	__u8 test_pat_gen;
451};
452
453#ifdef __KERNEL__
454struct 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 */
474enum 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
486enum isif_cfa_pattern {
487	ISIF_CFA_PAT_MOSAIC,
488	ISIF_CFA_PAT_STRIPE
489};
490
491struct 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
521enum 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