From patchwork Fri Mar 2 14:34:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10254807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBA3F6037F for ; Fri, 2 Mar 2018 14:35:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD047289B6 for ; Fri, 2 Mar 2018 14:35:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABD3B289D6; Fri, 2 Mar 2018 14:35:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B14B289D4 for ; Fri, 2 Mar 2018 14:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425775AbeCBOfT (ORCPT ); Fri, 2 Mar 2018 09:35:19 -0500 Received: from mail.bootlin.com ([62.4.15.54]:34011 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424981AbeCBOfO (ORCPT ); Fri, 2 Mar 2018 09:35:14 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 05064207BB; Fri, 2 Mar 2018 15:35:12 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id A395A207EF; Fri, 2 Mar 2018 15:35:01 +0100 (CET) From: Maxime Ripard To: Mauro Carvalho Chehab Cc: Laurent Pinchart , linux-media@vger.kernel.org, Thomas Petazzoni , Mylene Josserand , Hans Verkuil , Sakari Ailus , Hugues Fruchet , Maxime Ripard Subject: [PATCH 01/12] media: ov5640: Add auto-focus feature Date: Fri, 2 Mar 2018 15:34:49 +0100 Message-Id: <20180302143500.32650-2-maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180302143500.32650-1-maxime.ripard@bootlin.com> References: <20180302143500.32650-1-maxime.ripard@bootlin.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mylène Josserand Add the auto-focus ENABLE/DISABLE feature as V4L2 control. Disabled by default. Signed-off-by: Mylène Josserand Signed-off-by: Maxime Ripard --- drivers/media/i2c/ov5640.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index e2dd352224c7..f5e867d47ab8 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -80,8 +80,9 @@ #define OV5640_REG_POLARITY_CTRL00 0x4740 #define OV5640_REG_MIPI_CTRL00 0x4800 #define OV5640_REG_DEBUG_MODE 0x4814 -#define OV5640_REG_ISP_FORMAT_MUX_CTRL 0x501f +#define OV5640_REG_ISP_CTRL03 0x5003 #define OV5640_REG_PRE_ISP_TEST_SET1 0x503d +#define OV5640_REG_ISP_FORMAT_MUX_CTRL 0x501f #define OV5640_REG_SDE_CTRL0 0x5580 #define OV5640_REG_SDE_CTRL1 0x5581 #define OV5640_REG_SDE_CTRL3 0x5583 @@ -183,6 +184,7 @@ struct ov5640_ctrls { struct v4l2_ctrl *auto_gain; struct v4l2_ctrl *gain; }; + struct v4l2_ctrl *auto_focus; struct v4l2_ctrl *brightness; struct v4l2_ctrl *saturation; struct v4l2_ctrl *contrast; @@ -2094,6 +2096,12 @@ static int ov5640_set_ctrl_test_pattern(struct ov5640_dev *sensor, int value) 0xa4, value ? 0xa4 : 0); } +static int ov5640_set_ctrl_focus(struct ov5640_dev *sensor, int value) +{ + return ov5640_mod_reg(sensor, OV5640_REG_ISP_CTRL03, + BIT(1), value ? BIT(1) : 0); +} + static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl) { struct v4l2_subdev *sd = ctrl_to_sd(ctrl); @@ -2162,6 +2170,9 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEST_PATTERN: ret = ov5640_set_ctrl_test_pattern(sensor, ctrl->val); break; + case V4L2_CID_FOCUS_AUTO: + ret = ov5640_set_ctrl_focus(sensor, ctrl->val); + break; default: ret = -EINVAL; break; @@ -2224,6 +2235,9 @@ static int ov5640_init_controls(struct ov5640_dev *sensor) ARRAY_SIZE(test_pattern_menu) - 1, 0, 0, test_pattern_menu); + ctrls->auto_focus = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FOCUS_AUTO, + 0, 1, 1, 0); + if (hdl->error) { ret = hdl->error; goto free_ctrls;