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 <paul.kocialkowski@bootlin.com>
This commit is contained in:
+13
-5
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "request.h"
|
||||
#include "utils.h"
|
||||
#include "v4l2.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user