linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / usb / media / stv680.c
index af46029..b497a6a 100644 (file)
@@ -93,11 +93,11 @@ static unsigned int debug = 0;
 MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_DESCRIPTION (DRIVER_DESC);
 MODULE_LICENSE ("GPL");
-MODULE_PARM (debug, "i");
+module_param(debug, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC (debug, "Debug enabled or not");
-MODULE_PARM (swapRGB_on, "i");
+module_param(swapRGB_on, int, 0);
 MODULE_PARM_DESC (swapRGB_on, "Red/blue swap: 1=always, 0=auto, -1=never");
-MODULE_PARM (video_nr, "i");
+module_param(video_nr, int, 0);
 
 /********************************************************************
  *
@@ -118,20 +118,6 @@ MODULE_PARM (video_nr, "i");
  *
  * And the STV0680 driver - Kevin
  ********************************************************************/
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa (unsigned long adr)
-{
-       unsigned long kva, ret;
-
-       kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-       kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-       ret = __pa(kva);
-       return ret;
-}
-
 static void *rvmalloc (unsigned long size)
 {
        void *mem;
@@ -274,7 +260,7 @@ static int stv_stop_video (struct usb_stv *dev)
                        PDEBUG (0, "STV(i): Camera set to original resolution");
        }
        /* origMode */
-       kfree (buf);
+       kfree(buf);
        return i;
 }
 
@@ -290,7 +276,7 @@ static int stv_set_video_mode (struct usb_stv *dev)
        }
 
        if ((i = stv_set_config (dev, 1, 0, 0)) < 0) {
-               kfree (buf);
+               kfree(buf);
                return i;
        }
 
@@ -315,13 +301,13 @@ static int stv_set_video_mode (struct usb_stv *dev)
        goto exit;
 
 error:
-       kfree (buf);
+       kfree(buf);
        if (stop_video == 1)
                stv_stop_video (dev);
        return -1;
 
 exit:
-       kfree (buf);
+       kfree(buf);
        return 0;
 }
 
@@ -341,7 +327,7 @@ static int stv_init (struct usb_stv *stv680)
 
        /* set config 1, interface 0, alternate 0 */
        if ((i = stv_set_config (stv680, 1, 0, 0)) < 0) {
-               kfree (buffer);
+               kfree(buffer);
                PDEBUG (0, "STV(e): set config 1,0,0 failed");
                return -1;
        }
@@ -449,11 +435,11 @@ static int stv_init (struct usb_stv *stv680)
 error:
        i = stv_sndctrl (0, stv680, 0x80, 0, buffer, 0x02);     /* Get Last Error */
        PDEBUG (1, "STV(i): last error: %i,  command = 0x%x", buffer[0], buffer[1]);
-       kfree (buffer);
+       kfree(buffer);
        return -1;
 
 exit:
-       kfree (buffer);
+       kfree(buffer);
 
        /* video = 320x240, 352x288 */
        if (stv680->CIF == 1) {
@@ -512,12 +498,6 @@ exit:
 /****************************************************************************
  *  sysfs
  ***************************************************************************/
-static inline struct usb_stv *cd_to_stv(struct class_device *cd)
-{
-       struct video_device *vdev = to_video_device(cd);
-       return video_get_drvdata(vdev);
-}
-
 #define stv680_file(name, variable, field)                             \
 static ssize_t show_##name(struct class_device *class_dev, char *buf)  \
 {                                                                      \
@@ -704,7 +684,6 @@ static int stv680_start_stream (struct usb_stv *stv680)
                                   usb_rcvbulkpipe (stv680->udev, stv680->bulk_in_endpointAddr),
                                   stv680->sbuf[i].data, stv680->rawbufsize,
                                   stv680_video_irq, stv680);
-               urb->timeout = PENCAM_TIMEOUT * 2;
                stv680->urb[i] = urb;
                err = usb_submit_urb (stv680->urb[i], GFP_KERNEL);
                if (err)
@@ -726,13 +705,13 @@ static int stv680_stop_stream (struct usb_stv *stv680)
 
        for (i = 0; i < STV680_NUMSBUF; i++)
                if (stv680->urb[i]) {
-                       usb_unlink_urb (stv680->urb[i]);
+                       usb_kill_urb (stv680->urb[i]);
                        usb_free_urb (stv680->urb[i]);
                        stv680->urb[i] = NULL;
-                       kfree (stv680->sbuf[i].data);
+                       kfree(stv680->sbuf[i].data);
                }
        for (i = 0; i < STV680_NUMSCRATCH; i++) {
-               kfree (stv680->scratch[i].data);
+               kfree(stv680->scratch[i].data);
                stv680->scratch[i].data = NULL;
        }
 
@@ -1089,7 +1068,7 @@ static int stv_close (struct inode *inode, struct file *file)
        stv680->user = 0;
 
        if (stv680->removed) {
-               kfree (stv680);
+               kfree(stv680);
                stv680 = NULL;
                PDEBUG (0, "STV(i): device unregistered");
        }
@@ -1292,8 +1271,8 @@ static int stv680_mmap (struct file *file, struct vm_area_struct *vma)
        }
        pos = (unsigned long) stv680->fbuf;
        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)) {
                        up (&stv680->lock);
                        return -EAGAIN;
                }
