From patchwork Thu Apr 2 09:56:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 15899 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n329uN72027480 for ; Thu, 2 Apr 2009 09:56:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752834AbZDBJ4Y (ORCPT ); Thu, 2 Apr 2009 05:56:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755976AbZDBJ4X (ORCPT ); Thu, 2 Apr 2009 05:56:23 -0400 Received: from mail.gmx.net ([213.165.64.20]:44059 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752834AbZDBJ4X (ORCPT ); Thu, 2 Apr 2009 05:56:23 -0400 Received: (qmail invoked by alias); 02 Apr 2009 09:56:16 -0000 Received: from p57BD1AC4.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.26.196] by mail.gmx.net (mp016) with SMTP; 02 Apr 2009 11:56:16 +0200 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX1+raU4Jn/arLSIAcXICqJ9V/zGxIASmASVTZVpxEJ EYb6xghNmSDVs2 Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1LpJeq-0001sL-IC for linux-media@vger.kernel.org; Thu, 02 Apr 2009 11:56:24 +0200 Date: Thu, 2 Apr 2009 11:56:24 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Linux Media Mailing List Subject: [PATCH] mt9t031: use platform power hook Message-ID: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.53 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use platform power hook to turn the camera on and off. Signed-off-by: Guennadi Liakhovetski --- -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index 23f9ce9..2b0927b 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c @@ -141,8 +141,19 @@ static int get_shutter(struct soc_camera_device *icd, u32 *data) static int mt9t031_init(struct soc_camera_device *icd) { + struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); + struct soc_camera_link *icl = mt9t031->client->dev.platform_data; int ret; + if (icl->power) { + ret = icl->power(&mt9t031->client->dev, 1); + if (ret < 0) { + dev_err(icd->vdev->parent, + "Platform failed to power-on the camera.\n"); + return ret; + } + } + /* Disable chip output, synchronous option update */ ret = reg_write(icd, MT9T031_RESET, 1); if (ret >= 0) @@ -150,13 +161,23 @@ static int mt9t031_init(struct soc_camera_device *icd) if (ret >= 0) ret = reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2); + if (ret < 0 && icl->power) + icl->power(&mt9t031->client->dev, 0); + return ret >= 0 ? 0 : -EIO; } static int mt9t031_release(struct soc_camera_device *icd) { + struct mt9t031 *mt9t031 = container_of(icd, struct mt9t031, icd); + struct soc_camera_link *icl = mt9t031->client->dev.platform_data; + /* Disable the chip */ reg_clear(icd, MT9T031_OUTPUT_CONTROL, 2); + + if (icl->power) + icl->power(&mt9t031->client->dev, 0); + return 0; }