2016-06-30 15:18:56 +02:00
.. -*- coding: utf-8; mode: rst -*-
2016-07-01 13:42:29 -03:00
.. _VIDIOC_G_CTRL:
2016-06-30 15:18:56 +02:00
***** ***** ***** ***** ***** ***** *** *
ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
***** ***** ***** ***** ***** ***** *** *
2016-07-05 15:14:35 -03:00
Name
2016-07-05 07:58:48 -03:00
====
2016-06-30 15:18:56 +02:00
2016-07-05 07:58:48 -03:00
VIDIOC_G_CTRL - VIDIOC_S_CTRL - Get or set the value of a control
2016-06-30 15:18:56 +02:00
2016-07-05 15:14:35 -03:00
Synopsis
2016-06-30 15:18:56 +02:00
========
2016-07-02 09:49:16 -03:00
.. cpp:function :: int ioctl( int fd, int request, struct v4l2_control *argp )
2016-06-30 15:18:56 +02:00
2016-07-05 07:58:48 -03:00
2016-07-05 15:14:35 -03:00
Arguments
2016-06-30 15:18:56 +02:00
=========
`` fd ``
File descriptor returned by :ref: `open() <func-open>` .
`` request ``
VIDIOC_G_CTRL, VIDIOC_S_CTRL
`` argp ``
2016-07-05 15:14:35 -03:00
Description
2016-06-30 15:18:56 +02:00
===========
To get the current value of a control applications initialize the `` id ``
2016-07-03 13:28:28 -03:00
field of a struct :ref: `struct v4l2_control <v4l2-control>` and call the
2016-07-03 10:02:29 -03:00
:ref: `VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl with a pointer to this structure. To change the
2016-06-30 15:18:56 +02:00
value of a control applications initialize the `` id `` and `` value ``
2016-07-03 13:28:28 -03:00
fields of a struct :ref: `struct v4l2_control <v4l2-control>` and call the
2016-07-01 14:33:56 -03:00
:ref: `VIDIOC_S_CTRL <VIDIOC_G_CTRL>` ioctl.
2016-06-30 15:18:56 +02:00
2016-07-03 11:53:09 -03:00
When the `` id `` is invalid drivers return an `` EINVAL `` error code. When the
2016-06-30 15:18:56 +02:00
`` value `` is out of bounds drivers can choose to take the closest valid
2016-07-03 11:53:09 -03:00
value or return an `` ERANGE `` error code, whatever seems more appropriate.
2016-07-01 14:33:56 -03:00
However, :ref: `VIDIOC_S_CTRL <VIDIOC_G_CTRL>` is a write-only ioctl, it does not return the
2016-06-30 15:18:56 +02:00
actual new value. If the `` value `` is inappropriate for the control
(e.g. if it refers to an unsupported menu index of a menu control), then
EINVAL error code is returned as well.
These ioctls work only with user controls. For other control classes the
2016-07-03 10:02:29 -03:00
:ref: `VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` ,
2016-07-01 13:42:29 -03:00
:ref: `VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` or
:ref: `VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` must be used.
2016-06-30 15:18:56 +02:00
.. _v4l2-control:
.. flat-table :: struct v4l2_control
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
- .. row 1
- __u32
- `` id ``
- Identifies the control, set by the application.
- .. row 2
- __s32
- `` value ``
- New value or current value.
2016-07-05 15:14:35 -03:00
Return Value
2016-06-30 15:18:56 +02:00
============
On success 0 is returned, on error -1 and the `` errno `` variable is set
appropriately. The generic error codes are described at the
:ref: `Generic Error Codes <gen-errors>` chapter.
EINVAL
The struct :ref: `v4l2_control <v4l2-control>` `` id `` 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
2016-07-01 13:42:29 -03:00
to :ref: `VIDIOC_QUERYMENU <VIDIOC_QUERYCTRL>` ).
2016-06-30 15:18:56 +02:00
ERANGE
The struct :ref: `v4l2_control <v4l2-control>` `` value `` 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.