diff options
author | Paul Kocialkowski <paul.kocialkowski@bootlin.com> | 2018-08-06 16:38:48 +0200 |
---|---|---|
committer | Paul Kocialkowski <paul.kocialkowski@bootlin.com> | 2018-08-06 16:38:48 +0200 |
commit | 57999e38834bd1e90499591b76212c996dc87fc1 (patch) | |
tree | 84f14829add612c32cecd1862f4a73d5fda5d758 /src | |
parent | 7d1ac10517ccfa6acf129a64952d23e518f9c4a0 (diff) | |
download | libva-v4l2-request-57999e38834bd1e90499591b76212c996dc87fc1.tar.gz libva-v4l2-request-57999e38834bd1e90499591b76212c996dc87fc1.tar.bz2 libva-v4l2-request-57999e38834bd1e90499591b76212c996dc87fc1.zip |
v4l2: Add support for querying capabilities
This adds a helper function to query v4l2 capabilities, returning
either the device caps when available or the general device caps
otherwise.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/v4l2.c | 21 | ||||
-rw-r--r-- | src/v4l2.h | 1 |
2 files changed, 22 insertions, 0 deletions
@@ -32,6 +32,27 @@ #include "utils.h" #include "v4l2.h" +int v4l2_query_capabilities(int video_fd, unsigned int *capabilities) +{ + struct v4l2_capability capability; + int rc; + + memset(&capability, 0, sizeof(capability)); + + rc = ioctl(video_fd, VIDIOC_QUERYCAP, &capability); + if (rc < 0) + return -1; + + if (capabilities != NULL) { + if ((capability.capabilities & V4L2_CAP_DEVICE_CAPS) != 0) + *capabilities = capability.device_caps; + else + *capabilities = capability.capabilities; + } + + return 0; +} + bool v4l2_find_format(int video_fd, unsigned int type, unsigned int pixelformat) { struct v4l2_fmtdesc fmtdesc; @@ -29,6 +29,7 @@ #define SOURCE_SIZE_MAX (1024 * 1024) +int v4l2_query_capabilities(int video_fd, unsigned int *capabilities); bool v4l2_find_format(int video_fd, unsigned int type, unsigned int pixelformat); int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat, |