]> git.samba.org - sfrench/cifs-2.6.git/blob - Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst
[media] docs-rst: fix cross-references for videodev2.h
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / vidioc-subdev-g-fmt.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _VIDIOC_SUBDEV_G_FMT:
4
5 **********************************************
6 ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
7 **********************************************
8
9 Name
10 ====
11
12 VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad
13
14
15 Synopsis
16 ========
17
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
23
24
25 Arguments
26 =========
27
28 ``fd``
29     File descriptor returned by :ref:`open() <func-open>`.
30
31 ``argp``
32
33
34 Description
35 ===========
36
37 These ioctls are used to negotiate the frame format at specific subdev
38 pads in the image pipeline.
39
40 To retrieve the current format applications set the ``pad`` field of a
41 struct :c:type:`v4l2_subdev_format` to the desired
42 pad 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
45 driver fills the members of the ``format`` field.
46
47 To change the current format applications set both the ``pad`` and
48 ``which`` fields and all members of the ``format`` field. When they call
49 the ``VIDIOC_SUBDEV_S_FMT`` ioctl with a pointer to this structure the
50 driver verifies the requested format, adjusts it based on the hardware
51 capabilities and configures the device. Upon return the struct
52 :c:type:`v4l2_subdev_format` contains the current
53 format as would be returned by a ``VIDIOC_SUBDEV_G_FMT`` call.
54
55 Applications can query the device capabilities by setting the ``which``
56 to ``V4L2_SUBDEV_FORMAT_TRY``. When set, 'try' formats are not applied
57 to the device by the driver, but are changed exactly as active formats
58 and stored in the sub-device file handle. Two applications querying the
59 same sub-device would thus not interact with each other.
60
61 For instance, to try a format at the output pad of a sub-device,
62 applications would first set the try format at the sub-device input with
63 the ``VIDIOC_SUBDEV_S_FMT`` ioctl. They would then either retrieve the
64 default format at the output pad with the ``VIDIOC_SUBDEV_G_FMT`` ioctl,
65 or set the desired output pad format with the ``VIDIOC_SUBDEV_S_FMT``
66 ioctl and check the returned value.
67
68 Try formats do not depend on active formats, but can depend on the
69 current links configuration or sub-device controls value. For instance,
70 a low-pass noise filter might crop pixels at the frame boundaries,
71 modifying its output frame size.
72
73 Drivers must not return an error solely because the requested format
74 doesn't match the device capabilities. They must instead modify the
75 format to match what the hardware can provide. The modified format
76 should be as close as possible to the original request.
77
78
79 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
80
81 .. c:type:: v4l2_subdev_format
82
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
104           :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
105
106     -  .. row 3
107
108        -  struct :c:type:`v4l2_mbus_framefmt`
109
110        -  ``format``
111
112        -  Definition of an image format, see :c:type:`v4l2_mbus_framefmt` for
113           details.
114
115     -  .. row 4
116
117        -  __u32
118
119        -  ``reserved``\ [8]
120
121        -  Reserved for future extensions. Applications and drivers must set
122           the array to zero.
123
124
125
126 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
127
128 .. _v4l2-subdev-format-whence:
129
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
153 Return Value
154 ============
155
156 On success 0 is returned, on error -1 and the ``errno`` variable is set
157 appropriately. The generic error codes are described at the
158 :ref:`Generic Error Codes <gen-errors>` chapter.
159
160 EBUSY
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
166 EINVAL
167     The struct :c:type:`v4l2_subdev_format`
168     ``pad`` references a non-existing pad, or the ``which`` field
169     references a non-existing format.
170
171
172 ============
173
174 On success 0 is returned, on error -1 and the ``errno`` variable is set
175 appropriately. The generic error codes are described at the
176 :ref:`Generic Error Codes <gen-errors>` chapter.