From patchwork Sat Oct 28 08:41:45 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: 159242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1109634vqb; Sat, 28 Oct 2023 01:43:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrX5VChz8owppi5CEpkN4qTJLuYOq3xgceAx9ME+wQG4puMNHrYCG8DwL+X4BguRgo+n/8 X-Received: by 2002:a05:6a21:47c6:b0:17d:9da4:5eb3 with SMTP id as6-20020a056a2147c600b0017d9da45eb3mr4676708pzc.56.1698482617951; Sat, 28 Oct 2023 01:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698482617; cv=none; d=google.com; s=arc-20160816; b=tTCbQp1hqJmJm2DllLTfvKMzx2BqVQntsY6FuB2p5olN33KJm3GgJSHbWd/UT2KGbz TzP5quEjMt3KVmWYDvLfhO34EUaFxvMJO8gyXNS5aSC1K+gEhNb0FWjmApV5sDIVlJMO pomR27SqQHN24HbJvfn30EO+hhmbceI2FgEnfjtToRKNm5M6k2ZAy7XjQK+xrdHaXA4I 4fzqGn3wSjtSScwNF+XT3VMO49fN0QDVefwURvWxk/CbJUtccaoKXPY6+Mxa5G1gmJm9 ElSzk5m7fDzbJfB1j7owZW+6+8c+O3LxoZL/sbBRFbhak3E/iT5GeTnEiZGNC+wR63oo 0AZA== 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=IRidpg4JVPRDAFnHMvszIf1boZcA1du4Z2zZ/L6U1Js=; fh=Zgky+q+8PvhHkxojJIPDJHGW0QVIUIBdH6AVhu4TA4w=; b=L03NHJCri0rBWyMjjLZJGJOiDjGuK7RUtp2YoCG9gZDwfEh+XJAmvZLxfMSY1xbjhk d/xxFnWFNg7uQVn7Hj6228MF2C83IRkn8lLN1gqY6EuELdF2EYQ3bfCQNSszswhoNytS zl1IiXM/kCYs1RqRW8joB1RZFtZVicpYw9rb4A/bYxPmcqiYo5KkE0Qwtzs4PAVLpJvQ 2lTlHTvyiqixQ7zHiC84qN4f2hmGjOHnO36YNoxXo0Z9N3ZFNEf3qJhMC00vktWxTZxR pMGpxzUvZvxW8olxrqlV3fxWU/PK0mn3L7pku5AQfvjVPr8MtNztK6mhV0ZXuckgfBoP XA3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t9-20020a170902b20900b001c4660cd474si2241871plr.634.2023.10.28.01.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 01:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 8A54180A184C; Sat, 28 Oct 2023 01:42:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231945AbjJ1Imb (ORCPT + 28 others); Sat, 28 Oct 2023 04:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjJ1ImW (ORCPT ); Sat, 28 Oct 2023 04:42:22 -0400 Received: from smtprelay07.ispgateway.de (smtprelay07.ispgateway.de [134.119.228.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EEF710A; Sat, 28 Oct 2023 01:42:19 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay07.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qwetc-0006mt-0x; Sat, 28 Oct 2023 10:42:16 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Sat, 28 Oct 2023 10:41:45 +0200 Subject: [PATCH v3 1/4] media: i2c: imx214: Explain some magic numbers MIME-Version: 1.0 Message-Id: <20231028-imx214-v3-1-cd4bf77f9690@apitzsch.eu> References: <20231028-imx214-v3-0-cd4bf77f9690@apitzsch.eu> In-Reply-To: <20231028-imx214-v3-0-cd4bf77f9690@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.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 28 Oct 2023 01:42:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780988109994393850 X-GMAIL-MSGID: 1780988109994393850 Code refinement, no functional changes. Reviewed-by: Ricardo Ribalda Signed-off-by: André Apitzsch Reviewed-by: Kieran Bingham --- 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 4f77ea02cc27..1c30f6666d35 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,