Commit | Line | Data |
---|---|---|
9b5d0f1e SA |
1 | /* |
2 | * include/media/v4l2-int-device.h | |
3 | * | |
4 | * V4L2 internal ioctl interface. | |
5 | * | |
6 | * Copyright (C) 2007 Nokia Corporation. | |
7 | * | |
8 | * Contact: Sakari Ailus <sakari.ailus@nokia.com> | |
9 | * | |
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. | |
13 | * | |
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. | |
18 | * | |
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 | |
23 | */ | |
24 | ||
25 | #ifndef V4L2_INT_DEVICE_H | |
26 | #define V4L2_INT_DEVICE_H | |
27 | ||
9b5d0f1e SA |
28 | #include <media/v4l2-common.h> |
29 | ||
30 | #define V4L2NAMESIZE 32 | |
31 | ||
098c645e SA |
32 | /* |
33 | * | |
34 | * The internal V4L2 device interface core. | |
35 | * | |
36 | */ | |
37 | ||
9b5d0f1e SA |
38 | enum v4l2_int_type { |
39 | v4l2_int_type_master = 1, | |
40 | v4l2_int_type_slave | |
41 | }; | |
42 | ||
de477254 PG |
43 | struct module; |
44 | ||
098c645e SA |
45 | struct v4l2_int_device; |
46 | ||
47 | struct v4l2_int_master { | |
2c94a674 SA |
48 | int (*attach)(struct v4l2_int_device *slave); |
49 | void (*detach)(struct v4l2_int_device *slave); | |
098c645e SA |
50 | }; |
51 | ||
52 | typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *); | |
53 | typedef int (v4l2_int_ioctl_func_0)(struct v4l2_int_device *); | |
54 | typedef int (v4l2_int_ioctl_func_1)(struct v4l2_int_device *, void *); | |
55 | ||
56 | struct v4l2_int_ioctl_desc { | |
57 | int num; | |
58 | v4l2_int_ioctl_func *func; | |
59 | }; | |
60 | ||
61 | struct v4l2_int_slave { | |
62 | /* Don't touch master. */ | |
63 | struct v4l2_int_device *master; | |
64 | ||
65 | char attach_to[V4L2NAMESIZE]; | |
66 | ||
67 | int num_ioctls; | |
68 | struct v4l2_int_ioctl_desc *ioctls; | |
69 | }; | |
70 | ||
71 | struct v4l2_int_device { | |
72 | /* Don't touch head. */ | |
73 | struct list_head head; | |
74 | ||
75 | struct module *module; | |
76 | ||
77 | char name[V4L2NAMESIZE]; | |
78 | ||
79 | enum v4l2_int_type type; | |
80 | union { | |
81 | struct v4l2_int_master *master; | |
82 | struct v4l2_int_slave *slave; | |
83 | } u; | |
84 | ||
85 | void *priv; | |
86 | }; | |
87 | ||
36499e52 SA |
88 | void v4l2_int_device_try_attach_all(void); |
89 | ||
098c645e SA |
90 | int v4l2_int_device_register(struct v4l2_int_device *d); |
91 | void v4l2_int_device_unregister(struct v4l2_int_device *d); | |
92 | ||
93 | int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd); | |
94 | int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg); | |
95 | ||
96 | /* | |
97 | * | |
98 | * Types and definitions for IOCTL commands. | |
99 | * | |
100 | */ | |
101 | ||
84389910 SA |
102 | enum v4l2_power { |
103 | V4L2_POWER_OFF = 0, | |
104 | V4L2_POWER_ON, | |
105 | V4L2_POWER_STANDBY, | |
106 | }; | |
107 | ||
098c645e SA |
108 | /* Slave interface type. */ |
109 | enum v4l2_if_type { | |
08256ea0 SA |
110 | /* |
111 | * Parallel 8-, 10- or 12-bit interface, used by for example | |
112 | * on certain image sensors. | |
113 | */ | |
114 | V4L2_IF_TYPE_BT656, | |
115 | }; | |
116 | ||
117 | enum v4l2_if_type_bt656_mode { | |
118 | /* | |
119 | * Modes without Bt synchronisation codes. Separate | |
120 | * synchronisation signal lines are used. | |
121 | */ | |
122 | V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT, | |
123 | V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT, | |
124 | V4L2_IF_TYPE_BT656_MODE_NOBT_12BIT, | |
125 | /* | |
126 | * Use Bt synchronisation codes. The vertical and horizontal | |
127 | * synchronisation is done based on synchronisation codes. | |
128 | */ | |
129 | V4L2_IF_TYPE_BT656_MODE_BT_8BIT, | |
130 | V4L2_IF_TYPE_BT656_MODE_BT_10BIT, | |
131 | }; | |
132 | ||
133 | struct v4l2_if_type_bt656 { | |
134 | /* | |
135 | * 0: Frame begins when vsync is high. | |
136 | * 1: Frame begins when vsync changes from low to high. | |
137 | */ | |
138 | unsigned frame_start_on_rising_vs:1; | |
139 | /* Use Bt synchronisation codes for sync correction. */ | |
140 | unsigned bt_sync_correct:1; | |
141 | /* Swap every two adjacent image data elements. */ | |
142 | unsigned swap:1; | |
143 | /* Inverted latch clock polarity from slave. */ | |
144 | unsigned latch_clk_inv:1; | |
145 | /* Hs polarity. 0 is active high, 1 active low. */ | |
146 | unsigned nobt_hs_inv:1; | |
147 | /* Vs polarity. 0 is active high, 1 active low. */ | |
148 | unsigned nobt_vs_inv:1; | |
149 | enum v4l2_if_type_bt656_mode mode; | |
150 | /* Minimum accepted bus clock for slave (in Hz). */ | |
151 | u32 clock_min; | |
152 | /* Maximum accepted bus clock for slave. */ | |
153 | u32 clock_max; | |
154 | /* | |
155 | * Current wish of the slave. May only change in response to | |
156 | * ioctls that affect image capture. | |
157 | */ | |
158 | u32 clock_curr; | |
098c645e SA |
159 | }; |
160 | ||
161 | struct v4l2_ifparm { | |
162 | enum v4l2_if_type if_type; | |
163 | union { | |
08256ea0 | 164 | struct v4l2_if_type_bt656 bt656; |
098c645e SA |
165 | } u; |
166 | }; | |
167 | ||
168 | /* IOCTL command numbers. */ | |
9b5d0f1e SA |
169 | enum v4l2_int_ioctl_num { |
170 | /* | |
171 | * | |
172 | * "Proper" V4L ioctls, as in struct video_device. | |
173 | * | |
174 | */ | |
175 | vidioc_int_enum_fmt_cap_num = 1, | |
176 | vidioc_int_g_fmt_cap_num, | |
177 | vidioc_int_s_fmt_cap_num, | |
178 | vidioc_int_try_fmt_cap_num, | |
179 | vidioc_int_queryctrl_num, | |
180 | vidioc_int_g_ctrl_num, | |
181 | vidioc_int_s_ctrl_num, | |
621a3739 SV |
182 | vidioc_int_cropcap_num, |
183 | vidioc_int_g_crop_num, | |
184 | vidioc_int_s_crop_num, | |
9b5d0f1e SA |
185 | vidioc_int_g_parm_num, |
186 | vidioc_int_s_parm_num, | |
67bc04dd VH |
187 | vidioc_int_querystd_num, |
188 | vidioc_int_s_std_num, | |
189 | vidioc_int_s_video_routing_num, | |
9b5d0f1e SA |
190 | |
191 | /* | |
192 | * | |
193 | * Strictly internal ioctls. | |
194 | * | |
195 | */ | |
196 | /* Initialise the device when slave attaches to the master. */ | |
197 | vidioc_int_dev_init_num = 1000, | |
198 | /* Delinitialise the device at slave detach. */ | |
199 | vidioc_int_dev_exit_num, | |
84389910 | 200 | /* Set device power state. */ |
9b5d0f1e | 201 | vidioc_int_s_power_num, |
96014a95 SA |
202 | /* |
203 | * Get slave private data, e.g. platform-specific slave | |
204 | * configuration used by the master. | |
205 | */ | |
206 | vidioc_int_g_priv_num, | |
098c645e SA |
207 | /* Get slave interface parameters. */ |
208 | vidioc_int_g_ifparm_num, | |
9b5d0f1e SA |
209 | /* Does the slave need to be reset after VIDIOC_DQBUF? */ |
210 | vidioc_int_g_needs_reset_num, | |
f496bc71 SA |
211 | vidioc_int_enum_framesizes_num, |
212 | vidioc_int_enum_frameintervals_num, | |
9b5d0f1e SA |
213 | |
214 | /* | |
215 | * | |
216 | * VIDIOC_INT_* ioctls. | |
217 | * | |
218 | */ | |
219 | /* VIDIOC_INT_RESET */ | |
220 | vidioc_int_reset_num, | |
221 | /* VIDIOC_INT_INIT */ | |
222 | vidioc_int_init_num, | |
aecde8b5 | 223 | /* VIDIOC_DBG_G_CHIP_IDENT */ |
9b5d0f1e SA |
224 | vidioc_int_g_chip_ident_num, |
225 | ||
226 | /* | |
227 | * | |
228 | * Start of private ioctls. | |
229 | * | |
230 | */ | |
231 | vidioc_int_priv_start_num = 2000, | |
232 | }; | |
233 | ||
9b5d0f1e SA |
234 | /* |
235 | * | |
236 | * IOCTL wrapper functions for better type checking. | |
237 | * | |
238 | */ | |
239 | ||
240 | #define V4L2_INT_WRAPPER_0(name) \ | |
241 | static inline int vidioc_int_##name(struct v4l2_int_device *d) \ | |
242 | { \ | |
243 | return v4l2_int_ioctl_0(d, vidioc_int_##name##_num); \ | |
244 | } \ | |
245 | \ | |
246 | static inline struct v4l2_int_ioctl_desc \ | |
247 | vidioc_int_##name##_cb(int (*func) \ | |
248 | (struct v4l2_int_device *)) \ | |
249 | { \ | |
250 | struct v4l2_int_ioctl_desc desc; \ | |
251 | \ | |
252 | desc.num = vidioc_int_##name##_num; \ | |
253 | desc.func = (v4l2_int_ioctl_func *)func; \ | |
254 | \ | |
255 | return desc; \ | |
256 | } | |
257 | ||
258 | #define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \ | |
259 | static inline int vidioc_int_##name(struct v4l2_int_device *d, \ | |
260 | arg_type asterisk arg) \ | |
261 | { \ | |
262 | return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \ | |
63116feb | 263 | (void *)(unsigned long)arg); \ |
9b5d0f1e SA |
264 | } \ |
265 | \ | |
266 | static inline struct v4l2_int_ioctl_desc \ | |
267 | vidioc_int_##name##_cb(int (*func) \ | |
268 | (struct v4l2_int_device *, \ | |
269 | arg_type asterisk)) \ | |
270 | { \ | |
271 | struct v4l2_int_ioctl_desc desc; \ | |
272 | \ | |
273 | desc.num = vidioc_int_##name##_num; \ | |
274 | desc.func = (v4l2_int_ioctl_func *)func; \ | |
275 | \ | |
276 | return desc; \ | |
277 | } | |
278 | ||
279 | V4L2_INT_WRAPPER_1(enum_fmt_cap, struct v4l2_fmtdesc, *); | |
280 | V4L2_INT_WRAPPER_1(g_fmt_cap, struct v4l2_format, *); | |
281 | V4L2_INT_WRAPPER_1(s_fmt_cap, struct v4l2_format, *); | |
282 | V4L2_INT_WRAPPER_1(try_fmt_cap, struct v4l2_format, *); | |
283 | V4L2_INT_WRAPPER_1(queryctrl, struct v4l2_queryctrl, *); | |
284 | V4L2_INT_WRAPPER_1(g_ctrl, struct v4l2_control, *); | |
285 | V4L2_INT_WRAPPER_1(s_ctrl, struct v4l2_control, *); | |
621a3739 SV |
286 | V4L2_INT_WRAPPER_1(cropcap, struct v4l2_cropcap, *); |
287 | V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *); | |
288 | V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *); | |
9b5d0f1e SA |
289 | V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *); |
290 | V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *); | |
67bc04dd VH |
291 | V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *); |
292 | V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *); | |
293 | V4L2_INT_WRAPPER_1(s_video_routing, struct v4l2_routing, *); | |
9b5d0f1e SA |
294 | |
295 | V4L2_INT_WRAPPER_0(dev_init); | |
296 | V4L2_INT_WRAPPER_0(dev_exit); | |
84389910 | 297 | V4L2_INT_WRAPPER_1(s_power, enum v4l2_power, ); |
96014a95 | 298 | V4L2_INT_WRAPPER_1(g_priv, void, *); |
098c645e | 299 | V4L2_INT_WRAPPER_1(g_ifparm, struct v4l2_ifparm, *); |
9b5d0f1e | 300 | V4L2_INT_WRAPPER_1(g_needs_reset, void, *); |
f496bc71 SA |
301 | V4L2_INT_WRAPPER_1(enum_framesizes, struct v4l2_frmsizeenum, *); |
302 | V4L2_INT_WRAPPER_1(enum_frameintervals, struct v4l2_frmivalenum, *); | |
9b5d0f1e SA |
303 | |
304 | V4L2_INT_WRAPPER_0(reset); | |
305 | V4L2_INT_WRAPPER_0(init); | |
306 | V4L2_INT_WRAPPER_1(g_chip_ident, int, *); | |
307 | ||
308 | #endif |