Documentation/userspace-api/media/v4l/func-mmap.rst

Source file repositories/reference/linux-study-clean/Documentation/userspace-api/media/v4l/func-mmap.rst

File Facts

System
Linux kernel
Corpus path
Documentation/userspace-api/media/v4l/func-mmap.rst
Extension
.rst
Size
4592 bytes
Lines
138
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L

.. _func-mmap:

***********
V4L2 mmap()
***********

Name
====

v4l2-mmap - Map device memory into application address space

Synopsis
========

.. code-block:: c

    #include <unistd.h>
    #include <sys/mman.h>

.. c:function:: void *mmap( void *start, size_t length, int prot, int flags, int fd, off_t offset )

Arguments
=========

``start``
    Map the buffer to this address in the application's address space.
    When the ``MAP_FIXED`` flag is specified, ``start`` 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 ``NULL`` pointer here.

``length``
    Length of the memory area to map. This must be the same value as
    returned by the driver in the struct
    :c:type:`v4l2_buffer` ``length`` field for the
    single-planar API, and the same value as returned by the driver in
    the struct :c:type:`v4l2_plane` ``length`` field for
    the multi-planar API.

``prot``
    The ``prot`` argument describes the desired memory protection.
    Regardless of the device type and the direction of data exchange it
    should be set to ``PROT_READ`` | ``PROT_WRITE``, permitting read
    and write access to image buffers. Drivers should support at least
    this combination of flags.

    .. note::

      #. The Linux ``videobuf`` kernel module, which is used by some
	 drivers supports only ``PROT_READ`` | ``PROT_WRITE``. When the
	 driver does not support the desired protection, the
	 :c:func:`mmap()` function fails.

      #. Device memory accesses (e. 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 such case.

``flags``
    The ``flags`` 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.

    ``MAP_FIXED`` requests that the driver selects no other address than
    the one specified. If the specified address cannot be used,

Annotation

Implementation Notes