Sophie

Sophie

distrib > Fedora > 18 > x86_64 > media > updates > by-pkgid > 1a595394b241504ff370a8d12ebfcea7 > files > 3820

kernel-doc-3.11.10-100.fc18.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>ioctl VIDIOC_EXPBUF</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&#160;A.&#160;Function Reference" /><link rel="prev" href="vidioc-enumstd.html" title="ioctl VIDIOC_ENUMSTD" /><link rel="next" href="vidioc-g-audio.html" title="ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ioctl VIDIOC_EXPBUF</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-enumstd.html">Prev</a>&#160;</td><th width="60%" align="center">Appendix&#160;A.&#160;Function Reference</th><td width="20%" align="right">&#160;<a accesskey="n" href="vidioc-g-audio.html">Next</a></td></tr></table><hr /></div><div class="refentry"><a id="vidioc-expbuf"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_EXPBUF &#8212; Export a buffer as a DMABUF file descriptor.</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 <strong class="fsfunc">ioctl</strong>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">request</var>, </td></tr><tr><td>&#160;</td><td>struct v4l2_exportbuffer *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a id="idm140470009647088"></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_EXPBUF</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 id="idm140470009638960"></a><h2>Description</h2><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Experimental</h3><p>This is an <a class="link" href="hist-v4l2.html#experimental" title="Experimental API Elements"> experimental </a>
      interface and may change in the future.</p></div><p>This ioctl is an extension to the <a class="link" href="mmap.html" title="Streaming I/O (Memory Mapping)">memory
