Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi...
[sfrench/cifs-2.6.git] / drivers / media / video / omap3isp / isppreview.h
1 /*
2  * isppreview.h
3  *
4  * TI OMAP3 ISP - Preview module
5  *
6  * Copyright (C) 2010 Nokia Corporation
7  * Copyright (C) 2009 Texas Instruments, Inc.
8  *
9  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10  *           Sakari Ailus <sakari.ailus@iki.fi>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24  * 02110-1301 USA
25  */
26
27 #ifndef OMAP3_ISP_PREVIEW_H
28 #define OMAP3_ISP_PREVIEW_H
29
30 #include <linux/omap3isp.h>
31 #include <linux/types.h>
32 #include <media/v4l2-ctrls.h>
33
34 #include "ispvideo.h"
35
36 #define ISPPRV_BRIGHT_STEP              0x1
37 #define ISPPRV_BRIGHT_DEF               0x0
38 #define ISPPRV_BRIGHT_LOW               0x0
39 #define ISPPRV_BRIGHT_HIGH              0xFF
40 #define ISPPRV_BRIGHT_UNITS             0x1
41
42 #define ISPPRV_CONTRAST_STEP            0x1
43 #define ISPPRV_CONTRAST_DEF             0x10
44 #define ISPPRV_CONTRAST_LOW             0x0
45 #define ISPPRV_CONTRAST_HIGH            0xFF
46 #define ISPPRV_CONTRAST_UNITS           0x1
47
48 /* Features list */
49 #define PREV_LUMA_ENHANCE               OMAP3ISP_PREV_LUMAENH
50 #define PREV_INVERSE_ALAW               OMAP3ISP_PREV_INVALAW
51 #define PREV_HORZ_MEDIAN_FILTER         OMAP3ISP_PREV_HRZ_MED
52 #define PREV_CFA                        OMAP3ISP_PREV_CFA
53 #define PREV_CHROMA_SUPPRESS            OMAP3ISP_PREV_CHROMA_SUPP
54 #define PREV_WB                         OMAP3ISP_PREV_WB
55 #define PREV_BLKADJ                     OMAP3ISP_PREV_BLKADJ
56 #define PREV_RGB2RGB                    OMAP3ISP_PREV_RGB2RGB
57 #define PREV_COLOR_CONV                 OMAP3ISP_PREV_COLOR_CONV
58 #define PREV_YCLIMITS                   OMAP3ISP_PREV_YC_LIMIT
59 #define PREV_DEFECT_COR                 OMAP3ISP_PREV_DEFECT_COR
60 #define PREV_GAMMA_BYPASS               OMAP3ISP_PREV_GAMMABYPASS
61 #define PREV_DARK_FRAME_CAPTURE         OMAP3ISP_PREV_DRK_FRM_CAPTURE
62 #define PREV_DARK_FRAME_SUBTRACT        OMAP3ISP_PREV_DRK_FRM_SUBTRACT
63 #define PREV_LENS_SHADING               OMAP3ISP_PREV_LENS_SHADING
64 #define PREV_NOISE_FILTER               OMAP3ISP_PREV_NF
65 #define PREV_GAMMA                      OMAP3ISP_PREV_GAMMA
66
67 #define PREV_CONTRAST                   (1 << 17)
68 #define PREV_BRIGHTNESS                 (1 << 18)
69 #define PREV_AVERAGER                   (1 << 19)
70 #define PREV_FEATURES_END               (1 << 20)
71
72 enum preview_input_entity {
73         PREVIEW_INPUT_NONE,
74         PREVIEW_INPUT_CCDC,
75         PREVIEW_INPUT_MEMORY,
76 };
77
78 #define PREVIEW_OUTPUT_RESIZER          (1 << 1)
79 #define PREVIEW_OUTPUT_MEMORY           (1 << 2)
80
81 /* Configure byte layout of YUV image */
82 enum preview_ycpos_mode {
83         YCPOS_YCrYCb = 0,
84         YCPOS_YCbYCr = 1,
85         YCPOS_CbYCrY = 2,
86         YCPOS_CrYCbY = 3
87 };
88
89 /*
90  * struct prev_params - Structure for all configuration
91  * @features: Set of features enabled.
92  * @cfa: CFA coefficients.
93  * @csup: Chroma suppression coefficients.
94  * @luma: Luma enhancement coefficients.
95  * @nf: Noise filter coefficients.
96  * @dcor: Noise filter coefficients.
97  * @gamma: Gamma coefficients.
98  * @wbal: White Balance parameters.
99  * @blk_adj: Black adjustment parameters.
100  * @rgb2rgb: RGB blending parameters.
101  * @rgb2ycbcr: RGB to ycbcr parameters.
102  * @hmed: Horizontal median filter.
103  * @yclimit: YC limits parameters.
104  * @contrast: Contrast.
105  * @brightness: Brightness.
106  */
107 struct prev_params {
108         u32 features;
109         struct omap3isp_prev_cfa cfa;
110         struct omap3isp_prev_csup csup;
111         struct omap3isp_prev_luma luma;
112         struct omap3isp_prev_nf nf;
113         struct omap3isp_prev_dcor dcor;
114         struct omap3isp_prev_gtables gamma;
115         struct omap3isp_prev_wbal wbal;
116         struct omap3isp_prev_blkadj blk_adj;
117         struct omap3isp_prev_rgbtorgb rgb2rgb;
118         struct omap3isp_prev_csc rgb2ycbcr;
119         struct omap3isp_prev_hmed hmed;
120         struct omap3isp_prev_yclimit yclimit;
121         u8 contrast;
122         u8 brightness;
123 };
124
125 /*
126  * struct isptables_update - Structure for Table Configuration.
127  * @update: Specifies which tables should be updated.
128  * @flag: Specifies which tables should be enabled.
129  * @nf: Pointer to structure for Noise Filter
130  * @lsc: Pointer to LSC gain table. (currently not used)
131  * @gamma: Pointer to gamma correction tables.
132  * @cfa: Pointer to color filter array configuration.
133  * @wbal: Pointer to colour and digital gain configuration.
134  */
135 struct isptables_update {
136         u32 update;
137         u32 flag;
138         struct omap3isp_prev_nf *nf;
139         u32 *lsc;
140         struct omap3isp_prev_gtables *gamma;
141         struct omap3isp_prev_cfa *cfa;
142         struct omap3isp_prev_wbal *wbal;
143 };
144
145 /* Sink and source previewer pads */
146 #define PREV_PAD_SINK                   0
147 #define PREV_PAD_SOURCE                 1
148 #define PREV_PADS_NUM                   2
149
150 /*
151  * struct isp_prev_device - Structure for storing ISP Preview module information
152  * @subdev: V4L2 subdevice
153  * @pads: Media entity pads
154  * @formats: Active formats at the subdev pad
155  * @crop: Active crop rectangle
156  * @input: Module currently connected to the input pad
157  * @output: Bitmask of the active output
158  * @video_in: Input video entity
159  * @video_out: Output video entity
160  * @params: Module configuration data
161  * @shadow_update: If set, update the hardware configured in the next interrupt
162  * @underrun: Whether the preview entity has queued buffers on the output
163  * @state: Current preview pipeline state
164  * @lock: Shadow update lock
165  * @update: Bitmask of the parameters to be updated
166  *
167  * This structure is used to store the OMAP ISP Preview module Information.
168  */
169 struct isp_prev_device {
170         struct v4l2_subdev subdev;
171         struct media_pad pads[PREV_PADS_NUM];
172         struct v4l2_mbus_framefmt formats[PREV_PADS_NUM];
173         struct v4l2_rect crop;
174
175         struct v4l2_ctrl_handler ctrls;
176
177         enum preview_input_entity input;
178         unsigned int output;
179         struct isp_video video_in;
180         struct isp_video video_out;
181
182         struct prev_params params;
183         unsigned int shadow_update:1;
184         enum isp_pipeline_stream_state state;
185         wait_queue_head_t wait;
186         atomic_t stopping;
187         spinlock_t lock;
188         u32 update;
189 };
190
191 struct isp_device;
192
193 int omap3isp_preview_init(struct isp_device *isp);
194 void omap3isp_preview_cleanup(struct isp_device *isp);
195
196 int omap3isp_preview_register_entities(struct isp_prev_device *prv,
197                                        struct v4l2_device *vdev);
198 void omap3isp_preview_unregister_entities(struct isp_prev_device *prv);
199
200 void omap3isp_preview_isr_frame_sync(struct isp_prev_device *prev);
201 void omap3isp_preview_isr(struct isp_prev_device *prev);
202
203 int omap3isp_preview_busy(struct isp_prev_device *isp_prev);
204
205 void omap3isp_preview_restore_context(struct isp_device *isp);
206
207 #endif  /* OMAP3_ISP_PREVIEW_H */