http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-queryctrl.html
Name
VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU — Enumerate controls and menu control items
Synopsis
int ioctl( | int fd, |
int request, | |
struct v4l2_queryctrl *argp) ; |
int ioctl( | int fd, |
int request, | |
struct v4l2_querymenu *argp) ; |
Arguments
-
File descriptor returned by
open()
. -
VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU
-
fd
request
argp
Description
To query the attributes of a control applications set the id
field of a struct v4l2_queryctrl and call the VIDIOC_QUERYCTRL
ioctl with a pointer to this structure. The driver fills the rest of the structure or returns an EINVAL error code when theid
is invalid.
It is possible to enumerate controls by calling VIDIOC_QUERYCTRL
with successive id
values starting from V4L2_CID_BASE
up to and exclusive V4L2_CID_BASE_LASTP1
. Drivers may return EINVAL if a control in this range is not supported. Further applications can enumerate private controls, which are not defined in this specification, by starting at V4L2_CID_PRIVATE_BASE
and incrementing id
until the driver returns EINVAL.
In both cases, when the driver sets the V4L2_CTRL_FLAG_DISABLED
flag in the flags
field this control is permanently disabled and should be ignored by the application.[25]
When the application ORs id
with V4L2_CTRL_FLAG_NEXT_CTRL
the driver returns the next supported control, or EINVAL if there is none. Drivers which do not support this flag yet always return EINVAL.
Additional information is required for menu controls: the names of the menu items. To query them applications set the id
and index
fields of struct v4l2_querymenu and call the VIDIOC_QUERYMENU
ioctl with a pointer to this structure. The driver fills the rest of the structure or returns anEINVAL error code when theid
or index
is invalid. Menu items are enumeratedby callingVIDIOC_QUERYMENU
with successive index
values from struct v4l2_queryctrl minimum
to maximum
, inclusive. Note that it is possible forVIDIOC_QUERYMENU
to return anEINVAL error code for someindices between minimum
and maximum
. In that case that particular menu item is not supported by this driver. Also note that the minimum
value is not necessarily 0.
See also the examples in the section called “User Controls”.
Table A.90. struct v4l2_queryctrl
__u32 | id | Identifies the control, set by the application. SeeTable 1.1, “Control IDs” for predefined IDs. When the ID is ORed with V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and returns the first control with a higher ID. Drivers which do not support this flag yet always return an EINVAL error code. |
__u32 | type | Type of control, see Table A.92, “enum v4l2_ctrl_type”. |
__u8 | name [32] | Name of the control, a NUL-terminated ASCII string. This information is intended for the user. |
__s32 | minimum | Minimum value, inclusive. This field gives a lower bound forV4L2_CTRL_TYPE_INTEGER controls and the lowest valid index forV4L2_CTRL_TYPE_MENU controls.ForV4L2_CTRL_TYPE_STRING controls the minimum value gives the minimum length of the string. This lengthdoes not include the terminating zero. It may not be valid for any other type of control, including V4L2_CTRL_TYPE_INTEGER64 controls. Note that this is asigned value. |
__s32 | maximum | Maximum value, inclusive. This field gives an upper bound forV4L2_CTRL_TYPE_INTEGER controls and the highest valid index forV4L2_CTRL_TYPE_MENU controls. For V4L2_CTRL_TYPE_BITMASK controls it is the set of usable bits.ForV4L2_CTRL_TYPE_STRING controls the maximum value gives the maximum length of the string. This lengthdoes not include the terminating zero. It may not be valid for any other type of control, including V4L2_CTRL_TYPE_INTEGER64 controls. Note that this is asigned value. |
__s32 | step | This field gives a step size for Generally drivers should not scale hardware control values. It may be necessary for example when the This field gives the smallest change of an integer control actually affecting hardware. Often the informationis needed when the user can change controls by keyboard or GUIbuttons, rather than a slider. When for example a hardware register accepts values 0-511 and the driver reports 0-65535, step should be128. Note that although signed, the step value is supposed to be always positive. |
__s32 | default_value | The default value of a V4L2_CTRL_TYPE_INTEGER ,_BOOLEAN or_MENU control.Not valid for other types of controls. Drivers reset controls only when the driver is loaded, not later, in particular not when the func-open; is called. |
__u32 | flags | Control flags, see Table A.93, “Control Flags”. |
__u32 | reserved [2] | Reserved for future extensions. Drivers must set the array to zero. |
Table A.91. struct v4l2_querymenu
__u32 | id | Identifies the control, set by the application from the respective struct v4l2_queryctrlid . | |
__u32 | index | Index of the menu item, starting at zero, set by the application. | |
union | |||
__u8 | name [32] | Name of the menu item, a NUL-terminated ASCIIstring. This information is intended for the user. This field is validforV4L2_CTRL_FLAG_MENU type controls. | |
__s64 | value | Value of the integer menu item. This field is valid forV4L2_CTRL_FLAG_INTEGER_MENU type controls. | |
__u32 | reserved | Reserved for future extensions. Drivers must setthe array to zero. |
Table A.92. enum v4l2_ctrl_type
Type | minimum | step | maximum | Description |
---|---|---|---|---|
V4L2_CTRL_TYPE_INTEGER | any | any | any | An integer-valued control ranging from minimum to maximum inclusive. The step value indicates the increment between values which are actually different on the hardware. |
V4L2_CTRL_TYPE_BOOLEAN | 0 | 1 | 1 | A boolean-valued control. Zero corresponds to"disabled", and one means "enabled". |
V4L2_CTRL_TYPE_MENU | ≥ 0 | 1 | N-1 | The control has a menu of N choices. The names ofthe menu items can be enumerated with theVIDIOC_QUERYMENU ioctl. |
V4L2_CTRL_TYPE_INTEGER_MENU | ≥ 0 | 1 | N-1 | The control has a menu of N choices. The values of the menu items can be enumerated with theVIDIOC_QUERYMENU ioctl. This is similar toV4L2_CTRL_TYPE_MENU except that instead of strings, the menu items are signed 64-bit integers. |
V4L2_CTRL_TYPE_BITMASK | 0 | n/a | any | A bitmask field. The maximum value is the set of bits that canbe used, all other bits are to be 0. The maximum value is interpreted as a __u32,allowing the use of bit 31 in the bitmask. |
V4L2_CTRL_TYPE_BUTTON | 0 | 0 | 0 | A control which performs an action when set.Drivers must ignore the value passed withVIDIOC_S_CTRL and return anEINVAL error code on aVIDIOC_G_CTRL attempt. |
V4L2_CTRL_TYPE_INTEGER64 | n/a | n/a | n/a | A 64-bit integer valued control. Minimum, maximumand step size cannot be queried. |
V4L2_CTRL_TYPE_STRING | ≥ 0 | ≥ 1 | ≥ 0 | The minimum and maximum string lengths. The step sizemeans that the string must be (minimum + N * step) characters long forN ≥ 0. These lengths do not include the terminating zero, so in order topass a string of length 8 to VIDIOC_S_EXT_CTRLS you need to set thesize field of struct v4l2_ext_control to 9. For VIDIOC_G_EXT_CTRLS you canset the size field to maximum + 1.Which character encoding is used will depend on the string control itself andshould be part of the control documentation. |
V4L2_CTRL_TYPE_CTRL_CLASS | n/a | n/a | n/a | This is not a control. WhenVIDIOC_QUERYCTRL is called with a control IDequal to a control class code (seeTable A.63, “Control classes”) + 1, theioctl returns the name of the control class and this control type.Older drivers which do not support this feature return anEINVAL error code. |
Table A.93. Control Flags
V4L2_CTRL_FLAG_DISABLED | 0x0001 | This control is permanently永久地 disabled and should be ignored by the application. Any attempt to change the control will result in anEINVAL error code. |
V4L2_CTRL_FLAG_GRABBED | 0x0002 | This control is temporarily unchangeable, for example because another application took over control of there spective resource. Such controls may be displayed specially in auser interface. Attempts to change the control may result in an EBUSY error code. |
V4L2_CTRL_FLAG_READ_ONLY | 0x0004 | This control is permanently readable only. Any attempt to change the control will result in anEINVAL error code. |
V4L2_CTRL_FLAG_UPDATE | 0x0008 | A hint that changing this control may affect thevalue of other controls within the same control class. Applicationsshould update their user interface accordingly. |
V4L2_CTRL_FLAG_INACTIVE | 0x0010 | This control is not applicable to the currentconfiguration and should be displayed accordingly in a user interface.For example the flag may be set on a MPEG audio level 2 bitratecontrol when MPEG audio encoding level 1 was selected with anothercontrol. |
V4L2_CTRL_FLAG_SLIDER | 0x0020 | A hint that this control is best represented as aslider-like element in a user interface. |
V4L2_CTRL_FLAG_WRITE_ONLY | 0x0040 | This control is permanently writable only. Anyattempt to read the control will result in anEACCES error code error code. Thisflag is typically present for relative controls or action controls wherewriting a value will cause the device to carry out a given action(e. g. motor control) but no meaningful value can be returned. |
V4L2_CTRL_FLAG_VOLATILE | 0x0080 | This control is volatile, which means that the value of the controlchanges continuously. A typical example would be the current gain value if the deviceis in auto-gain mode. In such a case the hardware calculates the gain value based onthe lighting conditions which can change over time. Note that setting a new value fora volatile control will have no effect. The new value will just be ignored. |
Return Value
On success 0 is returned, on error-1 and theerrno
variable is set appropriately. The generic error codes are described at theGeneric Error Codes chapter.
-
EINVAL
-
The struct v4l2_queryctrl
id
is invalid. The struct v4l2_querymenuid
is invalid orindex
is out of range (less thanminimum
or greater thanmaximum
)or this particular menu item is not supported by the driver.
EACCES
-
An attempt was made to read a write-only control.