^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _VIDIOC_SUBDEV_G_SELECTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) **********************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) **********************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) VIDIOC_SUBDEV_G_SELECTION - VIDIOC_SUBDEV_S_SELECTION - Get or set selection rectangles on a subdev pad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. c:macro:: VIDIOC_SUBDEV_G_SELECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ``int ioctl(int fd, VIDIOC_SUBDEV_G_SELECTION, struct v4l2_subdev_selection *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. c:macro:: VIDIOC_SUBDEV_S_SELECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ``int ioctl(int fd, VIDIOC_SUBDEV_S_SELECTION, struct v4l2_subdev_selection *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ``argp``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Pointer to struct :c:type:`v4l2_subdev_selection`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) The selections are used to configure various image processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) functionality performed by the subdevs which affect the image size. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) currently includes cropping, scaling and composition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) The selection API replaces
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) :ref:`the old subdev crop API <VIDIOC_SUBDEV_G_CROP>`. All the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) function of the crop API, and more, are supported by the selections API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) See :ref:`subdev` for more information on how each selection target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) affects the image processing pipeline inside the subdevice.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) If the subdev device node has been registered in read-only mode, calls to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ``VIDIOC_SUBDEV_S_SELECTION`` are only valid if the ``which`` field is set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error is returned and the errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) variable is set to ``-EPERM``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) Types of selection targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) There are two types of selection targets: actual and bounds. The actual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) targets are the targets which configure the hardware. The BOUNDS target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) will return a rectangle that contain all possible actual rectangles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) Discovering supported features
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) To discover which targets are supported, the user can perform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ``VIDIOC_SUBDEV_G_SELECTION`` on them. Any unsupported target will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return ``EINVAL``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) Selection targets and flags are documented in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) :ref:`v4l2-selections-common`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .. c:type:: v4l2_subdev_selection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .. flat-table:: struct v4l2_subdev_selection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) :widths: 1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) - ``which``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) - Active or try selection, from enum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) - ``pad``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) - Pad number as reported by the media framework.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) - ``target``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) - Target selection rectangle. See :ref:`v4l2-selections-common`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) - ``flags``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) - Flags. See :ref:`v4l2-selection-flags`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * - struct :c:type:`v4l2_rect`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) - ``r``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) - Selection rectangle, in pixels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) - ``reserved``\ [8]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) - Reserved for future extensions. Applications and drivers must set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) the array to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) :ref:`Generic Error Codes <gen-errors>` chapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) EBUSY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) The selection rectangle can't be changed because the pad is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) currently busy. This can be caused, for instance, by an active video
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) stream on the pad. The ioctl must not be retried without performing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) another action to fix the problem first. Only returned by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ``VIDIOC_SUBDEV_S_SELECTION``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) The struct :c:type:`v4l2_subdev_selection`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ``pad`` references a non-existing pad, the ``which`` field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) references a non-existing format, or the selection target is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) supported on the given subdev pad.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) EPERM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) The ``VIDIOC_SUBDEV_S_SELECTION`` ioctl has been called on a read-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) subdevice and the ``which`` field is set to ``V4L2_SUBDEV_FORMAT_ACTIVE``.