summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2002-11-07 19:40:48 +0000
committerHolger Waechtler <devnull@localhost>2002-11-07 19:40:48 +0000
commitecdaecc3faa0526b4c80c4f1759a3b1be04d2546 (patch)
treef9674a161dd99c8a4c2b266a5101695e954dcb4f /linux/drivers/media
parent81e8895d0b64c877036853a5dbd8f9b1ba564364 (diff)
downloadmediapointer-dvb-s2-ecdaecc3faa0526b4c80c4f1759a3b1be04d2546.tar.gz
mediapointer-dvb-s2-ecdaecc3faa0526b4c80c4f1759a3b1be04d2546.tar.bz2
2.4 compatibility crap
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/dvb/av7110/av7110.c69
-rw-r--r--linux/drivers/media/dvb/dvb-core/compat.c91
-rw-r--r--linux/drivers/media/dvb/dvb-core/compat.h31
3 files changed, 181 insertions, 10 deletions
diff --git a/linux/drivers/media/dvb/av7110/av7110.c b/linux/drivers/media/dvb/av7110/av7110.c
index a18e45f80..5be8265ad 100644
--- a/linux/drivers/media/dvb/av7110/av7110.c
+++ b/linux/drivers/media/dvb/av7110/av7110.c
@@ -2819,12 +2819,9 @@ void p_to_t(u8 const *buf, long int length, u16 pid, u8 *counter,
* V4L SECTION
****************************************************************************/
-static int dvb_do_ioctl (struct inode *inode, struct file *file,
- unsigned int cmd, void *arg)
+static
+int av7110_video_ioctl (struct av7110_s *av7110, unsigned int cmd, void *arg)
{
- struct video_device *dev = video_devdata (file);
- av7110_t *av7110 = dev->priv;
-
switch (cmd) {
case VIDIOCGCAP:
{
@@ -2832,7 +2829,7 @@ static int dvb_do_ioctl (struct inode *inode, struct file *file,
dprintk(KERN_ERR "dvb: VIDIOCGCAP called\n");
- strcpy(b->name, &dev->name[0]);
+ strcpy(b->name, "DVB Board");
b->type = av7110->video.type;
@@ -3124,14 +3121,57 @@ static int dvb_do_ioctl (struct inode *inode, struct file *file,
}
-static int dvb_ioctl (struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
+
+static
+int dvb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
+{
+ return av7110_video_ioctl (dev->priv, cmd, arg);
+}
+
+
+#else
+
+
+static
+int dvb_do_ioctl (struct inode *inode, struct file *file,
+ unsigned int cmd, void *arg)
+{
+ struct video_device *dev = video_devdata (file);
+ return av7110_video_ioctl (dev->priv, cmd, arg);
+}
+
+
+static
+int dvb_ioctl (struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
{
return video_usercopy(inode, file, cmd, arg, dvb_do_ioctl);
}
+#endif
-static int dvb_mmap(struct file* file, struct vm_area_struct *vma)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
+static
+int dvb_mmap(struct video_device *dev, const char *adr, unsigned long size)
+{
+ struct av7110_s *av7110 = dev->priv;
+ struct vm_area_struct vma;
+
+ vma.vm_start = (unsigned long) adr;
+ vma.vm_end = vma.vm_start + size;
+
+ if (saacomm(SAA7146_DO_MMAP, &vma)) {
+ printk(KERN_ERR "av7110: dvb_mmap failed!\n");
+ return -1;
+ }
+
+ return 0;
+}
+#else
+static
+int dvb_mmap(struct file* file, struct vm_area_struct *vma)
{
struct video_device *dev = video_devdata (file);
av7110_t *av7110 = dev->priv;
@@ -3146,9 +3186,11 @@ static int dvb_mmap(struct file* file, struct vm_area_struct *vma)
return 0;
}
+#endif
-static unsigned int dvb_audio_poll(struct file *file, poll_table *wait)
+static
+unsigned int dvb_audio_poll(struct file *file, poll_table *wait)
{
struct dvb_device *dvbdev=(struct dvb_device *) file->private_data;
av7110_t *av7110=(av7110_t *) dvbdev->priv;
@@ -3169,11 +3211,13 @@ static unsigned int dvb_audio_poll(struct file *file, poll_table *wait)
}
+#if !(LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45))
static struct file_operations dvb_fops = {
.ioctl = dvb_ioctl,
.mmap = dvb_mmap,
.llseek = no_llseek
};
+#endif
/* template for video_device-structure */
@@ -3187,7 +3231,12 @@ static struct video_device dvb_template = {
VID_TYPE_FRAMERAM |
VID_TYPE_SCALES,
.hardware = VID_HARDWARE_SAA7146,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
+ .ioctl = dvb_ioctl,
+ .mmap = dvb_mmap,
+#else
.fops = &dvb_fops
+#endif
};
diff --git a/linux/drivers/media/dvb/dvb-core/compat.c b/linux/drivers/media/dvb/dvb-core/compat.c
new file mode 100644
index 000000000..af33c58b7
--- /dev/null
+++ b/linux/drivers/media/dvb/dvb-core/compat.c
@@ -0,0 +1,91 @@
+#include <linux/slab.h>
+#include "compat.h"
+
+/**
+ * compatibility crap for old kernels. No guarantee for a working driver
+ * even when everything compiles.
+ */
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)) || !CONFIG_VIDEO_DEV
+int generic_usercopy(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg,
+ int (*func)(struct inode *inode, struct file *file,
+ unsigned int cmd, void *arg))
+{
+ char sbuf[128];
+ void *mbuf = NULL;
+ void *parg = NULL;
+ int err = -EINVAL;
+
+ /* Copy arguments into temp kernel buffer */
+ switch (_IOC_DIR(cmd)) {
+ case _IOC_NONE:
+ parg = (void *)arg;
+ break;
+ case _IOC_READ: /* some v4l ioctls are marked wrong ... */
+ case _IOC_WRITE:
+ case (_IOC_WRITE | _IOC_READ):
+ if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
+ parg = sbuf;
+ } else {
+ /* too big to allocate from stack */
+ mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
+ if (NULL == mbuf)
+ return -ENOMEM;
+ parg = mbuf;
+ }
+
+ err = -EFAULT;
+ if (copy_from_user(parg, (void *)arg, _IOC_SIZE(cmd)))
+ goto out;
+ break;
+ }
+
+ /* call driver */
+ if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
+ err = -EINVAL;
+
+ if (err < 0)
+ goto out;
+
+ /* Copy results into user buffer */
+ switch (_IOC_DIR(cmd))
+ {
+ case _IOC_READ:
+ case (_IOC_WRITE | _IOC_READ):
+ if (copy_to_user((void *)arg, parg, _IOC_SIZE(cmd)))
+ err = -EFAULT;
+ break;
+ }
+
+out:
+ if (mbuf)
+ kfree(mbuf);
+
+ return err;
+}
+#endif
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45))
+struct page * vmalloc_to_page(void *vmalloc_addr)
+{
+ unsigned long addr = (unsigned long) vmalloc_addr;
+ struct page *page = NULL;
+ pgd_t *pgd = pgd_offset_k(addr);
+ pmd_t *pmd;
+ pte_t *ptep, pte;
+
+ if (!pgd_none(*pgd)) {
+ pmd = pmd_offset(pgd, addr);
+ if (!pmd_none(*pmd)) {
+ ptep = pte_offset(pmd, addr);
+ pte = *ptep;
+ if (pte_present(pte))
+ page = pte_page(pte);
+ }
+ }
+ return page;
+}
+#endif
+
diff --git a/linux/drivers/media/dvb/dvb-core/compat.h b/linux/drivers/media/dvb/dvb-core/compat.h
index 25af8145b..33f30145c 100644
--- a/linux/drivers/media/dvb/dvb-core/compat.h
+++ b/linux/drivers/media/dvb/dvb-core/compat.h
@@ -9,16 +9,47 @@
#include <linux/module.h>
#include <linux/list.h>
+#include <linux/videodev.h>
+
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(x)
#endif
+
#ifndef list_for_each_safe
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)) || !CONFIG_VIDEO_DEV
+#define video_usercopy generic_usercopy
+
+extern int generic_usercopy(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg,
+ int (*func)(struct inode *inode, struct file *file,
+ unsigned int cmd, void *arg));
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
+
+#define video_devdata(dev) (dev->priv)
+
+static inline
+void cond_resched (void)
+{
+ if (current->need_resched)
+ schedule();
+}
+
+extern struct page * vmalloc_to_page(void *addr);
+
+#define remap_page_range(vma,from,to,size,prot) \
+ remap_page_range(from,to,size,prot)
+
+#endif
+
#endif