summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-core.c51
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c7
-rw-r--r--v4l/ChangeLog12
3 files changed, 70 insertions, 0 deletions
diff --git a/linux/drivers/media/video/em28xx/em28xx-core.c b/linux/drivers/media/video/em28xx/em28xx-core.c
index abd626d42..e2e6426eb 100644
--- a/linux/drivers/media/video/em28xx/em28xx-core.c
+++ b/linux/drivers/media/video/em28xx/em28xx-core.c
@@ -116,6 +116,48 @@ void em28xx_print_ioctl(char *name, unsigned int cmd)
}
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+static void *rvmalloc(size_t size)
+{
+ void *mem;
+ unsigned long adr;
+
+ size = PAGE_ALIGN(size);
+
+ mem = vmalloc_32((unsigned long)size);
+ if (!mem)
+ return NULL;
+
+ adr = (unsigned long)mem;
+ while (size > 0) {
+ SetPageReserved(vmalloc_to_page((void *)adr));
+ adr += PAGE_SIZE;
+ size -= PAGE_SIZE;
+ }
+
+ return mem;
+}
+
+static void rvfree(void *mem, size_t size)
+{
+ unsigned long adr;
+
+ if (!mem)
+ return;
+
+ size = PAGE_ALIGN(size);
+
+ adr = (unsigned long)mem;
+ while (size > 0) {
+ ClearPageReserved(vmalloc_to_page((void *)adr));
+ adr += PAGE_SIZE;
+ size -= PAGE_SIZE;
+ }
+
+ vfree(mem);
+}
+#endif
+
/*
* em28xx_request_buffers()
* allocate a number of buffers
@@ -131,7 +173,11 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count)
dev->num_frames = count;
while (dev->num_frames > 0) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ if ((buff = rvmalloc(dev->num_frames * imagesize))) {
+#else
if ((buff = vmalloc_32(dev->num_frames * imagesize))) {
+#endif
memset(buff, 0, dev->num_frames * imagesize);
break;
}
@@ -177,7 +223,12 @@ void em28xx_queue_unusedframes(struct em28xx *dev)
void em28xx_release_buffers(struct em28xx *dev)
{
if (dev->num_frames) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ rvfree(dev->frame[0].bufmem,
+ dev->num_frames * PAGE_ALIGN(dev->frame[0].buf.length));
+#else
vfree(dev->frame[0].bufmem);
+#endif
dev->num_frames = 0;
}
}
diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c
index 1cdf022d9..bdfa47898 100644
--- a/linux/drivers/media/video/em28xx/em28xx-video.c
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c
@@ -745,8 +745,15 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
pos = dev->frame[i].bufmem;
while (size > 0) { /* size is page-aligned */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+ unsigned long page = vmalloc_to_pfn(pos);
+ if (remap_pfn_range(vma, start, page, PAGE_SIZE,
+ vma->vm_page_prot)) {
+ em28xx_videodbg("mmap: rename page map failed\n");
+#else
if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
em28xx_videodbg("mmap: vm_insert_page failed\n");
+#endif
up(&dev->fileop_lock);
return -EAGAIN;
}
diff --git a/v4l/ChangeLog b/v4l/ChangeLog
index 2de3aa2bc..539f03fdd 100644
--- a/v4l/ChangeLog
+++ b/v4l/ChangeLog
@@ -1,3 +1,15 @@
+2005-12-05 14:41 mchehab
+
+ * linux/drivers/media/video/em28xx/em28xx-core.c: (rvmalloc),
+ (rvfree):
+ * linux/drivers/media/video/em28xx/em28xx-video.c:
+
+ - Make em28xx page alloc compatible with kernels < 2.6.15
+
+ Signed-off-by: Sascha Sommer <saschasommer@freenet.de>
+ Signed-off-by: Michael Krufky <mkrufky@m1k.net>
+ Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
+
2005-12-05 14:03 mchehab
* linux/drivers/media/video/em28xx/em28xx-core.c: