1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
19 dmx-mmap - Map device memory into application address space
21 .. warning:: this API is still experimental
32 .. c:function:: void *mmap( void *start, size_t length, int prot, int flags, int fd, off_t offset )
39 Map the buffer to this address in the application's address space.
40 When the ``MAP_FIXED`` flag is specified, ``start`` must be a
41 multiple of the pagesize and mmap will fail when the specified
42 address cannot be used. Use of this option is discouraged;
43 applications should just specify a ``NULL`` pointer here.
46 Length of the memory area to map. This must be a multiple of the
47 DVB packet length (188, on most drivers).
50 The ``prot`` argument describes the desired memory protection.
51 Regardless of the device type and the direction of data exchange it
52 should be set to ``PROT_READ`` | ``PROT_WRITE``, permitting read
53 and write access to image buffers. Drivers should support at least
54 this combination of flags.
57 The ``flags`` parameter specifies the type of the mapped object,
58 mapping options and whether modifications made to the mapped copy of
59 the page are private to the process or are to be shared with other
62 ``MAP_FIXED`` requests that the driver selects no other address than
63 the one specified. If the specified address cannot be used,
64 :ref:`mmap() <dmx-mmap>` will fail. If ``MAP_FIXED`` is specified,
65 ``start`` must be a multiple of the pagesize. Use of this option is
68 One of the ``MAP_SHARED`` or ``MAP_PRIVATE`` flags must be set.
69 ``MAP_SHARED`` allows applications to share the mapped memory with
70 other (e. g. child-) processes.
74 The Linux Digital TV applications should not set the
75 ``MAP_PRIVATE``, ``MAP_DENYWRITE``, ``MAP_EXECUTABLE`` or ``MAP_ANON``
79 File descriptor returned by :ref:`open() <dmx_fopen>`.
82 Offset of the buffer in device memory, as returned by
83 :ref:`DMX_QUERYBUF` ioctl.
89 The :ref:`mmap() <dmx-mmap>` function asks to map ``length`` bytes starting at
90 ``offset`` in the memory of the device specified by ``fd`` into the
91 application address space, preferably at address ``start``. This latter
92 address is a hint only, and is usually specified as 0.
94 Suitable length and offset parameters are queried with the
95 :ref:`DMX_QUERYBUF` ioctl. Buffers must be allocated with the
96 :ref:`DMX_REQBUFS` ioctl before they can be queried.
98 To unmap buffers the :ref:`munmap() <dmx-munmap>` function is used.
104 On success :ref:`mmap() <dmx-mmap>` returns a pointer to the mapped buffer. On
105 error ``MAP_FAILED`` (-1) is returned, and the ``errno`` variable is set
106 appropriately. Possible error codes are:
109 ``fd`` is not a valid file descriptor.
112 ``fd`` is not open for reading and writing.
115 The ``start`` or ``length`` or ``offset`` are not suitable. (E. g.
116 they are too large, or not aligned on a ``PAGESIZE`` boundary.)
118 The ``flags`` or ``prot`` value is not supported.
120 No buffers have been allocated with the
121 :ref:`DMX_REQBUFS` ioctl.
124 Not enough physical or virtual memory was available to complete the