From e96e5f392a1d235bdd3e582dc235153f005bdaa4 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Mon, 6 Aug 2018 16:39:16 +0200 Subject: request: Check required v4l2 capabilities after opening the video node Since our use of the v4l2 API has some assumptions on the available userspace APIs, check the capabilities reported by the driver to make sure they are supported. Signed-off-by: Paul Kocialkowski --- src/request.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/request.c b/src/request.c index a36a505..2c3ed7f 100644 --- a/src/request.c +++ b/src/request.c @@ -37,6 +37,7 @@ #include "request.h" #include "utils.h" +#include "v4l2.h" #include #include @@ -59,8 +60,9 @@ VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context) { struct request_data *driver_data; struct VADriverVTable *vtable = context->vtable; - struct v4l2_capability capability; VAStatus status; + unsigned int capabilities; + unsigned int capabilities_required; int video_fd = -1; int media_fd = -1; char *video_path; @@ -151,10 +153,16 @@ VAStatus VA_DRIVER_INIT_FUNC(VADriverContextP context) if (video_fd < 0) return VA_STATUS_ERROR_OPERATION_FAILED; - rc = ioctl(video_fd, VIDIOC_QUERYCAP, &capability); - if (rc < 0 || !(capability.capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)) { - request_log("Video device %s does not support m2m mplanes\n", - video_path); + rc = v4l2_query_capabilities(video_fd, &capabilities); + if (rc < 0) { + status = VA_STATUS_ERROR_OPERATION_FAILED; + goto error; + } + + capabilities_required = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING; + + if ((capabilities & capabilities_required) != capabilities_required) { + request_log("Missing required driver capabilities\n"); status = VA_STATUS_ERROR_OPERATION_FAILED; goto error; } -- cgit v1.2.3