brintos

brintos / linux-shallow public Read only

0
0
Text · 6.4 KiB · 2b5b272 Raw
191 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_G_SELECTION:5 6********************************************7ioctl VIDIOC_G_SELECTION, VIDIOC_S_SELECTION8********************************************9 10Name11====12 13VIDIOC_G_SELECTION - VIDIOC_S_SELECTION - Get or set one of the selection rectangles14 15Synopsis16========17 18.. c:macro:: VIDIOC_G_SELECTION19 20``int ioctl(int fd, VIDIOC_G_SELECTION, struct v4l2_selection *argp)``21 22.. c:macro:: VIDIOC_S_SELECTION23 24``int ioctl(int fd, VIDIOC_S_SELECTION, struct v4l2_selection *argp)``25 26Arguments27=========28 29``fd``30    File descriptor returned by :c:func:`open()`.31 32``argp``33    Pointer to struct :c:type:`v4l2_selection`.34 35Description36===========37 38The ioctls are used to query and configure selection rectangles.39 40To query the cropping (composing) rectangle set struct41:c:type:`v4l2_selection` ``type`` field to the42respective buffer type. The next step is setting the43value of struct :c:type:`v4l2_selection` ``target``44field to ``V4L2_SEL_TGT_CROP`` (``V4L2_SEL_TGT_COMPOSE``). Please refer45to table :ref:`v4l2-selections-common` or :ref:`selection-api` for46additional targets. The ``flags`` and ``reserved`` fields of struct47:c:type:`v4l2_selection` are ignored and they must be48filled with zeros. The driver fills the rest of the structure or returns49EINVAL error code if incorrect buffer type or target was used. If50cropping (composing) is not supported then the active rectangle is not51mutable and it is always equal to the bounds rectangle. Finally, the52struct :c:type:`v4l2_rect` ``r`` rectangle is filled with53the current cropping (composing) coordinates. The coordinates are54expressed in driver-dependent units. The only exception are rectangles55for images in raw formats, whose coordinates are always expressed in56pixels.57 58To change the cropping (composing) rectangle set the struct59:c:type:`v4l2_selection` ``type`` field to the60respective buffer type. The next step is setting the61value of struct :c:type:`v4l2_selection` ``target`` to62``V4L2_SEL_TGT_CROP`` (``V4L2_SEL_TGT_COMPOSE``). Please refer to table63:ref:`v4l2-selections-common` or :ref:`selection-api` for additional64targets. The struct :c:type:`v4l2_rect` ``r`` rectangle need65to be set to the desired active area. Field struct66:c:type:`v4l2_selection` ``reserved`` is ignored and67must be filled with zeros. The driver may adjust coordinates of the68requested rectangle. An application may introduce constraints to control69rounding behaviour. The struct :c:type:`v4l2_selection`70``flags`` field must be set to one of the following:71 72-  ``0`` - The driver can adjust the rectangle size freely and shall73   choose a crop/compose rectangle as close as possible to the requested74   one.75 76-  ``V4L2_SEL_FLAG_GE`` - The driver is not allowed to shrink the77   rectangle. The original rectangle must lay inside the adjusted one.78 79-  ``V4L2_SEL_FLAG_LE`` - The driver is not allowed to enlarge the80   rectangle. The adjusted rectangle must lay inside the original one.81 82-  ``V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE`` - The driver must choose the83   size exactly the same as in the requested rectangle.84 85Please refer to :ref:`sel-const-adjust`.86 87The driver may have to adjusts the requested dimensions against hardware88limits and other parts as the pipeline, i.e. the bounds given by the89capture/output window or TV display. The closest possible values of90horizontal and vertical offset and sizes are chosen according to91following priority:92 931. Satisfy constraints from struct94   :c:type:`v4l2_selection` ``flags``.95 962. Adjust width, height, left, and top to hardware limits and97   alignments.98 993. Keep center of adjusted rectangle as close as possible to the100   original one.101 1024. Keep width and height as close as possible to original ones.103 1045. Keep horizontal and vertical offset as close as possible to original105   ones.106 107On success the struct :c:type:`v4l2_rect` ``r`` field108contains the adjusted rectangle. When the parameters are unsuitable the109application may modify the cropping (composing) or image parameters and110repeat the cycle until satisfactory parameters have been negotiated. If111constraints flags have to be violated at then ``ERANGE`` is returned. The112error indicates that *there exist no rectangle* that satisfies the113constraints.114 115Selection targets and flags are documented in116:ref:`v4l2-selections-common`.117 118.. _sel-const-adjust:119 120.. kernel-figure::  constraints.svg121    :alt:    constraints.svg122    :align:  center123 124    Size adjustments with constraint flags.125 126    Behaviour of rectangle adjustment for different constraint flags.127 128 129 130.. c:type:: v4l2_selection131 132.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|133 134.. flat-table:: struct v4l2_selection135    :header-rows:  0136    :stub-columns: 0137    :widths:       1 1 2138 139    * - __u32140      - ``type``141      - Type of the buffer (from enum142	:c:type:`v4l2_buf_type`).143    * - __u32144      - ``target``145      - Used to select between146	:ref:`cropping and composing rectangles <v4l2-selections-common>`.147    * - __u32148      - ``flags``149      - Flags controlling the selection rectangle adjustments, refer to150	:ref:`selection flags <v4l2-selection-flags>`.151    * - struct :c:type:`v4l2_rect`152      - ``r``153      - The selection rectangle.154    * - __u32155      - ``reserved[9]``156      - Reserved fields for future use. Drivers and applications must zero157	this array.158 159.. note::160   Unfortunately in the case of multiplanar buffer types161   (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``)162   this API was messed up with regards to how the :c:type:`v4l2_selection` ``type`` field163   should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while164   other drivers only accepted a non-multiplanar buffer type (i.e. without the165   ``_MPLANE`` at the end).166 167   Starting with kernel 4.13 both variations are allowed.168 169Return Value170============171 172On success 0 is returned, on error -1 and the ``errno`` variable is set173appropriately. The generic error codes are described at the174:ref:`Generic Error Codes <gen-errors>` chapter.175 176EINVAL177    Given buffer type ``type`` or the selection target ``target`` is not178    supported, or the ``flags`` argument is not valid.179 180ERANGE181    It is not possible to adjust struct :c:type:`v4l2_rect`182    ``r`` rectangle to satisfy all constraints given in the ``flags``183    argument.184 185ENODATA186    Selection is not supported for this input or output.187 188EBUSY189    It is not possible to apply change of the selection rectangle at the190    moment. Usually because streaming is in progress.191