Full support for Ginger Console
[linux-ginger.git] / drivers / media / video / isp / isppreview.h
blobbd24029f9a2c2d16a16e2eeda1085070e0026427
1 /*
2 * isppreview.h
4 * Driver header file for Preview module in TI's OMAP3 Camera ISP
6 * Copyright (C) 2009 Texas Instruments, Inc.
8 * Contributors:
9 * Senthilvadivu Guruswamy <svadivu@ti.com>
10 * Pallavi Kulkarni <p-kulkarni@ti.com>
11 * Sergio Aguirre <saaguirre@ti.com>
13 * This package is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 #ifndef OMAP_ISP_PREVIEW_H
23 #define OMAP_ISP_PREVIEW_H
25 #include <plat/isp_user.h>
26 /* Isp query control structure */
28 #define ISPPRV_BRIGHT_STEP 0x1
29 #define ISPPRV_BRIGHT_DEF 0x1
30 #define ISPPRV_BRIGHT_LOW 0x0
31 #define ISPPRV_BRIGHT_HIGH 0xFF
32 #define ISPPRV_BRIGHT_UNITS 0x1
34 #define ISPPRV_CONTRAST_STEP 0x1
35 #define ISPPRV_CONTRAST_DEF 0x10
36 #define ISPPRV_CONTRAST_LOW 0x0
37 #define ISPPRV_CONTRAST_HIGH 0xFF
38 #define ISPPRV_CONTRAST_UNITS 0x1
40 #define NO_AVE 0x0
41 #define AVE_2_PIX 0x1
42 #define AVE_4_PIX 0x2
43 #define AVE_8_PIX 0x3
44 #define AVE_ODD_PIXEL_DIST (1 << 4) /* For Bayer Sensors */
45 #define AVE_EVEN_PIXEL_DIST (1 << 2)
47 #define WB_GAIN_MAX 4
49 /* Features list */
50 #define PREV_AVERAGER (1 << 0)
51 #define PREV_INVERSE_ALAW (1 << 1)
52 #define PREV_HORZ_MEDIAN_FILTER (1 << 2)
53 #define PREV_NOISE_FILTER (1 << 3)
54 #define PREV_CFA (1 << 4)
55 #define PREV_GAMMA_BYPASS (1 << 5)
56 #define PREV_LUMA_ENHANCE (1 << 6)
57 #define PREV_CHROMA_SUPPRESS (1 << 7)
58 #define PREV_DARK_FRAME_SUBTRACT (1 << 8)
59 #define PREV_LENS_SHADING (1 << 9)
60 #define PREV_DARK_FRAME_CAPTURE (1 << 10)
61 #define PREV_DEFECT_COR (1 << 11)
64 #define ISP_NF_TABLE_SIZE (1 << 10)
66 #define ISP_GAMMA_TABLE_SIZE (1 << 10)
68 /* Table addresses */
69 #define ISPPRV_TBL_ADDR_RED_G_START 0x00
70 #define ISPPRV_TBL_ADDR_BLUE_G_START 0x800
71 #define ISPPRV_TBL_ADDR_GREEN_G_START 0x400
74 *Enumeration Constants for input and output format
76 enum preview_input {
77 PRV_RAW_CCDC,
78 PRV_RAW_MEM,
79 PRV_RGBBAYERCFA,
80 PRV_COMPCFA,
81 PRV_CCDC_DRKF,
82 PRV_OTHERS
84 enum preview_output {
85 PREVIEW_RSZ,
86 PREVIEW_MEM
89 * Configure byte layout of YUV image
91 enum preview_ycpos_mode {
92 YCPOS_YCrYCb = 0,
93 YCPOS_YCbYCr = 1,
94 YCPOS_CbYCrY = 2,
95 YCPOS_CrYCbY = 3
98 /**
99 * struct ispprev_gtable - Structure for Gamma Correction.
100 * @redtable: Pointer to the red gamma table.
101 * @greentable: Pointer to the green gamma table.
102 * @bluetable: Pointer to the blue gamma table.
104 struct ispprev_gtable {
105 u32 *redtable;
106 u32 *greentable;
107 u32 *bluetable;
111 * struct prev_white_balance - Structure for White Balance 2.
112 * @wb_dgain: White balance common gain.
113 * @wb_gain: Individual color gains.
114 * @wb_coefmatrix: Coefficient matrix
116 struct prev_white_balance {
117 u16 wb_dgain; /* white balance common gain */
118 u8 wb_gain[WB_GAIN_MAX]; /* individual color gains */
119 u8 wb_coefmatrix[WB_GAIN_MAX][WB_GAIN_MAX];
123 * struct prev_size_params - Structure for size parameters.
124 * @hstart: Starting pixel.
125 * @vstart: Starting line.
126 * @hsize: Width of input image.
127 * @vsize: Height of input image.
128 * @pixsize: Pixel size of the image in terms of bits.
129 * @in_pitch: Line offset of input image.
130 * @out_pitch: Line offset of output image.
132 struct prev_size_params {
133 unsigned int hstart;
134 unsigned int vstart;
135 unsigned int hsize;
136 unsigned int vsize;
137 unsigned char pixsize;
138 unsigned short in_pitch;
139 unsigned short out_pitch;
143 * struct prev_rgb2ycbcr_coeffs - Structure RGB2YCbCr parameters.
144 * @coeff: Color conversion gains in 3x3 matrix.
145 * @offset: Color conversion offsets.
147 struct prev_rgb2ycbcr_coeffs {
148 short coeff[RGB_MAX][RGB_MAX];
149 short offset[RGB_MAX];
153 * struct prev_darkfrm_params - Structure for Dark frame suppression.
154 * @addr: Memory start address.
155 * @offset: Line offset.
157 struct prev_darkfrm_params {
158 u32 addr;
159 u32 offset;
163 * struct prev_params - Structure for all configuration
164 * @features: Set of features enabled.
165 * @cfa: CFA coefficients.
166 * @csup: Chroma suppression coefficients.
167 * @ytable: Pointer to Luma enhancement coefficients.
168 * @nf: Noise filter coefficients.
169 * @dcor: Noise filter coefficients.
170 * @gtable: Gamma coefficients.
171 * @wbal: White Balance parameters.
172 * @blk_adj: Black adjustment parameters.
173 * @rgb2rgb: RGB blending parameters.
174 * @rgb2ycbcr: RGB to ycbcr parameters.
175 * @hmf_params: Horizontal median filter.
176 * @size_params: Size parameters.
177 * @drkf_params: Darkframe parameters.
178 * @lens_shading_shift:
179 * @average: Downsampling rate for averager.
180 * @contrast: Contrast.
181 * @brightness: Brightness.
183 struct prev_params {
184 u16 features;
185 enum preview_ycpos_mode pix_fmt;
186 struct ispprev_cfa cfa;
187 struct ispprev_csup csup;
188 u32 *ytable;
189 struct ispprev_nf nf;
190 struct ispprev_dcor dcor;
191 struct ispprev_gtable gtable;
192 struct ispprev_wbal wbal;
193 struct ispprev_blkadj blk_adj;
194 struct ispprev_rgbtorgb rgb2rgb;
195 struct ispprev_csc rgb2ycbcr;
196 struct ispprev_hmed hmf_params;
197 struct prev_size_params size_params;
198 struct prev_darkfrm_params drkf_params;
199 u8 lens_shading_shift;
200 u8 average;
201 u8 contrast;
202 u8 brightness;
206 * struct isptables_update - Structure for Table Configuration.
207 * @update: Specifies which tables should be updated.
208 * @flag: Specifies which tables should be enabled.
209 * @prev_nf: Pointer to structure for Noise Filter
210 * @lsc: Pointer to LSC gain table. (currently not used)
211 * @red_gamma: Pointer to red gamma correction table.
212 * @green_gamma: Pointer to green gamma correction table.
213 * @blue_gamma: Pointer to blue gamma correction table.
215 struct isptables_update {
216 u16 update;
217 u16 flag;
218 struct ispprev_nf *prev_nf;
219 u32 *lsc;
220 u32 *red_gamma;
221 u32 *green_gamma;
222 u32 *blue_gamma;
223 struct ispprev_cfa *prev_cfa;
227 * struct isp_prev_device - Structure for storing ISP Preview module information
228 * @prevout_w: Preview output width.
229 * @prevout_h: Preview output height.
230 * @previn_w: Preview input width.
231 * @previn_h: Preview input height.
232 * @prev_inpfmt: Preview input format.
233 * @prev_outfmt: Preview output format.
234 * @hmed_en: Horizontal median filter enable.
235 * @nf_en: Noise filter enable.
236 * @dcor_en: Defect correction enable.
237 * @cfa_en: Color Filter Array (CFA) interpolation enable.
238 * @csup_en: Chrominance suppression enable.
239 * @yenh_en: Luma enhancement enable.
240 * @fmtavg: Number of horizontal pixels to average in input formatter. The
241 * input width should be a multiple of this number.
242 * @brightness: Brightness in preview module.
243 * @contrast: Contrast in preview module.
244 * @color: Color effect in preview module.
245 * @cfafmt: Color Filter Array (CFA) Format.
247 * This structure is used to store the OMAP ISP Preview module Information.
249 struct isp_prev_device {
250 u8 update_color_matrix;
251 u8 update_rgb_blending;
252 u8 update_rgb_to_ycbcr;
253 u8 hmed_en;
254 u8 nf_en;
255 u8 dcor_en;
256 u8 cfa_en;
257 u8 csup_en;
258 u8 yenh_en;
259 u8 rg_update;
260 u8 gg_update;
261 u8 bg_update;
262 u8 cfa_update;
263 u8 nf_enable;
264 u8 nf_update;
265 u8 fmtavg;
266 u8 brightness;
267 u8 contrast;
268 enum v4l2_colorfx color;
269 enum cfa_fmt cfafmt;
270 struct ispprev_nf prev_nf_t;
271 struct prev_params params;
272 int shadow_update;
273 u32 sph;
274 u32 slv;
275 struct device *dev;
276 spinlock_t lock;
279 void isppreview_config_shadow_registers(struct isp_prev_device *isp_prev);
281 int isppreview_request(struct isp_prev_device *isp_prev);
283 int isppreview_free(struct isp_prev_device *isp_prev);
285 int isppreview_config_datapath(struct isp_prev_device *isp_prev,
286 struct isp_pipeline *pipe);
288 void isppreview_config_ycpos(struct isp_prev_device *isp_prev,
289 enum preview_ycpos_mode mode);
291 void isppreview_config_averager(struct isp_prev_device *isp_prev, u8 average);
293 void isppreview_enable_invalaw(struct isp_prev_device *isp_prev, u8 enable);
295 void isppreview_enable_drkframe(struct isp_prev_device *isp_prev, u8 enable);
297 void isppreview_enable_shadcomp(struct isp_prev_device *isp_prev, u8 enable);
299 void isppreview_config_drkf_shadcomp(struct isp_prev_device *isp_prev,
300 u8 scomp_shtval);
302 void isppreview_enable_gammabypass(struct isp_prev_device *isp_prev, u8 enable);
304 void isppreview_enable_hmed(struct isp_prev_device *isp_prev, u8 enable);
306 void isppreview_config_hmed(struct isp_prev_device *isp_prev,
307 struct ispprev_hmed);
309 void isppreview_enable_noisefilter(struct isp_prev_device *isp_prev, u8 enable);
311 void isppreview_config_noisefilter(struct isp_prev_device *isp_prev,
312 struct ispprev_nf prev_nf);
314 void isppreview_enable_dcor(struct isp_prev_device *isp_prev, u8 enable);
316 void isppreview_config_dcor(struct isp_prev_device *isp_prev,
317 struct ispprev_dcor prev_dcor);
320 void isppreview_config_cfa(struct isp_prev_device *isp_prev,
321 struct ispprev_cfa *cfa);
323 void isppreview_config_gammacorrn(struct isp_prev_device *isp_prev,
324 struct ispprev_gtable);
326 void isppreview_config_chroma_suppression(struct isp_prev_device *isp_prev,
327 struct ispprev_csup csup);
329 void isppreview_enable_cfa(struct isp_prev_device *isp_prev, u8 enable);
331 void isppreview_set_luma_enhancement(struct isp_prev_device *isp_prev,
332 u32 *ytable);
334 void isppreview_config_luma_enhancement(struct isp_prev_device *isp_prev,
335 u32 *ytable);
337 void isppreview_enable_luma_enhancement(struct isp_prev_device *isp_prev,
338 u8 enable);
340 void isppreview_enable_chroma_suppression(struct isp_prev_device *isp_prev,
341 u8 enable);
343 void isppreview_config_whitebalance(struct isp_prev_device *isp_prev,
344 struct ispprev_wbal);
346 void isppreview_config_blkadj(struct isp_prev_device *isp_prev,
347 struct ispprev_blkadj);
349 void isppreview_config_rgb_blending(struct isp_prev_device *isp_prev,
350 struct ispprev_rgbtorgb);
352 void isppreview_config_rgb_to_ycbcr(struct isp_prev_device *isp_prev,
353 struct ispprev_csc);
355 void isppreview_update_contrast(struct isp_prev_device *isp_prev, u8 *contrast);
357 void isppreview_query_contrast(struct isp_prev_device *isp_prev, u8 *contrast);
359 void isppreview_config_contrast(struct isp_prev_device *isp_prev, u8 contrast);
361 void isppreview_get_contrast_range(u8 *min_contrast, u8 *max_contrast);
363 void isppreview_update_brightness(struct isp_prev_device *isp_prev,
364 u8 *brightness);
366 void isppreview_config_brightness(struct isp_prev_device *isp_prev,
367 u8 brightness);
369 void isppreview_get_brightness_range(u8 *min_brightness, u8 *max_brightness);
371 void isppreview_set_color(struct isp_prev_device *isp_prev, u8 *mode);
373 void isppreview_get_color(struct isp_prev_device *isp_prev, u8 *mode);
375 void isppreview_query_brightness(struct isp_prev_device *isp_prev,
376 u8 *brightness);
378 void isppreview_config_yc_range(struct isp_prev_device *isp_prev,
379 struct ispprev_yclimit yclimit);
381 int isppreview_try_pipeline(struct isp_prev_device *isp_prev,
382 struct isp_pipeline *pipe);
384 int isppreview_s_pipeline(struct isp_prev_device *isp_prev,
385 struct isp_pipeline *pipe);
387 int isppreview_config_inlineoffset(struct isp_prev_device *isp_prev,
388 u32 offset);
390 int isppreview_set_inaddr(struct isp_prev_device *isp_prev, u32 addr);
392 int isppreview_config_outlineoffset(struct isp_prev_device *isp_prev,
393 u32 offset);
395 int isppreview_set_outaddr(struct isp_prev_device *isp_prev, u32 addr);
397 int isppreview_config_darklineoffset(struct isp_prev_device *isp_prev,
398 u32 offset);
400 int isppreview_set_darkaddr(struct isp_prev_device *isp_prev, u32 addr);
402 void isppreview_enable(struct isp_prev_device *isp_prev);
404 int isppreview_busy(struct isp_prev_device *isp_prev);
406 void isppreview_print_status(struct isp_prev_device *isp_prev,
407 struct isp_pipeline *pipe);
409 #ifndef CONFIG_ARCH_OMAP3410
410 void isppreview_save_context(struct device *dev);
411 #else
412 static inline void isppreview_save_context(struct device *dev) {}
413 #endif
415 #ifndef CONFIG_ARCH_OMAP3410
416 void isppreview_restore_context(struct device *dev);
417 #else
418 static inline void isppreview_restore_context(struct device *dev) {}
419 #endif
421 int omap34xx_isp_preview_config(struct isp_prev_device *isp_prev,
422 void *userspace_add);
424 void isppreview_set_skip(struct isp_prev_device *isp_prev, u32 h, u32 v);
426 #endif/* OMAP_ISP_PREVIEW_H */