[media] gen-errors.rst fix error table column limits
[deliverable/linux.git] / Documentation / media / uapi / v4l / vidioc-subdev-g-fmt.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
af4a4d0d 3.. _VIDIOC_SUBDEV_G_FMT:
5377d91f
MH
4
5**********************************************
6ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
7**********************************************
8
15e7d615 9Name
586027ce 10====
5377d91f 11
586027ce 12VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad
5377d91f 13
15e7d615
MCC
14
15Synopsis
5377d91f
MH
16========
17
b7e67f6c 18.. cpp:function:: int ioctl( int fd, int request, struct v4l2_subdev_format *argp )
5377d91f 19
586027ce 20
15e7d615 21Arguments
5377d91f
MH
22=========
23
24``fd``
25 File descriptor returned by :ref:`open() <func-open>`.
26
27``request``
28 VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
29
30``argp``
31
32
15e7d615 33Description
5377d91f
MH
34===========
35
36These ioctls are used to negotiate the frame format at specific subdev
37pads in the image pipeline.
38
39To retrieve the current format applications set the ``pad`` field of a
40struct :ref:`v4l2_subdev_format <v4l2-subdev-format>` to the desired
41pad number as reported by the media API and the ``which`` field to
42``V4L2_SUBDEV_FORMAT_ACTIVE``. When they call the
43``VIDIOC_SUBDEV_G_FMT`` ioctl with a pointer to this structure the
44driver fills the members of the ``format`` field.
45
46To change the current format applications set both the ``pad`` and
47``which`` fields and all members of the ``format`` field. When they call
48the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the
49driver verifies the requested format, adjusts it based on the hardware
50capabilities and configures the device. Upon return the struct
51:ref:`v4l2_subdev_format <v4l2-subdev-format>` contains the current
52format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call.
53
54Applications can query the device capabilities by setting the ``which``
55to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied
56to the device by the driver, but are changed exactly as active formats
57and stored in the sub-device file handle. Two applications querying the
58same sub-device would thus not interact with each other.
59
60For instance, to try a format at the output pad of a sub-device,
61applications would first set the try format at the sub-device input with
62the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the
63default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl,
64or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT``
65ioctl and check the returned value.
66
67Try formats do not depend on active formats, but can depend on the
68current links configuration or sub-device controls value. For instance,
69a low-pass noise filter might crop pixels at the frame boundaries,
70modifying its output frame size.
71
72Drivers must not return an error solely because the requested format
73doesn't match the device capabilities. They must instead modify the
74format to match what the hardware can provide. The modified format
75should be as close as possible to the original request.
76
77
78.. _v4l2-subdev-format:
79
5bd4bb78
MCC
80.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
81
5377d91f
MH
82.. flat-table:: struct v4l2_subdev_format
83 :header-rows: 0
84 :stub-columns: 0
85 :widths: 1 1 2
86
87
88 - .. row 1
89
90 - __u32
91
92 - ``pad``
93
94 - Pad number as reported by the media controller API.
95
96 - .. row 2
97
98 - __u32
99
100 - ``which``
101
102 - Format to modified, from enum
0579e6e3 103 :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
5377d91f
MH
104
105 - .. row 3
106
107 - struct :ref:`v4l2_mbus_framefmt <v4l2-mbus-framefmt>`
108
109 - ``format``
110
111 - Definition of an image format, see :ref:`v4l2-mbus-framefmt` for
0579e6e3 112 details.
5377d91f
MH
113
114 - .. row 4
115
116 - __u32
117
8968da9b 118 - ``reserved``\ [8]
5377d91f
MH
119
120 - Reserved for future extensions. Applications and drivers must set
0579e6e3 121 the array to zero.
5377d91f
MH
122
123
124
125.. _v4l2-subdev-format-whence:
126
5bd4bb78
MCC
127.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
128
5377d91f
MH
129.. flat-table:: enum v4l2_subdev_format_whence
130 :header-rows: 0
131 :stub-columns: 0
132 :widths: 3 1 4
133
134
135 - .. row 1
136
137 - V4L2_SUBDEV_FORMAT_TRY
138
139 - 0
140
141 - Try formats, used for querying device capabilities.
142
143 - .. row 2
144
145 - V4L2_SUBDEV_FORMAT_ACTIVE
146
147 - 1
148
149 - Active formats, applied to the hardware.
150
151
15e7d615 152Return Value
5377d91f
MH
153============
154
155On success 0 is returned, on error -1 and the ``errno`` variable is set
156appropriately. The generic error codes are described at the
157:ref:`Generic Error Codes <gen-errors>` chapter.
158
159EBUSY
160 The format can't be changed because the pad is currently busy. This
161 can be caused, for instance, by an active video stream on the pad.
162 The ioctl must not be retried without performing another action to
163 fix the problem first. Only returned by ``VIDIOC_SUBDEV_S_FMT``
164
165EINVAL
166 The struct :ref:`v4l2_subdev_format <v4l2-subdev-format>`
167 ``pad`` references a non-existing pad, or the ``which`` field
168 references a non-existing format.
169
170
5377d91f
MH
171============
172
173On success 0 is returned, on error -1 and the ``errno`` variable is set
174appropriately. The generic error codes are described at the
175:ref:`Generic Error Codes <gen-errors>` chapter.
This page took 0.050525 seconds and 5 git commands to generate.