func-open.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <refentry id="func-open">
  2. <refmeta>
  3. <refentrytitle>V4L2 open()</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>v4l2-open</refname>
  8. <refpurpose>Open a V4L2 device</refpurpose>
  9. </refnamediv>
  10. <refsynopsisdiv>
  11. <funcsynopsis>
  12. <funcsynopsisinfo>#include &lt;fcntl.h&gt;</funcsynopsisinfo>
  13. <funcprototype>
  14. <funcdef>int <function>open</function></funcdef>
  15. <paramdef>const char *<parameter>device_name</parameter></paramdef>
  16. <paramdef>int <parameter>flags</parameter></paramdef>
  17. </funcprototype>
  18. </funcsynopsis>
  19. </refsynopsisdiv>
  20. <refsect1>
  21. <title>Arguments</title>
  22. <variablelist>
  23. <varlistentry>
  24. <term><parameter>device_name</parameter></term>
  25. <listitem>
  26. <para>Device to be opened.</para>
  27. </listitem>
  28. </varlistentry>
  29. <varlistentry>
  30. <term><parameter>flags</parameter></term>
  31. <listitem>
  32. <para>Open flags. Access mode must be
  33. <constant>O_RDWR</constant>. This is just a technicality, input devices
  34. still support only reading and output devices only writing.</para>
  35. <para>When the <constant>O_NONBLOCK</constant> flag is
  36. given, the read() function and the &VIDIOC-DQBUF; ioctl will return
  37. the &EAGAIN; when no data is available or no buffer is in the driver
  38. outgoing queue, otherwise these functions block until data becomes
  39. available. All V4L2 drivers exchanging data with applications must
  40. support the <constant>O_NONBLOCK</constant> flag.</para>
  41. <para>Other flags have no effect.</para>
  42. </listitem>
  43. </varlistentry>
  44. </variablelist>
  45. </refsect1>
  46. <refsect1>
  47. <title>Description</title>
  48. <para>To open a V4L2 device applications call
  49. <function>open()</function> with the desired device name. This
  50. function has no side effects; all data format parameters, current
  51. input or output, control values or other properties remain unchanged.
  52. At the first <function>open()</function> call after loading the driver
  53. they will be reset to default values, drivers are never in an
  54. undefined state.</para>
  55. </refsect1>
  56. <refsect1>
  57. <title>Return Value</title>
  58. <para>On success <function>open</function> returns the new file
  59. descriptor. On error -1 is returned, and the <varname>errno</varname>
  60. variable is set appropriately. Possible error codes are:</para>
  61. <variablelist>
  62. <varlistentry>
  63. <term><errorcode>EACCES</errorcode></term>
  64. <listitem>
  65. <para>The caller has no permission to access the
  66. device.</para>
  67. </listitem>
  68. </varlistentry>
  69. <varlistentry>
  70. <term><errorcode>EBUSY</errorcode></term>
  71. <listitem>
  72. <para>The driver does not support multiple opens and the
  73. device is already in use.</para>
  74. </listitem>
  75. </varlistentry>
  76. <varlistentry>
  77. <term><errorcode>ENXIO</errorcode></term>
  78. <listitem>
  79. <para>No device corresponding to this device special file
  80. exists.</para>
  81. </listitem>
  82. </varlistentry>
  83. <varlistentry>
  84. <term><errorcode>ENOMEM</errorcode></term>
  85. <listitem>
  86. <para>Not enough kernel memory was available to complete the
  87. request.</para>
  88. </listitem>
  89. </varlistentry>
  90. <varlistentry>
  91. <term><errorcode>EMFILE</errorcode></term>
  92. <listitem>
  93. <para>The process already has the maximum number of
  94. files open.</para>
  95. </listitem>
  96. </varlistentry>
  97. <varlistentry>
  98. <term><errorcode>ENFILE</errorcode></term>
  99. <listitem>
  100. <para>The limit on the total number of files open on the
  101. system has been reached.</para>
  102. </listitem>
  103. </varlistentry>
  104. </variablelist>
  105. </refsect1>
  106. </refentry>