brintos

brintos / linux-shallow public Read only

0
0
Text · 3.8 KiB · 570d983 Raw
111 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_G_CROP:5 6**********************************7ioctl VIDIOC_G_CROP, VIDIOC_S_CROP8**********************************9 10Name11====12 13VIDIOC_G_CROP - VIDIOC_S_CROP - Get or set the current cropping rectangle14 15Synopsis16========17 18.. c:macro:: VIDIOC_G_CROP19 20``int ioctl(int fd, VIDIOC_G_CROP, struct v4l2_crop *argp)``21 22.. c:macro:: VIDIOC_S_CROP23 24``int ioctl(int fd, VIDIOC_S_CROP, const struct v4l2_crop *argp)``25 26Arguments27=========28 29``fd``30    File descriptor returned by :c:func:`open()`.31 32``argp``33    Pointer to struct :c:type:`v4l2_crop`.34 35Description36===========37 38To query the cropping rectangle size and position applications set the39``type`` field of a struct :c:type:`v4l2_crop` structure to the40respective buffer (stream) type and call the :ref:`VIDIOC_G_CROP <VIDIOC_G_CROP>` ioctl41with a pointer to this structure. The driver fills the rest of the42structure or returns the ``EINVAL`` error code if cropping is not supported.43 44To change the cropping rectangle applications initialize the ``type``45and struct :c:type:`v4l2_rect` substructure named ``c`` of a46v4l2_crop structure and call the :ref:`VIDIOC_S_CROP <VIDIOC_G_CROP>` ioctl with a pointer47to this structure.48 49The driver first adjusts the requested dimensions against hardware50limits, i. e. the bounds given by the capture/output window, and it51rounds to the closest possible values of horizontal and vertical offset,52width and height. In particular the driver must round the vertical53offset of the cropping rectangle to frame lines modulo two, such that54the field order cannot be confused.55 56Second the driver adjusts the image size (the opposite rectangle of the57scaling process, source or target depending on the data direction) to58the closest size possible while maintaining the current horizontal and59vertical scaling factor.60 61Finally the driver programs the hardware with the actual cropping and62image parameters. :ref:`VIDIOC_S_CROP <VIDIOC_G_CROP>` is a write-only ioctl, it does not63return the actual parameters. To query them applications must call64:ref:`VIDIOC_G_CROP <VIDIOC_G_CROP>` and :ref:`VIDIOC_G_FMT`. When the65parameters are unsuitable the application may modify the cropping or66image parameters and repeat the cycle until satisfactory parameters have67been negotiated.68 69When cropping is not supported then no parameters are changed and70:ref:`VIDIOC_S_CROP <VIDIOC_G_CROP>` returns the ``EINVAL`` error code.71 72.. c:type:: v4l2_crop73 74.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|75 76.. flat-table:: struct v4l2_crop77    :header-rows:  078    :stub-columns: 079    :widths:       1 1 280 81    * - __u3282      - ``type``83      - Type of the data stream, set by the application. Only these types84	are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``, ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,85	``V4L2_BUF_TYPE_VIDEO_OUTPUT``, ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and86	``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type` and the note below.87    * - struct :c:type:`v4l2_rect`88      - ``c``89      - Cropping rectangle. The same co-ordinate system as for struct90	:c:type:`v4l2_cropcap` ``bounds`` is used.91 92.. note::93   Unfortunately in the case of multiplanar buffer types94   (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``)95   this API was messed up with regards to how the :c:type:`v4l2_crop` ``type`` field96   should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while97   other drivers only accepted a non-multiplanar buffer type (i.e. without the98   ``_MPLANE`` at the end).99 100   Starting with kernel 4.13 both variations are allowed.101 102Return Value103============104 105On success 0 is returned, on error -1 and the ``errno`` variable is set106appropriately. The generic error codes are described at the107:ref:`Generic Error Codes <gen-errors>` chapter.108 109ENODATA110    Cropping is not supported for this input or output.111