Re: ioctl parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



(this might show up twice because I sent the first one with the 
wrong identity)

On Thursday 14 February 2002 06:39 am, Esa Ikonen wrote:
> Where could I read more about the subject?

That's a really good question, and I've been meaning to ask something similar 
on this list (not about ioctl, but on the v4l api).  The short answer is 
under the kernel source tree there is a Documentation/video4linux/API.html.  
The long answer is...  well, I'd like to know myself.  I've been trying to 
get a handle on the API because I've been writing a driver in my free time, 
but the API doc is so confusing I usually give up.

I'd be really interested if someone could expand on how to stream image data 
to a memory mapped buffer.

Near as I can tell on the application side it goes something like this:

1) ioctl VIDIOCGMBUF to find the details of what kind of buffer the driver 
needs.
2) Allocate a memory buffer that size
3) Call mmap to let the driver know where to put data (I don't actually know 
how to do this, but it was there in the structure along with open, read, 
write and ioctl)
4) ioctl VIDIOCMCAPTURE to capture a frame

At that point it becomes very hazy.  All the API has to say about 
VIDIOCMCAPTURE is:

"Once the mmap has been made the VIDIOCMCAPTURE ioctl sets the image size you 
wish to use (which should match or be below the initial query size). Having 
done so it will begin capturing to the memory mapped buffer."

That's it.  It doesn't mention what kind of parameter the ioctl takes.  If 
you want to find out what it takes you need to look at the source code of 
pre-existing v4l drivers, or videodev.h.  That statement *seems* to indicate 
that a call to VIDIOCMCAPTURE will begin streaming...  but reading through 
the cpia source code, it looks as though they do not return from the 
VIDIOCMCAPTURE ioctl until it has captured a frame to the mmap.

If this does start streaming, where does the next image go?  If my driver 
supports 3 mmap frames, and I call VIDIOCMCAPTURE with frame 0 in the 
video_mmap struct, it looks like the first frame coming in from the camera 
will go into the first mmap frame.  Where will the second frame go?  Will it 
go into the bit bucket unless I have called VIDIOCSYNC on frame 0 to free it? 
 How will I know when the next streamed image is ready in the mmap?  Do I 
need to call VIDIOCMCAPTURE once per frame I want to capture?

The doc continues saying:

"Whenever a buffer is "used" by the program it should called VIDIOCSYNC to 
free this frame up and continue. to add:VIDIOCSYNC takes the frame number you 
are freeing as its argument. When the buffer is unmapped or all the buffers 
are full capture ceases."

That kind of sounds like if I call VIDIOCMCAPTURE, I get one frame and the 
driver begins capturing pictures as best it can.  If I call VIDIOCSYNC, does 
that unmap the buffer?  If not, how do I unmap the buffer if I wanted to?

I'm sure I'm missing something, I'm not very experienced with unix 
programming.  Could some kind soul let me in on the voodoo knowledge I'm 
missing here?

-Joe





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux