ADLINK Technology RTV Series User Manual page 169

Multi-channel real-time video frame grabber series
Table of Contents

Advertisement

Memory map
Memory map system call, mmap (), allows the mapping of device
memory directly into a user processor's address space. From
device viewpoint, Direct Memory Access (DMA) operations pro-
vide peripherals with direct access to system memory without
CPU processing. This can save large of time and loading that
application or driver doesn't need to move data from devices to
system memory. Here we give and example showing how to set 4
buffer queues which store video data in turn.
/* global variables */
struct buffer {
void *start;
size_t length;
};
struct buffer *buffers = NULL;
static unsigned int n_buffers = 0;
void init_mmap(void)
{
struct v4l2_requestbuffers req;
memset (&req, 0, sizeof (reg));
req.count = 4;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
if (-1 == ioctl (fd, VIDIOC_REQBUFS, &req))
{
}
if (req.count < 2) {
}
buffers = calloc (req.count, sizeof
Programming Guide
if (EINVAL == errno) {
fprintf (stderr, "%s does not
support " "memory mapping\n",
dev_name);
exit (EXIT_FAILURE);
} else {
exit (EXIT_FAILURE);
}
fprintf (stderr, "Insufficient buffer
memory on %s\n", dev_name);
exit (EXIT_FAILURE);
(*buffers));
159

Advertisement

Table of Contents
loading

Table of Contents