Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1113369rdh; Fri, 27 Oct 2023 05:19:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFK9t8PVdHvacfz2f/QvKrq8y3M/8FBXMePaH6Glhu30V3QIRyaLnXEk5z8UD5xAkFDr7Kh X-Received: by 2002:a9d:6d0b:0:b0:6c4:a036:cc1b with SMTP id o11-20020a9d6d0b000000b006c4a036cc1bmr2540502otp.35.1698409178694; Fri, 27 Oct 2023 05:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698409178; cv=none; d=google.com; s=arc-20160816; b=C46BJhVRsXZWQhLlESNEhW+8IVjUMZTR6WtL0KZHA0zNiAT+PoEK2XwhM6DQqEA6f0 wZATV/Nw6A2vuMZ7sWHC4eYY9HP7c9H/IJcaVZHHKvDzwMwP6VcXeCQPkp2ENZedQrwX HY/536JS8GA+ag2gsUP2fDmXrIxB3oj4vG2vZRo92QutGqYjO/C3+Vnq5bofWOvLmINC g8tzMwJMplYb+fK/PIkJSUxvVoCK7/RPFfymvtQ7Vad/1RkrQWFUK+jlMFnlQqX183RE QkwoQbCZluS9OVGrSJyWScnyfJ+cX99HfsEYnfQeBbtSxbUC3umsW51SvFDtfxOf5aml vouA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AqcUK3rMJRfjCsMGrGcxUH3oQEAbifCdSyDlZBjCPTU=; fh=bv1cIc//zgrvF1XRiGbhys0cHoa9qReyr+OfULjED2E=; b=a7iKHsfo4NC9rWPGxNVAaa52Bi5MgeKgvsSqzg7Zu6qryha25npj6YJPg5tl0DBx/K q0cfsoyh9t2gs7grEQNK5YRM6szueTMc+chdiTQ8IxmYqXwxH3L6THIduWA5TQ6UbGkr IMlO+1M7d2wMi8Q44JgPFHbC+UYyNZVgFYfmnD6isT69S/+sBHw0D5o7lYRMuTZb0FJb xF8Jup9CVEEwvO/yZxyKARPZ7wQzLaji4sWc7VFzFf7S5gXiutc8wfBH1c0G6fMt/zIa K90bdWB4+FwJKKuCegeW5jbvL4pfdaANbDK0VG3iTzKqOu4OvNqCE6e6wG98wZLs/MjH vmcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="puLdL/mE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n64-20020a0de443000000b005a8612df2ecsi1956148ywe.476.2023.10.27.05.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 05:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="puLdL/mE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6009082516EA; Fri, 27 Oct 2023 05:19:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345809AbjJ0MT1 (ORCPT + 99 others); Fri, 27 Oct 2023 08:19:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345796AbjJ0MTZ (ORCPT ); Fri, 27 Oct 2023 08:19:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F54121; Fri, 27 Oct 2023 05:19:23 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FD6EC433C9; Fri, 27 Oct 2023 12:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698409163; bh=NKiYgbA3r0s+9hx1fHFamy9t0uf76ZTKQZG6f+4qCnQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=puLdL/mEhrpvSvhZHNUzcPmGXn3bGdDebNi3QBIEaaS6oqMbeH3ljMAa/IFDva0mm XCcIhYMNd2yNZM8YdD2v0NyKKnp7Dw8vqWyYCzd3+3gvcq9LKQTFEJhK0V1AkxQtBJ IS7ZLHoCduzA5GHJxsCKYgevqC1BZnSr958E7e0dHdvSRE0pzM4fO+XKeJz5ENkv8j QjZuaFQjkZlu74r0Tmimgy+Vh6Rmm5RveY9nmQ06mqFVN/HCPeT1+JwRnvbAZHrOHn pbX8XFVvd4w3IoJY6PuwxgxG0D53drlCM9d1tLQ3FvpQBZHgzkEs09NKnzdKBOHVG9 L5P1GyFyvR8bA== Received: by mail-vs1-f50.google.com with SMTP id ada2fe7eead31-457c134a702so751467137.1; Fri, 27 Oct 2023 05:19:23 -0700 (PDT) X-Gm-Message-State: AOJu0YzFmqozkrxM6cE8NcB4bf3Fl3T8/v9ZrauEx59Bu90Tns18JPdu KxD5YYkUQJMJnmgKzJAGme6key2UU50+vyuNprY= X-Received: by 2002:a67:ab4a:0:b0:44d:3d29:4940 with SMTP id k10-20020a67ab4a000000b0044d3d294940mr1688008vsh.35.1698409162622; Fri, 27 Oct 2023 05:19:22 -0700 (PDT) MIME-Version: 1.0 References: <20231023-imx214-v1-0-b33f1bbd1fcf@apitzsch.eu> <20231023-imx214-v1-1-b33f1bbd1fcf@apitzsch.eu> In-Reply-To: <20231023-imx214-v1-1-b33f1bbd1fcf@apitzsch.eu> From: Ricardo Ribalda Delgado Date: Fri, 27 Oct 2023 14:19:04 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/4] media: i2c: imx214: Explain some magic numbers To: git@apitzsch.eu Cc: Sakari Ailus , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 27 Oct 2023 05:19:35 -0700 (PDT) Hi Andr=C3=A9 Thanks for your patch! I usually do not care about creating a define for something that I use only once... but if you think this is more clear, let it be :) On Mon, Oct 23, 2023 at 11:49=E2=80=AFPM Andr=C3=A9 Apitzsch wrote: > > Code refinement, no functional changes. > > Signed-off-by: Andr=C3=A9 Apitzsch Reviewed-by: Ricardo Ribalda > --- > 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[] =3D { > "vdda", > "vddd", > @@ -665,7 +676,7 @@ static int imx214_set_ctrl(struct v4l2_ctrl *ctrl) > case V4L2_CID_EXPOSURE: > vals[1] =3D ctrl->val; > vals[0] =3D ctrl->val >> 8; > - ret =3D regmap_bulk_write(imx214->regmap, 0x202, vals, 2)= ; > + ret =3D regmap_bulk_write(imx214->regmap, IMX214_REG_EXPO= SURE, vals, 2); > if (ret < 0) > dev_err(imx214->dev, "Error %d\n", ret); > ret =3D 0; > @@ -743,7 +754,7 @@ static int imx214_start_streaming(struct imx214 *imx2= 14) > dev_err(imx214->dev, "could not sync v4l2 controls\n"); > goto error; > } > - ret =3D regmap_write(imx214->regmap, 0x100, 1); > + ret =3D regmap_write(imx214->regmap, IMX214_REG_MODE_SELECT, IMX2= 14_MODE_STREAMING); > if (ret < 0) { > dev_err(imx214->dev, "could not sent start table %d\n", r= et); > goto error; > @@ -761,7 +772,7 @@ static int imx214_stop_streaming(struct imx214 *imx21= 4) > { > int ret; > > - ret =3D regmap_write(imx214->regmap, 0x100, 0); > + ret =3D regmap_write(imx214->regmap, IMX214_REG_MODE_SELECT, IMX2= 14_MODE_STANDBY); > if (ret < 0) > dev_err(imx214->dev, "could not sent stop table %d\n", r= et); > > @@ -991,9 +1002,12 @@ static int imx214_probe(struct i2c_client *client) > * > * Yours sincerely, Ricardo. > */ > - imx214->exposure =3D v4l2_ctrl_new_std(&imx214->ctrls, &imx214_ct= rl_ops, > + imx214->exposure =3D v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_op= s, > V4L2_CID_EXPOSURE, > - 0, 3184, 1, 0x0c70); > + IMX214_EXPOSURE_MIN, > + IMX214_EXPOSURE_MAX, > + IMX214_EXPOSURE_STEP, > + IMX214_EXPOSURE_DEFAULT); > > imx214->unit_size =3D v4l2_ctrl_new_std_compound(&imx214->ctrls, > NULL, > > -- > 2.42.0 >