Message ID | 20231023-imx214-v1-1-b33f1bbd1fcf@apitzsch.eu |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1571362vqx; Mon, 23 Oct 2023 14:49:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdPpnOgM3cvZr1eN8NnXix/+3DzqFVAoB3PDKU3EUQPRIVX0ZlNLvcRHx+5kL3iCdgGGm3 X-Received: by 2002:a05:6a20:8f1d:b0:153:b16e:8db1 with SMTP id b29-20020a056a208f1d00b00153b16e8db1mr1018220pzk.10.1698097786953; Mon, 23 Oct 2023 14:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698097786; cv=none; d=google.com; s=arc-20160816; b=rFEYF7ACxRpdMyymrBWJzpOOvUHJXwo9YdAMjWcgZlBwQJFlA7gYItksXRu6C8PneC Md96kTdbVJkyDxOVQ397YHfBaMqEWJfnZWtC8oKHECzgZSJGGJcbprinbyz51/5AM0ZE bVudBlC9JmUo5tkZmMmDI8AVxOnots9+/yet/onNSLLJEW1oxFA+lazqBy46RM15lAYC KiAqNviKu3MXzJWZO2oytuYvG67x2prcGlwsxGcf4Reelqs5gVq+V6E4ncRN+IzlC39r lG1fqnuSitlJOu2IQRXD+OrfjrFwqyZnNP5E39Thfez5CJCqBhnBp/YH3GmhXX0G/VcK QtjQ== 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.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 v19-20020a17090ac91300b0027e022bd420si8225911pjt.77.2023.10.23.14.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 14:49:46 -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 D7BEF80C055A; Mon, 23 Oct 2023 14:49:45 -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 S232475AbjJWVtk (ORCPT <rfc822;aposhian.dev@gmail.com> + 27 others); Mon, 23 Oct 2023 17:49:40 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <git@apitzsch.eu>) id 1qv2ng-0004Kz-1Y; Mon, 23 Oct 2023 23:49:28 +0200 From: =?utf-8?q?Andr=C3=A9_Apitzsch?= <git@apitzsch.eu> 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 <ribalda@kernel.org>, Sakari Ailus <sakari.ailus@linux.intel.com>, Mauro Carvalho Chehab <mchehab@kernel.org> Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, =?utf-8?q?Andr=C3=A9_Apitzsch?= <git@apitzsch.eu> X-Mailer: b4 0.12.3 X-Df-Sender: YW5kcmVAYXBpdHpzY2guZXU= X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL,SPF_HELO_PASS,SPF_PASS autolearn=no 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: <linux-kernel.vger.kernel.org> 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]); Mon, 23 Oct 2023 14:49:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780584585492167583 X-GMAIL-MSGID: 1780584585492167583 |
Series |
media: i2c: imx214: Extend with sensor size and firmware information
|
|
Commit Message
André Apitzsch
Oct. 23, 2023, 9:47 p.m. UTC
Code refinement, no functional changes.
Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
drivers/media/i2c/imx214.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
Comments
Quoting André Apitzsch (2023-10-23 22:47:50) > Code refinement, no functional changes. > > Signed-off-by: André Apitzsch <git@apitzsch.eu> > --- > 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 <media/v4l2-fwnode.h> > #include <media/v4l2-subdev.h> > > +#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 I like this change, and I see that 0x0c70 was directly moved here from the code below. But could we replace 0xc70 here with 3184 please so that it's /far/ clearer that the Exposure Default == Exposure Max which is otherwise hidden? -- Regards Kieran > + > 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 >
Am Montag, dem 23.10.2023 um 23:44 +0100 schrieb Kieran Bingham: > Quoting André Apitzsch (2023-10-23 22:47:50) > > Code refinement, no functional changes. > > > > Signed-off-by: André Apitzsch <git@apitzsch.eu> > > --- > > 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 <media/v4l2-fwnode.h> > > #include <media/v4l2-subdev.h> > > > > +#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 > > I like this change, and I see that 0x0c70 was directly moved here > from > the code below. But could we replace 0xc70 here with 3184 please so > that > it's /far/ clearer that the Exposure Default == Exposure Max which is > otherwise hidden? > Hi Kieran, I can do that. But I propose to replace 3184 with 0x0c70 instead. Because that matches the entries used in the reg_8 lists mode_4096x2304[] and mode_1920x1080[]. {0x0202, 0x0C}, {0x0203, 0x70}, What do you think? Regards, André > -- > Regards > > Kieran >
Quoting André Apitzsch (2023-10-24 08:30:01) > Am Montag, dem 23.10.2023 um 23:44 +0100 schrieb Kieran Bingham: > > Quoting André Apitzsch (2023-10-23 22:47:50) > > > Code refinement, no functional changes. > > > > > > Signed-off-by: André Apitzsch <git@apitzsch.eu> > > > --- > > > 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 <media/v4l2-fwnode.h> > > > #include <media/v4l2-subdev.h> > > > > > > +#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 > > > > I like this change, and I see that 0x0c70 was directly moved here > > from > > the code below. But could we replace 0xc70 here with 3184 please so > > that > > it's /far/ clearer that the Exposure Default == Exposure Max which is > > otherwise hidden? > > > Hi Kieran, > > I can do that. But I propose to replace 3184 with 0x0c70 instead. > Because that matches the entries used in the reg_8 lists > mode_4096x2304[] and mode_1920x1080[]. > > {0x0202, 0x0C}, > {0x0203, 0x70}, > > What do you think? I think exposure values are easier to read as integers than hex values. This is the 'Coarse Integration Time' register with a unit of 'lines'. If you have lots of time, or wish to delve deeper - we could talk about splitting out those register tables to use CCI and/or more readable functions ;-) Do you have the datasheet for this sensor - or are you just working from the information within this driver? What device are you using to test this driver? -- Kieran > Regards, > André
Am Dienstag, dem 24.10.2023 um 13:52 +0100 schrieb Kieran Bingham: > Quoting André Apitzsch (2023-10-24 08:30:01) > > Am Montag, dem 23.10.2023 um 23:44 +0100 schrieb Kieran Bingham: > > > Quoting André Apitzsch (2023-10-23 22:47:50) > > > > Code refinement, no functional changes. > > > > > > > > Signed-off-by: André Apitzsch <git@apitzsch.eu> > > > > --- > > > > 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 <media/v4l2-fwnode.h> > > > > #include <media/v4l2-subdev.h> > > > > > > > > +#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 > > > > > > I like this change, and I see that 0x0c70 was directly moved here > > > from > > > the code below. But could we replace 0xc70 here with 3184 please > > > so > > > that > > > it's /far/ clearer that the Exposure Default == Exposure Max > > > which is > > > otherwise hidden? > > > > > Hi Kieran, > > > > I can do that. But I propose to replace 3184 with 0x0c70 instead. > > Because that matches the entries used in the reg_8 lists > > mode_4096x2304[] and mode_1920x1080[]. > > > > {0x0202, 0x0C}, > > {0x0203, 0x70}, > > > > What do you think? > > I think exposure values are easier to read as integers than hex > values. Okay, integer it is. > > This is the 'Coarse Integration Time' register with a unit of > 'lines'. > > If you have lots of time, or wish to delve deeper - we could talk > about splitting out those register tables to use CCI and/or more > readable functions ;-) I will consider it. > > Do you have the datasheet for this sensor - or are you just working > from the information within this driver? I don't have the datasheet, yet (maybe somebody could provide it), so I have to work with the information within this driver and downstream implementations, like the one by nvidia [1]. > > What device are you using to test this driver? > The sensor is part of my mobile, BQ Aquaris M5 (Longcheer L9100). Best regards, André [1] https://github.com/InES-HPMM/linux-l4t/blob/9150157d2b1f73aefe01e9a07e3b062a45d57247/drivers/media/i2c/imx214_mode_tbls.h > -- > Kieran > > > Regards, > > André
Hi André 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 PM André Apitzsch <git@apitzsch.eu> wrote: > > Code refinement, no functional changes. > > Signed-off-by: André Apitzsch <git@apitzsch.eu> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org> > --- > 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 <media/v4l2-fwnode.h> > #include <media/v4l2-subdev.h> > > +#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 >
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 <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h> +#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,