Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 1 | .. -*- coding: utf-8; mode: rst -*- |
| 2 | |
Mauro Carvalho Chehab | af4a4d0 | 2016-07-01 13:42:29 -0300 | [diff] [blame] | 3 | .. _VIDIOC_G_PARM: |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 4 | |
| 5 | ********************************** |
| 6 | ioctl VIDIOC_G_PARM, VIDIOC_S_PARM |
| 7 | ********************************** |
| 8 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 9 | Name |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 10 | ==== |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 11 | |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 12 | VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 13 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 14 | |
| 15 | Synopsis |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 16 | ======== |
| 17 | |
Mauro Carvalho Chehab | 41d8046 | 2016-08-19 16:53:38 -0300 | [diff] [blame] | 18 | .. c:function:: int ioctl( int fd, VIDIOC_G_PARM, v4l2_streamparm *argp ) |
| 19 | :name: VIDIOC_G_PARM |
| 20 | |
| 21 | .. c:function:: int ioctl( int fd, VIDIOC_S_PARM, v4l2_streamparm *argp ) |
| 22 | :name: VIDIOC_S_PARM |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 23 | |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 24 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 25 | Arguments |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 26 | ========= |
| 27 | |
| 28 | ``fd`` |
| 29 | File descriptor returned by :ref:`open() <func-open>`. |
| 30 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 31 | ``argp`` |
| 32 | |
| 33 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 34 | Description |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 35 | =========== |
| 36 | |
| 37 | The current video standard determines a nominal number of frames per |
| 38 | second. If less than this number of frames is to be captured or output, |
| 39 | applications can request frame skipping or duplicating on the driver |
Mauro Carvalho Chehab | 760c701 | 2016-07-04 12:56:17 -0300 | [diff] [blame] | 40 | side. This is especially useful when using the :ref:`read() <func-read>` or |
| 41 | :ref:`write() <func-write>`, which are not augmented by timestamps or sequence |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 42 | counters, and to avoid unnecessary data copying. |
| 43 | |
| 44 | Further these ioctls can be used to determine the number of buffers used |
| 45 | internally by a driver in read/write mode. For implications see the |
| 46 | section discussing the :ref:`read() <func-read>` function. |
| 47 | |
| 48 | To get and set the streaming parameters applications call the |
Mauro Carvalho Chehab | 4e03cb7 | 2016-07-03 10:02:29 -0300 | [diff] [blame] | 49 | :ref:`VIDIOC_G_PARM <VIDIOC_G_PARM>` and :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>` ioctl, respectively. They take a |
Mauro Carvalho Chehab | fc78c7c | 2016-09-08 05:43:01 -0300 | [diff] [blame] | 50 | pointer to a struct :c:type:`v4l2_streamparm` which contains a |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 51 | union holding separate parameters for input and output devices. |
| 52 | |
| 53 | |
Mauro Carvalho Chehab | 5bd4bb7 | 2016-08-17 08:14:19 -0300 | [diff] [blame] | 54 | .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{3.5cm}|p{7.0cm}| |
| 55 | |
Mauro Carvalho Chehab | e8be7e9 | 2016-08-29 17:37:59 -0300 | [diff] [blame] | 56 | .. c:type:: v4l2_streamparm |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 57 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 58 | .. flat-table:: struct v4l2_streamparm |
| 59 | :header-rows: 0 |
| 60 | :stub-columns: 0 |
| 61 | :widths: 1 1 1 2 |
| 62 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 63 | * - __u32 |
| 64 | - ``type`` |
| 65 | - |
| 66 | - The buffer (stream) type, same as struct |
| 67 | :c:type:`v4l2_format` ``type``, set by the |
| 68 | application. See :c:type:`v4l2_buf_type` |
| 69 | * - union |
| 70 | - ``parm`` |
| 71 | - |
| 72 | - |
| 73 | * - |
| 74 | - struct :c:type:`v4l2_captureparm` |
| 75 | - ``capture`` |
| 76 | - Parameters for capture devices, used when ``type`` is |
| 77 | ``V4L2_BUF_TYPE_VIDEO_CAPTURE``. |
| 78 | * - |
| 79 | - struct :c:type:`v4l2_outputparm` |
| 80 | - ``output`` |
| 81 | - Parameters for output devices, used when ``type`` is |
| 82 | ``V4L2_BUF_TYPE_VIDEO_OUTPUT``. |
| 83 | * - |
| 84 | - __u8 |
| 85 | - ``raw_data``\ [200] |
| 86 | - A place holder for future extensions. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 87 | |
| 88 | |
| 89 | |
Mauro Carvalho Chehab | 5bd4bb7 | 2016-08-17 08:14:19 -0300 | [diff] [blame] | 90 | .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| |
| 91 | |
Mauro Carvalho Chehab | e8be7e9 | 2016-08-29 17:37:59 -0300 | [diff] [blame] | 92 | .. c:type:: v4l2_captureparm |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 93 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 94 | .. flat-table:: struct v4l2_captureparm |
| 95 | :header-rows: 0 |
| 96 | :stub-columns: 0 |
| 97 | :widths: 1 1 2 |
| 98 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 99 | * - __u32 |
| 100 | - ``capability`` |
| 101 | - See :ref:`parm-caps`. |
| 102 | * - __u32 |
| 103 | - ``capturemode`` |
| 104 | - Set by drivers and applications, see :ref:`parm-flags`. |
| 105 | * - struct :c:type:`v4l2_fract` |
| 106 | - ``timeperframe`` |
| 107 | - This is the desired period between successive frames captured by |
| 108 | the driver, in seconds. The field is intended to skip frames on |
| 109 | the driver side, saving I/O bandwidth. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 110 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 111 | Applications store here the desired frame period, drivers return |
| 112 | the actual frame period, which must be greater or equal to the |
| 113 | nominal frame period determined by the current video standard |
| 114 | (struct :c:type:`v4l2_standard` ``frameperiod`` |
| 115 | field). Changing the video standard (also implicitly by switching |
| 116 | the video input) may reset this parameter to the nominal frame |
| 117 | period. To reset manually applications can just set this field to |
| 118 | zero. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 119 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 120 | Drivers support this function only when they set the |
| 121 | ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field. |
| 122 | * - __u32 |
| 123 | - ``extendedmode`` |
| 124 | - Custom (driver specific) streaming parameters. When unused, |
| 125 | applications and drivers must set this field to zero. Applications |
| 126 | using this field should check the driver name and version, see |
| 127 | :ref:`querycap`. |
| 128 | * - __u32 |
| 129 | - ``readbuffers`` |
| 130 | - Applications set this field to the desired number of buffers used |
| 131 | internally by the driver in :ref:`read() <func-read>` mode. |
| 132 | Drivers return the actual number of buffers. When an application |
| 133 | requests zero buffers, drivers should just return the current |
| 134 | setting rather than the minimum or an error code. For details see |
| 135 | :ref:`rw`. |
| 136 | * - __u32 |
| 137 | - ``reserved``\ [4] |
| 138 | - Reserved for future extensions. Drivers and applications must set |
| 139 | the array to zero. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 140 | |
| 141 | |
| 142 | |
Mauro Carvalho Chehab | 5bd4bb7 | 2016-08-17 08:14:19 -0300 | [diff] [blame] | 143 | .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| |
| 144 | |
Mauro Carvalho Chehab | e8be7e9 | 2016-08-29 17:37:59 -0300 | [diff] [blame] | 145 | .. c:type:: v4l2_outputparm |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 146 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 147 | .. flat-table:: struct v4l2_outputparm |
| 148 | :header-rows: 0 |
| 149 | :stub-columns: 0 |
| 150 | :widths: 1 1 2 |
| 151 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 152 | * - __u32 |
| 153 | - ``capability`` |
| 154 | - See :ref:`parm-caps`. |
| 155 | * - __u32 |
| 156 | - ``outputmode`` |
| 157 | - Set by drivers and applications, see :ref:`parm-flags`. |
| 158 | * - struct :c:type:`v4l2_fract` |
| 159 | - ``timeperframe`` |
| 160 | - This is the desired period between successive frames output by the |
| 161 | driver, in seconds. |
| 162 | * - :cspan:`2` |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 163 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 164 | The field is intended to repeat frames on the driver side in |
| 165 | :ref:`write() <func-write>` mode (in streaming mode timestamps |
| 166 | can be used to throttle the output), saving I/O bandwidth. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 167 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 168 | Applications store here the desired frame period, drivers return |
| 169 | the actual frame period, which must be greater or equal to the |
| 170 | nominal frame period determined by the current video standard |
| 171 | (struct :c:type:`v4l2_standard` ``frameperiod`` |
| 172 | field). Changing the video standard (also implicitly by switching |
| 173 | the video output) may reset this parameter to the nominal frame |
| 174 | period. To reset manually applications can just set this field to |
| 175 | zero. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 176 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 177 | Drivers support this function only when they set the |
| 178 | ``V4L2_CAP_TIMEPERFRAME`` flag in the ``capability`` field. |
| 179 | * - __u32 |
| 180 | - ``extendedmode`` |
| 181 | - Custom (driver specific) streaming parameters. When unused, |
| 182 | applications and drivers must set this field to zero. Applications |
| 183 | using this field should check the driver name and version, see |
| 184 | :ref:`querycap`. |
| 185 | * - __u32 |
| 186 | - ``writebuffers`` |
| 187 | - Applications set this field to the desired number of buffers used |
| 188 | internally by the driver in :ref:`write() <func-write>` mode. Drivers |
| 189 | return the actual number of buffers. When an application requests |
| 190 | zero buffers, drivers should just return the current setting |
| 191 | rather than the minimum or an error code. For details see |
| 192 | :ref:`rw`. |
| 193 | * - __u32 |
| 194 | - ``reserved``\ [4] |
| 195 | - Reserved for future extensions. Drivers and applications must set |
| 196 | the array to zero. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 197 | |
| 198 | |
| 199 | |
Mauro Carvalho Chehab | 5bd4bb7 | 2016-08-17 08:14:19 -0300 | [diff] [blame] | 200 | .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| |
| 201 | |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 202 | .. _parm-caps: |
| 203 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 204 | .. flat-table:: Streaming Parameters Capabilites |
| 205 | :header-rows: 0 |
| 206 | :stub-columns: 0 |
| 207 | :widths: 3 1 4 |
| 208 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 209 | * - ``V4L2_CAP_TIMEPERFRAME`` |
| 210 | - 0x1000 |
| 211 | - The frame skipping/repeating controlled by the ``timeperframe`` |
| 212 | field is supported. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 213 | |
| 214 | |
| 215 | |
Mauro Carvalho Chehab | 5bd4bb7 | 2016-08-17 08:14:19 -0300 | [diff] [blame] | 216 | .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| |
| 217 | |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 218 | .. _parm-flags: |
| 219 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 220 | .. flat-table:: Capture Parameters Flags |
| 221 | :header-rows: 0 |
| 222 | :stub-columns: 0 |
| 223 | :widths: 3 1 4 |
| 224 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 225 | * - ``V4L2_MODE_HIGHQUALITY`` |
| 226 | - 0x0001 |
| 227 | - High quality imaging mode. High quality mode is intended for still |
| 228 | imaging applications. The idea is to get the best possible image |
| 229 | quality that the hardware can deliver. It is not defined how the |
| 230 | driver writer may achieve that; it will depend on the hardware and |
| 231 | the ingenuity of the driver writer. High quality mode is a |
| 232 | different mode from the regular motion video capture modes. In |
| 233 | high quality mode: |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 234 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 235 | - The driver may be able to capture higher resolutions than for |
| 236 | motion capture. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 237 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 238 | - The driver may support fewer pixel formats than motion capture |
| 239 | (eg; true color). |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 240 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 241 | - The driver may capture and arithmetically combine multiple |
| 242 | successive fields or frames to remove color edge artifacts and |
| 243 | reduce the noise in the video data. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 244 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 245 | - The driver may capture images in slices like a scanner in order |
| 246 | to handle larger format images than would otherwise be |
| 247 | possible. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 248 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 249 | - An image capture operation may be significantly slower than |
| 250 | motion capture. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 251 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 252 | - Moving objects in the image might have excessive motion blur. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 253 | |
Laurent Pinchart | c2b66ca | 2016-09-05 08:44:34 -0300 | [diff] [blame] | 254 | - Capture might only work through the :ref:`read() <func-read>` call. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 255 | |
| 256 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 257 | Return Value |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 258 | ============ |
| 259 | |
| 260 | On success 0 is returned, on error -1 and the ``errno`` variable is set |
| 261 | appropriately. The generic error codes are described at the |
| 262 | :ref:`Generic Error Codes <gen-errors>` chapter. |