4 * Driver header file for Preview module in TI's OMAP3 Camera ISP
6 * Copyright (C) 2009 Texas Instruments, Inc.
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
44 #define AVE_ODD_PIXEL_DIST (1 << 4) /* For Bayer Sensors */
45 #define AVE_EVEN_PIXEL_DIST (1 << 2)
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)
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
89 * Configure byte layout of YUV image
91 enum preview_ycpos_mode
{
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
{
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
{
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
{
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.
185 enum preview_ycpos_mode pix_fmt
;
186 struct ispprev_cfa cfa
;
187 struct ispprev_csup csup
;
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
;
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
{
218 struct ispprev_nf
*prev_nf
;
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
;
268 enum v4l2_colorfx color
;
270 struct ispprev_nf prev_nf_t
;
271 struct prev_params params
;
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
,
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
,
334 void isppreview_config_luma_enhancement(struct isp_prev_device
*isp_prev
,
337 void isppreview_enable_luma_enhancement(struct isp_prev_device
*isp_prev
,
340 void isppreview_enable_chroma_suppression(struct isp_prev_device
*isp_prev
,
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
,
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
,
366 void isppreview_config_brightness(struct isp_prev_device
*isp_prev
,
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
,
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
,
390 int isppreview_set_inaddr(struct isp_prev_device
*isp_prev
, u32 addr
);
392 int isppreview_config_outlineoffset(struct isp_prev_device
*isp_prev
,
395 int isppreview_set_outaddr(struct isp_prev_device
*isp_prev
, u32 addr
);
397 int isppreview_config_darklineoffset(struct isp_prev_device
*isp_prev
,
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
);
412 static inline void isppreview_save_context(struct device
*dev
) {}
415 #ifndef CONFIG_ARCH_OMAP3410
416 void isppreview_restore_context(struct device
*dev
);
418 static inline void isppreview_restore_context(struct device
*dev
) {}
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 */