From patchwork Wed Dec 6 22:33:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Patchwork-Id: 174751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4421098vqy; Wed, 6 Dec 2023 14:39:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGumB0yTmQNTv1EsAJEB8byrLKRi4dhaJifHf7H8hnFmFxMBBmZ1Hs/Nf66eKp1iknOOMB5 X-Received: by 2002:a17:90a:2a86:b0:286:55f6:4311 with SMTP id j6-20020a17090a2a8600b0028655f64311mr4673329pjd.19.1701902340924; Wed, 06 Dec 2023 14:39:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701902340; cv=none; d=google.com; s=arc-20160816; b=F/Iy7QEeKYNxjJvgG9iUVjRUJjIEMPbS1dgEaAvVLNS/MD/Dseca13fIbGGxS7IbZG c9jq2wGOC4OvMTSbOvy5qsOCDiFEM7pjtlO/jFKGsp6FTsLX8bgwSlfDW3wNa2IW9x2U 2U8YDDgjrLPy8jH2TY2qHgckcnhctuPUUgTMcC6CzaPBV3ZzToEPU/YFHF3SxPz2Qs8h 9Jp4XI4nudIipYhpXEt9aMeKj+7RrrSmiYtpRsi4b6frj+BUw7ZgnGAZTSuesjs3MUFq 44FmffXhvMt70Mf3Z0M1dGhdVcNBeg2ftj5UnySg0YKJ7yKspCw/qjdPuMjDavzw9287 BXzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=K2iaUQNy3SnSZZeFHSw7T3EaRzCeHgVsRa+f2CI0TbY=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=npPPQ7rQHHjyILABcz9qYl5WXgYiGLFJPpp7xKKKuEHmKhY8ocVPinagDr5WZeWddk JbujVTLY3AHd4dKW+iJsCohQs+tbPwIWvEnF6lCc5NMkE3MJw0CZHYMDdJaF5eg8fZcV GLRem7jnRj2YQj81LQsUwaUAamSUh7nE36effvMAnXmWTTSxtovGAuOeKb4rJunzlXNK TfhmVjT6tYoUjit51flK/rO1/CT5qoM27Zx0xmMRnWieCprqYOxoaMmF/SZ/j7V3iUV1 /9tXLsWYl03itw7iLfYjI6LHc6eAQi5lSiiiXkAf9/jKcQtYF32KBiuQupHYMFk+lw+x bsuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ci24-20020a17090afc9800b00286acacd596si488513pjb.136.2023.12.06.14.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 14:39:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 64B9F8026A1F; Wed, 6 Dec 2023 14:38:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377467AbjLFWis (ORCPT + 99 others); Wed, 6 Dec 2023 17:38:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbjLFWir (ORCPT ); Wed, 6 Dec 2023 17:38:47 -0500 Received: from smtprelay03.ispgateway.de (smtprelay03.ispgateway.de [80.67.31.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BB25D72; Wed, 6 Dec 2023 14:38:53 -0800 (PST) Received: from [92.206.191.209] (helo=note-book.lan) by smtprelay03.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1rB0TH-0007Ur-1l; Wed, 06 Dec 2023 23:34:23 +0100 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Wed, 06 Dec 2023 23:33:55 +0100 Subject: [PATCH v4 1/4] media: i2c: imx214: Explain some magic numbers MIME-Version: 1.0 Message-Id: <20231206-imx214-v4-1-7ef604b01dcb@apitzsch.eu> References: <20231206-imx214-v4-0-7ef604b01dcb@apitzsch.eu> In-Reply-To: <20231206-imx214-v4-0-7ef604b01dcb@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: Kieran Bingham , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= , Ricardo Ribalda X-Mailer: b4 0.12.4 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 14:38:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784573948867840892 X-GMAIL-MSGID: 1784573948867840892 Code refinement, no functional changes. Reviewed-by: Ricardo Ribalda Reviewed-by: Kieran Bingham Signed-off-by: André Apitzsch --- drivers/media/i2c/imx214.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 8bc7b114c57d..7c9a240026c4 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -19,12 +19,23 @@ #include #include +#define IMX214_REG_MODE_SELECT 0x0100 +#define IMX214_MODE_STANDBY 0x00 +#define IMX214_MODE_STREAMING 0x01 + #define IMX214_DEFAULT_CLK_FREQ 24000000 #define IMX214_DEFAULT_LINK_FREQ 480000000 #define IMX214_DEFAULT_PIXEL_RATE ((IMX214_DEFAULT_LINK_FREQ * 8LL) / 10) #define IMX214_FPS 30 #define IMX214_MBUS_CODE MEDIA_BUS_FMT_SRGGB10_1X10 +/* Exposure control */ +#define IMX214_REG_EXPOSURE 0x0202 +#define IMX214_EXPOSURE_MIN 0 +#define IMX214_EXPOSURE_MAX 3184 +#define IMX214_EXPOSURE_STEP 1 +#define IMX214_EXPOSURE_DEFAULT 3184 + static const char * const imx214_supply_name[] = { "vdda", "vddd", @@ -665,7 +676,7 @@ static int imx214_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_EXPOSURE: vals[1] = ctrl->val; vals[0] = ctrl->val >> 8; - ret = regmap_bulk_write(imx214->regmap, 0x202, vals, 2); + ret = regmap_bulk_write(imx214->regmap, IMX214_REG_EXPOSURE, vals, 2); if (ret < 0) dev_err(imx214->dev, "Error %d\n", ret); ret = 0; @@ -743,7 +754,7 @@ static int imx214_start_streaming(struct imx214 *imx214) dev_err(imx214->dev, "could not sync v4l2 controls\n"); goto error; } - ret = regmap_write(imx214->regmap, 0x100, 1); + ret = regmap_write(imx214->regmap, IMX214_REG_MODE_SELECT, IMX214_MODE_STREAMING); if (ret < 0) { dev_err(imx214->dev, "could not sent start table %d\n", ret); goto error; @@ -761,7 +772,7 @@ static int imx214_stop_streaming(struct imx214 *imx214) { int ret; - ret = regmap_write(imx214->regmap, 0x100, 0); + ret = regmap_write(imx214->regmap, IMX214_REG_MODE_SELECT, IMX214_MODE_STANDBY); if (ret < 0) dev_err(imx214->dev, "could not sent stop table %d\n", ret); @@ -991,9 +1002,12 @@ static int imx214_probe(struct i2c_client *client) * * Yours sincerely, Ricardo. */ - imx214->exposure = v4l2_ctrl_new_std(&imx214->ctrls, &imx214_ctrl_ops, + imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops, V4L2_CID_EXPOSURE, - 0, 3184, 1, 0x0c70); + IMX214_EXPOSURE_MIN, + IMX214_EXPOSURE_MAX, + IMX214_EXPOSURE_STEP, + IMX214_EXPOSURE_DEFAULT); imx214->unit_size = v4l2_ctrl_new_std_compound(&imx214->ctrls, NULL,