Google
  Web www.spinics.net

Re: Where does m.offset point to?

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


Well, I think I figured this out, so I'm responding to myself so that some sort of response will be in the archives.

In response to VIDIOC_REQBUFS I map a single chunk of memory with vmalloc.
The size is important so I establish the frame size and then use PAGE_ALIGN to get the memory allocation required for each buffer. So the call to vmalloc is something like...


iFrameSizePage = PAGE_ALIGN(iFrameSize);
pcFrameBufferStart = (char *)vmalloc(iFrameCount * iFrameSizePage);

At the same time I create a list of struct v4l2_buffer. For each v4l2_buffer I initialise the .m.offset equal to the number of bytes away from the start of the allocated memory. Something like..

for(i=0;i<iFrameCount;i++){
   pxBufferList[i].m.offset = i * iFrameSizePage;
}

For the mmap functions, I'm using a nopage function taken from Rubini's book (page 395, scullv) which takes a virtual page address and then searches the page table.

It works quite well, but I designed my embedded system before I started to do video and boy... image frames take a lot of memory!

If anyone sees an error in what I've written, please let me know.

Joshua


Joshua Lamorie wrote:

Gidday there,

I'm building a Video4Linux driver for some proprietary hardware (interface to a CMOS sensor).

My initial driver was only doing read/write access, and now I want to get the memory mapped stuff going.

I have been looking at the example stuff in video-buf.[ch] but it seems to do a bit more than I need. I don't have PCI, I'm not doing DMA and the driver stores the frames in system memory (as opposed to in the device).

I'm a little confused about what to do for v4l2_buffer.m.offset while responding to VIDIOC_REQBUFS.

I have my buffers each allocated as
pxBufList[i] = (struct v4l2_buffer *)kmalloc(iPageAlignedBufSize,GFP_KERNEL)


but I'm not sure what to do with
pxBufList[i].m.offset

As far as I understand, I need to have this set to something so that when the application does VIDIOC_QUERYBUF m.offset has something useful to pass to mmap.

Any hints to a simpler implementation of this?

Thanks

Joshua



--

Xiphos Technologies
(514) 848-9640 x227
(514) 848-9644 fax

www.xiplink.com
_______________________________________________
The information transmitted is intended only for the
person or entity to which it is addressed and may contain
confidential and/or privileged material.  If you have
received this in error, please contact the sender and delete
this communication and any copy immediately. Thank you.

--

Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

[Home]     [Older V4L]     [Linux DVB]     [Video Disk Recorder]     [Video Technology]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Plasma TVs]     [Video Projectors]     [PDAs]     [Xorg]     [Util Linux NG]     [Xfree86]     [Devices]     [Big List of Linux Books]     [Free Photo Albums]     [LCD TVs]     [Fedora Users]     [Webcams]     [Fedora Women]     [HDTV]     [ALSA Users]     [ALSA Devel]     [Stuff]     [SSH]     [Linux USB]

Powered by Linux

Google PageRank Checking tool