V4L2命令之 VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU
来源:互联网 发布:恒大 知乎 编辑:程序博客网 时间:2024/05/22 17:28
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
fd
File descriptor returned by
open()
.request
VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU
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
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.__u32type
Type of control, see Table A.92, “enum v4l2_ctrl_type”.__u8name
[32]Name of the control, a NUL-terminated ASCII string. This information is intended for the user.__s32minimum
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.__s32maximum
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.__s32step
This field gives a step size for V4L2_CTRL_TYPE_INTEGER
controls. For V4L2_CTRL_TYPE_STRING
controls this field refers to the string length that has to be a multiple of this step size.It may not be valid for any other type of control, includingV4L2_CTRL_TYPE_INTEGER64
controls.
Generally drivers should not scale hardware control values. It may be necessary for example when the name
orid
implya particular unit and the hardware actually accepts only multiples of said unit. If so, drivers must take care values are properly rounded when scaling, such that errors will not accumulate on repeatedread-write cycles.
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.
__s32default_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.__u32flags
Control flags, see Table A.93, “Control Flags”.__u32reserved
[2]Reserved for future extensions. Drivers must set the array to zero.Table A.91. struct v4l2_querymenu
id
Identifies the control, set by the application from the respective struct v4l2_queryctrlid
.__u32index
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.__u32reserved
Reserved for future extensions. Drivers must setthe array to zero.Table A.92. enum v4l2_ctrl_type
minimum
step
maximum
V4L2_CTRL_TYPE_INTEGER
anyanyanyAn 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
011A boolean-valued control. Zero corresponds to"disabled", and one means "enabled".V4L2_CTRL_TYPE_MENU
≥ 01N-1The control has a menu of N choices. The names ofthe menu items can be enumerated with theVIDIOC_QUERYMENU
ioctl.V4L2_CTRL_TYPE_INTEGER_MENU
≥ 01N-1The 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
0n/aanyA 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
000A 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/an/an/aA 64-bit integer valued control. Minimum, maximumand step size cannot be queried.V4L2_CTRL_TYPE_STRING
≥ 0≥ 1≥ 0The 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/an/an/aThis 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
0x0001This 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
0x0002This 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
0x0004This control is permanently readable only. Any attempt to change the control will result in anEINVAL error code.V4L2_CTRL_FLAG_UPDATE
0x0008A 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
0x0010This 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
0x0020A hint that this control is best represented as aslider-like element in a user interface.V4L2_CTRL_FLAG_WRITE_ONLY
0x0040This 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
0x0080This 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.
- V4L2命令之 VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU
- V4L2命令之 VIDIOC_G_CTRL, VIDIOC_S_CTRL
- V4L2命令之 VIDIOC_STREAMON, VIDIOC_STREAMOFF
- V4L2命令之 VIDIOC_G_PARM, VIDIOC_S_PARM
- V4L2命令之 User Controls
- V4L2命令之 VIDIOC_G_CTRL, VIDIOC_S_CTRL
- V4L2命令之 VIDIOC_ENUM_FMT VIDIOC_ENUM_FRAMESIZES VIDIOC_ENUM_FRAMEINTERVALS
- v4l2控制命令精华
- v4l2-ctl 控制命令
- V4L2 常用控制命令
- v4l2文档之——v4l2 framework
- V4L2之ioctl错误
- Linux之V4L2编程
- V4L2 之V4L2_MEMORY_USERPTR
- Linux之V4L2基础编程
- Linux之V4L2基础编程
- Linux之V4L2基础编程
- Linux之V4L2基础编程
- 无题
- C语言编程需要注意的64位和32机器的区别
- DNS for linux 安装配置
- 二级缓存配置
- 手机另类刷机方法之Fastboot
- V4L2命令之 VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU
- 内积、标量积、点积、点乘
- HttpServletRequest和HttpServletResponse详解
- gcc -I -L -l区别
- 解决发布项目时,tomcat同名,项目路径下的setting中org.eclipse.wst.common.component改display名字
- Eclipse 中因为 tomcat 没完全关闭引起的 server 无法启动
- opencv习题3.3
- sql 范式
- 编程之美 1.1 让CPU占用率曲线听你的指挥