mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: "André Apitzsch" <git@apitzsch.eu>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Ricardo Ribalda" <ribalda@kernel.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>
Cc: "Jacopo Mondi" <jacopo.mondi@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	"André Apitzsch" <git@apitzsch.eu>,
	"Ricardo Ribalda" <ribalda@chromium.org>
Subject: Re: [PATCH v3 1/4] media: i2c: imx214: Explain some magic numbers
Date: Mon, 30 Oct 2023 15:57:45 +0000	[thread overview]
Message-ID: <169868146535.388626.1249625693260183894@ping.linuxembedded.co.uk> (raw)
In-Reply-To: <20231028-imx214-v3-1-cd4bf77f9690@apitzsch.eu>

Quoting André Apitzsch (2023-10-28 09:41:45)
> Code refinement, no functional changes.
> 
> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> 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..1c30f6666d35 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                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,
> 
> -- 
> 2.42.0
>

  reply	other threads:[~2023-10-30 15:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-28  8:41 [PATCH v3 0/4] media: i2c: imx214: Extend with sensor size and firmware information André Apitzsch
2023-10-28  8:41 ` [PATCH v3 1/4] media: i2c: imx214: Explain some magic numbers André Apitzsch
2023-10-30 15:57   ` Kieran Bingham [this message]
2023-10-28  8:41 ` [PATCH v3 2/4] media: i2c: imx214: Move controls init to separate function André Apitzsch
2023-10-28  8:41 ` [PATCH v3 3/4] media: i2c: imx214: Read orientation and rotation from system firmware André Apitzsch
2023-10-28  8:41 ` [PATCH v3 4/4] media: i2c: imx214: Add sensor's pixel matrix size André Apitzsch
2023-11-26 22:06 ` [PATCH v3 0/4] media: i2c: imx214: Extend with sensor size and firmware information André Apitzsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=169868146535.388626.1249625693260183894@ping.linuxembedded.co.uk \
    --to=kieran.bingham@ideasonboard.com \
    --cc=git@apitzsch.eu \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ribalda@chromium.org \
    --cc=ribalda@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®