219 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_DECODER_CMD:5 6************************************************7ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD8************************************************9 10Name11====12 13VIDIOC_DECODER_CMD - VIDIOC_TRY_DECODER_CMD - Execute an decoder command14 15Synopsis16========17 18.. c:macro:: VIDIOC_DECODER_CMD19 20``int ioctl(int fd, VIDIOC_DECODER_CMD, struct v4l2_decoder_cmd *argp)``21 22.. c:macro:: VIDIOC_TRY_DECODER_CMD23 24``int ioctl(int fd, VIDIOC_TRY_DECODER_CMD, struct v4l2_decoder_cmd *argp)``25 26Arguments27=========28 29``fd``30 File descriptor returned by :c:func:`open()`.31 32``argp``33 pointer to struct :c:type:`v4l2_decoder_cmd`.34 35Description36===========37 38These ioctls control an audio/video (usually MPEG-) decoder.39``VIDIOC_DECODER_CMD`` sends a command to the decoder,40``VIDIOC_TRY_DECODER_CMD`` can be used to try a command without actually41executing it. To send a command applications must initialize all fields42of a struct :c:type:`v4l2_decoder_cmd` and call43``VIDIOC_DECODER_CMD`` or ``VIDIOC_TRY_DECODER_CMD`` with a pointer to44this structure.45 46The ``cmd`` field must contain the command code. Some commands use the47``flags`` field for additional information.48 49A :c:func:`write()` or :ref:`VIDIOC_STREAMON`50call sends an implicit START command to the decoder if it has not been51started yet. Applies to both queues of mem2mem decoders.52 53A :c:func:`close()` or :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`54call of a streaming file descriptor sends an implicit immediate STOP55command to the decoder, and all buffered data is discarded. Applies to both56queues of mem2mem decoders.57 58In principle, these ioctls are optional, not all drivers may support them. They were59introduced in Linux 3.3. They are, however, mandatory for stateful mem2mem decoders60(as further documented in :ref:`decoder`).61 62.. tabularcolumns:: |p{2.0cm}|p{1.1cm}|p{2.2cm}|p{11.8cm}|63 64.. c:type:: v4l2_decoder_cmd65 66.. cssclass:: longtable67 68.. flat-table:: struct v4l2_decoder_cmd69 :header-rows: 070 :stub-columns: 071 :widths: 1 1 1 372 73 * - __u3274 - ``cmd``75 -76 - The decoder command, see :ref:`decoder-cmds`.77 * - __u3278 - ``flags``79 -80 - Flags to go with the command. If no flags are defined for this81 command, drivers and applications must set this field to zero.82 * - union {83 - (anonymous)84 * - struct85 - ``start``86 -87 - Structure containing additional data for the88 ``V4L2_DEC_CMD_START`` command.89 * -90 - __s3291 - ``speed``92 - Playback speed and direction. The playback speed is defined as93 ``speed``/1000 of the normal speed. So 1000 is normal playback.94 Negative numbers denote reverse playback, so -1000 does reverse95 playback at normal speed. Speeds -1, 0 and 1 have special96 meanings: speed 0 is shorthand for 1000 (normal playback). A speed97 of 1 steps just one frame forward, a speed of -1 steps just one98 frame back.99 * -100 - __u32101 - ``format``102 - Format restrictions. This field is set by the driver, not the103 application. Possible values are ``V4L2_DEC_START_FMT_NONE`` if104 there are no format restrictions or ``V4L2_DEC_START_FMT_GOP`` if105 the decoder operates on full GOPs (*Group Of Pictures*). This is106 usually the case for reverse playback: the decoder needs full107 GOPs, which it can then play in reverse order. So to implement108 reverse playback the application must feed the decoder the last109 GOP in the video file, then the GOP before that, etc. etc.110 * - struct111 - ``stop``112 -113 - Structure containing additional data for the ``V4L2_DEC_CMD_STOP``114 command.115 * -116 - __u64117 - ``pts``118 - Stop playback at this ``pts`` or immediately if the playback is119 already past that timestamp. Leave to 0 if you want to stop after120 the last frame was decoded.121 * - struct122 - ``raw``123 * -124 - __u32125 - ``data``\ [16]126 - Reserved for future extensions. Drivers and applications must set127 the array to zero.128 * - }129 -130 131 132.. tabularcolumns:: |p{5.6cm}|p{0.6cm}|p{11.1cm}|133 134.. cssclass:: longtable135 136.. _decoder-cmds:137 138.. flat-table:: Decoder Commands139 :header-rows: 0140 :stub-columns: 0141 :widths: 56 6 113142 143 * - ``V4L2_DEC_CMD_START``144 - 0145 - Start the decoder. When the decoder is already running or paused,146 this command will just change the playback speed. That means that147 calling ``V4L2_DEC_CMD_START`` when the decoder was paused will148 *not* resume the decoder. You have to explicitly call149 ``V4L2_DEC_CMD_RESUME`` for that. This command has one flag:150 ``V4L2_DEC_CMD_START_MUTE_AUDIO``. If set, then audio will be151 muted when playing back at a non-standard speed.152 153 For a device implementing the :ref:`decoder`, once the drain sequence154 is initiated with the ``V4L2_DEC_CMD_STOP`` command, it must be driven155 to completion before this command can be invoked. Any attempt to156 invoke the command while the drain sequence is in progress will trigger157 an ``EBUSY`` error code. The command may be also used to restart the158 decoder in case of an implicit stop initiated by the decoder itself,159 without the ``V4L2_DEC_CMD_STOP`` being called explicitly. See160 :ref:`decoder` for more details.161 * - ``V4L2_DEC_CMD_STOP``162 - 1163 - Stop the decoder. When the decoder is already stopped, this164 command does nothing. This command has two flags: if165 ``V4L2_DEC_CMD_STOP_TO_BLACK`` is set, then the decoder will set166 the picture to black after it stopped decoding. Otherwise the last167 image will repeat. If168 ``V4L2_DEC_CMD_STOP_IMMEDIATELY`` is set, then the decoder stops169 immediately (ignoring the ``pts`` value), otherwise it will keep170 decoding until timestamp >= pts or until the last of the pending171 data from its internal buffers was decoded.172 173 For a device implementing the :ref:`decoder`, the command will initiate174 the drain sequence as documented in :ref:`decoder`. No flags or other175 arguments are accepted in this case. Any attempt to invoke the command176 again before the sequence completes will trigger an ``EBUSY`` error177 code.178 * - ``V4L2_DEC_CMD_PAUSE``179 - 2180 - Pause the decoder. When the decoder has not been started yet, the181 driver will return an ``EPERM`` error code. When the decoder is182 already paused, this command does nothing. This command has one183 flag: if ``V4L2_DEC_CMD_PAUSE_TO_BLACK`` is set, then set the184 decoder output to black when paused.185 * - ``V4L2_DEC_CMD_RESUME``186 - 3187 - Resume decoding after a PAUSE command. When the decoder has not188 been started yet, the driver will return an ``EPERM`` error code. When189 the decoder is already running, this command does nothing. No190 flags are defined for this command.191 * - ``V4L2_DEC_CMD_FLUSH``192 - 4193 - Flush any held capture buffers. Only valid for stateless decoders.194 This command is typically used when the application reached the195 end of the stream and the last output buffer had the196 ``V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF`` flag set. This would prevent197 dequeueing the capture buffer containing the last decoded frame.198 So this command can be used to explicitly flush that final decoded199 frame. This command does nothing if there are no held capture buffers.200 201Return Value202============203 204On success 0 is returned, on error -1 and the ``errno`` variable is set205appropriately. The generic error codes are described at the206:ref:`Generic Error Codes <gen-errors>` chapter.207 208EBUSY209 A drain sequence of a device implementing the :ref:`decoder` is still in210 progress. It is not allowed to issue another decoder command until it211 completes.212 213EINVAL214 The ``cmd`` field is invalid.215 216EPERM217 The application sent a PAUSE or RESUME command when the decoder was218 not running.219