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
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
34 v4l2_int_type_master = 1,
38 enum v4l2_int_ioctl_num {
41 * "Proper" V4L ioctls, as in struct video_device.
44 vidioc_int_enum_fmt_cap_num = 1,
45 vidioc_int_g_fmt_cap_num,
46 vidioc_int_s_fmt_cap_num,
47 vidioc_int_try_fmt_cap_num,
48 vidioc_int_queryctrl_num,
49 vidioc_int_g_ctrl_num,
50 vidioc_int_s_ctrl_num,
51 vidioc_int_g_parm_num,
52 vidioc_int_s_parm_num,
56 * Strictly internal ioctls.
59 /* Initialise the device when slave attaches to the master. */
60 vidioc_int_dev_init_num = 1000,
61 /* Delinitialise the device at slave detach. */
62 vidioc_int_dev_exit_num,
63 /* Set device power state: 0 is off, non-zero is on. */
64 vidioc_int_s_power_num,
65 /* Get parallel interface clock speed for current settings. */
66 vidioc_int_g_ext_clk_num,
68 * Tell what the parallel interface clock speed actually is.
70 vidioc_int_s_ext_clk_num,
71 /* Does the slave need to be reset after VIDIOC_DQBUF? */
72 vidioc_int_g_needs_reset_num,
76 * VIDIOC_INT_* ioctls.
79 /* VIDIOC_INT_RESET */
83 /* VIDIOC_INT_G_CHIP_IDENT */
84 vidioc_int_g_chip_ident_num,
88 * Start of private ioctls.
91 vidioc_int_priv_start_num = 2000,
94 struct v4l2_int_device;
96 struct v4l2_int_master {
97 int (*attach)(struct v4l2_int_device *master,
98 struct v4l2_int_device *slave);
99 void (*detach)(struct v4l2_int_device *master);
102 typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
103 typedef int (v4l2_int_ioctl_func_0)(struct v4l2_int_device *);
104 typedef int (v4l2_int_ioctl_func_1)(struct v4l2_int_device *, void *);
106 struct v4l2_int_ioctl_desc {
108 v4l2_int_ioctl_func *func;
111 struct v4l2_int_slave {
112 /* Don't touch master. */
113 struct v4l2_int_device *master;
115 char attach_to[V4L2NAMESIZE];
118 struct v4l2_int_ioctl_desc *ioctls;
121 struct v4l2_int_device {
122 /* Don't touch head. */
123 struct list_head head;
125 struct module *module;
127 char name[V4L2NAMESIZE];
129 enum v4l2_int_type type;
131 struct v4l2_int_master *master;
132 struct v4l2_int_slave *slave;
138 int v4l2_int_device_register(struct v4l2_int_device *d);
139 void v4l2_int_device_unregister(struct v4l2_int_device *d);
141 int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd);
142 int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg);
146 * IOCTL wrapper functions for better type checking.
150 #define V4L2_INT_WRAPPER_0(name) \
151 static inline int vidioc_int_##name(struct v4l2_int_device *d) \
153 return v4l2_int_ioctl_0(d, vidioc_int_##name##_num); \
156 static inline struct v4l2_int_ioctl_desc \
157 vidioc_int_##name##_cb(int (*func) \
158 (struct v4l2_int_device *)) \
160 struct v4l2_int_ioctl_desc desc; \
162 desc.num = vidioc_int_##name##_num; \
163 desc.func = (v4l2_int_ioctl_func *)func; \
168 #define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \
169 static inline int vidioc_int_##name(struct v4l2_int_device *d, \
170 arg_type asterisk arg) \
172 return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \
173 (void *)(unsigned long)arg); \
176 static inline struct v4l2_int_ioctl_desc \
177 vidioc_int_##name##_cb(int (*func) \
178 (struct v4l2_int_device *, \
179 arg_type asterisk)) \
181 struct v4l2_int_ioctl_desc desc; \
183 desc.num = vidioc_int_##name##_num; \
184 desc.func = (v4l2_int_ioctl_func *)func; \
189 V4L2_INT_WRAPPER_1(enum_fmt_cap, struct v4l2_fmtdesc, *);
190 V4L2_INT_WRAPPER_1(g_fmt_cap, struct v4l2_format, *);
191 V4L2_INT_WRAPPER_1(s_fmt_cap, struct v4l2_format, *);
192 V4L2_INT_WRAPPER_1(try_fmt_cap, struct v4l2_format, *);
193 V4L2_INT_WRAPPER_1(queryctrl, struct v4l2_queryctrl, *);
194 V4L2_INT_WRAPPER_1(g_ctrl, struct v4l2_control, *);
195 V4L2_INT_WRAPPER_1(s_ctrl, struct v4l2_control, *);
196 V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
197 V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
199 V4L2_INT_WRAPPER_0(dev_init);
200 V4L2_INT_WRAPPER_0(dev_exit);
201 V4L2_INT_WRAPPER_1(s_power, int, );
202 V4L2_INT_WRAPPER_1(s_ext_clk, u32, );
203 V4L2_INT_WRAPPER_1(g_ext_clk, u32, *);
204 V4L2_INT_WRAPPER_1(g_needs_reset, void, *);
206 V4L2_INT_WRAPPER_0(reset);
207 V4L2_INT_WRAPPER_0(init);
208 V4L2_INT_WRAPPER_1(g_chip_ident, int, *);