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.h48
1 files changed, 45 insertions, 3 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 1efcacbed01a..c7c40f1d2624 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -16,12 +16,14 @@
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_VTX 3 26#define VFL_TYPE_SUBDEV 3
25#define VFL_TYPE_MAX 4 27#define VFL_TYPE_MAX 4
26 28
27struct v4l2_ioctl_callbacks; 29struct v4l2_ioctl_callbacks;
@@ -33,7 +35,25 @@ struct v4l2_ctrl_handler;
33 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
34 device access. It is cleared by video_unregister_device. */ 36 device access. It is cleared by video_unregister_device. */
35#define V4L2_FL_REGISTERED (0) 37#define V4L2_FL_REGISTERED (0)
38/* file->private_data points to struct v4l2_fh */
36#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
37 57
38struct v4l2_file_operations { 58struct v4l2_file_operations {
39 struct module *owner; 59 struct module *owner;
@@ -57,6 +77,9 @@ struct v4l2_file_operations {
57 77
58struct video_device 78struct video_device
59{ 79{
80#if defined(CONFIG_MEDIA_CONTROLLER)
81 struct media_entity entity;
82#endif
60 /* device ops */ 83 /* device ops */
61 const struct v4l2_file_operations *fops; 84 const struct v4l2_file_operations *fops;
62 85
@@ -71,6 +94,9 @@ struct video_device
71 /* Control handler associated with this device node. May be NULL. */ 94 /* Control handler associated with this device node. May be NULL. */
72 struct v4l2_ctrl_handler *ctrl_handler; 95 struct v4l2_ctrl_handler *ctrl_handler;
73 96
97 /* Priority state. If NULL, then v4l2_dev->prio will be used. */
98 struct v4l2_prio_state *prio;
99
74 /* device info */ 100 /* device info */
75 char name[32]; 101 char name[32];
76 int vfl_type; 102 int vfl_type;
@@ -97,20 +123,36 @@ struct video_device
97 123
98 /* ioctl callbacks */ 124 /* ioctl callbacks */
99 const struct v4l2_ioctl_ops *ioctl_ops; 125 const struct v4l2_ioctl_ops *ioctl_ops;
126
127 /* serialization lock */
128 struct mutex *lock;
100}; 129};
101 130
131#define media_entity_to_video_device(__e) \
132 container_of(__e, struct video_device, entity)
102/* dev to video-device */ 133/* dev to video-device */
103#define to_video_device(cd) container_of(cd, struct video_device, dev) 134#define to_video_device(cd) container_of(cd, struct video_device, dev)
104 135
136int __must_check __video_register_device(struct video_device *vdev, int type,
137 int nr, int warn_if_nr_in_use, struct module *owner);
138
105/* Register video devices. Note that if video_register_device fails, 139/* Register video devices. Note that if video_register_device fails,
106 the release() callback of the video_device structure is *not* called, so 140 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 141 the caller is responsible for freeing any data. Usually that means that
108 you call video_device_release() on failure. */ 142 you call video_device_release() on failure. */
109int __must_check video_register_device(struct video_device *vdev, int type, int nr); 143static inline int __must_check video_register_device(struct video_device *vdev,
144 int type, int nr)
145{
146 return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
147}
110 148
111/* Same as video_register_device, but no warning is issued if the desired 149/* Same as video_register_device, but no warning is issued if the desired
112 device node number was already in use. */ 150 device node number was already in use. */
113int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr); 151static inline int __must_check video_register_device_no_warn(
152 struct video_device *vdev, int type, int nr)
153{
154 return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
155}
114 156
115/* Unregister video devices. Will do nothing if vdev == NULL or 157/* Unregister video devices. Will do nothing if vdev == NULL or
116 video_is_registered() returns false. */ 158 video_is_registered() returns false. */