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>
This commit is contained in:
+21
@@ -32,6 +32,27 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "v4l2.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)
|
bool v4l2_find_format(int video_fd, unsigned int type, unsigned int pixelformat)
|
||||||
{
|
{
|
||||||
struct v4l2_fmtdesc fmtdesc;
|
struct v4l2_fmtdesc fmtdesc;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#define SOURCE_SIZE_MAX (1024 * 1024)
|
#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,
|
bool v4l2_find_format(int video_fd, unsigned int type,
|
||||||
unsigned int pixelformat);
|
unsigned int pixelformat);
|
||||||
int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
int v4l2_set_format(int video_fd, unsigned int type, unsigned int pixelformat,
|
||||||
|
|||||||
Reference in New Issue
Block a user