1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_QUERYBUF</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="user-func.html" title="Appendix A. Function Reference"><link rel="prev" href="vidioc-qbuf.html" title="ioctl VIDIOC_QBUF, VIDIOC_DQBUF"><link rel="next" href="vidioc-querycap.html" title="ioctl VIDIOC_QUERYCAP"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ioctl VIDIOC_QUERYBUF</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-qbuf.html">Prev</a> </td><th width="60%" align="center">Appendix A. Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="vidioc-querycap.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-querybuf"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_QUERYBUF — Query the status of a buffer</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ioctl</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">request</var>, </td></tr><tr><td> </td><td>struct v4l2_buffer *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1115732412"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>fd</code></em></span></dt><dd><p>File descriptor returned by <a class="link" href="func-open.html" title="V4L2 open()"><code class="function">open()</code></a>.</p></dd><dt><span class="term"><em class="parameter"><code>request</code></em></span></dt><dd><p>VIDIOC_QUERYBUF</p></dd><dt><span class="term"><em class="parameter"><code>argp</code></em></span></dt><dd><p></p></dd></dl></div></div><div class="refsect1"><a name="idp1115736500"></a><h2>Description</h2><p>This ioctl is part of the <a class="link" href="mmap.html" title="Streaming I/O (Memory Mapping)">streaming 2</a> I/O method. It can be used to query the status of a 3buffer at any time after buffers have been allocated with the 4<a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> ioctl.</p><p>Applications set the <em class="structfield"><code>type</code></em> field 5 of a struct <a class="link" href="buffer.html#v4l2-buffer" title="Table 3.1. struct v4l2_buffer">v4l2_buffer</a> to the same buffer type as was previously used with 6struct <a class="link" href="vidioc-g-fmt.html#v4l2-format" title="Table A.72. struct v4l2_format">v4l2_format</a> <em class="structfield"><code>type</code></em> and struct <a class="link" href="vidioc-reqbufs.html#v4l2-requestbuffers" title="Table A.100. struct v4l2_requestbuffers">v4l2_requestbuffers</a> 7<em class="structfield"><code>type</code></em>, and the <em class="structfield"><code>index</code></em> 8 field. Valid index numbers range from zero 9to the number of buffers allocated with <a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> 10 (struct <a class="link" href="vidioc-reqbufs.html#v4l2-requestbuffers" title="Table A.100. struct v4l2_requestbuffers">v4l2_requestbuffers</a> <em class="structfield"><code>count</code></em>) minus one. 11The <em class="structfield"><code>reserved</code></em> field should to set to 0. 12When using the <a class="link" href="planar-apis.html" title="Single- and multi-planar APIs">multi-planar API</a>, the 13<em class="structfield"><code>m.planes</code></em> field must contain a userspace pointer to an 14array of struct <a class="link" href="buffer.html#v4l2-plane" title="Table 3.2. struct v4l2_plane">v4l2_plane</a> and the <em class="structfield"><code>length</code></em> field has 15to be set to the number of elements in that array. 16After calling <code class="constant">VIDIOC_QUERYBUF</code> with a pointer to 17 this structure drivers return an error code or fill the rest of 18the structure.</p><p>In the <em class="structfield"><code>flags</code></em> field the 19<code class="constant">V4L2_BUF_FLAG_MAPPED</code>, 20<code class="constant">V4L2_BUF_FLAG_PREPARED</code>, 21<code class="constant">V4L2_BUF_FLAG_QUEUED</code> and 22<code class="constant">V4L2_BUF_FLAG_DONE</code> flags will be valid. The 23<em class="structfield"><code>memory</code></em> field will be set to the current 24I/O method. For the single-planar API, the <em class="structfield"><code>m.offset</code></em> 25contains the offset of the buffer from the start of the device memory, 26the <em class="structfield"><code>length</code></em> field its size. For the multi-planar API, 27fields <em class="structfield"><code>m.mem_offset</code></em> and 28<em class="structfield"><code>length</code></em> in the <em class="structfield"><code>m.planes</code></em> 29array elements will be used instead and the <em class="structfield"><code>length</code></em> 30field of struct <a class="link" href="buffer.html#v4l2-buffer" title="Table 3.1. struct v4l2_buffer">v4l2_buffer</a> is set to the number of filled-in array elements. 31The driver may or may not set the remaining fields and flags, they are 32meaningless in this context.</p><p>The <span class="structname">v4l2_buffer</span> structure is 33 specified in <a class="xref" href="buffer.html" title="Buffers">the section called “Buffers”</a>.</p></div><div class="refsect1"><a name="idp1115747884"></a><h2>Return Value</h2><p>On success <span class="returnvalue">0</span> is returned, on error <span class="returnvalue">-1</span> and the <code class="varname">errno</code> variable is set appropriately. The generic error codes are described at the <a class="link" href="gen_errors.html#gen-errors" title="Table 19.1. Generic error codes">Generic Error Codes</a> chapter.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The buffer <em class="structfield"><code>type</code></em> is not 34supported, or the <em class="structfield"><code>index</code></em> is out of bounds.</p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="vidioc-qbuf.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="vidioc-querycap.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_QBUF, VIDIOC_DQBUF </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ioctl VIDIOC_QUERYCAP</td></tr></table></div></body></html> 35