18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _VIDIOC_CROPCAP:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci********************
78c2ecf20Sopenharmony_ciioctl VIDIOC_CROPCAP
88c2ecf20Sopenharmony_ci********************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciVIDIOC_CROPCAP - Information about the video cropping and scaling abilities
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_CROPCAP
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)``
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciArguments
238c2ecf20Sopenharmony_ci=========
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci``fd``
268c2ecf20Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci``argp``
298c2ecf20Sopenharmony_ci    Pointer to struct :c:type:`v4l2_cropcap`.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciDescription
328c2ecf20Sopenharmony_ci===========
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciApplications use this function to query the cropping limits, the pixel
358c2ecf20Sopenharmony_ciaspect of images and to calculate scale factors. They set the ``type``
368c2ecf20Sopenharmony_cifield of a v4l2_cropcap structure to the respective buffer (stream)
378c2ecf20Sopenharmony_citype and call the :ref:`VIDIOC_CROPCAP` ioctl with a pointer to this
388c2ecf20Sopenharmony_cistructure. Drivers fill the rest of the structure. The results are
398c2ecf20Sopenharmony_ciconstant except when switching the video standard. Remember this switch
408c2ecf20Sopenharmony_cican occur implicit when switching the video input or output.
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciThis ioctl must be implemented for video capture or output devices that
438c2ecf20Sopenharmony_cisupport cropping and/or scaling and/or have non-square pixels, and for
448c2ecf20Sopenharmony_cioverlay devices.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci.. c:type:: v4l2_cropcap
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_cropcap
518c2ecf20Sopenharmony_ci    :header-rows:  0
528c2ecf20Sopenharmony_ci    :stub-columns: 0
538c2ecf20Sopenharmony_ci    :widths:       1 1 2
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci    * - __u32
568c2ecf20Sopenharmony_ci      - ``type``
578c2ecf20Sopenharmony_ci      - Type of the data stream, set by the application. Only these types
588c2ecf20Sopenharmony_ci	are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``, ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
598c2ecf20Sopenharmony_ci	``V4L2_BUF_TYPE_VIDEO_OUTPUT``, ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and
608c2ecf20Sopenharmony_ci	``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type` and the note below.
618c2ecf20Sopenharmony_ci    * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
628c2ecf20Sopenharmony_ci      - ``bounds``
638c2ecf20Sopenharmony_ci      - Defines the window within capturing or output is possible, this
648c2ecf20Sopenharmony_ci	may exclude for example the horizontal and vertical blanking
658c2ecf20Sopenharmony_ci	areas. The cropping rectangle cannot exceed these limits. Width
668c2ecf20Sopenharmony_ci	and height are defined in pixels, the driver writer is free to
678c2ecf20Sopenharmony_ci	choose origin and units of the coordinate system in the analog
688c2ecf20Sopenharmony_ci	domain.
698c2ecf20Sopenharmony_ci    * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
708c2ecf20Sopenharmony_ci      - ``defrect``
718c2ecf20Sopenharmony_ci      - Default cropping rectangle, it shall cover the "whole picture".
728c2ecf20Sopenharmony_ci	Assuming pixel aspect 1/1 this could be for example a 640 × 480
738c2ecf20Sopenharmony_ci	rectangle for NTSC, a 768 × 576 rectangle for PAL and SECAM
748c2ecf20Sopenharmony_ci	centered over the active picture area. The same co-ordinate system
758c2ecf20Sopenharmony_ci	as for ``bounds`` is used.
768c2ecf20Sopenharmony_ci    * - struct :c:type:`v4l2_fract`
778c2ecf20Sopenharmony_ci      - ``pixelaspect``
788c2ecf20Sopenharmony_ci      - This is the pixel aspect (y / x) when no scaling is applied, the
798c2ecf20Sopenharmony_ci	ratio of the actual sampling frequency and the frequency required
808c2ecf20Sopenharmony_ci	to get square pixels.
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	When cropping coordinates refer to square pixels, the driver sets
838c2ecf20Sopenharmony_ci	``pixelaspect`` to 1/1. Other common values are 54/59 for PAL and
848c2ecf20Sopenharmony_ci	SECAM, 11/10 for NTSC sampled according to [:ref:`itu601`].
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci.. note::
878c2ecf20Sopenharmony_ci   Unfortunately in the case of multiplanar buffer types
888c2ecf20Sopenharmony_ci   (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``)
898c2ecf20Sopenharmony_ci   this API was messed up with regards to how the :c:type:`v4l2_cropcap` ``type`` field
908c2ecf20Sopenharmony_ci   should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while
918c2ecf20Sopenharmony_ci   other drivers only accepted a non-multiplanar buffer type (i.e. without the
928c2ecf20Sopenharmony_ci   ``_MPLANE`` at the end).
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci   Starting with kernel 4.13 both variations are allowed.
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci.. _v4l2-rect-crop:
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_rect
1028c2ecf20Sopenharmony_ci    :header-rows:  0
1038c2ecf20Sopenharmony_ci    :stub-columns: 0
1048c2ecf20Sopenharmony_ci    :widths:       1 1 2
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci    * - __s32
1078c2ecf20Sopenharmony_ci      - ``left``
1088c2ecf20Sopenharmony_ci      - Horizontal offset of the top, left corner of the rectangle, in
1098c2ecf20Sopenharmony_ci	pixels.
1108c2ecf20Sopenharmony_ci    * - __s32
1118c2ecf20Sopenharmony_ci      - ``top``
1128c2ecf20Sopenharmony_ci      - Vertical offset of the top, left corner of the rectangle, in
1138c2ecf20Sopenharmony_ci	pixels.
1148c2ecf20Sopenharmony_ci    * - __u32
1158c2ecf20Sopenharmony_ci      - ``width``
1168c2ecf20Sopenharmony_ci      - Width of the rectangle, in pixels.
1178c2ecf20Sopenharmony_ci    * - __u32
1188c2ecf20Sopenharmony_ci      - ``height``
1198c2ecf20Sopenharmony_ci      - Height of the rectangle, in pixels.
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ciReturn Value
1228c2ecf20Sopenharmony_ci============
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
1258c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the
1268c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ciEINVAL
1298c2ecf20Sopenharmony_ci    The struct :c:type:`v4l2_cropcap` ``type`` is
1308c2ecf20Sopenharmony_ci    invalid.
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ciENODATA
1338c2ecf20Sopenharmony_ci    Cropping is not supported for this input or output.
134