From 8b9dd1b7fc05d0a7f9c1cd7088ca04fb120b0b51 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 13 Oct 2015 03:52:49 +0300 Subject: isp: v4l2: Fix capabilities parsing When adding support for device_caps the kernel changed the userspace API and started reporting both output and capture through the capabilities field. Use the device_caps field instead to get the per-device-node capabilities. Signed-off-by: Laurent Pinchart --- isp/v4l2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'isp/v4l2.c') diff --git a/isp/v4l2.c b/isp/v4l2.c index be5c604..6f3ffbe 100644 --- a/isp/v4l2.c +++ b/isp/v4l2.c @@ -258,6 +258,7 @@ struct v4l2_device *v4l2_open(const char *devname) { struct v4l2_device *dev; struct v4l2_capability cap; + __u32 capabilities; int ret; dev = malloc(sizeof *dev); @@ -285,9 +286,17 @@ struct v4l2_device *v4l2_open(const char *devname) return NULL; } - if (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) + /* If the device_caps field is set use it, otherwise use the older + * capabilities field. We can't rely on the capabilities field + * unconditionally as kernels that support device_caps for the omap3isp + * driver (>= v3.19) will set both CAPTURE and OUTPUT in the + * capabilities field. + */ + capabilities = cap.device_caps ? : cap.capabilities; + + if (capabilities & V4L2_CAP_VIDEO_CAPTURE) dev->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - else if (cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) + else if (capabilities & V4L2_CAP_VIDEO_OUTPUT) dev->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; else { printf("Error opening device %s: neither video capture " -- cgit v1.2.3