linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / media / video / cpia.c
index 84ad0be..85d964b 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/proc_fs.h>
 #include <linux/ctype.h>
 #include <linux/pagemap.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
 
@@ -56,7 +57,7 @@ extern int cpia_usb_init(void);
 static int video_nr = -1;
 
 #ifdef MODULE
-MODULE_PARM(video_nr,"i");
+module_param(video_nr, int, 0);
 MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfeld.com>");
 MODULE_DESCRIPTION("V4L-driver for Vision CPiA based cameras");
 MODULE_LICENSE("GPL");
@@ -215,20 +216,6 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
  * Memory management
  *
  **********************************************************************/
-
-/* 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;
@@ -1410,7 +1397,7 @@ static void destroy_proc_cpia_cam(struct cam_data *cam)
 
 static void proc_cpia_create(void)
 {
-       cpia_proc_root = create_proc_entry("cpia", S_IFDIR, NULL);
+       cpia_proc_root = proc_mkdir("cpia", NULL);
 
        if (cpia_proc_root)
                cpia_proc_root->owner = THIS_MODULE;
@@ -2886,9 +2873,7 @@ static int fetch_frame(void *data)
                                cond_resched();
 
                                /* sleep for 10 ms, hopefully ;) */
-                               current->state = TASK_INTERRUPTIBLE;
-
-                               schedule_timeout(10*HZ/1000);
+                               msleep_interruptible(10);
                                if (signal_pending(current))
                                        return -EINTR;
 
@@ -2951,8 +2936,7 @@ static int fetch_frame(void *data)
                                           CPIA_GRAB_SINGLE, 0, 0, 0);
                                /* FIXME: Trial & error - need up to 70ms for
                                   the grab mode change to complete ? */
-                               current->state = TASK_INTERRUPTIBLE;
-                               schedule_timeout(70*HZ / 1000);
+                               msleep_interruptible(70);
                                if (signal_pending(current))
                                        return -EINTR;
                        }
@@ -3003,8 +2987,7 @@ static int goto_high_power(struct cam_data *cam)
 {
        if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0))
                return -EIO;
-       current->state = TASK_INTERRUPTIBLE;
-       schedule_timeout(40*HZ/1000);   /* windows driver does it too */
+       msleep_interruptible(40);       /* windows driver does it too */
        if(signal_pending(current))
                return -EINTR;
        if (do_command(cam, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0))
@@ -3074,10 +3057,8 @@ static int set_camera_state(struct cam_data *cam)
        
        /* Wait 6 frames for the sensor to get all settings and
           AEC/ACB to settle */
-       current->state = TASK_INTERRUPTIBLE;
-       schedule_timeout((6*(cam->params.sensorFps.baserate ? 33 : 40) *
-                           (1 << cam->params.sensorFps.divisor) + 10) *
-                        HZ / 1000);
+       msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) *
+                              (1 << cam->params.sensorFps.divisor) + 10);
 
        if(signal_pending(current))
                return -EINTR;
@@ -3388,7 +3369,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
        //DBG("cpia_ioctl: %u\n", ioctlnr);
 
        switch (ioctlnr) {
-       /* query capabilites */
+       /* query capabilities */
        case VIDIOCGCAP:
        {
                struct video_capability *b = arg;
@@ -3800,8 +3781,8 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
 
        pos = (unsigned long)(cam->frame_buf);
        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(&cam->busy_lock);
                        return -EAGAIN;
                }
@@ -3826,6 +3807,7 @@ static struct file_operations cpia_fops = {
        .read           = cpia_read,
        .mmap           = cpia_mmap,
        .ioctl          = cpia_ioctl,
+       .compat_ioctl   = v4l_compat_ioctl32,
        .llseek         = no_llseek,
 };