Specifications
if (ioctl (fd, VIDIOCGMBUF, &videombuf) < 0) {
perror (" init VIDIOCGMBUF FAILED\n");
}
pFramebuffer = (unsigned char *) mmap (0, videombuf.size,
PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
Using VIDIOCGMBUF ioctl to get the structure of videombuf whose
structure contents are the following figure, then using the mmap for mapping
the video space to processor’s address space.
size The number of bytes to map
frames The number of frames
offsets The offset of each frame
Table 3. video_mbuf Structure Fields
Reading images loop
Using the mmap interface to read images for M318B which supports
mmap interface, the following figure shows the steps:
m
m
a
p
(
)
VIDIOCGMBUF
V
I
D
I
O
C
M
C
A
P
T
U
R
E
V
I
D
I
O
C
M
C
A
P
T
U
R
E
V
I
D
I
O
C
M
C
A
P
T
U
R
E
V
I
D
I
O
C
M
C
A
P
T
U
R
E
VIDIOCSYNC
VIDIOCSYNC
VIDIOCMCAPTURE
VIDIOCSYNC
VIDIOCMCAPTURE
Use mmap() for
mapping video frame to
kernel buffer
Let camera do
capture photo first
Use sync make
sure data was ok
Sync frame 2 and
capture frame 1
Continue to frame
4 than loop to
frame 1
Application
in user space
Driver in
kernel space
Application
in user space
Driver in
kernel space
truct
video_mbuf
Driver return 4
frames with video
buffer
1.
6.5.4.
3.2.
38