linux-v4l2: Add helper function to get input caps
Add a helper function to get the capabilities of a specific or the currently selected input of the device.
This commit is contained in:
@@ -133,6 +133,27 @@ int_fast32_t v4l2_set_input(int_fast32_t dev, int *input)
|
||||
: v4l2_ioctl(dev, VIDIOC_S_INPUT, input);
|
||||
}
|
||||
|
||||
int_fast32_t v4l2_get_input_caps(int_fast32_t dev, int input, uint32_t *caps)
|
||||
{
|
||||
if (!dev || !caps)
|
||||
return -1;
|
||||
|
||||
if (input == -1) {
|
||||
if (v4l2_ioctl(dev, VIDIOC_G_INPUT, &input) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct v4l2_input in;
|
||||
memset(&in, 0, sizeof(in));
|
||||
in.index = input;
|
||||
|
||||
if (v4l2_ioctl(dev, VIDIOC_ENUMINPUT, &in) < 0)
|
||||
return -1;
|
||||
|
||||
*caps = in.capabilities;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int_fast32_t v4l2_set_format(int_fast32_t dev, int *resolution,
|
||||
int *pixelformat, int *bytesperline)
|
||||
{
|
||||
|
@@ -219,6 +219,17 @@ int_fast32_t v4l2_destroy_mmap(struct v4l2_buffer_data *buf);
|
||||
*/
|
||||
int_fast32_t v4l2_set_input(int_fast32_t dev, int *input);
|
||||
|
||||
/**
|
||||
* Get capabilities for an input.
|
||||
*
|
||||
* @param dev handle for the v4l2 device
|
||||
* @param input index of the input or -1 to use the currently selected
|
||||
* @param caps capabilities for the input
|
||||
*
|
||||
* @return negative on failure
|
||||
*/
|
||||
int_fast32_t v4l2_get_input_caps(int_fast32_t dev, int input, uint32_t *caps);
|
||||
|
||||
/**
|
||||
* Set the video format on the device.
|
||||
*
|
||||
|
Reference in New Issue
Block a user