0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003
0004 .. _VIDIOC_CROPCAP:
0005
0006 ********************
0007 ioctl VIDIOC_CROPCAP
0008 ********************
0009
0010 Name
0011 ====
0012
0013 VIDIOC_CROPCAP - Information about the video cropping and scaling abilities
0014
0015 Synopsis
0016 ========
0017
0018 .. c:macro:: VIDIOC_CROPCAP
0019
0020 ``int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)``
0021
0022 Arguments
0023 =========
0024
0025 ``fd``
0026 File descriptor returned by :c:func:`open()`.
0027
0028 ``argp``
0029 Pointer to struct :c:type:`v4l2_cropcap`.
0030
0031 Description
0032 ===========
0033
0034 Applications use this function to query the cropping limits, the pixel
0035 aspect of images and to calculate scale factors. They set the ``type``
0036 field of a v4l2_cropcap structure to the respective buffer (stream)
0037 type and call the :ref:`VIDIOC_CROPCAP` ioctl with a pointer to this
0038 structure. Drivers fill the rest of the structure. The results are
0039 constant except when switching the video standard. Remember this switch
0040 can occur implicit when switching the video input or output.
0041
0042 This ioctl must be implemented for video capture or output devices that
0043 support cropping and/or scaling and/or have non-square pixels, and for
0044 overlay devices.
0045
0046 .. c:type:: v4l2_cropcap
0047
0048 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
0049
0050 .. flat-table:: struct v4l2_cropcap
0051 :header-rows: 0
0052 :stub-columns: 0
0053 :widths: 1 1 2
0054
0055 * - __u32
0056 - ``type``
0057 - Type of the data stream, set by the application. Only these types
0058 are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``, ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
0059 ``V4L2_BUF_TYPE_VIDEO_OUTPUT``, ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and
0060 ``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type` and the note below.
0061 * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
0062 - ``bounds``
0063 - Defines the window within capturing or output is possible, this
0064 may exclude for example the horizontal and vertical blanking
0065 areas. The cropping rectangle cannot exceed these limits. Width
0066 and height are defined in pixels, the driver writer is free to
0067 choose origin and units of the coordinate system in the analog
0068 domain.
0069 * - struct :ref:`v4l2_rect <v4l2-rect-crop>`
0070 - ``defrect``
0071 - Default cropping rectangle, it shall cover the "whole picture".
0072 Assuming pixel aspect 1/1 this could be for example a 640 × 480
0073 rectangle for NTSC, a 768 × 576 rectangle for PAL and SECAM
0074 centered over the active picture area. The same co-ordinate system
0075 as for ``bounds`` is used.
0076 * - struct :c:type:`v4l2_fract`
0077 - ``pixelaspect``
0078 - This is the pixel aspect (y / x) when no scaling is applied, the
0079 ratio of the actual sampling frequency and the frequency required
0080 to get square pixels.
0081
0082 When cropping coordinates refer to square pixels, the driver sets
0083 ``pixelaspect`` to 1/1. Other common values are 54/59 for PAL and
0084 SECAM, 11/10 for NTSC sampled according to [:ref:`itu601`].
0085
0086 .. note::
0087 Unfortunately in the case of multiplanar buffer types
0088 (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``)
0089 this API was messed up with regards to how the :c:type:`v4l2_cropcap` ``type`` field
0090 should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while
0091 other drivers only accepted a non-multiplanar buffer type (i.e. without the
0092 ``_MPLANE`` at the end).
0093
0094 Starting with kernel 4.13 both variations are allowed.
0095
0096
0097 .. _v4l2-rect-crop:
0098
0099 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
0100
0101 .. flat-table:: struct v4l2_rect
0102 :header-rows: 0
0103 :stub-columns: 0
0104 :widths: 1 1 2
0105
0106 * - __s32
0107 - ``left``
0108 - Horizontal offset of the top, left corner of the rectangle, in
0109 pixels.
0110 * - __s32
0111 - ``top``
0112 - Vertical offset of the top, left corner of the rectangle, in
0113 pixels.
0114 * - __u32
0115 - ``width``
0116 - Width of the rectangle, in pixels.
0117 * - __u32
0118 - ``height``
0119 - Height of the rectangle, in pixels.
0120
0121 Return Value
0122 ============
0123
0124 On success 0 is returned, on error -1 and the ``errno`` variable is set
0125 appropriately. The generic error codes are described at the
0126 :ref:`Generic Error Codes <gen-errors>` chapter.
0127
0128 EINVAL
0129 The struct :c:type:`v4l2_cropcap` ``type`` is
0130 invalid.
0131
0132 ENODATA
0133 Cropping is not supported for this input or output.