From patchwork Mon Sep 12 11:25:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 7830 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Mon, 12 Sep 2011 11:26:33 +0000 Received: from canuck.infradead.org [134.117.69.58] by localhost.localdomain with IMAP (fetchmail-6.3.20) for (single-drop); Tue, 13 Sep 2011 12:25:18 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R34el-0003aw-NT; Mon, 12 Sep 2011 11:26:33 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755105Ab1ILL03 (ORCPT + 1 other); Mon, 12 Sep 2011 07:26:29 -0400 Received: from d1.icnet.pl ([212.160.220.21]:54366 "EHLO d1.icnet.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754602Ab1ILL02 (ORCPT ); Mon, 12 Sep 2011 07:26:28 -0400 Received: from 87-205-12-81.ip.netia.com.pl ([87.205.12.81] helo=vclass.localnet) by d1.icnet.pl with asmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1R34eh-0003NZ-ML; Mon, 12 Sep 2011 13:26:27 +0200 From: Janusz Krzysztofik Organization: Tele-Info-System, Poznan, PL To: linux-media@vger.kernel.org Subject: [PATCH] media: ov6650: Fix wrong register used for red control Date: Mon, 12 Sep 2011 13:25:25 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.38-gentoo-r6; KDE/4.6.3; i686; ; ) Cc: Guennadi Liakhovetski , Hans Verkuil , Mauro Carvalho Chehab MIME-Version: 1.0 Message-Id: <201109121325.25986.jkrzyszt@tis.icnet.pl> X-SA-Exim-Scanned: No (on d1.icnet); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110912_122632_184370_0D3E792D X-CRM114-Status: GOOD ( 16.46 ) X-Spam-Score: -2.2 (--) X-Spam-Report: SpamAssassin version 3.3.2 on casper.infradead.org summary: Content analysis details: (-2.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [209.132.180.67 listed in list.dnswl.org] 2.8 KB_DATE_CONTAINS_TAB KB_DATE_CONTAINS_TAB 2.5 TAB_IN_FROM From starts with a tab -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] REG_BLUE has been used by mistake instead of REG_RED. Fix it. While being at it, fix a few minor issues: * with no "retrun ret;" at the end, there is no need to initialize ret any longer, * consequently use conditional expressions, not if...else constructs, throughout ov6650_s_ctrl(), * v4l2_ctrl_new_std_menu() max value of V4L2_EXPOSURE_MANUAL instead of equivalent 1 looks more clear. Created on top of "Converting soc_camera to the control framework" series. Signed-off-by: Janusz Krzysztofik --- drivers/media/video/ov6650.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/media/video/ov6650.c b/drivers/media/video/ov6650.c index 089a4aa..c0709ee 100644 --- a/drivers/media/video/ov6650.c +++ b/drivers/media/video/ov6650.c @@ -310,7 +310,7 @@ static int ov6550_g_volatile_ctrl(struct v4l2_ctrl *ctrl) struct v4l2_subdev *sd = &priv->subdev; struct i2c_client *client = v4l2_get_subdevdata(sd); uint8_t reg, reg2; - int ret = 0; + int ret; switch (ctrl->id) { case V4L2_CID_AUTOGAIN: @@ -342,7 +342,7 @@ static int ov6550_s_ctrl(struct v4l2_ctrl *ctrl) struct ov6650 *priv = container_of(ctrl->handler, struct ov6650, hdl); struct v4l2_subdev *sd = &priv->subdev; struct i2c_client *client = v4l2_get_subdevdata(sd); - int ret = 0; + int ret; switch (ctrl->id) { case V4L2_CID_AUTOGAIN: @@ -357,7 +357,7 @@ static int ov6550_s_ctrl(struct v4l2_ctrl *ctrl) if (!ret && !ctrl->val) { ret = ov6650_reg_write(client, REG_BLUE, priv->blue->val); if (!ret) - ret = ov6650_reg_write(client, REG_BLUE, + ret = ov6650_reg_write(client, REG_RED, priv->red->val); } return ret; @@ -370,10 +370,8 @@ static int ov6550_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_BRIGHTNESS: return ov6650_reg_write(client, REG_BRT, ctrl->val); case V4L2_CID_EXPOSURE_AUTO: - if (ctrl->val == V4L2_EXPOSURE_AUTO) - ret = ov6650_reg_rmw(client, REG_COMB, COMB_AEC, 0); - else - ret = ov6650_reg_rmw(client, REG_COMB, 0, COMB_AEC); + ret = ov6650_reg_rmw(client, REG_COMB, ctrl->val == + V4L2_EXPOSURE_AUTO ? COMB_AEC : 0, COMB_AEC); if (!ret && ctrl->val == V4L2_EXPOSURE_MANUAL) ret = ov6650_reg_write(client, REG_AECH, priv->exposure->val); @@ -993,8 +991,8 @@ static int ov6650_probe(struct i2c_client *client, v4l2_ctrl_new_std(&priv->hdl, &ov6550_ctrl_ops, V4L2_CID_BRIGHTNESS, 0, 0xff, 1, 0x80); priv->autoexposure = v4l2_ctrl_new_std_menu(&priv->hdl, - &ov6550_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, - V4L2_EXPOSURE_AUTO); + &ov6550_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, + V4L2_EXPOSURE_MANUAL, 0, V4L2_EXPOSURE_AUTO); priv->exposure = v4l2_ctrl_new_std(&priv->hdl, &ov6550_ctrl_ops, V4L2_CID_EXPOSURE, 0, 0xff, 1, DEF_AECH); v4l2_ctrl_new_std(&priv->hdl, &ov6550_ctrl_ops,