3.2.5. Digital TV mmap()¶
dmx-mmap - Map device memory into application address space
this API is still experimental
#include <unistd.h> #include <sys/mman.h>
mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)¶
Map the buffer to this address in the application’s address space. When the
MAP_FIXEDflag is specified,
startmust 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
Length of the memory area to map. This must be a multiple of the DVB packet length (188, on most drivers).
protargument describes the desired memory protection. Regardless of the device type and the direction of data exchange it should be set to
PROT_WRITE, permitting read and write access to image buffers. Drivers should support at least this combination of flags.
flagsparameter 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_FIXEDrequests that the driver selects no other address than the one specified. If the specified address cannot be used,
mmap()will fail. If
startmust be a multiple of the pagesize. Use of this option is discouraged.
One of the
MAP_PRIVATEflags must be set.
MAP_SHAREDallows applications to share the mapped memory with other (e. g. child-) processes.
The Linux Digital TV applications should not set the
File descriptor returned by
Offset of the buffer in device memory, as returned by ioctl DMX_QUERYBUF ioctl.
mmap() function asks to map
length bytes starting at
offset in the memory of the device specified by
fd into the
application address space, preferably at address
start. This latter
address is a hint only, and is usually specified as 0.
To unmap buffers the
munmap() function is used.
188.8.131.52. Return Value¶
mmap() returns a pointer to the mapped buffer. On
MAP_FAILED (-1) is returned, and the
errno variable is set
appropriately. Possible error codes are:
fdis not a valid file descriptor.
fdis not open for reading and writing.
offsetare not suitable. (E. g. they are too large, or not aligned on a
protvalue is not supported.
No buffers have been allocated with the ioctl DMX_REQBUFS ioctl.
Not enough physical or virtual memory was available to complete the request.