Blame view

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