V4L2命令之 VIDIOC_G_CTRL, VIDIOC_S_CTRL

参考地址:http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-ctrl.html

Name

VIDIOC_G_CTRL, VIDIOC_S_CTRL — Get or set the value of a control

Synopsis

int ioctl(int fd,

int request,

struct v4l2_control*argp);
 

Arguments

fd

File descriptor returned by open().

request

VIDIOC_G_CTRL, VIDIOC_S_CTRL

argp

Description

To get the current value of a control applications initialize theid  field of a structv4l2_control and call theVIDIOC_G_CTRL ioctl with a pointer to this structure. To change the value of a control applications initialize theid  andvalue fields of a structv4l2_control and call theVIDIOC_S_CTRL ioctl.

要获取一个控制的值,程序需要先初始化控制id,然后调用命令VIDIOC_G_CTRL。要改变一个控制的值,程序需要分别初始化结构体 v4l2_control 的id和value这两个域,再调用命令VIDIOC_S_CTRL

id 在include/linux/videodev2.h中定义

/*  User-class control IDs defined by V4L2 */
#define V4L2_CID_MAX_CTRLS        1024
#define V4L2_CID_BASE            (V4L2_CTRL_CLASS_USER | 0x900)
#define V4L2_CID_USER_BASE         V4L2_CID_BASE
/*  IDs reserved for driver specific controls */
#define V4L2_CID_PRIVATE_BASE        0x08000000

#define V4L2_CID_USER_CLASS         (V4L2_CTRL_CLASS_USER | 1)
#define V4L2_CID_BRIGHTNESS        (V4L2_CID_BASE+0)
#define V4L2_CID_CONTRAST        (V4L2_CID_BASE+1)
#define V4L2_CID_SATURATION        (V4L2_CID_BASE+2)
#define V4L2_CID_HUE            (V4L2_CID_BASE+3)
#define V4L2_CID_AUDIO_VOLUME        (V4L2_CID_BASE+5)

.................................

.................................

When the id  is invalid drivers return anEINVAL error code. When thevalue  is out of bounds drivers can choose to take the closest valid value or returnanERANGE error code, whatever seems more appropriate. However,VIDIOC_S_CTRL is a write-only ioctl, it does not return the actual new value. If thevalueis inappropriate for the control (e.g. if it refers to an unsupportedmenu index of a menu control), thenEINVAL error code is returned as well.

These ioctls work only with user controls. For other control classes the VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS orVIDIOC_TRY_EXT_CTRLS must be used.

Table A.52. struct v4l2_control

__u32idIdentifies the control, set by the application.
__s32valueNew value or current value.

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_controlid  is invalid or the value is inappropriate for the given control (i.e. if a menu item is selected that is not supported by the driver according toVIDIOC_QUERYMENU).

ERANGE

The struct v4l2_controlvalue is out of bounds.

EBUSY

The control is temporarily not changeable, possibly because another applications took over control of the device function this control belongs to.

EACCES

Attempt to set a read-only control or to get a write-only control.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值