Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: DTV.dmx
0003 
0004 .. _dmx-mmap:
0005 
0006 *****************
0007 Digital TV mmap()
0008 *****************
0009 
0010 Name
0011 ====
0012 
0013 dmx-mmap - Map device memory into application address space
0014 
0015 .. warning:: this API is still experimental
0016 
0017 Synopsis
0018 ========
0019 
0020 .. code-block:: c
0021 
0022     #include <unistd.h>
0023     #include <sys/mman.h>
0024 
0025 .. c:function:: void *mmap( void *start, size_t length, int prot, int flags, int fd, off_t offset )
0026 
0027 Arguments
0028 =========
0029 
0030 ``start``
0031     Map the buffer to this address in the application's address space.
0032     When the ``MAP_FIXED`` flag is specified, ``start`` must be a
0033     multiple of the pagesize and mmap will fail when the specified
0034     address cannot be used. Use of this option is discouraged;
0035     applications should just specify a ``NULL`` pointer here.
0036 
0037 ``length``
0038     Length of the memory area to map. This must be a multiple of the
0039     DVB packet length (188, on most drivers).
0040 
0041 ``prot``
0042     The ``prot`` argument describes the desired memory protection.
0043     Regardless of the device type and the direction of data exchange it
0044     should be set to ``PROT_READ`` | ``PROT_WRITE``, permitting read
0045     and write access to image buffers. Drivers should support at least
0046     this combination of flags.
0047 
0048 ``flags``
0049     The ``flags`` parameter specifies the type of the mapped object,
0050     mapping options and whether modifications made to the mapped copy of
0051     the page are private to the process or are to be shared with other
0052     references.
0053 
0054     ``MAP_FIXED`` requests that the driver selects no other address than
0055     the one specified. If the specified address cannot be used,
0056     :c:func:`mmap()` will fail. If ``MAP_FIXED`` is specified,
0057     ``start`` must be a multiple of the pagesize. Use of this option is
0058     discouraged.
0059 
0060     One of the ``MAP_SHARED`` or ``MAP_PRIVATE`` flags must be set.
0061     ``MAP_SHARED`` allows applications to share the mapped memory with
0062     other (e. g. child-) processes.
0063 
0064     .. note::
0065 
0066        The Linux Digital TV applications should not set the
0067        ``MAP_PRIVATE``, ``MAP_DENYWRITE``, ``MAP_EXECUTABLE`` or ``MAP_ANON``
0068        flags.
0069 
0070 ``fd``
0071     File descriptor returned by :c:func:`open()`.
0072 
0073 ``offset``
0074     Offset of the buffer in device memory, as returned by
0075     :ref:`DMX_QUERYBUF` ioctl.
0076 
0077 Description
0078 ===========
0079 
0080 The :c:func:`mmap()` function asks to map ``length`` bytes starting at
0081 ``offset`` in the memory of the device specified by ``fd`` into the
0082 application address space, preferably at address ``start``. This latter
0083 address is a hint only, and is usually specified as 0.
0084 
0085 Suitable length and offset parameters are queried with the
0086 :ref:`DMX_QUERYBUF` ioctl. Buffers must be allocated with the
0087 :ref:`DMX_REQBUFS` ioctl before they can be queried.
0088 
0089 To unmap buffers the :c:func:`munmap()` function is used.
0090 
0091 Return Value
0092 ============
0093 
0094 On success :c:func:`mmap()` returns a pointer to the mapped buffer. On
0095 error ``MAP_FAILED`` (-1) is returned, and the ``errno`` variable is set
0096 appropriately. Possible error codes are:
0097 
0098 EBADF
0099     ``fd`` is not a valid file descriptor.
0100 
0101 EACCES
0102     ``fd`` is not open for reading and writing.
0103 
0104 EINVAL
0105     The ``start`` or ``length`` or ``offset`` are not suitable. (E. g.
0106     they are too large, or not aligned on a ``PAGESIZE`` boundary.)
0107 
0108     The ``flags`` or ``prot`` value is not supported.
0109 
0110     No buffers have been allocated with the
0111     :ref:`DMX_REQBUFS` ioctl.
0112 
0113 ENOMEM
0114     Not enough physical or virtual memory was available to complete the
0115     request.