Path: blob/master/Documentation/DocBook/v4l/media-func-ioctl.xml
10823 views
<refentry id="media-func-ioctl">1<refmeta>2<refentrytitle>media ioctl()</refentrytitle>3&manvol;4</refmeta>56<refnamediv>7<refname>media-ioctl</refname>8<refpurpose>Control a media device</refpurpose>9</refnamediv>1011<refsynopsisdiv>12<funcsynopsis>13<funcsynopsisinfo>#include <sys/ioctl.h></funcsynopsisinfo>14<funcprototype>15<funcdef>int <function>ioctl</function></funcdef>16<paramdef>int <parameter>fd</parameter></paramdef>17<paramdef>int <parameter>request</parameter></paramdef>18<paramdef>void *<parameter>argp</parameter></paramdef>19</funcprototype>20</funcsynopsis>21</refsynopsisdiv>2223<refsect1>24<title>Arguments</title>2526<variablelist>27<varlistentry>28<term><parameter>fd</parameter></term>29<listitem>30<para>&fd;</para>31</listitem>32</varlistentry>33<varlistentry>34<term><parameter>request</parameter></term>35<listitem>36<para>Media ioctl request code as defined in the media.h header file,37for example MEDIA_IOC_SETUP_LINK.</para>38</listitem>39</varlistentry>40<varlistentry>41<term><parameter>argp</parameter></term>42<listitem>43<para>Pointer to a request-specific structure.</para>44</listitem>45</varlistentry>46</variablelist>47</refsect1>4849<refsect1>50<title>Description</title>51<para>The <function>ioctl()</function> function manipulates media device52parameters. The argument <parameter>fd</parameter> must be an open file53descriptor.</para>54<para>The ioctl <parameter>request</parameter> code specifies the media55function to be called. It has encoded in it whether the argument is an56input, output or read/write parameter, and the size of the argument57<parameter>argp</parameter> in bytes.</para>58<para>Macros and structures definitions specifying media ioctl requests and59their parameters are located in the media.h header file. All media ioctl60requests, their respective function and parameters are specified in61<xref linkend="media-user-func" />.</para>62</refsect1>6364<refsect1>65<title>Return Value</title>6667<para><function>ioctl()</function> returns <returnvalue>0</returnvalue> on68success. On failure, <returnvalue>-1</returnvalue> is returned, and the69<varname>errno</varname> variable is set appropriately. Generic error codes70are listed below, and request-specific error codes are listed in the71individual requests descriptions.</para>72<para>When an ioctl that takes an output or read/write parameter fails,73the parameter remains unmodified.</para>7475<variablelist>76<varlistentry>77<term><errorcode>EBADF</errorcode></term>78<listitem>79<para><parameter>fd</parameter> is not a valid open file descriptor.80</para>81</listitem>82</varlistentry>83<varlistentry>84<term><errorcode>EFAULT</errorcode></term>85<listitem>86<para><parameter>argp</parameter> references an inaccessible memory87area.</para>88</listitem>89</varlistentry>90<varlistentry>91<term><errorcode>EINVAL</errorcode></term>92<listitem>93<para>The <parameter>request</parameter> or the data pointed to by94<parameter>argp</parameter> is not valid. This is a very common error95code, see the individual ioctl requests listed in96<xref linkend="media-user-func" /> for actual causes.</para>97</listitem>98</varlistentry>99<varlistentry>100<term><errorcode>ENOMEM</errorcode></term>101<listitem>102<para>Insufficient kernel memory was available to complete the103request.</para>104</listitem>105</varlistentry>106<varlistentry>107<term><errorcode>ENOTTY</errorcode></term>108<listitem>109<para><parameter>fd</parameter> is not associated with a character110special device.</para>111</listitem>112</varlistentry>113</variablelist>114</refsect1>115</refentry>116117118