1.. Permission is granted to copy, distribute and/or modify this
2.. document under the terms of the GNU Free Documentation License,
3.. Version 1.1 or any later version published by the Free Software
4.. Foundation, with no Invariant Sections, no Front-Cover Texts
5.. and no Back-Cover Texts. A copy of the license is included at
6.. Documentation/userspace-api/media/fdl-appendix.rst.
7..
8.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10.. _media-func-ioctl:
11
12*************
13media ioctl()
14*************
15
16Name
17====
18
19media-ioctl - Control a media device
20
21
22Synopsis
23========
24
25.. code-block:: c
26
27    #include <sys/ioctl.h>
28
29
30.. c:function:: int ioctl( int fd, int request, void *argp )
31    :name: mc-ioctl
32
33Arguments
34=========
35
36``fd``
37    File descriptor returned by :c:func:`open() <mc-open>`.
38
39``request``
40    Media ioctl request code as defined in the media.h header file, for
41    example MEDIA_IOC_SETUP_LINK.
42
43``argp``
44    Pointer to a request-specific structure.
45
46
47Description
48===========
49
50The :ref:`ioctl() <media-func-ioctl>` function manipulates media device
51parameters. The argument ``fd`` must be an open file descriptor.
52
53The ioctl ``request`` code specifies the media function to be called. It
54has encoded in it whether the argument is an input, output or read/write
55parameter, and the size of the argument ``argp`` in bytes.
56
57Macros and structures definitions specifying media ioctl requests and
58their parameters are located in the media.h header file. All media ioctl
59requests, their respective function and parameters are specified in
60:ref:`media-user-func`.
61
62
63Return Value
64============
65
66On success 0 is returned, on error -1 and the ``errno`` variable is set
67appropriately. The generic error codes are described at the
68:ref:`Generic Error Codes <gen-errors>` chapter.
69
70Request-specific error codes are listed in the individual requests
71descriptions.
72
73When an ioctl that takes an output or read/write parameter fails, the
74parameter remains unmodified.
75