@@ -1364,6 +1343,7 @@ static struct file_operations stv680_fops = {
        .read =         stv680_read,
        .mmap =         stv680_mmap,
        .ioctl =        stv680_ioctl,
+       .compat_ioctl = v4l_compat_ioctl32,
        .llseek =       no_llseek,
 };
 static struct video_device stv680_template = {
@@ -1392,12 +1372,17 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
 
        interface = &intf->altsetting[0];
        /* Is it a STV680? */
-       if ((dev->descriptor.idVendor == USB_PENCAM_VENDOR_ID) && (dev->descriptor.idProduct == USB_PENCAM_PRODUCT_ID)) {
+       if ((le16_to_cpu(dev->descriptor.idVendor) == USB_PENCAM_VENDOR_ID) &&
+           (le16_to_cpu(dev->descriptor.idProduct) == USB_PENCAM_PRODUCT_ID)) {
                camera_name = "STV0680";
                PDEBUG (0, "STV(i): STV0680 camera found.");
+       } else if ((le16_to_cpu(dev->descriptor.idVendor) == USB_CREATIVEGOMINI_VENDOR_ID) &&
+                  (le16_to_cpu(dev->descriptor.idProduct) == USB_CREATIVEGOMINI_PRODUCT_ID)) {
+               camera_name = "Creative WebCam Go Mini";
+               PDEBUG (0, "STV(i): Creative WebCam Go Mini found.");
        } else {
-               PDEBUG (0, "STV(e): Vendor/Product ID do not match STV0680 values.");
-               PDEBUG (0, "STV(e): Check that the STV0680 camera is connected to the computer.");
+               PDEBUG (0, "STV(e): Vendor/Product ID do not match STV0680 or Creative WebCam Go Mini values.");
+               PDEBUG (0, "STV(e): Check that the STV0680 or Creative WebCam Go Mini camera is connected to the computer.");
                retval = -ENODEV;
                goto error;
        }
@@ -1458,17 +1443,17 @@ static inline void usb_stv680_remove_disconnected (struct usb_stv *stv680)
 
        for (i = 0; i < STV680_NUMSBUF; i++)
                if (stv680->urb[i]) {
-                       usb_unlink_urb (stv680->urb[i]);
+                       usb_kill_urb (stv680->urb[i]);
                        usb_free_urb (stv680->urb[i]);
                        stv680->urb[i] = NULL;
-                       kfree (stv680->sbuf[i].data);
+                       kfree(stv680->sbuf[i].data);
                }
        for (i = 0; i < STV680_NUMSCRATCH; i++)
-               kfree (stv680->scratch[i].data);
+               kfree(stv680->scratch[i].data);
        PDEBUG (0, "STV(i): %s disconnected", stv680->camera_name);
 
        /* Free the memory */
-       kfree (stv680);
+       kfree(stv680);
 }
 
 static void stv680_disconnect (struct usb_interface *intf)
@@ -1493,7 +1478,6 @@ static void stv680_disconnect (struct usb_interface *intf)
 }
 
 static struct usb_driver stv680_driver = {
-       .owner =        THIS_MODULE,
        .name =         "stv680",
        .probe =        stv680_probe,
        .disconnect =   stv680_disconnect,