Expose options for v4l2
This commit is contained in:
parent
6460d1b902
commit
883a951cea
@ -56,6 +56,7 @@ void libcamera_device_dump_options(device_t *dev, FILE *stream)
|
||||
control_id->name().c_str(), control_id->id(), control_id->type(),
|
||||
control_info.toString().c_str());
|
||||
}
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
|
||||
int libcamera_device_open(device_t *dev)
|
||||
|
@ -155,3 +155,58 @@ error:
|
||||
free(valuep);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void v4l2_device_dump_options(device_t *dev, FILE *stream)
|
||||
{
|
||||
fprintf(stream, "%s Options:\n", dev->name);
|
||||
|
||||
for (int i = 0; i < dev->v4l2->ncontrols; i++) {
|
||||
device_v4l2_control_t *control = &dev->v4l2->controls[i];
|
||||
|
||||
fprintf(stream, "- available option: %s (%08x, type=%d): ",
|
||||
control->control.name, control->control.id, control->control.type);
|
||||
|
||||
switch(control->control.type) {
|
||||
case V4L2_CTRL_TYPE_U8:
|
||||
case V4L2_CTRL_TYPE_U16:
|
||||
case V4L2_CTRL_TYPE_U32:
|
||||
case V4L2_CTRL_TYPE_BOOLEAN:
|
||||
case V4L2_CTRL_TYPE_INTEGER:
|
||||
fprintf(stream, "[%lld..%lld]\n", control->control.minimum, control->control.maximum);
|
||||
break;
|
||||
|
||||
case V4L2_CTRL_TYPE_BUTTON:
|
||||
fprintf(stream, "button\n");
|
||||
break;
|
||||
|
||||
case V4L2_CTRL_TYPE_MENU:
|
||||
case V4L2_CTRL_TYPE_INTEGER_MENU:
|
||||
fprintf(stream, "[%lld..%lld]\n", control->control.minimum, control->control.maximum);
|
||||
|
||||
for (int j = control->control.minimum; j <= control->control.maximum; j++) {
|
||||
struct v4l2_querymenu menu = {
|
||||
.id = control->control.id,
|
||||
.index = j
|
||||
};
|
||||
|
||||
if (0 == ioctl(control->fd, VIDIOC_QUERYMENU, &menu)) {
|
||||
if (control->control.type == V4L2_CTRL_TYPE_MENU) {
|
||||
fprintf(stream, "\t\t%d: %s\n", j, menu.name);
|
||||
} else {
|
||||
fprintf(stream, "\t\t%d: %lld\n", j, menu.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case V4L2_CTRL_TYPE_STRING:
|
||||
fprintf(stream, "(string)\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stream, "(unsupported)\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ device_hw_t v4l2_device_hw = {
|
||||
.device_close = v4l2_device_close,
|
||||
.device_set_decoder_start = v4l2_device_set_decoder_start,
|
||||
.device_video_force_key = v4l2_device_video_force_key,
|
||||
.device_dump_options = v4l2_device_dump_options,
|
||||
.device_set_fps = v4l2_device_set_fps,
|
||||
.device_set_option = v4l2_device_set_option,
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <linux/v4l2-subdev.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct buffer_s buffer_t;
|
||||
typedef struct buffer_list_s buffer_list_t;
|
||||
@ -37,6 +38,7 @@ int v4l2_device_open(device_t *dev);
|
||||
void v4l2_device_close(device_t *dev);
|
||||
int v4l2_device_set_decoder_start(device_t *dev, bool do_on);
|
||||
int v4l2_device_video_force_key(device_t *dev);
|
||||
void v4l2_device_dump_options(device_t *dev, FILE *stream);
|
||||
int v4l2_device_set_fps(device_t *dev, int desired_fps);
|
||||
int v4l2_device_set_option(device_t *dev, const char *key, const char *value);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user