vidioc-g-ctrl.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. .. -*- coding: utf-8; mode: rst -*-
  2. .. _VIDIOC_G_CTRL:
  3. **********************************
  4. ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
  5. **********************************
  6. Name
  7. ====
  8. VIDIOC_G_CTRL - VIDIOC_S_CTRL - Get or set the value of a control
  9. Synopsis
  10. ========
  11. .. c:function:: int ioctl( int fd, VIDIOC_G_CTRL, struct v4l2_control *argp )
  12. :name: VIDIOC_G_CTRL
  13. .. c:function:: int ioctl( int fd, VIDIOC_S_CTRL, struct v4l2_control *argp )
  14. :name: VIDIOC_S_CTRL
  15. Arguments
  16. =========
  17. ``fd``
  18. File descriptor returned by :ref:`open() <func-open>`.
  19. ``argp``
  20. Description
  21. ===========
  22. To get the current value of a control applications initialize the ``id``
  23. field of a struct :c:type:`v4l2_control` and call the
  24. :ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl with a pointer to this structure. To change the
  25. value of a control applications initialize the ``id`` and ``value``
  26. fields of a struct :c:type:`v4l2_control` and call the
  27. :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` ioctl.
  28. When the ``id`` is invalid drivers return an ``EINVAL`` error code. When the
  29. ``value`` is out of bounds drivers can choose to take the closest valid
  30. value or return an ``ERANGE`` error code, whatever seems more appropriate.
  31. However, :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` is a write-only ioctl, it does not return the
  32. actual new value. If the ``value`` is inappropriate for the control
  33. (e.g. if it refers to an unsupported menu index of a menu control), then
  34. EINVAL error code is returned as well.
  35. These ioctls work only with user controls. For other control classes the
  36. :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`,
  37. :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` or
  38. :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` must be used.
  39. .. c:type:: v4l2_control
  40. .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
  41. .. flat-table:: struct v4l2_control
  42. :header-rows: 0
  43. :stub-columns: 0
  44. :widths: 1 1 2
  45. * - __u32
  46. - ``id``
  47. - Identifies the control, set by the application.
  48. * - __s32
  49. - ``value``
  50. - New value or current value.
  51. Return Value
  52. ============
  53. On success 0 is returned, on error -1 and the ``errno`` variable is set
  54. appropriately. The generic error codes are described at the
  55. :ref:`Generic Error Codes <gen-errors>` chapter.
  56. EINVAL
  57. The struct :c:type:`v4l2_control` ``id`` is invalid
  58. or the ``value`` is inappropriate for the given control (i.e. if a
  59. menu item is selected that is not supported by the driver according
  60. to :ref:`VIDIOC_QUERYMENU <VIDIOC_QUERYCTRL>`).
  61. ERANGE
  62. The struct :c:type:`v4l2_control` ``value`` is out of
  63. bounds.
  64. EBUSY
  65. The control is temporarily not changeable, possibly because another
  66. applications took over control of the device function this control
  67. belongs to.
  68. EACCES
  69. Attempt to set a read-only control or to get a write-only control.