Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1501074rda; Mon, 23 Oct 2023 14:49:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTTJGoPz6FoeO2zUQNcK1uw5qHY4s0J0YnO4FB8LMwebsWEc+NS2bcJHdHx4U6gjvh2l3h X-Received: by 2002:a17:902:cec8:b0:1ca:b820:74ed with SMTP id d8-20020a170902cec800b001cab82074edmr10138101plg.14.1698097796906; Mon, 23 Oct 2023 14:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698097796; cv=none; d=google.com; s=arc-20160816; b=0dVebFWONLD1S9FETU8yBo0Ctq0m9W4mfZ5VU6CoXTj8KNtGrnZxSqjMxslmrdfYpx +Tw4e+wRFsuoYCWNL2wVYcb5wxcoweC//IsKIx4c6DRjr9I8HXqgn5/Twm1sRLO6xNF8 59Mkw8MA2nJvOzHuQ3Hg0P4LzkB0U7dnBa0niy+UfU54xdSq8sIF4BpRLMUR8Y3OILf8 7OgUGnexR2QgZtksudq1NeeNgYKfrzgHeZfqSM+/15wsJA8BWJg9u6GlUZfFSGlErRaM gRm84p2W4MII74JVaCZSyWsg+5WyMeiBOzxqUoZwd3GmBNJo0r+arpQvXivqDZNoObyX i4XA== 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=hjfXoVN3bkEwgLziR1nECUia4TO+JXVJv/b8AD785OA=; fh=p+mi5Td8bOurAzEd8CdVTJhDRtapyUXUHLHoRH6vUVQ=; b=rCxUVSbfh+FRCUvX6rqYnuBz6s9Vx3ACnqOPkjJlUYd5h7uwdXQ6UgwENJXQkK6Ken 2KCs8WA7G8PzO1oXsL1JPLip3Hi4+nr4GexgCVeEAOQ60vWbZDob+NZg8l43GsY+8wOr BDo8f7eydF6Z02n1b9Df963DHCv261kGKq9hR8jsBQK/kwgokUXBLbbjAfSG44CxChS/ V33FpuFAhVMJt7300PBn6jQ+vwJkfTcTAj+QZiy/KVqDYLpRrinzTbGytuqMQ60A4tzb iqNdp91yOpNwpau4FiCc8ouz0/nbSvmaOOrZ001GeGuWppVBlMN1faABKtS2dv5qgMVm JxDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u10-20020a170903124a00b001c9af06686dsi6769152plh.166.2023.10.23.14.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 8AD2980403A3; Mon, 23 Oct 2023 14:49:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbjJWVtj (ORCPT + 99 others); Mon, 23 Oct 2023 17:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbjJWVtf (ORCPT ); Mon, 23 Oct 2023 17:49:35 -0400 Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1653FD for ; Mon, 23 Oct 2023 14:49:32 -0700 (PDT) Received: from [92.206.139.21] (helo=note-book.lan) by smtprelay01.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qv2ng-0004Kz-1Y; Mon, 23 Oct 2023 23:49:28 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= Date: Mon, 23 Oct 2023 23:47:50 +0200 Subject: [PATCH 1/4] media: i2c: imx214: Explain some magic numbers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231023-imx214-v1-1-b33f1bbd1fcf@apitzsch.eu> References: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> In-Reply-To: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> To: Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 14:49:52 -0700 (PDT) Code refinement, no functional changes. 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 4f77ea02cc27..9218c149d4c8 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 0x0c70 + 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, -- 2.42.0