From patchwork Mon Jan 10 22:18:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roberto Rodriguez Alkala X-Patchwork-Id: 469801 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0AMJAwE031383 for ; Mon, 10 Jan 2011 22:19:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754887Ab1AJWSt (ORCPT ); Mon, 10 Jan 2011 17:18:49 -0500 Received: from mail-gx0-f174.google.com ([209.85.161.174]:43224 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754779Ab1AJWSr (ORCPT ); Mon, 10 Jan 2011 17:18:47 -0500 Received: by gxk9 with SMTP id 9so5106158gxk.19 for ; Mon, 10 Jan 2011 14:18:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=2I75TWAz3/BeovUZBjPLpddnd2ubXTYQc14Wcp8YEUc=; b=Xm91u8JVMgT7Jxge1q9OFyBo+HLbNEPPfxbpwu+eeKNvavxLMwAuIRlzvnHunYS0Lp tbu7pVI3C6tmNX3P7sReJrSSzKIuNAwiyT8n4vTfH7A85Ljmo4Sg5uA70shmT06mW5Gp SOslryDEzUJpuMr44J797X2+LqXeLnPzlu5pU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=YPlMtaWODNDIA9cRKUENkAX+IsflYZg8yznBw5JU+yA6+B0ze4KHiCtpeRii4NQXtS GXQaB45qQy1LN8OwZb2/UBC8rIgQ4FLfHEMgua7VKvOptHB0yFek6DSwsUn207fS+kEo ha54hSdidAwYzCZmoYGe7/CwlqyGqbG7S2b4w= Received: by 10.100.201.10 with SMTP id y10mr828096anf.57.1294697926982; Mon, 10 Jan 2011 14:18:46 -0800 (PST) Received: from localhost.localdomain (host-2-229.a2.cvc.com.py [186.0.189.229]) by mx.google.com with ESMTPS id x31sm38063850ana.29.2011.01.10.14.18.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 10 Jan 2011 14:18:46 -0800 (PST) From: Roberto Rodriguez Alcala To: linux-media@vger.kernel.org, g.liakhovetski@gmx.de Cc: Roberto Rodriguez Alcala Subject: [PATCH 2/2] [media] ov7670: Allow configuration of night mode Date: Mon, 10 Jan 2011 19:18:27 -0300 Message-Id: <1294697907-1714-3-git-send-email-rralcala@gmail.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1294697907-1714-1-git-send-email-rralcala@gmail.com> References: <1294697907-1714-1-git-send-email-rralcala@gmail.com> 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 10 Jan 2011 22:19:24 +0000 (UTC) diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c index c881a64..cfe96e5 100644 --- a/drivers/media/video/ov7670.c +++ b/drivers/media/video/ov7670.c @@ -1255,6 +1255,36 @@ static int ov7670_s_gain(struct v4l2_subdev *sd, int value) } /* + * Get or Set Night Mode. + */ +static int ov7670_g_nightmode(struct v4l2_subdev *sd, __s32 *value) +{ + int ret; + unsigned char com11; + + ret = ov7670_read(sd, REG_COM11, &com11); + *value = (com11 & COM11_NIGHT) != 0; + return ret; +} + +static int ov7670_s_nightmode(struct v4l2_subdev *sd, int value) +{ + int ret; + unsigned char com11; + + ret = ov7670_read(sd, REG_COM11, &com11); + if (ret == 0) { + if (value) + com11 |= COM11_NIGHT; + else + com11 &= ~COM11_NIGHT; + ret = ov7670_write(sd, REG_COM11, com11); + } + return ret; +} + + +/* * Tweak autogain. */ static int ov7670_g_autogain(struct v4l2_subdev *sd, __s32 *value) @@ -1382,6 +1412,8 @@ static int ov7670_queryctrl(struct v4l2_subdev *sd, return v4l2_ctrl_query_fill(qc, 0, 65535, 1, 500); case V4L2_CID_EXPOSURE_AUTO: return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0); + case V4L2_CID_NIGHT_MODE: + return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0); } return -EINVAL; } @@ -1409,6 +1441,8 @@ static int ov7670_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) return ov7670_g_exp(sd, &ctrl->value); case V4L2_CID_EXPOSURE_AUTO: return ov7670_g_autoexp(sd, &ctrl->value); + case V4L2_CID_NIGHT_MODE: + return ov7670_g_nightmode(sd, &ctrl->value); } return -EINVAL; } @@ -1437,6 +1471,8 @@ static int ov7670_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) case V4L2_CID_EXPOSURE_AUTO: return ov7670_s_autoexp(sd, (enum v4l2_exposure_auto_type) ctrl->value); + case V4L2_CID_NIGHT_MODE: + return ov7670_s_nightmode(sd, ctrl->value); } return -EINVAL; }