4 * TI OMAP3 ISP - CCDC module
6 * Copyright (C) 2009-2010 Nokia Corporation
7 * Copyright (C) 2009 Texas Instruments, Inc.
9 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 * Sakari Ailus <sakari.ailus@iki.fi>
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.
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.
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
27 #ifndef OMAP3_ISP_CCDC_H
28 #define OMAP3_ISP_CCDC_H
30 #include <linux/omap3isp.h>
31 #include <linux/workqueue.h>
35 enum ccdc_input_entity
{
43 #define CCDC_OUTPUT_MEMORY (1 << 0)
44 #define CCDC_OUTPUT_PREVIEW (1 << 1)
45 #define CCDC_OUTPUT_RESIZER (1 << 2)
47 #define OMAP3ISP_CCDC_NEVENTS 16
50 * struct ispccdc_syncif - Structure for Sync Interface between sensor and CCDC
51 * @ccdc_mastermode: Master mode. 1 - Master, 0 - Slave.
52 * @fldstat: Field state. 0 - Odd Field, 1 - Even Field.
54 * @fldmode: 0 - Progressive, 1 - Interlaced.
55 * @datapol: 0 - Positive, 1 - Negative.
56 * @fldpol: 0 - Positive, 1 - Negative.
57 * @hdpol: 0 - Positive, 1 - Negative.
58 * @vdpol: 0 - Positive, 1 - Negative.
59 * @fldout: 0 - Input, 1 - Output.
60 * @hs_width: Width of the Horizontal Sync pulse, used for HS/VS Output.
61 * @vs_width: Width of the Vertical Sync pulse, used for HS/VS Output.
62 * @ppln: Number of pixels per line, used for HS/VS Output.
63 * @hlprf: Number of half lines per frame, used for HS/VS Output.
64 * @bt_r656_en: 1 - Enable ITU-R BT656 mode, 0 - Sync mode.
66 struct ispccdc_syncif
{
84 * struct ispccdc_vp - Structure for Video Port parameters
85 * @pixelclk: Input pixel clock in Hz
88 unsigned int pixelclk
;
91 enum ispccdc_lsc_state
{
92 LSC_STATE_STOPPED
= 0,
93 LSC_STATE_STOPPING
= 1,
94 LSC_STATE_RUNNING
= 2,
95 LSC_STATE_RECONFIG
= 3,
98 struct ispccdc_lsc_config_req
{
99 struct list_head list
;
100 struct omap3isp_ccdc_lsc_config config
;
101 unsigned char enable
;
103 struct iovm_struct
*iovm
;
107 * ispccdc_lsc - CCDC LSC parameters
108 * @update_config: Set when user changes config
109 * @request_enable: Whether LSC is requested to be enabled
110 * @config: LSC config set by user
111 * @update_table: Set when user provides a new LSC table to table_new
112 * @table_new: LSC table set by user, ISP address
113 * @table_inuse: LSC table currently in use, ISP address
116 enum ispccdc_lsc_state state
;
117 struct work_struct table_work
;
119 /* LSC queue of configurations */
121 struct ispccdc_lsc_config_req
*request
; /* requested configuration */
122 struct ispccdc_lsc_config_req
*active
; /* active configuration */
123 struct list_head free_queue
; /* configurations for freeing */
126 #define CCDC_STOP_NOT_REQUESTED 0x00
127 #define CCDC_STOP_REQUEST 0x01
128 #define CCDC_STOP_EXECUTED (0x02 | CCDC_STOP_REQUEST)
129 #define CCDC_STOP_CCDC_FINISHED 0x04
130 #define CCDC_STOP_LSC_FINISHED 0x08
131 #define CCDC_STOP_FINISHED \
132 (CCDC_STOP_EXECUTED | CCDC_STOP_CCDC_FINISHED | CCDC_STOP_LSC_FINISHED)
134 #define CCDC_EVENT_VD1 0x10
135 #define CCDC_EVENT_VD0 0x20
136 #define CCDC_EVENT_LSC_DONE 0x40
138 /* Sink and source CCDC pads */
139 #define CCDC_PAD_SINK 0
140 #define CCDC_PAD_SOURCE_OF 1
141 #define CCDC_PAD_SOURCE_VP 2
142 #define CCDC_PADS_NUM 3
145 * struct isp_ccdc_device - Structure for the CCDC module to store its own
147 * @subdev: V4L2 subdevice
148 * @pads: Sink and source media entity pads
149 * @formats: Active video formats
150 * @input: Active input
151 * @output: Active outputs
152 * @video_out: Output video node
153 * @alaw: A-law compression enabled (1) or disabled (0)
154 * @lpf: Low pass filter enabled (1) or disabled (0)
155 * @obclamp: Optical-black clamp enabled (1) or disabled (0)
156 * @fpc_en: Faulty pixels correction enabled (1) or disabled (0)
157 * @blcomp: Black level compensation configuration
158 * @clamp: Optical-black or digital clamp configuration
159 * @fpc: Faulty pixels correction configuration
160 * @lsc: Lens shading compensation configuration
161 * @update: Bitmask of controls to update during the next interrupt
162 * @shadow_update: Controls update in progress by userspace
163 * @syncif: Interface synchronization configuration
164 * @vpcfg: Video port configuration
165 * @underrun: A buffer underrun occurred and a new buffer has been queued
166 * @state: Streaming state
167 * @lock: Serializes shadow_update with interrupt handler
168 * @wait: Wait queue used to stop the module
169 * @stopping: Stopping state
170 * @ioctl_lock: Serializes ioctl calls and LSC requests freeing
172 struct isp_ccdc_device
{
173 struct v4l2_subdev subdev
;
174 struct media_pad pads
[CCDC_PADS_NUM
];
175 struct v4l2_mbus_framefmt formats
[CCDC_PADS_NUM
];
177 enum ccdc_input_entity input
;
179 struct isp_video video_out
;
185 struct omap3isp_ccdc_blcomp blcomp
;
186 struct omap3isp_ccdc_bclamp clamp
;
187 struct omap3isp_ccdc_fpc fpc
;
188 struct ispccdc_lsc lsc
;
190 unsigned int shadow_update
;
192 struct ispccdc_syncif syncif
;
193 struct ispccdc_vp vpcfg
;
195 unsigned int underrun
:1;
196 enum isp_pipeline_stream_state state
;
198 wait_queue_head_t wait
;
199 unsigned int stopping
;
200 struct mutex ioctl_lock
;
205 int omap3isp_ccdc_init(struct isp_device
*isp
);
206 void omap3isp_ccdc_cleanup(struct isp_device
*isp
);
207 int omap3isp_ccdc_register_entities(struct isp_ccdc_device
*ccdc
,
208 struct v4l2_device
*vdev
);
209 void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device
*ccdc
);
211 int omap3isp_ccdc_busy(struct isp_ccdc_device
*isp_ccdc
);
212 int omap3isp_ccdc_isr(struct isp_ccdc_device
*isp_ccdc
, u32 events
);
213 void omap3isp_ccdc_restore_context(struct isp_device
*isp
);
214 void omap3isp_ccdc_max_rate(struct isp_ccdc_device
*ccdc
,
215 unsigned int *max_rate
);
217 #endif /* OMAP3_ISP_CCDC_H */