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>ioctl VIDIOC_QUERYBUF</TITLE 6><META 7NAME="GENERATOR" 8CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK 9REL="HOME" 10TITLE="Video for Linux Two API Specification" 11HREF="book1.htm"><LINK 12REL="UP" 13TITLE="Function Reference" 14HREF="r7624.htm"><LINK 15REL="PREVIOUS" 16TITLE="ioctl VIDIOC_QBUF, VIDIOC_DQBUF" 17HREF="r12878.htm"><LINK 18REL="NEXT" 19TITLE="ioctl VIDIOC_QUERYCAP" 20HREF="r13105.htm"></HEAD 21><BODY 22CLASS="REFENTRY" 23BGCOLOR="#FFFFFF" 24TEXT="#000000" 25LINK="#0000FF" 26VLINK="#840084" 27ALINK="#0000FF" 28><DIV 29CLASS="NAVHEADER" 30><TABLE 31SUMMARY="Header navigation table" 32WIDTH="100%" 33BORDER="0" 34CELLPADDING="0" 35CELLSPACING="0" 36><TR 37><TH 38COLSPAN="3" 39ALIGN="center" 40>Video for Linux Two API Specification: Revision 0.24</TH 41></TR 42><TR 43><TD 44WIDTH="10%" 45ALIGN="left" 46VALIGN="bottom" 47><A 48HREF="r12878.htm" 49ACCESSKEY="P" 50>Prev</A 51></TD 52><TD 53WIDTH="80%" 54ALIGN="center" 55VALIGN="bottom" 56></TD 57><TD 58WIDTH="10%" 59ALIGN="right" 60VALIGN="bottom" 61><A 62HREF="r13105.htm" 63ACCESSKEY="N" 64>Next</A 65></TD 66></TR 67></TABLE 68><HR 69ALIGN="LEFT" 70WIDTH="100%"></DIV 71><H1 72><A 73NAME="VIDIOC-QUERYBUF" 74></A 75>ioctl VIDIOC_QUERYBUF</H1 76><DIV 77CLASS="REFNAMEDIV" 78><A 79NAME="AEN13026" 80></A 81><H2 82>Name</H2 83>VIDIOC_QUERYBUF -- Query the status of a buffer</DIV 84><DIV 85CLASS="REFSYNOPSISDIV" 86><A 87NAME="AEN13029" 88></A 89><H2 90>Synopsis</H2 91><DIV 92CLASS="FUNCSYNOPSIS" 93><P 94></P 95><A 96NAME="AEN13030" 97></A 98><P 99><CODE 100><CODE 101CLASS="FUNCDEF" 102>int ioctl</CODE 103>(int fd, int request, struct v4l2_buffer *argp);</CODE 104></P 105><P 106></P 107></DIV 108></DIV 109><DIV 110CLASS="REFSECT1" 111><A 112NAME="AEN13040" 113></A 114><H2 115>Arguments</H2 116><P 117></P 118><DIV 119CLASS="VARIABLELIST" 120><DL 121><DT 122><CODE 123CLASS="PARAMETER" 124>fd</CODE 125></DT 126><DD 127><P 128>File descriptor returned by <A 129HREF="r14090.htm" 130><CODE 131CLASS="FUNCTION" 132>open()</CODE 133></A 134>.</P 135></DD 136><DT 137><CODE 138CLASS="PARAMETER" 139>request</CODE 140></DT 141><DD 142><P 143>VIDIOC_QUERYBUF</P 144></DD 145><DT 146><CODE 147CLASS="PARAMETER" 148>argp</CODE 149></DT 150><DD 151><P 152></P 153></DD 154></DL 155></DIV 156></DIV 157><DIV 158CLASS="REFSECT1" 159><A 160NAME="AEN13060" 161></A 162><H2 163>Description</H2 164><P 165>This ioctl is part of the <A 166HREF="x5791.htm" 167>memory 168mapping</A 169> I/O method. It can be used to query the status of a 170buffer at any time after buffers have been allocated with the 171<A 172HREF="r13696.htm" 173><CODE 174CLASS="CONSTANT" 175>VIDIOC_REQBUFS</CODE 176></A 177> ioctl.</P 178><P 179>Applications set the <CODE 180CLASS="STRUCTFIELD" 181>type</CODE 182> field 183 of a struct <A 184HREF="x5953.htm#V4L2-BUFFER" 185>v4l2_buffer</A 186> to the same buffer type as previously 187struct <A 188HREF="r10944.htm#V4L2-FORMAT" 189>v4l2_format</A 190> <CODE 191CLASS="STRUCTFIELD" 192>type</CODE 193> and struct <A 194HREF="r13696.htm#V4L2-REQUESTBUFFERS" 195>v4l2_requestbuffers</A 196> 197<CODE 198CLASS="STRUCTFIELD" 199>type</CODE 200>, and the <CODE 201CLASS="STRUCTFIELD" 202>index</CODE 203> 204 field. Valid index numbers range from zero 205to the number of buffers allocated with <A 206HREF="r13696.htm" 207><CODE 208CLASS="CONSTANT" 209>VIDIOC_REQBUFS</CODE 210></A 211> 212 (struct <A 213HREF="r13696.htm#V4L2-REQUESTBUFFERS" 214>v4l2_requestbuffers</A 215> <CODE 216CLASS="STRUCTFIELD" 217>count</CODE 218>) minus one. 219After calling <CODE 220CLASS="CONSTANT" 221>VIDIOC_QUERYBUF</CODE 222> with a pointer to 223 this structure drivers return an error code or fill the rest of 224the structure.</P 225><P 226>In the <CODE 227CLASS="STRUCTFIELD" 228>flags</CODE 229> field the 230<CODE 231CLASS="CONSTANT" 232>V4L2_BUF_FLAG_MAPPED</CODE 233>, 234<CODE 235CLASS="CONSTANT" 236>V4L2_BUF_FLAG_QUEUED</CODE 237> and 238<CODE 239CLASS="CONSTANT" 240>V4L2_BUF_FLAG_DONE</CODE 241> flags will be valid. The 242<CODE 243CLASS="STRUCTFIELD" 244>memory</CODE 245> field will be set to 246<CODE 247CLASS="CONSTANT" 248>V4L2_MEMORY_MMAP</CODE 249>, the <CODE 250CLASS="STRUCTFIELD" 251>m.offset</CODE 252> 253contains the offset of the buffer from the start of the device memory, 254the <CODE 255CLASS="STRUCTFIELD" 256>length</CODE 257> field its size. The driver may 258or may not set the remaining fields and flags, they are meaningless in 259this context.</P 260><P 261>The <CODE 262CLASS="STRUCTNAME" 263>v4l2_buffer</CODE 264> structure is 265 specified in <A 266HREF="x5953.htm" 267>Section 3.5</A 268>.</P 269></DIV 270><DIV 271CLASS="REFSECT1" 272><A 273NAME="AEN13091" 274></A 275><H2 276>Return Value</H2 277><P 278>On success <SPAN 279CLASS="RETURNVALUE" 280>0</SPAN 281> is returned, on error <SPAN 282CLASS="RETURNVALUE" 283>-1</SPAN 284> and the <CODE 285CLASS="VARNAME" 286>errno</CODE 287> variable is set appropriately:</P 288><P 289></P 290><DIV 291CLASS="VARIABLELIST" 292><DL 293><DT 294><SPAN 295CLASS="ERRORCODE" 296>EINVAL</SPAN 297></DT 298><DD 299><P 300>The buffer <CODE 301CLASS="STRUCTFIELD" 302>type</CODE 303> is not 304supported, or the <CODE 305CLASS="STRUCTFIELD" 306>index</CODE 307> is out of bounds.</P 308></DD 309></DL 310></DIV 311></DIV 312><DIV 313CLASS="NAVFOOTER" 314><HR 315ALIGN="LEFT" 316WIDTH="100%"><TABLE 317SUMMARY="Footer navigation table" 318WIDTH="100%" 319BORDER="0" 320CELLPADDING="0" 321CELLSPACING="0" 322><TR 323><TD 324WIDTH="33%" 325ALIGN="left" 326VALIGN="top" 327><A 328HREF="r12878.htm" 329ACCESSKEY="P" 330>Prev</A 331></TD 332><TD 333WIDTH="34%" 334ALIGN="center" 335VALIGN="top" 336><A 337HREF="book1.htm" 338ACCESSKEY="H" 339>Home</A 340></TD 341><TD 342WIDTH="33%" 343ALIGN="right" 344VALIGN="top" 345><A 346HREF="r13105.htm" 347ACCESSKEY="N" 348>Next</A 349></TD 350></TR 351><TR 352><TD 353WIDTH="33%" 354ALIGN="left" 355VALIGN="top" 356>ioctl VIDIOC_QBUF, VIDIOC_DQBUF</TD 357><TD 358WIDTH="34%" 359ALIGN="center" 360VALIGN="top" 361><A 362HREF="r7624.htm" 363ACCESSKEY="U" 364>Up</A 365></TD 366><TD 367WIDTH="33%" 368ALIGN="right" 369VALIGN="top" 370>ioctl VIDIOC_QUERYCAP</TD 371></TR 372></TABLE 373></DIV 374></BODY 375></HTML 376> 377