blob: 6ee830623d5da1c1ab3b0a5914bd8726a7447679 [file] [log] [blame]
Laurent Pinchartde1135d2011-02-12 18:05:06 -03001/*
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
Laurent Pinchart3108e022012-04-05 12:38:23 -030048/* Additional features not listed in linux/omap3isp.h */
49#define OMAP3ISP_PREV_CONTRAST (1 << 17)
50#define OMAP3ISP_PREV_BRIGHTNESS (1 << 18)
51#define OMAP3ISP_PREV_FEATURES_END (1 << 19)
Laurent Pinchartde1135d2011-02-12 18:05:06 -030052
53enum preview_input_entity {
54 PREVIEW_INPUT_NONE,
55 PREVIEW_INPUT_CCDC,
56 PREVIEW_INPUT_MEMORY,
57};
58
59#define PREVIEW_OUTPUT_RESIZER (1 << 1)
60#define PREVIEW_OUTPUT_MEMORY (1 << 2)
61
62/* Configure byte layout of YUV image */
63enum preview_ycpos_mode {
64 YCPOS_YCrYCb = 0,
65 YCPOS_YCbYCr = 1,
66 YCPOS_CbYCrY = 2,
67 YCPOS_CrYCbY = 3
68};
69
70/*
71 * struct prev_params - Structure for all configuration
72 * @features: Set of features enabled.
73 * @cfa: CFA coefficients.
74 * @csup: Chroma suppression coefficients.
75 * @luma: Luma enhancement coefficients.
76 * @nf: Noise filter coefficients.
77 * @dcor: Noise filter coefficients.
78 * @gamma: Gamma coefficients.
79 * @wbal: White Balance parameters.
Laurent Pinchart9b001842012-04-05 13:51:17 -030080 * @blkadj: Black adjustment parameters.
Laurent Pinchartde1135d2011-02-12 18:05:06 -030081 * @rgb2rgb: RGB blending parameters.
Laurent Pinchart9b001842012-04-05 13:51:17 -030082 * @csc: Color space conversion (RGB to YCbCr) parameters.
Laurent Pinchartde1135d2011-02-12 18:05:06 -030083 * @hmed: Horizontal median filter.
84 * @yclimit: YC limits parameters.
Laurent Pinchartde1135d2011-02-12 18:05:06 -030085 * @contrast: Contrast.
86 * @brightness: Brightness.
87 */
88struct prev_params {
89 u32 features;
90 struct omap3isp_prev_cfa cfa;
91 struct omap3isp_prev_csup csup;
92 struct omap3isp_prev_luma luma;
93 struct omap3isp_prev_nf nf;
94 struct omap3isp_prev_dcor dcor;
95 struct omap3isp_prev_gtables gamma;
96 struct omap3isp_prev_wbal wbal;
Laurent Pinchart9b001842012-04-05 13:51:17 -030097 struct omap3isp_prev_blkadj blkadj;
Laurent Pinchartde1135d2011-02-12 18:05:06 -030098 struct omap3isp_prev_rgbtorgb rgb2rgb;
Laurent Pinchart9b001842012-04-05 13:51:17 -030099 struct omap3isp_prev_csc csc;
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300100 struct omap3isp_prev_hmed hmed;
101 struct omap3isp_prev_yclimit yclimit;
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300102 u8 contrast;
103 u8 brightness;
104};
105
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300106/* Sink and source previewer pads */
107#define PREV_PAD_SINK 0
108#define PREV_PAD_SOURCE 1
109#define PREV_PADS_NUM 2
110
111/*
112 * struct isp_prev_device - Structure for storing ISP Preview module information
113 * @subdev: V4L2 subdevice
114 * @pads: Media entity pads
115 * @formats: Active formats at the subdev pad
Laurent Pinchart1f69fd92011-09-21 20:05:45 -0300116 * @crop: Active crop rectangle
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300117 * @input: Module currently connected to the input pad
118 * @output: Bitmask of the active output
119 * @video_in: Input video entity
120 * @video_out: Output video entity
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300121 * @params: Module configuration data
122 * @shadow_update: If set, update the hardware configured in the next interrupt
123 * @underrun: Whether the preview entity has queued buffers on the output
124 * @state: Current preview pipeline state
125 * @lock: Shadow update lock
126 * @update: Bitmask of the parameters to be updated
127 *
128 * This structure is used to store the OMAP ISP Preview module Information.
129 */
130struct isp_prev_device {
131 struct v4l2_subdev subdev;
132 struct media_pad pads[PREV_PADS_NUM];
133 struct v4l2_mbus_framefmt formats[PREV_PADS_NUM];
Laurent Pinchart1f69fd92011-09-21 20:05:45 -0300134 struct v4l2_rect crop;
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300135
136 struct v4l2_ctrl_handler ctrls;
137
138 enum preview_input_entity input;
139 unsigned int output;
140 struct isp_video video_in;
141 struct isp_video video_out;
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300142
143 struct prev_params params;
144 unsigned int shadow_update:1;
145 enum isp_pipeline_stream_state state;
146 wait_queue_head_t wait;
147 atomic_t stopping;
148 spinlock_t lock;
149 u32 update;
150};
151
152struct isp_device;
153
154int omap3isp_preview_init(struct isp_device *isp);
155void omap3isp_preview_cleanup(struct isp_device *isp);
156
157int omap3isp_preview_register_entities(struct isp_prev_device *prv,
158 struct v4l2_device *vdev);
159void omap3isp_preview_unregister_entities(struct isp_prev_device *prv);
160
161void omap3isp_preview_isr_frame_sync(struct isp_prev_device *prev);
162void omap3isp_preview_isr(struct isp_prev_device *prev);
163
164int omap3isp_preview_busy(struct isp_prev_device *isp_prev);
165
166void omap3isp_preview_restore_context(struct isp_device *isp);
167
168#endif /* OMAP3_ISP_PREVIEW_H */