summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-12-05 14:54:22 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-12-05 14:54:22 +0000
commit48cb2dbb0a6508a5c26230aaa9ba19f2bd61869e (patch)
treeff50c10f3bb9bf5f8f5f6d845357b9d90e904108 /linux
parent1d440680a0d576fd9d332e29e6de9c40d064b502 (diff)
downloadmediapointer-dvb-s2-48cb2dbb0a6508a5c26230aaa9ba19f2bd61869e.tar.gz
mediapointer-dvb-s2-48cb2dbb0a6508a5c26230aaa9ba19f2bd61869e.tar.bz2
Make em28xx page alloc compatible with kernels < 2.6.15
From: Sascha Sommer <saschasommer@freenet.de> kernel-sync - 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>
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-core.c51
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c7
2 files changed, 58 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;
}