STRUCT V4L2_CTRL(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐ŸŽ€ struct v4l2_ctrl(9) โ€” The control structure ๐ŸŽ€

okay bestie, welcome to the Kernel API Manual page for struct v4l2_ctrl(9) ๐Ÿ’… this is the whole control-structure situation, and itโ€™s lowkey iconic.


โœจ NAME โœจ

struct v4l2_ctrl โ€” The control structure. ๐Ÿซถ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

so hereโ€™s the actual shape of struct v4l2_ctrl, and yes every field is exactly where it should be:

       struct v4l2_ctrl {
           struct list_head node;
           struct list_head ev_subs;
           struct v4l2_ctrl_handler *handler;
           struct v4l2_ctrl **cluster;
           unsigned int ncontrols;
           unsigned int done:1;
           unsigned int is_new:1;
           unsigned int has_changed:1;
           unsigned int is_private:1;
           unsigned int is_auto:1;
           unsigned int is_int:1;
           unsigned int is_string:1;
           unsigned int is_ptr:1;
           unsigned int is_array:1;
           unsigned int is_dyn_array:1;
           unsigned int has_volatiles:1;
           unsigned int call_notify:1;
           unsigned int manual_mode_value:8;
           const struct v4l2_ctrl_ops *ops;
           const struct v4l2_ctrl_type_ops *type_ops;
           u32 id;
           const char *name;
           enum v4l2_ctrl_type type;
           s64 minimum, maximum, default_value;
           u32 elems;
           u32 elem_size;
           u32 new_elems;
           u32 dims[V4L2_CTRL_MAX_DIMS];
           u32 nr_of_dims;
           union {
             u64 step;
             u64 menu_skip_mask;
           };
           union {
             const char * const *qmenu;
             const s64 *qmenu_int;
           };
           unsigned long flags;
           void *priv;
           void *p_array;
           u32 p_array_alloc_elems;
           s32 val;
           struct {
             s32 val;
           } cur;
           union v4l2_ctrl_ptr p_def;
           union v4l2_ctrl_ptr p_min;
           union v4l2_ctrl_ptr p_max;
           union v4l2_ctrl_ptr p_new;
           union v4l2_ctrl_ptr p_cur;
        };

๐Ÿงš Members ๐Ÿงš

  • node โ€” the list node. just vibing in the linked list ๐Ÿ’ซ
  • ev_subs โ€” the list of control event subscriptions ๐ŸŽŸ๏ธ
  • handler โ€” the handler that owns the control ๐Ÿ‘‘
  • cluster โ€” points to the start of the cluster array ๐Ÿซ‚
  • ncontrols โ€” number of controls in the cluster array ๐Ÿ”ข
  • done โ€” internal flag: set for each processed control ๐Ÿซก
  • is_new โ€” set when the user specified a new value for this control. It is also set when called from v4l2_ctrl_handler_setup. Drivers should never set this flag. โš ๏ธ
  • has_changed โ€” set when the current value differs from the new value. Drivers should never use this flag. ๐Ÿšซ
  • is_private โ€” if set, then this control is private to its handler and it will not be added to any other handlers. Drivers can set this flag. ๐Ÿ”’
  • is_auto โ€” if set, then this control selects whether the other cluster members are in 'automatic' mode or 'manual' mode. This is used for autogain/gain type clusters. Drivers should never set this flag directly. ๐ŸŽ›๏ธ
  • is_int โ€” if set, then this control has a simple integer value (i.e. it uses ctrl->val). ๐Ÿ”ข
  • is_string โ€” if set, then this control has type V4L2_CTRL_TYPE_STRING. ๐Ÿงต
  • is_ptr โ€” if set, then this control is an array and/or has type >= V4L2_CTRL_COMPOUND_TYPES and/or has type V4L2_CTRL_TYPE_STRING. In other words, struct v4l2_ext_control uses field p to point to the data. ๐Ÿ‘‰
  • is_array โ€” if set, then this control contains an N-dimensional array. ๐ŸงŠ
  • is_dyn_array โ€” if set, then this control contains a dynamically sized 1-dimensional array. If this is set, then is_array is also set. ๐ŸŒŠ
  • has_volatiles โ€” if set, then one or more members of the cluster are volatile. Drivers should never touch this flag. ๐Ÿงจ
  • call_notify โ€” if set, then call the handler's notify function whenever the control's value changes. ๐Ÿ“ฃ
  • manual_mode_value โ€” if the is_auto flag is set, then this is the value of the auto control that determines if that control is in manual mode. So if the value of the auto control equals this value, then the whole cluster is in manual mode. Drivers should never set this flag directly. ๐Ÿ•น๏ธ
  • ops โ€” the control ops. ๐Ÿ› ๏ธ
  • type_ops โ€” the control type ops. ๐Ÿงฐ
  • id โ€” the control ID. ๐Ÿ†”
  • name โ€” the control name. ๐Ÿท๏ธ
  • type โ€” the control type. ๐Ÿงฌ
  • minimum โ€” the control's minimum value. โฌ‡๏ธ
  • maximum โ€” the control's maximum value. โฌ†๏ธ
  • default_value โ€” the control's default value. ๐ŸŽฏ
  • elems โ€” the number of elements in the N-dimensional array. ๐Ÿงฎ
  • elem_size โ€” the size in bytes of the control. ๐Ÿ“
  • new_elems โ€” the number of elements in p_new. This is the same as elems, except for dynamic arrays. In that case it is in the range of 1 to p_array_alloc_elems. ๐Ÿ”
  • dims โ€” the size of each dimension. ๐Ÿ“
  • nr_of_dims โ€” the number of dimensions in dims. ๐Ÿ”ข
  • {unnamed_union} โ€” anonymous. this is the union where step / menu_skip_mask live ๐Ÿซฅ
  • step โ€” the control's step value for non-menu controls. ๐Ÿ‘ฃ
  • menu_skip_mask โ€” the control's skip mask for menu controls. This makes it easy to skip menu items that are not valid. If bit X is set, then menu item X is skipped. Of course, this only works for menus with <= 32 menu items. There are no menus that come close to that number, so this is OK. Should we ever need more, then this will have to be extended to a u64 or a bit array. ๐Ÿšซ
  • {unnamed_union} โ€” anonymous. this is the union where qmenu / qmenu_int live ๐Ÿซฅ
  • qmenu โ€” a const char * array for all menu items. Array entries that are empty strings ("") correspond to non-existing menu items (this is in addition to the menu_skip_mask above). The last entry must be NULL. Used only if the type is V4L2_CTRL_TYPE_MENU. ๐Ÿ“‹
  • qmenu_int โ€” a 64-bit integer array for integer menu items. The size of array must be equal to the menu size, e. g.:
:math:`ceil(ac{maximum - minimum}{step}) + 1`

Used only if the type is V4L2_CTRL_TYPE_INTEGER_MENU. ๐Ÿ”ข

  • flags โ€” the control's flags. ๐Ÿšฉ
  • priv โ€” the control's private pointer. For use by the driver. It is untouched by the control framework. Note that this pointer is not freed when the control is deleted. Should this be needed then a new internal bitfield can be added to tell the framework to free this pointer. ๐Ÿ”
  • p_array โ€” pointer to the allocated array. Only valid if is_array is true. ๐Ÿงท
  • p_array_alloc_elems โ€” the number of elements in the allocated array for both the cur and new values. So p_array is actually sized for 2 * p_array_alloc_elems * elem_size. Only valid if is_array is true. ๐Ÿงฎ
  • val โ€” the control's new s32 value. ๐Ÿ†•
  • cur โ€” structure to store the current value. ๐Ÿ“ฆ
  • cur.val โ€” the control's current value, if the type is represented via a u32 integer (see enum v4l2_ctrl_type). ๐ŸŽš๏ธ
  • p_def โ€” the control's default value represented via a union which provides a standard way of accessing control types through a pointer (for compound controls only). ๐ŸŽ
  • p_min โ€” the control's minimum value represented via a union which provides a standard way of accessing control types through a pointer (for compound controls only). โฌ‡๏ธ
  • p_max โ€” the control's maximum value represented via a union which provides a standard way of accessing control types through a pointer (for compound controls only). โฌ†๏ธ
  • p_new โ€” the control's new value represented via a union which provides a standard way of accessing control types through a pointer. ๐Ÿ†•
  • p_cur โ€” the control's current value represented via a union which provides a standard way of accessing control types through a pointer. ๐ŸŽฏ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ


okay thatโ€™s the whole page, bestie ๐Ÿซถ source/version path: ./include/media, date: October 2026, and the page is struct v4l2_ctrl(9). mwah ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from