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