blob: e52ddc9fa8f4b09c303644da595c68980e2810ca [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001/*
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
28#include <linux/module.h>
29#include <media/v4l2-common.h>
30
31#define V4L2NAMESIZE 32
32
33
34enum v4l2_int_type {
35 v4l2_int_type_master = 1,
36 v4l2_int_type_slave
37};
38
39struct v4l2_int_device;
40
41struct v4l2_int_master {
42 int (*attach)(struct v4l2_int_device *slave);
43 void (*detach)(struct v4l2_int_device *slave);
44};
45
46typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
47typedef int (v4l2_int_ioctl_func_0)(struct v4l2_int_device *);
48typedef int (v4l2_int_ioctl_func_1)(struct v4l2_int_device *, void *);
49
50struct v4l2_int_ioctl_desc {
51 int num;
52 v4l2_int_ioctl_func *func;
53};
54
55struct v4l2_int_slave {
56
57 struct v4l2_int_device *master;
58
59 char attach_to[V4L2NAMESIZE];
60
61 int num_ioctls;
62 struct v4l2_int_ioctl_desc *ioctls;
63};
64
65struct v4l2_int_device {
66
67 struct list_head head;
68
69 struct module *module;
70
71 char name[V4L2NAMESIZE];
72
73 enum v4l2_int_type type;
74 union {
75 struct v4l2_int_master *master;
76 struct v4l2_int_slave *slave;
77 } u;
78
79 void *priv;
80};
81
82void v4l2_int_device_try_attach_all(void);
83
84int v4l2_int_device_register(struct v4l2_int_device *d);
85void v4l2_int_device_unregister(struct v4l2_int_device *d);
86
87int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd);
88int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg);
89
90
91enum v4l2_power {
92 V4L2_POWER_OFF = 0,
93 V4L2_POWER_ON,
94 V4L2_POWER_STANDBY,
95};
96
97enum v4l2_if_type {
98 V4L2_IF_TYPE_BT656,
99};
100
101enum v4l2_if_type_bt656_mode {
102 V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT,
103 V4L2_IF_TYPE_BT656_MODE_NOBT_10BIT,
104 V4L2_IF_TYPE_BT656_MODE_NOBT_12BIT,
105 V4L2_IF_TYPE_BT656_MODE_BT_8BIT,
106 V4L2_IF_TYPE_BT656_MODE_BT_10BIT,
107};
108
109struct v4l2_if_type_bt656 {
110 unsigned frame_start_on_rising_vs:1;
111
112 unsigned bt_sync_correct:1;
113
114 unsigned swap:1;
115
116 unsigned latch_clk_inv:1;
117
118 unsigned nobt_hs_inv:1;
119
120 unsigned nobt_vs_inv:1;
121 enum v4l2_if_type_bt656_mode mode;
122
123 u32 clock_min;
124
125 u32 clock_max;
126 u32 clock_curr;
127};
128
129struct v4l2_ifparm {
130 enum v4l2_if_type if_type;
131 union {
132 struct v4l2_if_type_bt656 bt656;
133 } u;
134};
135
136enum v4l2_int_ioctl_num {
137 vidioc_int_enum_fmt_cap_num = 1,
138 vidioc_int_g_fmt_cap_num,
139 vidioc_int_s_fmt_cap_num,
140 vidioc_int_try_fmt_cap_num,
141 vidioc_int_queryctrl_num,
142 vidioc_int_g_ctrl_num,
143 vidioc_int_s_ctrl_num,
144 vidioc_int_cropcap_num,
145 vidioc_int_g_crop_num,
146 vidioc_int_s_crop_num,
147 vidioc_int_g_parm_num,
148 vidioc_int_s_parm_num,
149 vidioc_int_querystd_num,
150 vidioc_int_s_std_num,
151 vidioc_int_s_video_routing_num,
152
153
154 vidioc_int_dev_init_num = 1000,
155
156 vidioc_int_dev_exit_num,
157
158 vidioc_int_s_power_num,
159 vidioc_int_g_priv_num,
160
161 vidioc_int_g_ifparm_num,
162
163 vidioc_int_g_needs_reset_num,
164 vidioc_int_enum_framesizes_num,
165 vidioc_int_enum_frameintervals_num,
166
167
168 vidioc_int_reset_num,
169
170 vidioc_int_init_num,
171
172 vidioc_int_g_chip_ident_num,
173
174 vidioc_int_priv_start_num = 2000,
175};
176
177
178#define V4L2_INT_WRAPPER_0(name) \
179 static inline int vidioc_int_##name(struct v4l2_int_device *d) \
180 { \
181 return v4l2_int_ioctl_0(d, vidioc_int_##name##_num); \
182 } \
183 \
184 static inline struct v4l2_int_ioctl_desc \
185 vidioc_int_##name##_cb(int (*func) \
186 (struct v4l2_int_device *)) \
187 { \
188 struct v4l2_int_ioctl_desc desc; \
189 \
190 desc.num = vidioc_int_##name##_num; \
191 desc.func = (v4l2_int_ioctl_func *)func; \
192 \
193 return desc; \
194 }
195
196#define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \
197 static inline int vidioc_int_##name(struct v4l2_int_device *d, \
198 arg_type asterisk arg) \
199 { \
200 return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \
201 (void *)(unsigned long)arg); \
202 } \
203 \
204 static inline struct v4l2_int_ioctl_desc \
205 vidioc_int_##name##_cb(int (*func) \
206 (struct v4l2_int_device *, \
207 arg_type asterisk)) \
208 { \
209 struct v4l2_int_ioctl_desc desc; \
210 \
211 desc.num = vidioc_int_##name##_num; \
212 desc.func = (v4l2_int_ioctl_func *)func; \
213 \
214 return desc; \
215 }
216
217V4L2_INT_WRAPPER_1(enum_fmt_cap, struct v4l2_fmtdesc, *);
218V4L2_INT_WRAPPER_1(g_fmt_cap, struct v4l2_format, *);
219V4L2_INT_WRAPPER_1(s_fmt_cap, struct v4l2_format, *);
220V4L2_INT_WRAPPER_1(try_fmt_cap, struct v4l2_format, *);
221V4L2_INT_WRAPPER_1(queryctrl, struct v4l2_queryctrl, *);
222V4L2_INT_WRAPPER_1(g_ctrl, struct v4l2_control, *);
223V4L2_INT_WRAPPER_1(s_ctrl, struct v4l2_control, *);
224V4L2_INT_WRAPPER_1(cropcap, struct v4l2_cropcap, *);
225V4L2_INT_WRAPPER_1(g_crop, struct v4l2_crop, *);
226V4L2_INT_WRAPPER_1(s_crop, struct v4l2_crop, *);
227V4L2_INT_WRAPPER_1(g_parm, struct v4l2_streamparm, *);
228V4L2_INT_WRAPPER_1(s_parm, struct v4l2_streamparm, *);
229V4L2_INT_WRAPPER_1(querystd, v4l2_std_id, *);
230V4L2_INT_WRAPPER_1(s_std, v4l2_std_id, *);
231V4L2_INT_WRAPPER_1(s_video_routing, struct v4l2_routing, *);
232
233V4L2_INT_WRAPPER_0(dev_init);
234V4L2_INT_WRAPPER_0(dev_exit);
235V4L2_INT_WRAPPER_1(s_power, enum v4l2_power, );
236V4L2_INT_WRAPPER_1(g_priv, void, *);
237V4L2_INT_WRAPPER_1(g_ifparm, struct v4l2_ifparm, *);
238V4L2_INT_WRAPPER_1(g_needs_reset, void, *);
239V4L2_INT_WRAPPER_1(enum_framesizes, struct v4l2_frmsizeenum, *);
240V4L2_INT_WRAPPER_1(enum_frameintervals, struct v4l2_frmivalenum, *);
241
242V4L2_INT_WRAPPER_0(reset);
243V4L2_INT_WRAPPER_0(init);
244V4L2_INT_WRAPPER_1(g_chip_ident, int, *);
245
246#endif