From 4e148a232f30f78c0662881aa622a8dbf459a0b4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 18 May 2010 00:46:09 -0300 Subject: [PATCH] --- yaml --- r: 192745 b: refs/heads/master c: 4f9fb5ed020324d6c151db34460df572b0fdc491 h: refs/heads/master i: 192743: 195c1f08bad0fe4566db924e185268da4421475f v: v3 --- [refs] | 2 +- trunk/drivers/media/video/soc_camera.c | 18 +++++++++++++++++- trunk/include/media/soc_camera.h | 8 ++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 86eed9b102a2..8cf0cc3acc91 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e26b31449142a18512b57dbea515af234992ba7c +refs/heads/master: 4f9fb5ed020324d6c151db34460df572b0fdc491 diff --git a/trunk/drivers/media/video/soc_camera.c b/trunk/drivers/media/video/soc_camera.c index a24174ddec46..0c65031f3d82 100644 --- a/trunk/drivers/media/video/soc_camera.c +++ b/trunk/drivers/media/video/soc_camera.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -388,6 +389,11 @@ static int soc_camera_open(struct file *file) 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 @@ static int soc_camera_open(struct file *file) 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 @@ static int soc_camera_close(struct file *file) 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 video_dev_create(struct soc_camera_device *icd) */ 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 @@ static int soc_camera_video_start(struct soc_camera_device *icd) return ret; } + /* Restore device type, possibly set by the subdevice driver */ + icd->vdev->dev.type = type; + return 0; } diff --git a/trunk/include/media/soc_camera.h b/trunk/include/media/soc_camera.h index 5a173652cf4a..c9a5bbfa6ab5 100644 --- a/trunk/include/media/soc_camera.h +++ b/trunk/include/media/soc_camera.h @@ -284,4 +284,12 @@ static inline void soc_camera_limit_side(int *start, int *length, 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 +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