vserver 2.0 rc7
[linux-2.6.git] / drivers / usb / media / pwc / pwc-if.c
index d5c4f24..b77e65c 100644 (file)
@@ -68,8 +68,6 @@
 #include "pwc-ioctl.h"
 #include "pwc-kiara.h"
 #include "pwc-timon.h"
-#include "pwc-dec23.h"
-#include "pwc-dec1.h"
 #include "pwc-uncompress.h"
 
 /* Function prototypes and driver templates */
@@ -129,7 +127,7 @@ static int default_mbufs = 2;       /* Default number of mmap() buffers */
        int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX;
 static int power_save = 0;
 static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */
-       int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */
+static int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */
 static struct {
        int type;
        char serial_number[30];
@@ -141,7 +139,7 @@ static struct {
 
 static int pwc_video_open(struct inode *inode, struct file *file);
 static int pwc_video_close(struct inode *inode, struct file *file);
-static ssize_t pwc_video_read(struct file *file, char *buf,
+static ssize_t pwc_video_read(struct file *file, char __user * buf,
                          size_t count, loff_t *ppos);
 static unsigned int pwc_video_poll(struct file *file, poll_table *wait);
 static int  pwc_video_ioctl(struct inode *inode, struct file *file,
@@ -272,7 +270,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
                return -ENXIO;
        }
 #endif 
-       /* Allocate Isochronuous pipe buffers */
+       /* Allocate Isochronous pipe buffers */
        for (i = 0; i < MAX_ISO_BUFS; i++) {
                if (pdev->sbuf[i].data == NULL) {
                        kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL);
@@ -322,7 +320,8 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
          case 730:
          case 740:
          case 750:
-           Trace(TRACE_MEMORY,"private_data(%d)\n",sizeof(struct pwc_dec23_private));
+#if 0    
+           Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
            kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);       /* Timon & Kiara */
            break;
          case 645:
@@ -330,11 +329,9 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
            /* TODO & FIXME */
            kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
            break;
+#endif  
+       ;
         }
-       if (kbuf == NULL) {
-          Err("Failed to allocate decompress table.\n");
-          return -ENOMEM;
-       }
        pdev->decompress_data = kbuf;
        
        /* Allocate image buffer; double buffer for mmap() */
@@ -618,7 +615,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
        int i, fst, flen;
        int awake;
        struct pwc_frame_buf *fbuf;
-       unsigned char *fillptr = 0, *iso_buf = 0;
+       unsigned char *fillptr = NULL, *iso_buf = NULL;
 
        awake = 0;
        pdev = (struct pwc_device *)urb->context;
@@ -844,13 +841,13 @@ static int pwc_isoc_init(struct pwc_device *pdev)
        pdev->vmax_packet_size = -1;
        for (i = 0; i < idesc->desc.bNumEndpoints; i++)
                if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) {
-                       pdev->vmax_packet_size = idesc->endpoint[i].desc.wMaxPacketSize;
+                       pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize);
                        break;
                }
        
        if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
                Err("Failed to find packet size for video endpoint in current alternate setting.\n");
-               return -ENFILE; /* Odd error, that should be noticable */
+               return -ENFILE; /* Odd error, that should be noticeable */
        }
 
        /* Set alternate interface */
@@ -932,7 +929,7 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev)
                if (urb != 0) {
                        if (pdev->iso_init) {
                                Trace(TRACE_MEMORY, "Unlinking URB %p\n", urb);
-                               usb_unlink_urb(urb);
+                               usb_kill_urb(urb);
                        }
                        Trace(TRACE_MEMORY, "Freeing URB\n");
                        usb_free_urb(urb);
@@ -1131,11 +1128,11 @@ static int pwc_video_close(struct inode *inode, struct file *file)
          case 730:
          case 740:
          case 750:
-           pwc_dec23_exit();   /* Timon & Kiara */
+/*         pwc_dec23_exit();   *//* Timon & Kiara */
            break;
          case 645:
          case 646:
-           pwc_dec1_exit();
+/*         pwc_dec1_exit(); */
            break;
         }
 
@@ -1170,7 +1167,7 @@ static int pwc_video_close(struct inode *inode, struct file *file)
                 device is tricky anyhow.
  */
 
