Home | History | Annotate | Download | only in spec
      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
      2 <HTML
      3 ><HEAD
      4 ><TITLE
      5 >V4L2 open()</TITLE
      6 ><META
      7 NAME="GENERATOR"
      8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
      9 REL="HOME"
     10 TITLE="Video for Linux Two API Specification"
     11 HREF="book1.htm"><LINK
     12 REL="UP"
     13 TITLE="Function Reference"
     14 HREF="r7624.htm"><LINK
     15 REL="PREVIOUS"
     16 TITLE="V4L2 munmap()"
     17 HREF="r14037.htm"><LINK
     18 REL="NEXT"
     19 TITLE="V4L2 poll()"
     20 HREF="r14169.htm"></HEAD
     21 ><BODY
     22 CLASS="REFENTRY"
     23 BGCOLOR="#FFFFFF"
     24 TEXT="#000000"
     25 LINK="#0000FF"
     26 VLINK="#840084"
     27 ALINK="#0000FF"
     28 ><DIV
     29 CLASS="NAVHEADER"
     30 ><TABLE
     31 SUMMARY="Header navigation table"
     32 WIDTH="100%"
     33 BORDER="0"
     34 CELLPADDING="0"
     35 CELLSPACING="0"
     36 ><TR
     37 ><TH
     38 COLSPAN="3"
     39 ALIGN="center"
     40 >Video for Linux Two API Specification: Revision 0.24</TH
     41 ></TR
     42 ><TR
     43 ><TD
     44 WIDTH="10%"
     45 ALIGN="left"
     46 VALIGN="bottom"
     47 ><A
     48 HREF="r14037.htm"
     49 ACCESSKEY="P"
     50 >Prev</A
     51 ></TD
     52 ><TD
     53 WIDTH="80%"
     54 ALIGN="center"
     55 VALIGN="bottom"
     56 ></TD
     57 ><TD
     58 WIDTH="10%"
     59 ALIGN="right"
     60 VALIGN="bottom"
     61 ><A
     62 HREF="r14169.htm"
     63 ACCESSKEY="N"
     64 >Next</A
     65 ></TD
     66 ></TR
     67 ></TABLE
     68 ><HR
     69 ALIGN="LEFT"
     70 WIDTH="100%"></DIV
     71 ><H1
     72 ><A
     73 NAME="FUNC-OPEN"
     74 ></A
     75 >V4L2 open()</H1
     76 ><DIV
     77 CLASS="REFNAMEDIV"
     78 ><A
     79 NAME="AEN14094"
     80 ></A
     81 ><H2
     82 >Name</H2
     83 >v4l2-open&nbsp;--&nbsp;Open a V4L2 device</DIV
     84 ><DIV
     85 CLASS="REFSYNOPSISDIV"
     86 ><A
     87 NAME="AEN14097"
     88 ></A
     89 ><H2
     90 >Synopsis</H2
     91 ><DIV
     92 CLASS="FUNCSYNOPSIS"
     93 ><P
     94 ></P
     95 ><A
     96 NAME="AEN14098"
     97 ></A
     98 ><PRE
     99 CLASS="FUNCSYNOPSISINFO"
    100 >#include &lt;fcntl.h&gt;</PRE
    101 ><P
    102 ><CODE
    103 ><CODE
    104 CLASS="FUNCDEF"
    105 >int open</CODE
    106 >(const char *device_name, int flags);</CODE
    107 ></P
    108 ><P
    109 ></P
    110 ></DIV
    111 ></DIV
    112 ><DIV
    113 CLASS="REFSECT1"
    114 ><A
    115 NAME="AEN14107"
    116 ></A
    117 ><H2
    118 >Arguments</H2
    119 ><P
    120 ></P
    121 ><DIV
    122 CLASS="VARIABLELIST"
    123 ><DL
    124 ><DT
    125 ><CODE
    126 CLASS="PARAMETER"
    127 >device_name</CODE
    128 ></DT
    129 ><DD
    130 ><P
    131 >Device to be opened.</P
    132 ></DD
    133 ><DT
    134 ><CODE
    135 CLASS="PARAMETER"
    136 >flags</CODE
    137 ></DT
    138 ><DD
    139 ><P
    140 >Open flags. Access mode must be
    141 <CODE
    142 CLASS="CONSTANT"
    143 >O_RDWR</CODE
    144 >. This is just a technicality, input devices
    145 still support only reading and output devices only writing.</P
    146 ><P
    147 >When the <CODE
    148 CLASS="CONSTANT"
    149 >O_NONBLOCK</CODE
    150 > flag is
    151 given, the read() function and the <A
    152 HREF="r12878.htm"
    153 ><CODE
    154 CLASS="CONSTANT"
    155 >VIDIOC_DQBUF</CODE
    156 ></A
    157 > ioctl will return
    158 the <SPAN
    159 CLASS="ERRORCODE"
    160 >EAGAIN</SPAN
    161 > error code when no data is available or no buffer is in the driver
    162 outgoing queue, otherwise these functions block until data becomes
    163 available. All V4L2 drivers exchanging data with applications must
    164 support the <CODE
    165 CLASS="CONSTANT"
    166 >O_NONBLOCK</CODE
    167 > flag.</P
    168 ><P
    169 >Other flags have no effect.</P
    170 ></DD
    171 ></DL
    172 ></DIV
    173 ></DIV
    174 ><DIV
    175 CLASS="REFSECT1"
    176 ><A
    177 NAME="AEN14128"
    178 ></A
    179 ><H2
    180 >Description</H2
    181 ><P
    182 >To open a V4L2 device applications call
    183 <CODE
    184 CLASS="FUNCTION"
    185 >open()</CODE
    186 > with the desired device name. This
    187 function has no side effects; all data format parameters, current
    188 input or output, control values or other properties remain unchanged.
    189 At the first <CODE
    190 CLASS="FUNCTION"
    191 >open()</CODE
    192 > call after loading the driver
    193 they will be reset to default values, drivers are never in an
    194 undefined state.</P
    195 ></DIV
    196 ><DIV
    197 CLASS="REFSECT1"
    198 ><A
    199 NAME="AEN14133"
    200 ></A
    201 ><H2
    202 >Return Value</H2
    203 ><P
    204 >On success <CODE
    205 CLASS="FUNCTION"
    206 >open</CODE
    207 > returns the new file
    208 descriptor. On error -1 is returned, and the <CODE
    209 CLASS="VARNAME"
    210 >errno</CODE
    211 >
    212 variable is set appropriately. Possible error codes are:</P
    213 ><P
    214 ></P
    215 ><DIV
    216 CLASS="VARIABLELIST"
    217 ><DL
    218 ><DT
    219 ><SPAN
    220 CLASS="ERRORCODE"
    221 >EACCES</SPAN
    222 ></DT
    223 ><DD
    224 ><P
    225 >The caller has no permission to access the
    226 device.</P
    227 ></DD
    228 ><DT
    229 ><SPAN
    230 CLASS="ERRORCODE"
    231 >EBUSY</SPAN
    232 ></DT
    233 ><DD
    234 ><P
    235 >The driver does not support multiple opens and the
    236 device is already in use.</P
    237 ></DD
    238 ><DT
    239 ><SPAN
    240 CLASS="ERRORCODE"
    241 >ENXIO</SPAN
    242 ></DT
    243 ><DD
    244 ><P
    245 >No device corresponding to this device special file
    246 exists.</P
    247 ></DD
    248 ><DT
    249 ><SPAN
    250 CLASS="ERRORCODE"
    251 >ENOMEM</SPAN
    252 ></DT
    253 ><DD
    254 ><P
    255 >Not enough kernel memory was available to complete the
    256 request.</P
    257 ></DD
    258 ><DT
    259 ><SPAN
    260 CLASS="ERRORCODE"
    261 >EMFILE</SPAN
    262 ></DT
    263 ><DD
    264 ><P
    265 >The  process  already  has  the  maximum number of
    266 files open.</P
    267 ></DD
    268 ><DT
    269 ><SPAN
    270 CLASS="ERRORCODE"
    271 >ENFILE</SPAN
    272 ></DT
    273 ><DD
    274 ><P
    275 >The limit on the total number of files open on the
    276 system has been reached.</P
    277 ></DD
    278 ></DL
    279 ></DIV
    280 ></DIV
    281 ><DIV
    282 CLASS="NAVFOOTER"
    283 ><HR
    284 ALIGN="LEFT"
    285 WIDTH="100%"><TABLE
    286 SUMMARY="Footer navigation table"
    287 WIDTH="100%"
    288 BORDER="0"
    289 CELLPADDING="0"
    290 CELLSPACING="0"
    291 ><TR
    292 ><TD
    293 WIDTH="33%"
    294 ALIGN="left"
    295 VALIGN="top"
    296 ><A
    297 HREF="r14037.htm"
    298 ACCESSKEY="P"
    299 >Prev</A
    300 ></TD
    301 ><TD
    302 WIDTH="34%"
    303 ALIGN="center"
    304 VALIGN="top"
    305 ><A
    306 HREF="book1.htm"
    307 ACCESSKEY="H"
    308 >Home</A
    309 ></TD
    310 ><TD
    311 WIDTH="33%"
    312 ALIGN="right"
    313 VALIGN="top"
    314 ><A
    315 HREF="r14169.htm"
    316 ACCESSKEY="N"
    317 >Next</A
    318 ></TD
    319 ></TR
    320 ><TR
    321 ><TD
    322 WIDTH="33%"
    323 ALIGN="left"
    324 VALIGN="top"
    325 >V4L2 munmap()</TD
    326 ><TD
    327 WIDTH="34%"
    328 ALIGN="center"
    329 VALIGN="top"
    330 ><A
    331 HREF="r7624.htm"
    332 ACCESSKEY="U"
    333 >Up</A
    334 ></TD
    335 ><TD
    336 WIDTH="33%"
    337 ALIGN="right"
    338 VALIGN="top"
    339 >V4L2 poll()</TD
    340 ></TR
    341 ></TABLE
    342 ></DIV
    343 ></BODY
    344 ></HTML
    345 >
    346