Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 2c51d8eb79f8810ada971ee8c30ce1e5 > files > 2757

kernel-doc-2.6.32-71.14.1.el6.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>V4L2 mmap()</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="apa.html" title="Appendix&#160;A.&#160;Function Reference" /><link rel="prev" href="re61.html" title="ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF" /><link rel="next" href="re63.html" title="V4L2 munmap()" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">V4L2 mmap()</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re61.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="re63.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="V4L2 mmap()"><a id="func-mmap"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>v4l2-mmap &#8212; Map device memory into application address space</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">
#include &lt;unistd.h&gt;
#include &lt;sys/mman.h&gt;</pre><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void *<b class="fsfunc">mmap</b>(</code></td><td>void *<var class="pdparam">start</var>, </td></tr><tr><td>&#160;</td><td>size_t <var class="pdparam">length</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">prot</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">flags</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td>&#160;</td><td>off_t <var class="pdparam">offset</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1" title="Arguments"><a id="id2738846"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>start</code></em></span></dt><dd><p>Map the buffer to this address in the
application's address space. When the <code class="constant">MAP_FIXED</code>
flag is specified, <em class="parameter"><code>start</code></em> must be a multiple of the
pagesize and mmap will fail when the specified address
cannot be used. Use of this option is discouraged; applications should
just specify a <code class="constant">NULL</code> pointer here.</p></dd><dt><span class="term"><em class="parameter"><code>length</code></em></span></dt><dd><p>Length of the memory area to map. This must be the
same value as returned by the driver in the struct&#160;<a class="link" href="ch03s05.html#v4l2-buffer" title="Table&#160;3.1.&#160;struct v4l2_buffer">v4l2_buffer</a>
<em class="structfield"><code>length</code></em> field.</p></dd><dt><span class="term"><em class="parameter"><code>prot</code></em></span></dt><dd><p>The <em class="parameter"><code>prot</code></em> argument describes the
desired memory protection. Regardless of the device type and the
direction of data exchange it should be set to
<code class="constant">PROT_READ</code> | <code class="constant">PROT_WRITE</code>,
permitting read and write access to image buffers. Drivers should
support at least this combination of flags. Note the Linux
<code class="filename">video-buf</code> kernel module, which is used by the
bttv, saa7134, saa7146, cx88 and vivi driver supports only
<code class="constant">PROT_READ</code> | <code class="constant">PROT_WRITE</code>. When
the driver does not support the desired protection the
<code class="function">mmap()</code> function fails.</p><p>Note device memory accesses (e.&#160;g. the memory on a
graphics card with video capturing hardware) may incur a performance
penalty compared to main memory accesses, or reads may be
significantly slower than writes or vice versa. Other I/O methods may
be more efficient in this case.</p></dd><dt><span class="term"><em class="parameter"><code>flags</code></em></span></dt><dd><p>The <em class="parameter"><code>flags</code></em> parameter
specifies the type of the mapped object, mapping options and whether
modifications made to the mapped copy of the page are private to the
process or are to be shared with other references.</p><p><code class="constant">MAP_FIXED</code> requests that the
driver selects no other address than the one specified. If the
specified address cannot be used, <code class="function">mmap()</code> will fail. If
<code class="constant">MAP_FIXED</code> is specified,
<em class="parameter"><code>start</code></em> must be a multiple of the pagesize. Use
of this option is discouraged.</p><p>One of the <code class="constant">MAP_SHARED</code> or
<code class="constant">MAP_PRIVATE</code> flags must be set.
<code class="constant">MAP_SHARED</code> allows applications to share the
mapped memory with other (e.&#160;g. child-) processes. Note the Linux
<code class="filename">video-buf</code> module which is used by the bttv,
saa7134, saa7146, cx88 and vivi driver supports only
<code class="constant">MAP_SHARED</code>. <code class="constant">MAP_PRIVATE</code>
requests copy-on-write semantics. V4L2 applications should not set the
<code class="constant">MAP_PRIVATE</code>, <code class="constant">MAP_DENYWRITE</code>,
<code class="constant">MAP_EXECUTABLE</code> or <code class="constant">MAP_ANON</code>
flag.</p></dd><dt><span class="term"><em class="parameter"><code>fd</code></em></span></dt><dd><p>File descriptor returned by <a class="link" href="re64.html" title="V4L2 open()"><code class="function">open()</code></a>.</p></dd><dt><span class="term"><em class="parameter"><code>offset</code></em></span></dt><dd><p>Offset of the buffer in device memory. This must be the
same value as returned by the driver in the struct&#160;<a class="link" href="ch03s05.html#v4l2-buffer" title="Table&#160;3.1.&#160;struct v4l2_buffer">v4l2_buffer</a>
<em class="structfield"><code>m</code></em> union <em class="structfield"><code>offset</code></em> field.</p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2739138"></a><h2>Description</h2><p>The <code class="function">mmap()</code> function asks to map
<em class="parameter"><code>length</code></em> bytes starting at
<em class="parameter"><code>offset</code></em> in the memory of the device specified by
<em class="parameter"><code>fd</code></em> into the application address space,
preferably at address <em class="parameter"><code>start</code></em>. This latter
address is a hint only, and is usually specified as 0.</p><p>Suitable length and offset parameters are queried with the
<a class="link" href="re55.html" title="ioctl VIDIOC_QUERYBUF"><code class="constant">VIDIOC_QUERYBUF</code></a> ioctl. Buffers must be allocated with the
<a class="link" href="re59.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> ioctl before they can be queried.</p><p>To unmap buffers the <a class="link" href="re63.html" title="V4L2 munmap()"><code class="function">munmap()</code></a> function is used.</p></div><div class="refsect1" title="Return Value"><a id="id2739214"></a><h2>Return Value</h2><p>On success <code class="function">mmap()</code> returns a pointer to
the mapped buffer. On error <code class="constant">MAP_FAILED</code> (-1) is
returned, and the <code class="varname">errno</code> variable is set
appropriately. Possible error codes are:</p><div class="variablelist"><dl><dt><span class="term"><span class="errorcode">EBADF</span></span></dt><dd><p><em class="parameter"><code>fd</code></em> is not a valid file
descriptor.</p></dd><dt><span class="term"><span class="errorcode">EACCES</span></span></dt><dd><p><em class="parameter"><code>fd</code></em> is
not open for reading and writing.</p></dd><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The <em class="parameter"><code>start</code></em> or
<em class="parameter"><code>length</code></em> or <em class="parameter"><code>offset</code></em> are not
suitable. (E.&#160;g. they are too large, or not aligned on a
<code class="constant">PAGESIZE</code> boundary.)</p><p>The <em class="parameter"><code>flags</code></em> or
<em class="parameter"><code>prot</code></em> value is not supported.</p><p>No buffers have been allocated with the
<a class="link" href="re59.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> ioctl.</p></dd><dt><span class="term"><span class="errorcode">ENOMEM</span></span></dt><dd><p>Not enough physical or virtual memory was available to
complete the request.</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="re61.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="apa.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="re63.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;V4L2 munmap()</td></tr></table></div></body></html>