Full support for Ginger Console
[linux-ginger.git] / include / media / v4l2-int-device.h
blobed32d3f0ac84dea8a1050a20d28a8bfff4b8a109
1 /*
2 * include/media/v4l2-int-device.h
4 * V4L2 internal ioctl interface.
6 * Copyright (C) 2007 Nokia Corporation.
8 * Contact: Sakari Ailus <sakari.ailus@nokia.com>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
25 #ifndef V4L2_INT_DEVICE_H
26 #define V4L2_INT_DEVICE_H
28 #include <linux/module.h>
29 #include <media/v4l2-common.h>
31 #define V4L2NAMESIZE 32
35 * The internal V4L2 device interface core.
39 enum v4l2_int_type {
40 v4l2_int_type_master = 1,
41 v4l2_int_type_slave
44 struct v4l2_int_device;
46 struct v4l2_int_master {
47 int (*attach)(struct v4l2_int_device *slave);
48 void (*detach)(struct v4l2_int_device *slave);
51 typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
52 typedef int (v4l2_int_ioctl_func_0)(struct v4l2_int_device *);
53 typedef int (v4l2_int_ioctl_func_1)(struct v4l2_int_device *, void *);
55 struct v4l2_int_ioctl_desc {
56 int num;
57 v4l2_int_ioctl_func *func;
60 struct v4l2_int_slave {
61 /* Don't touch master. */
62 struct v4l2_int_device *master;
64 char attach_to[V4L2NAMESIZE];
66 int num_ioctls;
67 struct v4l2_int_ioctl_desc *ioctls;
70 struct v4l2_int_device {
71 /* Don't touch head. */
72 struct list_head head;
74 struct module *module;
76 char name[V4L2NAMESIZE];
78 enum v4l2_int_type type;
79 union {
80 struct v4l2_int_master *master;
81 struct v4l2_int_slave *slave;
82 } u;
84 void *priv;
87 struct v4l2_int_device *v4l2_int_device_dummy(void);
89 void v4l2_int_device_try_attach_all(void);
91 int v4l2_int_device_register(struct v4l2_int_device *d);
92 void v4l2_int_device_unregister(struct v4l2_int_device *d);
94 int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd);
95 int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg);
99 * Types and definitions for IOCTL commands.
103 enum v4l2_power {
104 V4L2_POWER_OFF = 0,
105 V4L2_POWER_ON,
106 V4L2_POWER_STANDBY,
109 /* Slave interface type. */
110 enum v4l2_if_type {
112 * Parallel 8-, 10- or 12-bit interface, used by for example
113 * on certain image sensors.
115 V4L2_IF_TYPE_BT656,
118 enum v4l2_if_type_bt656_mode {
120 * Modes without Bt synchronisation codes. Separate
121 * synchronisation signal lines are used.
123 V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
124 V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT,
125 V4L2_IF_TYPE_BT656_MODE_NOBT_12BIT,
127 * Use Bt synchronisation codes. The vertical and horizontal
128 * synchronisation is done based on synchronisation codes.
130 V4L2_IF_TYPE_BT656_MODE_BT_8BIT,
131 V4L2_IF_TYPE_BT656_MODE_BT_10BIT,
134 struct v4l2_if_type_bt656 {
136 * 0: Frame begins when vsync is high.
137 * 1: Frame begins when vsync changes from low to high.
139 unsigned frame_start_on_rising_vs:1;
140 /* Use Bt synchronisation codes for sync correction. */
141 unsigned bt_sync_correct:1;
142 /* Swap every two adjacent image data elements. */
143 unsigned swap:1;
144 /* Inverted latch clock polarity from slave. */
145 unsigned latch_clk_inv:1;
146 /* Hs polarity. 0 is active high, 1 active low. */
147 unsigned nobt_hs_inv:1;
148 /* Vs polarity. 0 is active high, 1 active low. */
149 unsigned nobt_vs_inv:1;
150 enum v4l2_if_type_bt656_mode mode;
151 /* Minimum accepted bus clock for slave (in Hz). */
152 u32 clock_min;
153 /* Maximum accepted bus clock for slave. */
154 u32 clock_max;
156 * Current wish of the slave. May only change in response to
157 * ioctls that affect image capture.
159 u32 clock_curr;
162 struct v4l2_ifparm {
163 enum v4l2_if_type if_type;
164 union {
165 struct v4l2_if_type_bt656 bt656;
166 } u;
169 /* IOCTL command numbers. */
170 enum v4l2_int_ioctl_num {
173 * "Proper" V4L ioctls, as in struct video_device.
176 vidioc_int_querycap_num = 1,
177 vidioc_int_enum_fmt_cap_num,
178 vidioc_int_g_fmt_cap_num,
179 vidioc_int_s_fmt_cap_num,
180 vidioc_int_try_fmt_cap_num,
181 vidioc_int_queryctrl_num,
182 vidioc_int_querymenu_num,
183 vidioc_int_g_ctrl_num,
184 vidioc_int_s_ctrl_num,
185 vidioc_int_cropcap_num,
186 vidioc_int_g_crop_num,
187 vidioc_int_s_crop_num,
188 vidioc_int_g_parm_num,
189 vidioc_int_s_parm_num,
190 vidioc_int_querystd_num,
191 vidioc_int_s_std_num,
192 vidioc_int_s_video_routing_num,
196 * Strictly internal ioctls.
199 /* Initialise the device when slave attaches to the master. */
200 vidioc_int_dev_init_num = 1000,
201 /* Delinitialise the device at slave detach. */
202 vidioc_int_dev_exit_num,
203 /* Set device power state. */
204 vidioc_int_s_power_num,
206 * Get slave private data, e.g. platform-specific slave
207 * configuration used by the master.
209 vidioc_int_g_priv_num,
210 /* Get slave interface parameters. */
211 vidioc_int_g_ifparm_num,
212 /* Does the slave need to be reset after VIDIOC_DQBUF? */
213 vidioc_int_g_needs_reset_num,
214 vidioc_int_enum_framesizes_num,
215 vidioc_int_enum_frameintervals_num,
219 * VIDIOC_INT_* ioctls.
222 /* VIDIOC_INT_RESET */
223 vidioc_int_reset_num,
224 /* VIDIOC_INT_INIT */
225 vidioc_int_init_num,
226 /* VIDIOC_DBG_G_CHIP_IDENT */
227 vidioc_int_g_chip_ident_num,
231 * Start of private ioctls.
234 vidioc_int_priv_start_num = 2000,
235 /* VIDIOC_INT_PRIV_G_PIXCLK */
236 vidioc_int_priv_g_pixclk_num,
237 /* VIDIOC_INT_PRIV_G_ACTIVESIZE */
238 vidioc_int_priv_g_activesize_num,
239 /* VIDIOC_INT_PRIV_G_FULLSIZE */
240 vidioc_int_priv_g_fullsize_num,
245 * IOCTL wrapper functions for better type checking.
249 #define V4L2_INT_WRAPPER_0(name) \
250 static inline int vidioc_int_##name(struct v4l2_int_device *d) \
252 return v4l2_int_ioctl_0(d, vidioc_int_##name##_num); \
255 static inline struct v4l2_int_ioctl_desc \
256 vidioc_int_##name##_cb(int (*func) \
257 (struct v4l2_int_device *)) \
259 struct v4l2_int_ioctl_desc desc; \
261 desc.num = vidioc_int_##name##_num; \
262 desc.func = (v4l2_int_ioctl_func *)func; \
264 return desc; \
267 #define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \
268 static inline int vidioc_int_##name(struct v4l2_int_device *d, \
269 arg_type asterisk arg) \
271 return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \
272 (void *)(unsigned long)arg); \
275 static inline struct v4l2_int_ioctl_desc \
276 vidioc_int_##name##_cb(int (*func) \
277 (struct v4l2_int_device *, \
278 arg_type asterisk)) \
280 struct v4l2_int_ioctl_desc desc; \
282 desc.num = vidioc_int_##name##_num; \
283 desc.func = (v4l2_int_ioctl_func *)func; \
285 return desc; \
288 V4L2_INT_WRAPPER_1(querycap, struct v4l2_capability, *);
289 V4L2_INT_WRAPPER_1(enum_fmt_cap, struct v4l2_fmtdesc, *);
290 V4L2_INT_WRAPPER_1(g_fmt_cap, struct v4l2_format, *);
291 V4L2_INT_WRAPPER_1(s_fmt_cap, struct v4l2_format, *);
292 V4L2_INT_WRAPPER_1(try_fmt_cap, struct v4l2_format, *);
293 V4L2_INT_WRAPPER_1(queryctrl, struct v4l2_queryctrl, *);
294 V4L2_INT_WRAPPER_1(querymenu, struct v4l2_querymenu, *);
295 V4L2_INT_WRAPPER_1(g_ctrl, struct v4l2_control, *);
296 V4L2_INT_WRAPPER_1(s_ctrl, struct v4l2_control, *);
297 V4L2_INT_WRAPPER_1(cropcap, struct v4l2_cropcap, *);
298 V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
299 V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
300 V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
301 V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
302 V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
303 V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
304 V4L2_INT_WRAPPER_1(s_video_routing, struct v4l2_routing, *);
306 V4L2_INT_WRAPPER_0(dev_init);
307 V4L2_INT_WRAPPER_0(dev_exit);
308 V4L2_INT_WRAPPER_1(s_power, enum v4l2_power, );
309 V4L2_INT_WRAPPER_1(g_priv, void, *);
310 V4L2_INT_WRAPPER_1(g_ifparm, struct v4l2_ifparm, *);
311 V4L2_INT_WRAPPER_1(g_needs_reset, void, *);
312 V4L2_INT_WRAPPER_1(enum_framesizes, struct v4l2_frmsizeenum, *);
313 V4L2_INT_WRAPPER_1(enum_frameintervals, struct v4l2_frmivalenum, *);
315 V4L2_INT_WRAPPER_0(reset);
316 V4L2_INT_WRAPPER_0(init);
317 V4L2_INT_WRAPPER_1(g_chip_ident, int, *);
319 V4L2_INT_WRAPPER_1(priv_g_pixclk, u32, *);
320 V4L2_INT_WRAPPER_1(priv_g_activesize, struct v4l2_pix_format, *);
321 V4L2_INT_WRAPPER_1(priv_g_fullsize, struct v4l2_pix_format, *);
322 #endif