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