diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-22 06:29:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-06 16:30:54 -0400 |
commit | 5a5adf6b669cf1a3dd2af419cd68a4c491f384a3 (patch) | |
tree | 42b1c4709c3c5cca04fb15bd369e6ae4921645d4 /include | |
parent | 5d44f5e3e388739f017a74e73dab2a995673915f (diff) |
[media] v4l2-dev/ioctl.c: add vb2_queue support to video_device
This prepares struct video_device for easier integration with vb2.
It also introduces a new lock that protects the vb2_queue. It is up
to the driver to use it or not. And the driver can associate an owner
filehandle with the queue to check whether queuing requests are
permitted for the calling filehandle.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/media/v4l2-dev.h | 3 | ||||
-rw-r--r-- | include/media/v4l2-ioctl.h | 5 | ||||
-rw-r--r-- | include/media/videobuf2-core.h | 13 |
3 files changed, 21 insertions, 0 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index a056e6ee1b68..5c416cdc88d5 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -100,6 +100,9 @@ struct video_device | |||
100 | /* Control handler associated with this device node. May be NULL. */ | 100 | /* Control handler associated with this device node. May be NULL. */ |
101 | struct v4l2_ctrl_handler *ctrl_handler; | 101 | struct v4l2_ctrl_handler *ctrl_handler; |
102 | 102 | ||
103 | /* vb2_queue associated with this device node. May be NULL. */ | ||
104 | struct vb2_queue *queue; | ||
105 | |||
103 | /* Priority state. If NULL, then v4l2_dev->prio will be used. */ | 106 | /* Priority state. If NULL, then v4l2_dev->prio will be used. */ |
104 | struct v4l2_prio_state *prio; | 107 | struct v4l2_prio_state *prio; |
105 | 108 | ||
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index dfd984f10d42..19e93523c2d8 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h | |||
@@ -304,6 +304,11 @@ extern int v4l2_video_std_construct(struct v4l2_standard *vs, | |||
304 | then do printk(KERN_DEBUG "%s: ", prefix) first. */ | 304 | then do printk(KERN_DEBUG "%s: ", prefix) first. */ |
305 | extern void v4l_printk_ioctl(const char *prefix, unsigned int cmd); | 305 | extern void v4l_printk_ioctl(const char *prefix, unsigned int cmd); |
306 | 306 | ||
307 | /* Internal use only: get the mutex (if any) that we need to lock for the | ||
308 | given command. */ | ||
309 | struct video_device; | ||
310 | extern struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd); | ||
311 | |||
307 | /* names for fancy debug output */ | 312 | /* names for fancy debug output */ |
308 | extern const char *v4l2_field_names[]; | 313 | extern const char *v4l2_field_names[]; |
309 | extern const char *v4l2_type_names[]; | 314 | extern const char *v4l2_type_names[]; |
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index a15d1f1b319e..924e95e0a0a6 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
@@ -244,12 +244,23 @@ struct vb2_ops { | |||
244 | void (*buf_queue)(struct vb2_buffer *vb); | 244 | void (*buf_queue)(struct vb2_buffer *vb); |
245 | }; | 245 | }; |
246 | 246 | ||
247 | struct v4l2_fh; | ||
248 | |||
247 | /** | 249 | /** |
248 | * struct vb2_queue - a videobuf queue | 250 | * struct vb2_queue - a videobuf queue |
249 | * | 251 | * |
250 | * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h | 252 | * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h |
251 | * @io_modes: supported io methods (see vb2_io_modes enum) | 253 | * @io_modes: supported io methods (see vb2_io_modes enum) |
252 | * @io_flags: additional io flags (see vb2_fileio_flags enum) | 254 | * @io_flags: additional io flags (see vb2_fileio_flags enum) |
255 | * @lock: pointer to a mutex that protects the vb2_queue struct. The | ||
256 | * driver can set this to a mutex to let the v4l2 core serialize | ||
257 | * the queuing ioctls. If the driver wants to handle locking | ||
258 | * itself, then this should be set to NULL. This lock is not used | ||
259 | * by the videobuf2 core API. | ||
260 | * @owner: The filehandle that 'owns' the buffers, i.e. the filehandle | ||
261 | * that called reqbufs, create_buffers or started fileio. | ||
262 | * This field is not used by the videobuf2 core API, but it allows | ||
263 | * drivers to easily associate an owner filehandle with the queue. | ||
253 | * @ops: driver-specific callbacks | 264 | * @ops: driver-specific callbacks |
254 | * @mem_ops: memory allocator specific callbacks | 265 | * @mem_ops: memory allocator specific callbacks |
255 | * @drv_priv: driver private data | 266 | * @drv_priv: driver private data |
@@ -273,6 +284,8 @@ struct vb2_queue { | |||
273 | enum v4l2_buf_type type; | 284 | enum v4l2_buf_type type; |
274 | unsigned int io_modes; | 285 | unsigned int io_modes; |
275 | unsigned int io_flags; | 286 | unsigned int io_flags; |
287 | struct mutex *lock; | ||
288 | struct v4l2_fh *owner; | ||
276 | 289 | ||
277 | const struct vb2_ops *ops; | 290 | const struct vb2_ops *ops; |
278 | const struct vb2_mem_ops *mem_ops; | 291 | const struct vb2_mem_ops *mem_ops; |