mapping</a> I/O method, therefore it is available only for
<code class="constant">V4L2_MEMORY_MMAP</code> buffers.  It can be used to export a
buffer as a DMABUF file at any time after buffers have been allocated with the
<a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> ioctl.</p><p> To export a buffer, applications fill struct&#160;<a class="link" href="vidioc-expbuf.html#v4l2-exportbuffer" title="Table&#160;A.46.&#160;struct v4l2_exportbuffer">v4l2_exportbuffer</a>.  The
<em class="structfield"><code> type </code></em> field is set to the same buffer type as was
previously used with  struct&#160;<a class="link" href="vidioc-reqbufs.html#v4l2-requestbuffers" title="Table&#160;A.94.&#160;struct v4l2_requestbuffers">v4l2_requestbuffers</a><em class="structfield"><code> type </code></em>.
Applications must also set the <em class="structfield"><code> index </code></em> field. Valid
index numbers range from zero to the number of buffers allocated with
<a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> (struct&#160;<a class="link" href="vidioc-reqbufs.html#v4l2-requestbuffers" title="Table&#160;A.94.&#160;struct v4l2_requestbuffers">v4l2_requestbuffers</a><em class="structfield"><code> count </code></em>)
minus one.  For the multi-planar API, applications set the <em class="structfield"><code> plane
</code></em> field to the index of the plane to be exported. Valid planes
range from zero to the maximal number of valid planes for the currently active
format. For the single-planar API, applications must set <em class="structfield"><code> plane
</code></em> to zero.  Additional flags may be posted in the <em class="structfield"><code>
flags </code></em> field.  Refer to a manual for open() for details.
Currently only O_CLOEXEC is supported.  All other fields must be set to zero.
In the case of multi-planar API, every plane is exported separately using
multiple <code class="constant"> VIDIOC_EXPBUF </code> calls. </p><p> After calling <code class="constant">VIDIOC_EXPBUF</code> the <em class="structfield"><code> fd
</code></em> field will be set by a driver.  This is a DMABUF file
descriptor. The application may pass it to other DMABUF-aware devices. Refer to
<a class="link" href="dmabuf.html" title="Streaming I/O (DMA buffer importing)">DMABUF importing</a> for details about importing
DMABUF files into V4L2 nodes. It is recommended to close a DMABUF file when it
is no longer used to allow the associated memory to be reclaimed. </p></div><div class="refsect1"><a id="idm140470009622976"></a><h2>Examples</h2><div class="example"><a id="idm140470009622304"></a><p class="title"><strong>Example&#160;A.1.&#160;Exporting a buffer.</strong></p><div class="example-contents"><pre class="programlisting">
int buffer_export(int v4lfd, enum&#160;<a class="link" href="buffer.html#v4l2-buf-type" title="Table&#160;3.3.&#160;enum v4l2_buf_type">v4l2_buf_type</a> bt, int index, int *dmafd)
{
	struct&#160;<a class="link" href="vidioc-expbuf.html#v4l2-exportbuffer" title="Table&#160;A.46.&#160;struct v4l2_exportbuffer">v4l2_exportbuffer</a> expbuf;

	memset(&amp;expbuf, 0, sizeof(expbuf));
	expbuf.type = bt;
	expbuf.index = index;
	if (ioctl(v4lfd, <a class="link" href="vidioc-expbuf.html" title="ioctl VIDIOC_EXPBUF"><code class="constant">VIDIOC_EXPBUF</code></a>, &amp;expbuf) == -1) {
		perror("VIDIOC_EXPBUF");
		return -1;
	}

	*dmafd = expbuf.fd;

	return 0;
}
      </pre></div></div><br class="example-break" /><div class="example"><a id="idm140470009617872"></a><p class="title"><strong>Example&#160;A.2.&#160;Exporting a buffer using the multi-planar API.</strong></p><div class="example-contents"><pre class="programlisting">
int buffer_export_mp(int v4lfd, enum&#160;<a class="link" href="buffer.html#v4l2-buf-type" title="Table&#160;3.3.&#160;enum v4l2_buf_type">v4l2_buf_type</a> bt, int index,
	int dmafd[], int n_planes)
{
	int i;

	for (i = 0; i &lt; n_planes; ++i) {
		struct&#160;<a class="link" href="vidioc-expbuf.html#v4l2-exportbuffer" title="Table&#160;A.46.&#160;struct v4l2_exportbuffer">v4l2_exportbuffer</a> expbuf;

		memset(&amp;expbuf, 0, sizeof(expbuf));
		expbuf.type = bt;
		expbuf.index = index;
		expbuf.plane = i;
		if (ioctl(v4lfd, <a class="link" href="vidioc-expbuf.html" title="ioctl VIDIOC_EXPBUF"><code class="constant">VIDIOC_EXPBUF</code></a>, &amp;expbuf) == -1) {
			perror("VIDIOC_EXPBUF");
			while (i)
				close(dmafd[--i]);
			return -1;
		}
		dmafd[i] = expbuf.fd;
	}

	return 0;
}
      </pre></div></div><br class="example-break" /><div class="table"><a id="v4l2-exportbuffer"></a><p class="title"><strong>Table&#160;A.46.&#160;struct <span class="structname">v4l2_exportbuffer</span></strong></p><div class="table-contents"><table summary="struct v4l2_exportbuffer" width="100%" border="0"><colgroup><col class="c1" /><col class="c2" /><col class="c3" /></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>type</code></em></td><td valign="top">Type of the buffer, same as struct&#160;<a class="link" href="vidioc-g-fmt.html#v4l2-format" title="Table&#160;A.67.&#160;struct v4l2_format">v4l2_format</a>
<em class="structfield"><code>type</code></em> or struct&#160;<a class="link" href="vidioc-reqbufs.html#v4l2-requestbuffers" title="Table&#160;A.94.&#160;struct v4l2_requestbuffers">v4l2_requestbuffers</a>
<em class="structfield"><code>type</code></em>, set by the application. See <a class="xref" href="buffer.html#v4l2-buf-type" title="Table&#160;3.3.&#160;enum v4l2_buf_type">Table&#160;3.3, &#8220;enum v4l2_buf_type&#8221;</a></td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>index</code></em></td><td valign="top">Number of the buffer, set by the application. This field is
only used for <a class="link" href="mmap.html" title="Streaming I/O (Memory Mapping)">memory mapping</a> I/O and can range from
zero to the number of buffers allocated with the <a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> and/or
<a class="link" href="vidioc-create-bufs.html" title="ioctl VIDIOC_CREATE_BUFS"><code class="constant">VIDIOC_CREATE_BUFS</code></a> ioctls. </td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>plane</code></em></td><td valign="top">Index of the plane to be exported when using the
multi-planar API. Otherwise this value must be set to zero. </td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>flags</code></em></td><td valign="top">Flags for the newly created file, currently only <code class="constant">
O_CLOEXEC </code> is supported, refer to the manual of open() for more
details.</td></tr><tr><td valign="top">__s32</td><td valign="top"><em class="structfield"><code>fd</code></em></td><td valign="top">The DMABUF file descriptor associated with a buffer. Set by
		the driver.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>reserved[11]</code></em></td><td valign="top">Reserved field for future use. Must be set to zero.</td></tr></tbody></table></div></div><br class="table-break" /></div><div class="refsect1"><a id="idm140470009590272"></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&#160;19.1.&#160;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>A queue is not in MMAP mode or DMABUF exporting is not
supported or <em class="structfield"><code> flags </code></em> or <em class="structfield"><code> type
</code></em> or <em class="structfield"><code> index </code></em> or <em class="structfield"><code> plane
</code></em> fields are invalid.</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-enumstd.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="vidioc-g-audio.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_ENUMSTD&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO</td></tr></table></div></body></html>