Merge remote-tracking branch 'ftrace/for-next'
[deliverable/linux.git] / Documentation / media / uapi / v4l / vidioc-g-crop.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
af4a4d0d 3.. _VIDIOC_G_CROP:
5377d91f
MH
4
5**********************************
6ioctl VIDIOC_G_CROP, VIDIOC_S_CROP
7**********************************
8
15e7d615 9Name
586027ce 10====
5377d91f 11
586027ce 12VIDIOC_G_CROP - VIDIOC_S_CROP - Get or set the current cropping rectangle
5377d91f 13
15e7d615
MCC
14
15Synopsis
5377d91f
MH
16========
17
41d80465
MCC
18.. c:function:: int ioctl( int fd, VIDIOC_G_CROP, struct v4l2_crop *argp )
19 :name: VIDIOC_G_CROP
5377d91f 20
41d80465
MCC
21.. c:function:: int ioctl( int fd, VIDIOC_S_CROP, const struct v4l2_crop *argp )
22 :name: VIDIOC_S_CROP
5377d91f 23
586027ce 24
15e7d615 25Arguments
5377d91f
MH
26=========
27
28``fd``
29 File descriptor returned by :ref:`open() <func-open>`.
30
5377d91f
MH
31``argp``
32
33
15e7d615 34Description
5377d91f
MH
35===========
36
37To query the cropping rectangle size and position applications set the
fc78c7c7 38``type`` field of a struct :c:type:`v4l2_crop` structure to the
4e03cb76 39respective buffer (stream) type and call the :ref:`VIDIOC_G_CROP <VIDIOC_G_CROP>` ioctl
5377d91f 40with a pointer to this structure. The driver fills the rest of the
cdb4af0f 41structure or returns the ``EINVAL`` error code if cropping is not supported.
5377d91f
MH
42
43To change the cropping rectangle applications initialize the ``type``
e8be7e97 44and struct :c:type:`v4l2_rect` substructure named ``c`` of a
2212ff25 45v4l2_crop structure and call the :ref:`VIDIOC_S_CROP <VIDIOC_G_CROP>` ioctl with a pointer
5377d91f
MH
46to this structure.
47
48Do not use the multiplanar buffer types. Use
49``V4L2_BUF_TYPE_VIDEO_CAPTURE`` instead of
50``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`` and use
51``V4L2_BUF_TYPE_VIDEO_OUTPUT`` instead of
52``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``.
53
54The driver first adjusts the requested dimensions against hardware
55limits, i. e. the bounds given by the capture/output window, and it
56rounds to the closest possible values of horizontal and vertical offset,
57width and height. In particular the driver must round the vertical
58offset of the cropping rectangle to frame lines modulo two, such that
59the field order cannot be confused.
60
61Second the driver adjusts the image size (the opposite rectangle of the
62scaling process, source or target depending on the data direction) to
63the closest size possible while maintaining the current horizontal and
64vertical scaling factor.
65
66Finally the driver programs the hardware with the actual cropping and
2212ff25 67image parameters. :ref:`VIDIOC_S_CROP <VIDIOC_G_CROP>` is a write-only ioctl, it does not
5377d91f 68return the actual parameters. To query them applications must call
4e03cb76 69:ref:`VIDIOC_G_CROP <VIDIOC_G_CROP>` and :ref:`VIDIOC_G_FMT`. When the
5377d91f
MH
70parameters are unsuitable the application may modify the cropping or
71image parameters and repeat the cycle until satisfactory parameters have
72been negotiated.
73
74When cropping is not supported then no parameters are changed and
cdb4af0f 75:ref:`VIDIOC_S_CROP <VIDIOC_G_CROP>` returns the ``EINVAL`` error code.
5377d91f
MH
76
77
e8be7e97 78.. c:type:: v4l2_crop
5377d91f 79
5bd4bb78
MCC
80.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
81
5377d91f
MH
82.. flat-table:: struct v4l2_crop
83 :header-rows: 0
84 :stub-columns: 0
85 :widths: 1 1 2
86
87
88 - .. row 1
89
90 - __u32
91
92 - ``type``
93
94 - Type of the data stream, set by the application. Only these types
0579e6e3
MCC
95 are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``,
96 ``V4L2_BUF_TYPE_VIDEO_OUTPUT`` and
56683d7d 97 ``V4L2_BUF_TYPE_VIDEO_OVERLAY``. See :c:type:`v4l2_buf_type`.
5377d91f
MH
98
99 - .. row 2
100
e8be7e97 101 - struct :c:type:`v4l2_rect`
5377d91f
MH
102
103 - ``c``
104
105 - Cropping rectangle. The same co-ordinate system as for struct
e8be7e97 106 :c:type:`v4l2_cropcap` ``bounds`` is used.
5377d91f
MH
107
108
15e7d615 109Return Value
5377d91f
MH
110============
111
112On success 0 is returned, on error -1 and the ``errno`` variable is set
113appropriately. The generic error codes are described at the
114:ref:`Generic Error Codes <gen-errors>` chapter.
3f8d56b0
HV
115
116ENODATA
117 Cropping is not supported for this input or output.
This page took 0.051875 seconds and 5 git commands to generate.