The patch number 14398 was added via Douglas Schilling Landgraf 
<[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <[email protected]>

------

From: Guennadi Liakhovetski  <[email protected]>
soc-camera: add runtime pm support for subdevices


To save power soc-camera powers subdevices down, when they are not in use,
if this is supported by the platform. However, the V4L standard dictates,
that video nodes shall preserve configuration between uses. This requires
runtime power management, which is implemented by this patch. It allows
subdevice drivers to specify their runtime power-management methods, by
assigning a type to the video device.

Priority: normal

Signed-off-by: Guennadi Liakhovetski <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Douglas Schilling Landgraf <[email protected]>


---

 linux/drivers/media/video/soc_camera.c |   18 +++++++++++++++++-
 linux/include/media/soc_camera.h       |    8 ++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff -r 3612456e80ea -r 0d8a0cabdb9a linux/drivers/media/video/soc_camera.c
--- a/linux/drivers/media/video/soc_camera.c    Sat Mar 06 20:48:47 2010 -0300
+++ b/linux/drivers/media/video/soc_camera.c    Sat Mar 06 20:51:28 2010 -0300
@@ -24,6 +24,7 @@
 #include <linux/mutex.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/vmalloc.h>
 
 #include <media/soc_camera.h>
@@ -388,6 +389,11 @@
                        goto eiciadd;
                }
 
+               pm_runtime_enable(&icd->vdev->dev);
+               ret = pm_runtime_resume(&icd->vdev->dev);
+               if (ret < 0 && ret != -ENOSYS)
+                       goto eresume;
+
                /*
                 * Try to configure with default parameters. Notice: this is the
                 * very first open, so, we cannot race against other calls,
@@ -409,10 +415,12 @@
        return 0;
 
        /*
-        * First five errors are entered with the .video_lock held
+        * First four errors are entered with the .video_lock held
         * and use_count == 1
         */
 esfmt:
+       pm_runtime_disable(&icd->vdev->dev);
+eresume:
        ici->ops->remove(icd);
 eiciadd:
        if (icl->power)
@@ -437,7 +445,11 @@
        if (!icd->use_count) {
                struct soc_camera_link *icl = to_soc_camera_link(icd);
 
+               pm_runtime_suspend(&icd->vdev->dev);
+               pm_runtime_disable(&icd->vdev->dev);
+
                ici->ops->remove(icd);
+
                if (icl->power)
                        icl->power(icd->pdev, 0);
        }
@@ -1319,6 +1331,7 @@
  */
 static int soc_camera_video_start(struct soc_camera_device *icd)
 {
+       struct device_type *type = icd->vdev->dev.type;
        int ret;
 
        if (!icd->dev.parent)
@@ -1335,6 +1348,9 @@
                return ret;
        }
 
+       /* Restore device type, possibly set by the subdevice driver */
+       icd->vdev->dev.type = type;
+
        return 0;
 }
 
diff -r 3612456e80ea -r 0d8a0cabdb9a linux/include/media/soc_camera.h
--- a/linux/include/media/soc_camera.h  Sat Mar 06 20:48:47 2010 -0300
+++ b/linux/include/media/soc_camera.h  Sat Mar 06 20:51:28 2010 -0300
@@ -284,4 +284,12 @@
 extern unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
                                                   unsigned long flags);
 
+/* This is only temporary here - until v4l2-subdev begins to link to 
video_device */
+#include <linux/i2c.h>
+static inline struct video_device *soc_camera_i2c_to_vdev(struct i2c_client 
*client)
+{
+       struct soc_camera_device *icd = client->dev.platform_data;
+       return icd->vdev;
+}
+
 #endif


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/0d8a0cabdb9a161666ee0f78aeef2dd8ea529974

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to