aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-dev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/v4l2-dev.h')
-rw-r--r--include/media/v4l2-dev.h142
1 files changed, 91 insertions, 51 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 28a686eb7d09..53f32022fabe 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -21,31 +21,63 @@
21 21
22#define VIDEO_MAJOR 81 22#define VIDEO_MAJOR 81
23 23
24#define VFL_TYPE_GRABBER 0 24/**
25#define VFL_TYPE_VBI 1 25 * enum vfl_devnode_type - type of V4L2 device node
26#define VFL_TYPE_RADIO 2 26 *
27#define VFL_TYPE_SUBDEV 3 27 * @VFL_TYPE_GRABBER: for video input/output devices
28#define VFL_TYPE_SDR 4 28 * @VFL_TYPE_VBI: for vertical blank data (i.e. closed captions, teletext)
29#define VFL_TYPE_TOUCH 5 29 * @VFL_TYPE_RADIO: for radio tuners
30#define VFL_TYPE_MAX 6 30 * @VFL_TYPE_SUBDEV: for V4L2 subdevices
31 31 * @VFL_TYPE_SDR: for Software Defined Radio tuners
32/* Is this a receiver, transmitter or mem-to-mem? */ 32 * @VFL_TYPE_TOUCH: for touch sensors
33/* Ignored for VFL_TYPE_SUBDEV. */ 33 */
34#define VFL_DIR_RX 0 34enum vfl_devnode_type {
35#define VFL_DIR_TX 1 35 VFL_TYPE_GRABBER = 0,
36#define VFL_DIR_M2M 2 36 VFL_TYPE_VBI = 1,
37 VFL_TYPE_RADIO = 2,
38 VFL_TYPE_SUBDEV = 3,
39 VFL_TYPE_SDR = 4,
40 VFL_TYPE_TOUCH = 5,
41};
42#define VFL_TYPE_MAX VFL_TYPE_TOUCH
43
44/**
45 * enum vfl_direction - Identifies if a &struct video_device corresponds
46 * to a receiver, a transmitter or a mem-to-mem device.
47 *
48 * @VFL_DIR_RX: device is a receiver.
49 * @VFL_DIR_TX: device is a transmitter.
50 * @VFL_DIR_M2M: device is a memory to memory device.
51 *
52 * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV.
53 */
54enum vfl_devnode_direction {
55 VFL_DIR_RX,
56 VFL_DIR_TX,
57 VFL_DIR_M2M,
58};
37 59
38struct v4l2_ioctl_callbacks; 60struct v4l2_ioctl_callbacks;
39struct video_device; 61struct video_device;
40struct v4l2_device; 62struct v4l2_device;
41struct v4l2_ctrl_handler; 63struct v4l2_ctrl_handler;
42 64
43/* Flag to mark the video_device struct as registered. 65/**
44 Drivers can clear this flag if they want to block all future 66 * enum v4l2_video_device_flags - Flags used by &struct video_device
45 device access. It is cleared by video_unregister_device. */ 67 *
46#define V4L2_FL_REGISTERED (0) 68 * @V4L2_FL_REGISTERED:
47/* file->private_data points to struct v4l2_fh */ 69 * indicates that a &struct video_device is registered.
48#define V4L2_FL_USES_V4L2_FH (1) 70 * Drivers can clear this flag if they want to block all future
71 * device access. It is cleared by video_unregister_device.
72 * @V4L2_FL_USES_V4L2_FH:
73 * indicates that file->private_data points to &struct v4l2_fh.
74 * This flag is set by the core when v4l2_fh_init() is called.
75 * All new drivers should use it.
76 */
77enum v4l2_video_device_flags {
78 V4L2_FL_REGISTERED = 0,
79 V4L2_FL_USES_V4L2_FH = 1,
80};
49 81
50/* Priority helper functions */ 82/* Priority helper functions */
51 83
@@ -152,7 +184,7 @@ struct v4l2_file_operations {
152 struct module *owner; 184 struct module *owner;
153 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 185 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
154 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 186 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
155 unsigned int (*poll) (struct file *, struct poll_table_struct *); 187 __poll_t (*poll) (struct file *, struct poll_table_struct *);
156 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 188 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
157#ifdef CONFIG_COMPAT 189#ifdef CONFIG_COMPAT
158 long (*compat_ioctl32) (struct file *, unsigned int, unsigned long); 190 long (*compat_ioctl32) (struct file *, unsigned int, unsigned long);
@@ -166,7 +198,7 @@ struct v4l2_file_operations {
166 198
167/* 199/*
168 * Newer version of video_device, handled by videodev2.c 200 * Newer version of video_device, handled by videodev2.c
169 * This version moves redundant code from video device code to 201 * This version moves redundant code from video device code to
170 * the common handler 202 * the common handler
171 */ 203 */
172 204
@@ -189,11 +221,12 @@ struct v4l2_file_operations {
189 * @prio: pointer to &struct v4l2_prio_state with device's Priority state. 221 * @prio: pointer to &struct v4l2_prio_state with device's Priority state.
190 * If NULL, then v4l2_dev->prio will be used. 222 * If NULL, then v4l2_dev->prio will be used.
191 * @name: video device name 223 * @name: video device name
192 * @vfl_type: V4L device type 224 * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type
193 * @vfl_dir: V4L receiver, transmitter or m2m 225 * @vfl_dir: V4L receiver, transmitter or m2m
194 * @minor: device node 'minor'. It is set to -1 if the registration failed 226 * @minor: device node 'minor'. It is set to -1 if the registration failed
195 * @num: number of the video device node 227 * @num: number of the video device node
196 * @flags: video device flags. Use bitops to set/clear/test flags 228 * @flags: video device flags. Use bitops to set/clear/test flags.
229 * Contains a set of &enum v4l2_video_device_flags.
197 * @index: attribute to differentiate multiple indices on one physical device 230 * @index: attribute to differentiate multiple indices on one physical device
198 * @fh_lock: Lock for all v4l2_fhs 231 * @fh_lock: Lock for all v4l2_fhs
199 * @fh_list: List of &struct v4l2_fh 232 * @fh_list: List of &struct v4l2_fh
@@ -237,8 +270,8 @@ struct video_device
237 270
238 /* device info */ 271 /* device info */
239 char name[32]; 272 char name[32];
240 int vfl_type; 273 enum vfl_devnode_type vfl_type;
241 int vfl_dir; 274 enum vfl_devnode_direction vfl_dir;
242 int minor; 275 int minor;
243 u16 num; 276 u16 num;
244 unsigned long flags; 277 unsigned long flags;
@@ -261,18 +294,30 @@ struct video_device
261 struct mutex *lock; 294 struct mutex *lock;
262}; 295};
263 296
264#define media_entity_to_video_device(__e) \ 297/**
265 container_of(__e, struct video_device, entity) 298 * media_entity_to_video_device - Returns a &struct video_device from
266/* dev to video-device */ 299 * the &struct media_entity embedded on it.
300 *
301 * @entity: pointer to &struct media_entity
302 */
303#define media_entity_to_video_device(entity) \
304 container_of(entity, struct video_device, entity)
305
306/**
307 * to_video_device - Returns a &struct video_device from the
308 * &struct device embedded on it.
309 *
310 * @cd: pointer to &struct device
311 */
267#define to_video_device(cd) container_of(cd, struct video_device, dev) 312#define to_video_device(cd) container_of(cd, struct video_device, dev)
268 313
269/** 314/**
270 * __video_register_device - register video4linux devices 315 * __video_register_device - register video4linux devices
271 * 316 *
272 * @vdev: struct video_device to register 317 * @vdev: struct video_device to register
273 * @type: type of device to register 318 * @type: type of device to register, as defined by &enum vfl_devnode_type
274 * @nr: which device node number is desired: 319 * @nr: which device node number is desired:
275 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) 320 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
276 * @warn_if_nr_in_use: warn if the desired device node number 321 * @warn_if_nr_in_use: warn if the desired device node number
277 * was already in use and another number was chosen instead. 322 * was already in use and another number was chosen instead.
278 * @owner: module that owns the video device node 323 * @owner: module that owns the video device node
@@ -289,43 +334,37 @@ struct video_device
289 * 334 *
290 * Returns 0 on success. 335 * Returns 0 on success.
291 * 336 *
292 * Valid values for @type are:
293 *
294 * - %VFL_TYPE_GRABBER - A frame grabber
295 * - %VFL_TYPE_VBI - Vertical blank data (undecoded)
296 * - %VFL_TYPE_RADIO - A radio card
297 * - %VFL_TYPE_SUBDEV - A subdevice
298 * - %VFL_TYPE_SDR - Software Defined Radio
299 * - %VFL_TYPE_TOUCH - A touch sensor
300 *
301 * .. note:: 337 * .. note::
302 * 338 *
303 * This function is meant to be used only inside the V4L2 core. 339 * This function is meant to be used only inside the V4L2 core.
304 * Drivers should use video_register_device() or 340 * Drivers should use video_register_device() or
305 * video_register_device_no_warn(). 341 * video_register_device_no_warn().
306 */ 342 */
307int __must_check __video_register_device(struct video_device *vdev, int type, 343int __must_check __video_register_device(struct video_device *vdev,
308 int nr, int warn_if_nr_in_use, struct module *owner); 344 enum vfl_devnode_type type,
345 int nr, int warn_if_nr_in_use,
346 struct module *owner);
309 347
310/** 348/**
311 * video_register_device - register video4linux devices 349 * video_register_device - register video4linux devices
312 * 350 *
313 * @vdev: struct video_device to register 351 * @vdev: struct video_device to register
314 * @type: type of device to register 352 * @type: type of device to register, as defined by &enum vfl_devnode_type
315 * @nr: which device node number is desired: 353 * @nr: which device node number is desired:
316 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) 354 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
317 * 355 *
318 * Internally, it calls __video_register_device(). Please see its 356 * Internally, it calls __video_register_device(). Please see its
319 * documentation for more details. 357 * documentation for more details.
320 * 358 *
321 * .. note:: 359 * .. note::
322 * if video_register_device fails, the release() callback of 360 * if video_register_device fails, the release() callback of
323 * &struct video_device structure is *not* called, so the caller 361 * &struct video_device structure is *not* called, so the caller
324 * is responsible for freeing any data. Usually that means that 362 * is responsible for freeing any data. Usually that means that
325 * you video_device_release() should be called on failure. 363 * you video_device_release() should be called on failure.
326 */ 364 */
327static inline int __must_check video_register_device(struct video_device *vdev, 365static inline int __must_check video_register_device(struct video_device *vdev,
328 int type, int nr) 366 enum vfl_devnode_type type,
367 int nr)
329{ 368{
330 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner); 369 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
331} 370}
@@ -334,9 +373,9 @@ static inline int __must_check video_register_device(struct video_device *vdev,
334 * video_register_device_no_warn - register video4linux devices 373 * video_register_device_no_warn - register video4linux devices
335 * 374 *
336 * @vdev: struct video_device to register 375 * @vdev: struct video_device to register
337 * @type: type of device to register 376 * @type: type of device to register, as defined by &enum vfl_devnode_type
338 * @nr: which device node number is desired: 377 * @nr: which device node number is desired:
339 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) 378 * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
340 * 379 *
341 * This function is identical to video_register_device() except that no 380 * This function is identical to video_register_device() except that no
342 * warning is issued if the desired device node number was already in use. 381 * warning is issued if the desired device node number was already in use.
@@ -345,13 +384,14 @@ static inline int __must_check video_register_device(struct video_device *vdev,
345 * documentation for more details. 384 * documentation for more details.
346 * 385 *
347 * .. note:: 386 * .. note::
348 * if video_register_device fails, the release() callback of 387 * if video_register_device fails, the release() callback of
349 * &struct video_device structure is *not* called, so the caller 388 * &struct video_device structure is *not* called, so the caller
350 * is responsible for freeing any data. Usually that means that 389 * is responsible for freeing any data. Usually that means that
351 * you video_device_release() should be called on failure. 390 * you video_device_release() should be called on failure.
352 */ 391 */
353static inline int __must_check video_register_device_no_warn( 392static inline int __must_check
354 struct video_device *vdev, int type, int nr) 393video_register_device_no_warn(struct video_device *vdev,
394 enum vfl_devnode_type type, int nr)
355{ 395{
356 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner); 396 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
357} 397}
@@ -383,7 +423,7 @@ void video_device_release(struct video_device *vdev);
383 423
384/** 424/**
385 * video_device_release_empty - helper function to implement the 425 * video_device_release_empty - helper function to implement the
386 * video_device->release\(\) callback. 426 * video_device->release\(\) callback.
387 * 427 *
388 * @vdev: pointer to &struct video_device 428 * @vdev: pointer to &struct video_device
389 * 429 *