diff --git a/device/libcamera/device.cc b/device/libcamera/device.cc index f648946..0f2d919 100644 --- a/device/libcamera/device.cc +++ b/device/libcamera/device.cc @@ -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) diff --git a/device/v4l2/device_options.c b/device/v4l2/device_options.c index ec509c2..8534f47 100644 --- a/device/v4l2/device_options.c +++ b/device/v4l2/device_options.c @@ -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"); +} diff --git a/device/v4l2/v4l2.c b/device/v4l2/v4l2.c index eda5b95..88012e1 100644 --- a/device/v4l2/v4l2.c +++ b/device/v4l2/v4l2.c @@ -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, diff --git a/device/v4l2/v4l2.h b/device/v4l2/v4l2.h index f6c366f..80bb39b 100644 --- a/device/v4l2/v4l2.h +++ b/device/v4l2/v4l2.h @@ -5,6 +5,7 @@ #include #include #include +#include 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);