0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: MC
0003
0004 .. _media-func-ioctl:
0005
0006 *************
0007 media ioctl()
0008 *************
0009
0010 Name
0011 ====
0012
0013 media-ioctl - Control a media device
0014
0015 Synopsis
0016 ========
0017
0018 .. code-block:: c
0019
0020 #include <sys/ioctl.h>
0021
0022 ``int ioctl(int fd, int request, void *argp)``
0023
0024 Arguments
0025 =========
0026
0027 ``fd``
0028 File descriptor returned by :c:func:`open()`.
0029
0030 ``request``
0031 Media ioctl request code as defined in the media.h header file, for
0032 example MEDIA_IOC_SETUP_LINK.
0033
0034 ``argp``
0035 Pointer to a request-specific structure.
0036
0037 Description
0038 ===========
0039
0040 The :ref:`ioctl() <media-func-ioctl>` function manipulates media device
0041 parameters. The argument ``fd`` must be an open file descriptor.
0042
0043 The ioctl ``request`` code specifies the media function to be called. It
0044 has encoded in it whether the argument is an input, output or read/write
0045 parameter, and the size of the argument ``argp`` in bytes.
0046
0047 Macros and structures definitions specifying media ioctl requests and
0048 their parameters are located in the media.h header file. All media ioctl
0049 requests, their respective function and parameters are specified in
0050 :ref:`media-user-func`.
0051
0052 Return Value
0053 ============
0054
0055 On success 0 is returned, on error -1 and the ``errno`` variable is set
0056 appropriately. The generic error codes are described at the
0057 :ref:`Generic Error Codes <gen-errors>` chapter.
0058
0059 Request-specific error codes are listed in the individual requests
0060 descriptions.
0061
0062 When an ioctl that takes an output or read/write parameter fails, the
0063 parameter remains unmodified.