V4L/DVB (8610): Add suspend/resume capabilities to soc_camera.
authorRobert Jarzmik <robert.jarzmik@free.fr>
Fri, 1 Aug 2008 23:14:50 +0000 (20:14 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 6 Aug 2008 09:57:32 +0000 (06:57 -0300)
Add suspend/resume hooks to call soc operation specific
suspend and resume functions. This ensures the camera
chip has been previously resumed, as well as the camera
bus.
These hooks in camera chip drivers should save/restore
chip context between suspend and resume time.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/soc_camera.c
include/media/soc_camera.h

index b6be5ee..66ebe59 100644 (file)
@@ -732,10 +732,36 @@ static int soc_camera_remove(struct device *dev)
        return 0;
 }
 
+static int soc_camera_suspend(struct device *dev, pm_message_t state)
+{
+       struct soc_camera_device *icd = to_soc_camera_dev(dev);
+       struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
+       int ret = 0;
+
+       if (ici->ops->suspend)
+               ret = ici->ops->suspend(icd, state);
+
+       return ret;
+}
+
+static int soc_camera_resume(struct device *dev)
+{
+       struct soc_camera_device *icd = to_soc_camera_dev(dev);
+       struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
+       int ret = 0;
+
+       if (ici->ops->resume)
+               ret = ici->ops->resume(icd);
+
+       return ret;
+}
+
 static struct bus_type soc_camera_bus_type = {
        .name           = "soc-camera",
        .probe          = soc_camera_probe,
        .remove         = soc_camera_remove,
+       .suspend        = soc_camera_suspend,
+       .resume         = soc_camera_resume,
 };
 
 static struct device_driver ic_drv = {
index 1de98f1..d548de3 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/videodev2.h>
 #include <media/videobuf-core.h>
+#include <linux/pm.h>
 
 struct soc_camera_device {
        struct list_head list;
@@ -63,6 +64,8 @@ struct soc_camera_host_ops {
        struct module *owner;
        int (*add)(struct soc_camera_device *);
        void (*remove)(struct soc_camera_device *);
+       int (*suspend)(struct soc_camera_device *, pm_message_t state);
+       int (*resume)(struct soc_camera_device *);
        int (*set_fmt_cap)(struct soc_camera_device *, __u32,
                           struct v4l2_rect *);
        int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
@@ -111,6 +114,8 @@ struct soc_camera_ops {
        struct module *owner;
        int (*probe)(struct soc_camera_device *);
        void (*remove)(struct soc_camera_device *);
+       int (*suspend)(struct soc_camera_device *, pm_message_t state);
+       int (*resume)(struct soc_camera_device *);
        int (*init)(struct soc_camera_device *);
        int (*release)(struct soc_camera_device *);
        int (*start_capture)(struct soc_camera_device *);