-static ssize_t pwc_video_read(struct file *file, char *buf,
+static ssize_t pwc_video_read(struct file *file, char __user * buf,
                          size_t count, loff_t *ppos)
 {
        struct video_device *vdev = file->private_data;
@@ -1179,7 +1176,7 @@ static ssize_t pwc_video_read(struct file *file, char *buf,
        DECLARE_WAITQUEUE(wait, current);
         int bytes_to_read;
 
-       Trace(TRACE_READ, "video_read(0x%p, %p, %d) called.\n", vdev, buf, count);
+       Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count);
        if (vdev == NULL)
                return -EFAULT;
        pdev = vdev->priv;
@@ -1619,8 +1616,8 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma)
 
        pos = (unsigned long)pdev->image_data;
        while (size > 0) {
-               page = kvirt_to_pa(pos);
-               if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
+               page = vmalloc_to_pfn((void *)pos);
+               if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
                        return -EAGAIN;
 
                start += PAGE_SIZE;
@@ -1653,7 +1650,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
 
        /* Check if we can handle this device */
        Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", 
-               udev->descriptor.idVendor, udev->descriptor.idProduct, 
+               le16_to_cpu(udev->descriptor.idVendor),
+               le16_to_cpu(udev->descriptor.idProduct),
                intf->altsetting->desc.bInterfaceNumber);
 
        /* the interfaces are probed one by one. We are only interested in the
@@ -1663,8 +1661,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
        if (intf->altsetting->desc.bInterfaceNumber > 0)
                return -ENODEV;
 
-       vendor_id = udev->descriptor.idVendor;
-       product_id = udev->descriptor.idProduct;
+       vendor_id = le16_to_cpu(udev->descriptor.idVendor);
+       product_id = le16_to_cpu(udev->descriptor.idProduct);
 
        if (vendor_id == 0x0471) {
                switch (product_id) {
@@ -1896,7 +1894,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
        }
 
        init_MUTEX(&pdev->modlock);
-       pdev->ptrlock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&pdev->ptrlock);
 
        pdev->udev = udev;
        init_waitqueue_head(&pdev->frameq);
@@ -1915,7 +1913,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
        pdev->vdev->owner = THIS_MODULE;
        video_set_drvdata(pdev->vdev, pdev);
 
-       pdev->release = udev->descriptor.bcdDevice;
+       pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);
        Trace(TRACE_PROBE, "Release: %04x\n", pdev->release);
 
        /* Now search device_hint[] table for a match, so we can hint a node number. */
@@ -2027,7 +2025,7 @@ static int pwc_atoi(const char *s)
  * Initialization code & module stuff 
  */
 
-static char *size = NULL;
+static char size[10];
 static int fps = 0;
 static int fbufs = 0;
 static int mbufs = 0;
@@ -2036,23 +2034,23 @@ static int compression = -1;
 static int leds[2] = { -1, -1 };
 static char *dev_hint[MAX_DEV_HINTS] = { };
 
-MODULE_PARM(size, "s");
+module_param_string(size, size, sizeof(size), 0);
 MODULE_PARM_DESC(size, "Initial image size. One of sqcif, qsif, qcif, sif, cif, vga");
-MODULE_PARM(fps, "i");
+module_param(fps, int, 0000);
 MODULE_PARM_DESC(fps, "Initial frames per second. Varies with model, useful range 5-30");
-MODULE_PARM(fbufs, "i");
+module_param(fbufs, int, 0000);
 MODULE_PARM_DESC(fbufs, "Number of internal frame buffers to reserve");
-MODULE_PARM(mbufs, "i");
+module_param(mbufs, int, 0000);
 MODULE_PARM_DESC(mbufs, "Number of external (mmap()ed) image buffers");
-MODULE_PARM(trace, "i");
+module_param(trace, int, 0000);
 MODULE_PARM_DESC(trace, "For debugging purposes");
-MODULE_PARM(power_save, "i");
+module_param(power_save, bool, 0000);
 MODULE_PARM_DESC(power_save, "Turn power save feature in camera on or off");
-MODULE_PARM(compression, "i");
+module_param(compression, int, 0000);
 MODULE_PARM_DESC(compression, "Preferred compression quality. Range 0 (uncompressed) to 3 (high compression)");
-MODULE_PARM(leds, "2i");
+module_param_array(leds, int, NULL, 0000);
 MODULE_PARM_DESC(leds, "LED on,off time in milliseconds");
-MODULE_PARM(dev_hint, "0-20s");
+module_param_array(dev_hint, charp, NULL, 0000);
 MODULE_PARM_DESC(dev_hint, "Device node hints");
 
 MODULE_DESCRIPTION("Philips & OEM USB webcam driver");
@@ -2078,7 +2076,7 @@ static int __init usb_pwc_init(void)
                Info("Default framerate set to %d.\n", default_fps);
        }
 
-       if (size) {
+       if (size[0]) {
                /* string; try matching with array */
                for (sz = 0; sz < PSZ_MAX; sz++) {
                        if (!strcmp(sizenames[sz], size)) { /* Found! */
@@ -2127,7 +2125,7 @@ static int __init usb_pwc_init(void)
        if (leds[1] >= 0)
                led_off = leds[1];
 
-       /* Big device node whoopla. Basicly, it allows you to assign a
+       /* Big device node whoopla. Basically, it allows you to assign a
           device node (/dev/videoX) to a camera, based on its type
           & serial number. The format is [type[.serialnumber]:]node.