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