Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux...
[sfrench/cifs-2.6.git] / drivers / media / video / cafe_ccic.c
index ef5361824f878f01266567839226871cb07a89f9..5195b1f3378a627d60dd66452033ae1f2e56f353 100644 (file)
@@ -3,6 +3,9 @@
  * multifunction chip.  Currently works with the Omnivision OV7670
  * sensor.
  *
+ * The data sheet for this device can be found at:
+ *    http://www.marvell.com/products/pcconn/88ALP01.jsp
+ *
  * Copyright 2006 One Laptop Per Child Association, Inc.
  * Copyright 2006-7 Jonathan Corbet <corbet@lwn.net>
  *
@@ -14,7 +17,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/pci.h>
@@ -63,13 +65,13 @@ MODULE_SUPPORTED_DEVICE("Video");
  */
 
 #define MAX_DMA_BUFS 3
-static int alloc_bufs_at_load = 0;
-module_param(alloc_bufs_at_load, bool, 0444);
-MODULE_PARM_DESC(alloc_bufs_at_load,
-               "Non-zero value causes DMA buffers to be allocated at module "
-               "load time.  This increases the chances of successfully getting "
-               "those buffers, but at the cost of nailing down the memory from "
-               "the outset.");
+static int alloc_bufs_at_read;
+module_param(alloc_bufs_at_read, bool, 0444);
+MODULE_PARM_DESC(alloc_bufs_at_read,
+               "Non-zero value causes DMA buffers to be allocated when the "
+               "video capture device is read, rather than at module load "
+               "time.  This saves memory, but decreases the chances of "
+               "successfully getting those buffers.");
 
 static int n_dma_bufs = 3;
 module_param(n_dma_bufs, uint, 0644);
@@ -97,7 +99,7 @@ MODULE_PARM_DESC(max_buffers,
                "will be allowed to allocate.  These buffers are big and live "
                "in vmalloc space.");
 
-static int flip = 0;
+static int flip;
 module_param(flip, bool, 0444);
 MODULE_PARM_DESC(flip,
                "If set, the sensor will be instructed to flip the image "
@@ -1198,7 +1200,7 @@ static int cafe_setup_siobuf(struct cafe_camera *cam, int index)
        buf->v4lbuf.field = V4L2_FIELD_NONE;
        buf->v4lbuf.memory = V4L2_MEMORY_MMAP;
        /*
-        * Offset: must be 32-bit even on a 64-bit system.  video-buf
+        * Offset: must be 32-bit even on a 64-bit system.  videobuf-dma-sg
         * just uses the length times the index, but the spec warns
         * against doing just that - vma merging problems.  So we
         * leave a gap between each pair of buffers.
@@ -1503,7 +1505,7 @@ static int cafe_v4l_release(struct inode *inode, struct file *filp)
        }
        if (cam->users == 0) {
                cafe_ctlr_power_down(cam);
-               if (! alloc_bufs_at_load)
+               if (alloc_bufs_at_read)
                        cafe_free_dma_bufs(cam);
        }
        mutex_unlock(&cam->s_mutex);
@@ -2162,7 +2164,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
        /*
         * If so requested, try to get our DMA buffers now.
         */
-       if (alloc_bufs_at_load) {
+       if (!alloc_bufs_at_read) {
                if (cafe_alloc_dma_bufs(cam, 1))
                        cam_warn(cam, "Unable to alloc DMA buffers at load"
                                        " will try again later.");
@@ -2233,13 +2235,16 @@ static int cafe_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct cafe_camera *cam = cafe_find_by_pdev(pdev);
        int ret;
+       enum cafe_state cstate;
 
        ret = pci_save_state(pdev);
        if (ret)
                return ret;
+       cstate = cam->state; /* HACK - stop_dma sets to idle */
        cafe_ctlr_stop_dma(cam);
        cafe_ctlr_power_down(cam);
        pci_disable_device(pdev);
+       cam->state = cstate;
        return 0;
 }