On Wed, Apr 25, 2001 at 07:47:30PM -0700, Bill Dirks wrote: > Gerd Knorr wrote: > > bttv gives you a just a shared anonymous mapping, and the kernel > > vm will allocate and map these pages on use. It is normal userspace > > memory, it is _not_ unswappable kernel memory remapped to userspace. > > How do you do this? This is what the vm does by default, unless you remap stuff at mmap() time or register your own nopage() handler. bttv just does some sanity checks for the mmap() parameters and updates its internal data structures. > Does the memory appear contiguous to the driver? Virtual memory (userspace view) is linear, physical memory is fragmented. bttv doesn't care btw, it never touches the buffer memory directly. It only needs the bus addresses returned by pci_map_sg to build the bt848 risc programs. Bus addresses are fragmented too. > Can the driver create a buffer this way for its own internal use, No. It's userspace memory, not kernel memory. Any reason why I should allocate a buffer for internal use? > or does it not exist until the user calls mmap()? It is created by the mmap() call. And it is specific to the file handle. Another process opening /dev/video too will not share the buffer memory, but will get it's own memory chunk. > > The problem I see here is that there are many different ways to handle > > mmap(). I don't think there is a reasonable way to hide v4l1 and v4l2 > > style mmap() differences in the compatibility layer. That's why I'd > > like handle v4l2 the same way as v4l1, so the drivers don't need to > > handle both. > > V4L2 has this generalized stream concept, and a driver can have multiple > streams that are set up independently. There's no way a single mmap() > call will suffice. How do I setup a second, independent stream? Maybe I've missed something, but I think you can't do that without a second file handle. In which case there is no problem -- you can have one mapping per file handle. Gerd