#pragma once #include #include "error.h" /* Opaque handle — defined in v4l2_ctrl.c */ struct V4l2_Ctrl_Handle; typedef enum V4l2_Ctrl_Type { CTRL_TYPE_INTEGER = 1, CTRL_TYPE_BOOLEAN = 2, CTRL_TYPE_MENU = 3, CTRL_TYPE_BUTTON = 4, CTRL_TYPE_INTEGER64 = 5, CTRL_TYPE_CTRL_CLASS = 6, CTRL_TYPE_STRING = 7, CTRL_TYPE_BITMASK = 8, CTRL_TYPE_INTEGER_MENU = 9, CTRL_TYPE_UNKNOWN = 0xff, } V4l2_Ctrl_Type; struct V4l2_Ctrl_Desc { uint32_t id; char name[32]; V4l2_Ctrl_Type type; int32_t min; int32_t max; int32_t step; int32_t default_value; int32_t current_value; uint32_t flags; }; struct V4l2_Menu_Item { uint32_t index; char name[32]; /* for CTRL_TYPE_MENU */ int64_t value; /* for CTRL_TYPE_INTEGER_MENU */ }; /* * Enumerate all /dev/video* device nodes present on the system. */ struct App_Error v4l2_ctrl_find_devices( void (*callback)(const char *device_path, void *userdata), void *userdata); struct App_Error v4l2_ctrl_open(const char *device_path, struct V4l2_Ctrl_Handle **out); void v4l2_ctrl_close(struct V4l2_Ctrl_Handle *handle); /* * Enumerate all controls on the device. * For menu and integer-menu controls, menu_items is a non-NULL array of * menu_count items. For all other types, menu_items is NULL and menu_count is 0. */ struct App_Error v4l2_ctrl_enumerate( struct V4l2_Ctrl_Handle *handle, void (*callback)( const struct V4l2_Ctrl_Desc *desc, uint32_t menu_count, const struct V4l2_Menu_Item *menu_items, void *userdata), void *userdata); struct App_Error v4l2_ctrl_get( struct V4l2_Ctrl_Handle *handle, uint32_t id, int32_t *value_out); struct App_Error v4l2_ctrl_set( struct V4l2_Ctrl_Handle *handle, uint32_t id, int32_t value); /* Human-readable name for a control type */ const char *v4l2_ctrl_type_name(V4l2_Ctrl_Type type);