aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-03-03 18:12:31 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-24 10:59:02 -0400
commit2180f92def1921397f422f278b3cc65751b749cc (patch)
tree3bf6090c56cd6eb0fc85107b8f6f17b1f9c80979 /include/media
parent6cd247ef22e493e1884e576c066661538b031981 (diff)
[media] v4l2-core: add code to check for specific ops
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>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/v4l2-device.h13
-rw-r--r--include/media/v4l2-subdev.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index d61febfb1668..c9b1593923f6 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -190,4 +190,17 @@ v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev);
190 ##args); \ 190 ##args); \
191}) 191})
192 192
193#define v4l2_device_has_op(v4l2_dev, o, f) \
194({ \
195 struct v4l2_subdev *__sd; \
196 bool __result = false; \
197 list_for_each_entry(__sd, &(v4l2_dev)->subdevs, list) { \
198 if (v4l2_subdev_has_op(__sd, o, f)) { \
199 __result = true; \
200 break; \
201 } \
202 } \
203 __result; \
204})
205
193#endif 206#endif
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 8158a0810fdc..c42703a37602 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -687,4 +687,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
687 ((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \ 687 ((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \
688 (sd)->v4l2_dev->notify((sd), (notification), (arg))) 688 (sd)->v4l2_dev->notify((sd), (notification), (arg)))
689 689
690#define v4l2_subdev_has_op(sd, o, f) \
691 ((sd)->ops->o && (sd)->ops->o->f)
692
690#endif 693#endif