[media] v4l2-core: add code to check for specific ops
authorHans Verkuil <hans.verkuil@cisco.com>
Sun, 3 Mar 2013 23:12:31 +0000 (20:12 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Mar 2013 14:59:02 +0000 (11:59 -0300)
This patch adds a v4l2_subdev_has_op() macro and a v4l2_device_has_op macro to
quickly check if a specific subdev or any subdev supports a particular subdev
operation.
This makes it easy for drivers to disable certain ioctls if none of the subdevs
supports the necessary functionality.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
include/media/v4l2-device.h
include/media/v4l2-subdev.h

index d61febfb1668549caa6b5610af09e3144aa3226e..c9b1593923f6ef01a3cd069a8f1fdb1a74f178e4 100644 (file)
@@ -190,4 +190,17 @@ v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
                        ##args);                                        \
 })
 
+#define v4l2_device_has_op(v4l2_dev, o, f)                             \
+({                                                                     \
+       struct v4l2_subdev *__sd;                                       \
+       bool __result = false;                                          \
+       list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) {         \
+               if (v4l2_subdev_has_op(__sd, o, f)) {                   \
+                       __result = true;                                \
+                       break;                                          \
+               }                                                       \
+       }                                                               \
+       __result;                                                       \
+})
+
 #endif
index 8158a0810fdc1176ba26bf73ec21afd8fe4e13c5..c42703a37602c87cd399311a569421c5cf0f83f6 100644 (file)
@@ -687,4 +687,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
        ((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
         (sd)->v4l2_dev->notify((sd), (notification), (arg)))
 
+#define v4l2_subdev_has_op(sd, o, f) \
+       ((sd)->ops->o && (sd)->ops->o->f)
+
 #endif