brintos

brintos / linux-shallow public Read only

0
0
Text · 5.3 KiB · 2b5867a Raw
170 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_ENCODER_CMD:5 6************************************************7ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD8************************************************9 10Name11====12 13VIDIOC_ENCODER_CMD - VIDIOC_TRY_ENCODER_CMD - Execute an encoder command14 15Synopsis16========17 18.. c:macro:: VIDIOC_ENCODER_CMD19 20``int ioctl(int fd, VIDIOC_ENCODER_CMD, struct v4l2_encoder_cmd *argp)``21 22.. c:macro:: VIDIOC_TRY_ENCODER_CMD23 24``int ioctl(int fd, VIDIOC_TRY_ENCODER_CMD, struct v4l2_encoder_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_encoder_cmd`.34 35Description36===========37 38These ioctls control an audio/video (usually MPEG-) encoder.39``VIDIOC_ENCODER_CMD`` sends a command to the encoder,40``VIDIOC_TRY_ENCODER_CMD`` can be used to try a command without actually41executing it.42 43To send a command applications must initialize all fields of a struct44:c:type:`v4l2_encoder_cmd` and call45``VIDIOC_ENCODER_CMD`` or ``VIDIOC_TRY_ENCODER_CMD`` with a pointer to46this structure.47 48The ``cmd`` field must contain the command code. Some commands use the49``flags`` field for additional information.50 51After a STOP command, :c:func:`read()` calls will read52the remaining data buffered by the driver. When the buffer is empty,53:c:func:`read()` will return zero and the next :c:func:`read()`54call will restart the encoder.55 56A :c:func:`read()` or :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>`57call sends an implicit START command to the encoder if it has not been58started yet. Applies to both queues of mem2mem encoders.59 60A :c:func:`close()` or :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`61call of a streaming file descriptor sends an implicit immediate STOP to62the encoder, and all buffered data is discarded. Applies to both queues of63mem2mem encoders.64 65These ioctls are optional, not all drivers may support them. They were66introduced in Linux 2.6.21. They are, however, mandatory for stateful mem2mem67encoders (as further documented in :ref:`encoder`).68 69.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|70 71.. c:type:: v4l2_encoder_cmd72 73.. flat-table:: struct v4l2_encoder_cmd74    :header-rows:  075    :stub-columns: 076    :widths:       1 1 277 78    * - __u3279      - ``cmd``80      - The encoder command, see :ref:`encoder-cmds`.81    * - __u3282      - ``flags``83      - Flags to go with the command, see :ref:`encoder-flags`. If no84	flags are defined for this command, drivers and applications must85	set this field to zero.86    * - __u3287      - ``data``\ [8]88      - Reserved for future extensions. Drivers and applications must set89	the array to zero.90 91 92.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|93 94.. _encoder-cmds:95 96.. flat-table:: Encoder Commands97    :header-rows:  098    :stub-columns: 099    :widths:       3 1 4100 101    * - ``V4L2_ENC_CMD_START``102      - 0103      - Start the encoder. When the encoder is already running or paused,104	this command does nothing. No flags are defined for this command.105 106	For a device implementing the :ref:`encoder`, once the drain sequence107	is initiated with the ``V4L2_ENC_CMD_STOP`` command, it must be driven108	to completion before this command can be invoked.  Any attempt to109	invoke the command while the drain sequence is in progress will trigger110	an ``EBUSY`` error code. See :ref:`encoder` for more details.111    * - ``V4L2_ENC_CMD_STOP``112      - 1113      - Stop the encoder. When the ``V4L2_ENC_CMD_STOP_AT_GOP_END`` flag114	is set, encoding will continue until the end of the current *Group115	Of Pictures*, otherwise encoding will stop immediately. When the116	encoder is already stopped, this command does nothing.117 118	For a device implementing the :ref:`encoder`, the command will initiate119	the drain sequence as documented in :ref:`encoder`. No flags or other120	arguments are accepted in this case. Any attempt to invoke the command121	again before the sequence completes will trigger an ``EBUSY`` error122	code.123    * - ``V4L2_ENC_CMD_PAUSE``124      - 2125      - Pause the encoder. When the encoder has not been started yet, the126	driver will return an ``EPERM`` error code. When the encoder is127	already paused, this command does nothing. No flags are defined128	for this command.129    * - ``V4L2_ENC_CMD_RESUME``130      - 3131      - Resume encoding after a PAUSE command. When the encoder has not132	been started yet, the driver will return an ``EPERM`` error code. When133	the encoder is already running, this command does nothing. No134	flags are defined for this command.135 136.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|137 138.. _encoder-flags:139 140.. flat-table:: Encoder Command Flags141    :header-rows:  0142    :stub-columns: 0143    :widths:       3 1 4144 145    * - ``V4L2_ENC_CMD_STOP_AT_GOP_END``146      - 0x0001147      - Stop encoding at the end of the current *Group Of Pictures*,148	rather than immediately.149 150        Does not apply to :ref:`encoder`.151 152Return Value153============154 155On success 0 is returned, on error -1 and the ``errno`` variable is set156appropriately. The generic error codes are described at the157:ref:`Generic Error Codes <gen-errors>` chapter.158 159EBUSY160    A drain sequence of a device implementing the :ref:`encoder` is still in161    progress. It is not allowed to issue another encoder command until it162    completes.163 164EINVAL165    The ``cmd`` field is invalid.166 167EPERM168    The application sent a PAUSE or RESUME command when the encoder was169    not running.170