Skip to contentSkip to conversation

PATCH 2.4.0.10.6: video4linux API update, bttv mmap rewrite

PATCH Jeff Garzik 1 participant 1 message Oct 28, 2000

lore
Share & tools
lore
#0 lore raw

Thought some people here might be interested in this too... Description quoted below.

Signature · 4 lines
Jeff Garzik             | "Mind if I drive?"  -Sam
Building 1024           | "Not if you don't mind me clawing at the
MandrakeSoft            |  dash and screaming like a cheerleader."
                        |      -Max
Quoted 8 lines

This patch, against 2.4.0-test10-pre6, updates bttv to use the new and groovy method of supporting mmap.

Advantages:
* Code more simple.
* mmap now only limited to number of free pages in the system (busts vmalloc limits)
* mmap no longer requires vmalloc, or remap_page_range.

Quoted 7 lines

Disadvantages:
* Requires videodev API update (new member: mmap_vma).
* KNOWN BUG: If your gbufsize causes a frame to cross a page boundary, you lose. The code doesn't support this, and doesn't check for it either. Boom. (this is fixable though)
* Totally untested. I don't own any bttv hardware.

Index: include/linux/videodev.h
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/include/linux/videodev.h,v retrieving revision 1.1.1.1

linux/videodev.h +1 -0
diff -u -r1.1.1.1 videodev.h
@@ -32,6 +32,7 @@
 	int busy;
 	int minor;
 	devfs_handle_t devfs_handle;
+	int (*mmap_vma)(struct file *, struct vm_area_struct *, struct video_device *);
 };
 
 extern int videodev_init(void);

Index: drivers/media/video/bttv-driver.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/media/video/bttv-driver.c,v retrieving revision 1.1.1.2

media/video/bttv-driver.c +130 -124

335 lines not on this page · raw message

Index: drivers/media/video/bttv.h
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/media/video/bttv.h,v retrieving revision 1.1.1.2

media/video/bttv.h +10 -1
diff -u -r1.1.1.2 bttv.h
@@ -251,6 +251,13 @@
 	unsigned long re;
 };
 
+
+struct bttv_dma {
+	void *cpuaddr;
+	dma_addr_t handle;
+};
+
+
 struct bttv {
 	struct video_device video_dev;
 	struct video_device radio_dev;
@@ -312,7 +319,9 @@
 	struct bttv_gbuf *gbuf;
 	int gqueue[MAX_GBUFFERS];
 	int gq_in,gq_out,gq_grab,gq_start;
-        char *fbuffer;
+	
+	struct bttv_dma *page;
+	unsigned int n_pages;
 
 	struct bttv_pll_info pll;
 	unsigned int Fsc;

Index: drivers/media/video/videodev.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/media/video/videodev.c,v retrieving revision 1.1.1.1

media/video/videodev.c +3 -1
diff -u -r1.1.1.1 videodev.c
@@ -227,7 +227,9 @@
 {
 	int ret = -EINVAL;
 	struct video_device *vfl=video_device[MINOR(file->f_dentry->d_inode->i_rdev)];
-	if(vfl->mmap) {
+	if (vfl->mmap_vma)
+		return vfl->mmap_vma (file, vma, vfl);
+	if (vfl->mmap) {
 		lock_kernel();
 		ret = vfl->mmap(vfl, (char *)vma->vm_start, 
 				(unsigned long)(vma->vm_end-vma->vm_start));