From patchwork Thu Feb 4 19:20:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 77178 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o14JKoUl003051 for ; Thu, 4 Feb 2010 19:20:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932422Ab0BDTUY (ORCPT ); Thu, 4 Feb 2010 14:20:24 -0500 Received: from mail.gmx.net ([213.165.64.20]:33307 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932078Ab0BDTUW (ORCPT ); Thu, 4 Feb 2010 14:20:22 -0500 Received: (qmail invoked by alias); 04 Feb 2010 19:20:11 -0000 Received: from p57BD19DD.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.25.221] by mail.gmx.net (mp072) with SMTP; 04 Feb 2010 20:20:11 +0100 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX193A75nBuN3vyL1fX/1YZX2/zdCwJD8sVHhKhrrqN 2vJ2Wql8uSR43b Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1Nd7FG-0007PW-6Q; Thu, 04 Feb 2010 20:20:06 +0100 Date: Thu, 4 Feb 2010 20:20:06 +0100 (CET) From: Guennadi Liakhovetski To: Linux Media Mailing List cc: Laurent Pinchart , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH] soc-camera: add runtime pm support for subdevices Message-ID: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.53000000000000003 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 19:20:50 +0000 (UTC) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 6b3fbcc..53201f3 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -387,6 +388,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, @@ -408,10 +414,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) @@ -436,7 +444,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); } @@ -1294,6 +1306,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) @@ -1310,6 +1323,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/include/media/soc_camera.h b/include/media/soc_camera.h index dcc5b86..58b39a9 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -282,4 +282,12 @@ static inline void soc_camera_limit_side(unsigned int *start, 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