aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-dev.h
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-10 04:36:00 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 08:17:28 -0400
commit48ea0be06028d97b57602372f032afbec02e7e97 (patch)
treee4d089a40163ba3491b0d5989048cec29ccbba17 /include/media/v4l2-dev.h
parent8ab75e3ecd8f232d9564510f0c601a6aa7a149ea (diff)
[media] v4l2-dev/ioctl: determine the valid ioctls upfront
Rather than testing whether an ioctl is implemented in the driver or not every time the ioctl is called, do it upfront when the device is registered. This also allows a driver to disable certain ioctls based on the capabilities of the detected board, something you can't do today without creating separate v4l2_ioctl_ops structs for each new variation. For the most part it is pretty straightforward, but for control ioctls a flag is needed since it is possible that you have per-filehandle controls, and that can't be determined upfront of course. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/v4l2-dev.h')
-rw-r--r--include/media/v4l2-dev.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index d00b9d3511f2..a5ecec66d3c8 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -126,6 +126,7 @@ struct video_device
126 126
127 /* ioctl callbacks */ 127 /* ioctl callbacks */
128 const struct v4l2_ioctl_ops *ioctl_ops; 128 const struct v4l2_ioctl_ops *ioctl_ops;
129 DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
129 130
130 /* serialization lock */ 131 /* serialization lock */
131 DECLARE_BITMAP(dont_use_lock, BASE_VIDIOC_PRIVATE); 132 DECLARE_BITMAP(dont_use_lock, BASE_VIDIOC_PRIVATE);
@@ -184,6 +185,16 @@ static inline void v4l2_dont_use_lock(struct video_device *vdev, unsigned int cm
184 set_bit(_IOC_NR(cmd), vdev->dont_use_lock); 185 set_bit(_IOC_NR(cmd), vdev->dont_use_lock);
185} 186}
186 187
188/* Mark that this command isn't implemented, must be called before
189 video_device_register. See also the comments in determine_valid_ioctls().
190 This function allows drivers to provide just one v4l2_ioctl_ops struct, but
191 disable ioctls based on the specific card that is actually found. */
192static inline void v4l2_dont_use_cmd(struct video_device *vdev, unsigned int cmd)
193{
194 if (_IOC_NR(cmd) < BASE_VIDIOC_PRIVATE)
195 set_bit(_IOC_NR(cmd), vdev->valid_ioctls);
196}
197
187/* helper functions to access driver private data. */ 198/* helper functions to access driver private data. */
188static inline void *video_get_drvdata(struct video_device *vdev) 199static inline void *video_get_drvdata(struct video_device *vdev)
189{ 200{