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.h46
1 files changed, 43 insertions, 3 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 15802a067a12..8266d5ade2ff 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -16,12 +16,15 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18 18
19#include <media/media-entity.h>
20
19#define VIDEO_MAJOR 81 21#define VIDEO_MAJOR 81
20 22
21#define VFL_TYPE_GRABBER 0 23#define VFL_TYPE_GRABBER 0
22#define VFL_TYPE_VBI 1 24#define VFL_TYPE_VBI 1
23#define VFL_TYPE_RADIO 2 25#define VFL_TYPE_RADIO 2
24#define VFL_TYPE_MAX 3 26#define VFL_TYPE_SUBDEV 3
27#define VFL_TYPE_MAX 4
25 28
26struct v4l2_ioctl_callbacks; 29struct v4l2_ioctl_callbacks;
27struct video_device; 30struct video_device;
@@ -32,7 +35,25 @@ struct v4l2_ctrl_handler;
32 Drivers can clear this flag if they want to block all future 35 Drivers can clear this flag if they want to block all future
33 device access. It is cleared by video_unregister_device. */ 36 device access. It is cleared by video_unregister_device. */
34#define V4L2_FL_REGISTERED (0) 37#define V4L2_FL_REGISTERED (0)
38/* file->private_data points to struct v4l2_fh */
35#define V4L2_FL_USES_V4L2_FH (1) 39#define V4L2_FL_USES_V4L2_FH (1)
40/* Use the prio field of v4l2_fh for core priority checking */
41#define V4L2_FL_USE_FH_PRIO (2)
42
43/* Priority helper functions */
44
45struct v4l2_prio_state {
46 atomic_t prios[4];
47};
48
49void v4l2_prio_init(struct v4l2_prio_state *global);
50int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
51 enum v4l2_priority new);
52void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
53void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
54enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
55int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
56
36 57
37struct v4l2_file_operations { 58struct v4l2_file_operations {
38 struct module *owner; 59 struct module *owner;
@@ -54,6 +75,9 @@ struct v4l2_file_operations {
54 75
55struct video_device 76struct video_device
56{ 77{
78#if defined(CONFIG_MEDIA_CONTROLLER)
79 struct media_entity entity;
80#endif
57 /* device ops */ 81 /* device ops */
58 const struct v4l2_file_operations *fops; 82 const struct v4l2_file_operations *fops;
59 83
@@ -68,6 +92,9 @@ struct video_device
68 /* Control handler associated with this device node. May be NULL. */ 92 /* Control handler associated with this device node. May be NULL. */
69 struct v4l2_ctrl_handler *ctrl_handler; 93 struct v4l2_ctrl_handler *ctrl_handler;
70 94
95 /* Priority state. If NULL, then v4l2_dev->prio will be used. */
96 struct v4l2_prio_state *prio;
97
71 /* device info */ 98 /* device info */
72 char name[32]; 99 char name[32];
73 int vfl_type; 100 int vfl_type;
@@ -99,18 +126,31 @@ struct video_device
99 struct mutex *lock; 126 struct mutex *lock;
100}; 127};
101 128
129#define media_entity_to_video_device(entity) \
130 container_of(entity, struct video_device, entity)
102/* dev to video-device */ 131/* dev to video-device */
103#define to_video_device(cd) container_of(cd, struct video_device, dev) 132#define to_video_device(cd) container_of(cd, struct video_device, dev)
104 133
134int __must_check __video_register_device(struct video_device *vdev, int type,
135 int nr, int warn_if_nr_in_use, struct module *owner);
136
105/* Register video devices. Note that if video_register_device fails, 137/* Register video devices. Note that if video_register_device fails,
106 the release() callback of the video_device structure is *not* called, so 138 the release() callback of the video_device structure is *not* called, so
107 the caller is responsible for freeing any data. Usually that means that 139 the caller is responsible for freeing any data. Usually that means that
108 you call video_device_release() on failure. */ 140 you call video_device_release() on failure. */
109int __must_check video_register_device(struct video_device *vdev, int type, int nr); 141static inline int __must_check video_register_device(struct video_device *vdev,
142 int type, int nr)
143{
144 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
145}
110 146
111/* Same as video_register_device, but no warning is issued if the desired 147/* Same as video_register_device, but no warning is issued if the desired
112 device node number was already in use. */ 148 device node number was already in use. */
113int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); 149static inline int __must_check video_register_device_no_warn(
150 struct video_device *vdev, int type, int nr)
151{
152 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
153}
114 154
115/* Unregister video devices. Will do nothing if vdev == NULL or 155/* Unregister video devices. Will do nothing if vdev == NULL or
116 video_is_registered() returns false. */ 156 video_is_registered() returns false. */