~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/userspace-api/media/v4l/func-mmap.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/userspace-api/media/v4l/func-mmap.rst (Architecture sparc64) and /Documentation/userspace-api/media/v4l/func-mmap.rst (Architecture mips)


  1 .. SPDX-License-Identifier: GFDL-1.1-no-invari      1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2 .. c:namespace:: V4L                                2 .. c:namespace:: V4L
  3                                                     3 
  4 .. _func-mmap:                                      4 .. _func-mmap:
  5                                                     5 
  6 ***********                                         6 ***********
  7 V4L2 mmap()                                         7 V4L2 mmap()
  8 ***********                                         8 ***********
  9                                                     9 
 10 Name                                               10 Name
 11 ====                                               11 ====
 12                                                    12 
 13 v4l2-mmap - Map device memory into application     13 v4l2-mmap - Map device memory into application address space
 14                                                    14 
 15 Synopsis                                           15 Synopsis
 16 ========                                           16 ========
 17                                                    17 
 18 .. code-block:: c                                  18 .. code-block:: c
 19                                                    19 
 20     #include <unistd.h>                            20     #include <unistd.h>
 21     #include <sys/mman.h>                          21     #include <sys/mman.h>
 22                                                    22 
 23 .. c:function:: void *mmap( void *start, size_     23 .. c:function:: void *mmap( void *start, size_t length, int prot, int flags, int fd, off_t offset )
 24                                                    24 
 25 Arguments                                          25 Arguments
 26 =========                                          26 =========
 27                                                    27 
 28 ``start``                                          28 ``start``
 29     Map the buffer to this address in the appl     29     Map the buffer to this address in the application's address space.
 30     When the ``MAP_FIXED`` flag is specified,      30     When the ``MAP_FIXED`` flag is specified, ``start`` must be a
 31     multiple of the pagesize and mmap will fai     31     multiple of the pagesize and mmap will fail when the specified
 32     address cannot be used. Use of this option     32     address cannot be used. Use of this option is discouraged;
 33     applications should just specify a ``NULL`     33     applications should just specify a ``NULL`` pointer here.
 34                                                    34 
 35 ``length``                                         35 ``length``
 36     Length of the memory area to map. This mus     36     Length of the memory area to map. This must be the same value as
 37     returned by the driver in the struct           37     returned by the driver in the struct
 38     :c:type:`v4l2_buffer` ``length`` field for     38     :c:type:`v4l2_buffer` ``length`` field for the
 39     single-planar API, and the same value as r     39     single-planar API, and the same value as returned by the driver in
 40     the struct :c:type:`v4l2_plane` ``length``     40     the struct :c:type:`v4l2_plane` ``length`` field for
 41     the multi-planar API.                          41     the multi-planar API.
 42                                                    42 
 43 ``prot``                                           43 ``prot``
 44     The ``prot`` argument describes the desire     44     The ``prot`` argument describes the desired memory protection.
 45     Regardless of the device type and the dire     45     Regardless of the device type and the direction of data exchange it
 46     should be set to ``PROT_READ`` | ``PROT_WR     46     should be set to ``PROT_READ`` | ``PROT_WRITE``, permitting read
 47     and write access to image buffers. Drivers     47     and write access to image buffers. Drivers should support at least
 48     this combination of flags.                     48     this combination of flags.
 49                                                    49 
 50     .. note::                                      50     .. note::
 51                                                    51 
 52       #. The Linux ``videobuf`` kernel module,     52       #. The Linux ``videobuf`` kernel module, which is used by some
 53          drivers supports only ``PROT_READ`` |     53          drivers supports only ``PROT_READ`` | ``PROT_WRITE``. When the
 54          driver does not support the desired p     54          driver does not support the desired protection, the
 55          :c:func:`mmap()` function fails.          55          :c:func:`mmap()` function fails.
 56                                                    56 
 57       #. Device memory accesses (e. g. the mem     57       #. Device memory accesses (e. g. the memory on a graphics card
 58          with video capturing hardware) may in     58          with video capturing hardware) may incur a performance penalty
 59          compared to main memory accesses, or      59          compared to main memory accesses, or reads may be significantly
 60          slower than writes or vice versa. Oth     60          slower than writes or vice versa. Other I/O methods may be more
 61          efficient in such case.                   61          efficient in such case.
 62                                                    62 
 63 ``flags``                                          63 ``flags``
 64     The ``flags`` parameter specifies the type     64     The ``flags`` parameter specifies the type of the mapped object,
 65     mapping options and whether modifications      65     mapping options and whether modifications made to the mapped copy of
 66     the page are private to the process or are     66     the page are private to the process or are to be shared with other
 67     references.                                    67     references.
 68                                                    68 
 69     ``MAP_FIXED`` requests that the driver sel     69     ``MAP_FIXED`` requests that the driver selects no other address than
 70     the one specified. If the specified addres     70     the one specified. If the specified address cannot be used,
 71     :c:func:`mmap()` will fail. If ``MAP_FIXED     71     :c:func:`mmap()` will fail. If ``MAP_FIXED`` is specified,
 72     ``start`` must be a multiple of the pagesi     72     ``start`` must be a multiple of the pagesize. Use of this option is
 73     discouraged.                                   73     discouraged.
 74                                                    74 
 75     One of the ``MAP_SHARED`` or ``MAP_PRIVATE     75     One of the ``MAP_SHARED`` or ``MAP_PRIVATE`` flags must be set.
 76     ``MAP_SHARED`` allows applications to shar     76     ``MAP_SHARED`` allows applications to share the mapped memory with
 77     other (e. g. child-) processes.                77     other (e. g. child-) processes.
 78                                                    78 
 79     .. note::                                      79     .. note::
 80                                                    80 
 81        The Linux ``videobuf`` module  which is     81        The Linux ``videobuf`` module  which is used by some
 82        drivers supports only ``MAP_SHARED``. `     82        drivers supports only ``MAP_SHARED``. ``MAP_PRIVATE`` requests
 83        copy-on-write semantics. V4L2 applicati     83        copy-on-write semantics. V4L2 applications should not set the
 84        ``MAP_PRIVATE``, ``MAP_DENYWRITE``, ``M     84        ``MAP_PRIVATE``, ``MAP_DENYWRITE``, ``MAP_EXECUTABLE`` or ``MAP_ANON``
 85        flags.                                      85        flags.
 86                                                    86 
 87 ``fd``                                             87 ``fd``
 88     File descriptor returned by :c:func:`open(     88     File descriptor returned by :c:func:`open()`.
 89                                                    89 
 90 ``offset``                                         90 ``offset``
 91     Offset of the buffer in device memory. Thi     91     Offset of the buffer in device memory. This must be the same value
 92     as returned by the driver in the struct        92     as returned by the driver in the struct
 93     :c:type:`v4l2_buffer` ``m`` union ``offset     93     :c:type:`v4l2_buffer` ``m`` union ``offset`` field for
 94     the single-planar API, and the same value      94     the single-planar API, and the same value as returned by the driver
 95     in the struct :c:type:`v4l2_plane` ``m`` u     95     in the struct :c:type:`v4l2_plane` ``m`` union
 96     ``mem_offset`` field for the multi-planar      96     ``mem_offset`` field for the multi-planar API.
 97                                                    97 
 98 Description                                        98 Description
 99 ===========                                        99 ===========
100                                                   100 
101 The :c:func:`mmap()` function asks to map ``le    101 The :c:func:`mmap()` function asks to map ``length`` bytes starting at
102 ``offset`` in the memory of the device specifi    102 ``offset`` in the memory of the device specified by ``fd`` into the
103 application address space, preferably at addre    103 application address space, preferably at address ``start``. This latter
104 address is a hint only, and is usually specifi    104 address is a hint only, and is usually specified as 0.
105                                                   105 
106 Suitable length and offset parameters are quer    106 Suitable length and offset parameters are queried with the
107 :ref:`VIDIOC_QUERYBUF` ioctl. Buffers must be     107 :ref:`VIDIOC_QUERYBUF` ioctl. Buffers must be
108 allocated with the :ref:`VIDIOC_REQBUFS` ioctl    108 allocated with the :ref:`VIDIOC_REQBUFS` ioctl
109 before they can be queried.                       109 before they can be queried.
110                                                   110 
111 To unmap buffers the :c:func:`munmap()` functi    111 To unmap buffers the :c:func:`munmap()` function is used.
112                                                   112 
113 Return Value                                      113 Return Value
114 ============                                      114 ============
115                                                   115 
116 On success :c:func:`mmap()` returns a pointer     116 On success :c:func:`mmap()` returns a pointer to the mapped buffer. On
117 error ``MAP_FAILED`` (-1) is returned, and the    117 error ``MAP_FAILED`` (-1) is returned, and the ``errno`` variable is set
118 appropriately. Possible error codes are:          118 appropriately. Possible error codes are:
119                                                   119 
120 EBADF                                             120 EBADF
121     ``fd`` is not a valid file descriptor.        121     ``fd`` is not a valid file descriptor.
122                                                   122 
123 EACCES                                            123 EACCES
124     ``fd`` is not open for reading and writing    124     ``fd`` is not open for reading and writing.
125                                                   125 
126 EINVAL                                            126 EINVAL
127     The ``start`` or ``length`` or ``offset``     127     The ``start`` or ``length`` or ``offset`` are not suitable. (E. g.
128     they are too large, or not aligned on a ``    128     they are too large, or not aligned on a ``PAGESIZE`` boundary.)
129                                                   129 
130     The ``flags`` or ``prot`` value is not sup    130     The ``flags`` or ``prot`` value is not supported.
131                                                   131 
132     No buffers have been allocated with the       132     No buffers have been allocated with the
133     :ref:`VIDIOC_REQBUFS` ioctl.                  133     :ref:`VIDIOC_REQBUFS` ioctl.
134                                                   134 
135 ENOMEM                                            135 ENOMEM
136     Not enough physical or virtual memory was     136     Not enough physical or virtual memory was available to complete the
137     request.                                      137     request.
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php