162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: V4L 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _VIDIOC_SUBDEV_G_SELECTION: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci********************************************************** 762306a36Sopenharmony_ciioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION 862306a36Sopenharmony_ci********************************************************** 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciName 1162306a36Sopenharmony_ci==== 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciVIDIOC_SUBDEV_G_SELECTION - VIDIOC_SUBDEV_S_SELECTION - Get or set selection rectangles on a subdev pad 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciSynopsis 1662306a36Sopenharmony_ci======== 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_SUBDEV_G_SELECTION 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_SUBDEV_G_SELECTION, struct v4l2_subdev_selection *argp)`` 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_SUBDEV_S_SELECTION 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_SUBDEV_S_SELECTION, struct v4l2_subdev_selection *argp)`` 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciArguments 2762306a36Sopenharmony_ci========= 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci``fd`` 3062306a36Sopenharmony_ci File descriptor returned by :c:func:`open()`. 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci``argp`` 3362306a36Sopenharmony_ci Pointer to struct :c:type:`v4l2_subdev_selection`. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciDescription 3662306a36Sopenharmony_ci=========== 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciThe selections are used to configure various image processing 3962306a36Sopenharmony_cifunctionality performed by the subdevs which affect the image size. This 4062306a36Sopenharmony_cicurrently includes cropping, scaling and composition. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciThe selection API replaces 4362306a36Sopenharmony_ci:ref:`the old subdev crop API <VIDIOC_SUBDEV_G_CROP>`. All the 4462306a36Sopenharmony_cifunction of the crop API, and more, are supported by the selections API. 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ciSee :ref:`subdev` for more information on how each selection target 4762306a36Sopenharmony_ciaffects the image processing pipeline inside the subdevice. 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ciIf the subdev device node has been registered in read-only mode, calls to 5062306a36Sopenharmony_ci``VIDIOC_SUBDEV_S_SELECTION`` are only valid if the ``which`` field is set to 5162306a36Sopenharmony_ci``V4L2_SUBDEV_FORMAT_TRY``, otherwise an error is returned and the errno 5262306a36Sopenharmony_civariable is set to ``-EPERM``. 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ciTypes of selection targets 5562306a36Sopenharmony_ci-------------------------- 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ciThere are two types of selection targets: actual and bounds. The actual 5862306a36Sopenharmony_citargets are the targets which configure the hardware. The BOUNDS target 5962306a36Sopenharmony_ciwill return a rectangle that contain all possible actual rectangles. 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ciDiscovering supported features 6262306a36Sopenharmony_ci------------------------------ 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ciTo discover which targets are supported, the user can perform 6562306a36Sopenharmony_ci``VIDIOC_SUBDEV_G_SELECTION`` on them. Any unsupported target will 6662306a36Sopenharmony_cireturn ``EINVAL``. 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ciSelection targets and flags are documented in 6962306a36Sopenharmony_ci:ref:`v4l2-selections-common`. 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci.. c:type:: v4l2_subdev_selection 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}| 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci.. flat-table:: struct v4l2_subdev_selection 7662306a36Sopenharmony_ci :header-rows: 0 7762306a36Sopenharmony_ci :stub-columns: 0 7862306a36Sopenharmony_ci :widths: 1 1 2 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci * - __u32 8162306a36Sopenharmony_ci - ``which`` 8262306a36Sopenharmony_ci - Active or try selection, from enum 8362306a36Sopenharmony_ci :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`. 8462306a36Sopenharmony_ci * - __u32 8562306a36Sopenharmony_ci - ``pad`` 8662306a36Sopenharmony_ci - Pad number as reported by the media framework. 8762306a36Sopenharmony_ci * - __u32 8862306a36Sopenharmony_ci - ``target`` 8962306a36Sopenharmony_ci - Target selection rectangle. See :ref:`v4l2-selections-common`. 9062306a36Sopenharmony_ci * - __u32 9162306a36Sopenharmony_ci - ``flags`` 9262306a36Sopenharmony_ci - Flags. See :ref:`v4l2-selection-flags`. 9362306a36Sopenharmony_ci * - struct :c:type:`v4l2_rect` 9462306a36Sopenharmony_ci - ``r`` 9562306a36Sopenharmony_ci - Selection rectangle, in pixels. 9662306a36Sopenharmony_ci * - __u32 9762306a36Sopenharmony_ci - ``stream`` 9862306a36Sopenharmony_ci - Stream identifier. 9962306a36Sopenharmony_ci * - __u32 10062306a36Sopenharmony_ci - ``reserved``\ [7] 10162306a36Sopenharmony_ci - Reserved for future extensions. Applications and drivers must set 10262306a36Sopenharmony_ci the array to zero. 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ciReturn Value 10562306a36Sopenharmony_ci============ 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 10862306a36Sopenharmony_ciappropriately. The generic error codes are described at the 10962306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ciEBUSY 11262306a36Sopenharmony_ci The selection rectangle can't be changed because the pad is 11362306a36Sopenharmony_ci currently busy. This can be caused, for instance, by an active video 11462306a36Sopenharmony_ci stream on the pad. The ioctl must not be retried without performing 11562306a36Sopenharmony_ci another action to fix the problem first. Only returned by 11662306a36Sopenharmony_ci ``VIDIOC_SUBDEV_S_SELECTION`` 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ciEINVAL 11962306a36Sopenharmony_ci The struct :c:type:`v4l2_subdev_selection` 12062306a36Sopenharmony_ci ``pad`` references a non-existing pad, the ``which`` field 12162306a36Sopenharmony_ci references a non-existing format, or the selection target is not 12262306a36Sopenharmony_ci supported on the given subdev pad. 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ciEPERM 12562306a36Sopenharmony_ci The ``VIDIOC_SUBDEV_S_SELECTION`` ioctl has been called on a read-only 12662306a36Sopenharmony_ci subdevice and the ``which`` field is set to ``V4L2_SUBDEV_FORMAT_ACTIVE``. 127