1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun.. c:namespace:: V4L 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun.. _VIDIOC_CROPCAP: 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun******************** 7*4882a593Smuzhiyunioctl VIDIOC_CROPCAP 8*4882a593Smuzhiyun******************** 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunName 11*4882a593Smuzhiyun==== 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunVIDIOC_CROPCAP - Information about the video cropping and scaling abilities 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunSynopsis 16*4882a593Smuzhiyun======== 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun.. c:macro:: VIDIOC_CROPCAP 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun``int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)`` 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunArguments 23*4882a593Smuzhiyun========= 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun``fd`` 26*4882a593Smuzhiyun File descriptor returned by :c:func:`open()`. 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun``argp`` 29*4882a593Smuzhiyun Pointer to struct :c:type:`v4l2_cropcap`. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunDescription 32*4882a593Smuzhiyun=========== 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunApplications use this function to query the cropping limits, the pixel 35*4882a593Smuzhiyunaspect of images and to calculate scale factors. They set the ``type`` 36*4882a593Smuzhiyunfield of a v4l2_cropcap structure to the respective buffer (stream) 37*4882a593Smuzhiyuntype and call the :ref:`VIDIOC_CROPCAP` ioctl with a pointer to this 38*4882a593Smuzhiyunstructure. Drivers fill the rest of the structure. The results are 39*4882a593Smuzhiyunconstant except when switching the video standard. Remember this switch 40*4882a593Smuzhiyuncan occur implicit when switching the video input or output. 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunThis ioctl must be implemented for video capture or output devices that 43*4882a593Smuzhiyunsupport cropping and/or scaling and/or have non-square pixels, and for 44*4882a593Smuzhiyunoverlay devices. 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun.. c:type:: v4l2_cropcap 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun.. flat-table:: struct v4l2_cropcap 51*4882a593Smuzhiyun :header-rows: 0 52*4882a593Smuzhiyun :stub-columns: 0 53*4882a593Smuzhiyun :widths: 1 1 2 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun * - __u32 56*4882a593Smuzhiyun - ``type`` 57*4882a593Smuzhiyun - Type of the data stream, set by the application. Only these types 58*4882a593Smuzhiyun are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``, ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``, 59*4882a593Smuzhiyun ``V4L2_BUF_TYPE_VIDEO_OUTPUT``, ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`` and 60*4882a593Smuzhiyun ``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type` and the note below. 61*4882a593Smuzhiyun * - struct :ref:`v4l2_rect <v4l2-rect-crop>` 62*4882a593Smuzhiyun - ``bounds`` 63*4882a593Smuzhiyun - Defines the window within capturing or output is possible, this 64*4882a593Smuzhiyun may exclude for example the horizontal and vertical blanking 65*4882a593Smuzhiyun areas. The cropping rectangle cannot exceed these limits. Width 66*4882a593Smuzhiyun and height are defined in pixels, the driver writer is free to 67*4882a593Smuzhiyun choose origin and units of the coordinate system in the analog 68*4882a593Smuzhiyun domain. 69*4882a593Smuzhiyun * - struct :ref:`v4l2_rect <v4l2-rect-crop>` 70*4882a593Smuzhiyun - ``defrect`` 71*4882a593Smuzhiyun - Default cropping rectangle, it shall cover the "whole picture". 72*4882a593Smuzhiyun Assuming pixel aspect 1/1 this could be for example a 640 × 480 73*4882a593Smuzhiyun rectangle for NTSC, a 768 × 576 rectangle for PAL and SECAM 74*4882a593Smuzhiyun centered over the active picture area. The same co-ordinate system 75*4882a593Smuzhiyun as for ``bounds`` is used. 76*4882a593Smuzhiyun * - struct :c:type:`v4l2_fract` 77*4882a593Smuzhiyun - ``pixelaspect`` 78*4882a593Smuzhiyun - This is the pixel aspect (y / x) when no scaling is applied, the 79*4882a593Smuzhiyun ratio of the actual sampling frequency and the frequency required 80*4882a593Smuzhiyun to get square pixels. 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun When cropping coordinates refer to square pixels, the driver sets 83*4882a593Smuzhiyun ``pixelaspect`` to 1/1. Other common values are 54/59 for PAL and 84*4882a593Smuzhiyun SECAM, 11/10 for NTSC sampled according to [:ref:`itu601`]. 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun.. note:: 87*4882a593Smuzhiyun Unfortunately in the case of multiplanar buffer types 88*4882a593Smuzhiyun (``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``) 89*4882a593Smuzhiyun this API was messed up with regards to how the :c:type:`v4l2_cropcap` ``type`` field 90*4882a593Smuzhiyun should be filled in. Some drivers only accepted the ``_MPLANE`` buffer type while 91*4882a593Smuzhiyun other drivers only accepted a non-multiplanar buffer type (i.e. without the 92*4882a593Smuzhiyun ``_MPLANE`` at the end). 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun Starting with kernel 4.13 both variations are allowed. 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun.. _v4l2-rect-crop: 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun.. flat-table:: struct v4l2_rect 102*4882a593Smuzhiyun :header-rows: 0 103*4882a593Smuzhiyun :stub-columns: 0 104*4882a593Smuzhiyun :widths: 1 1 2 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun * - __s32 107*4882a593Smuzhiyun - ``left`` 108*4882a593Smuzhiyun - Horizontal offset of the top, left corner of the rectangle, in 109*4882a593Smuzhiyun pixels. 110*4882a593Smuzhiyun * - __s32 111*4882a593Smuzhiyun - ``top`` 112*4882a593Smuzhiyun - Vertical offset of the top, left corner of the rectangle, in 113*4882a593Smuzhiyun pixels. 114*4882a593Smuzhiyun * - __u32 115*4882a593Smuzhiyun - ``width`` 116*4882a593Smuzhiyun - Width of the rectangle, in pixels. 117*4882a593Smuzhiyun * - __u32 118*4882a593Smuzhiyun - ``height`` 119*4882a593Smuzhiyun - Height of the rectangle, in pixels. 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunReturn Value 122*4882a593Smuzhiyun============ 123*4882a593Smuzhiyun 124*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set 125*4882a593Smuzhiyunappropriately. The generic error codes are described at the 126*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter. 127*4882a593Smuzhiyun 128*4882a593SmuzhiyunEINVAL 129*4882a593Smuzhiyun The struct :c:type:`v4l2_cropcap` ``type`` is 130*4882a593Smuzhiyun invalid. 131*4882a593Smuzhiyun 132*4882a593SmuzhiyunENODATA 133*4882a593Smuzhiyun Cropping is not supported for this input or output. 134