devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
To: Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Conor Dooley <conor+dt@kernel.org>,
	Hans Verkuil <hverkuil@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] media: i2c: Add OmniVision OV6211 image sensor driver
Date: Thu, 17 Jul 2025 18:00:11 +0300	[thread overview]
Message-ID: <7d1ee0d8-0ffc-4aae-8531-852ce8c8b4c0@linaro.org> (raw)
In-Reply-To: <175276139540.560048.14744394485094549778@ping.linuxembedded.co.uk>

Hi Kieran.

On 7/17/25 17:09, Kieran Bingham wrote:
> Quoting Vladimir Zapolskiy (2025-07-17 13:40:01)

<snip>

>> +       { 0x3808, 0x01 },
>> +       { 0x3809, 0x90 },
> 
> 0x190 == 400;
> 
>> +       { 0x380a, 0x01 },
>> +       { 0x380b, 0x90 },
> 
> So I bet these are the width and height registers.
> 
> Have you got a data sheet for this ? It would be /really/ far more
> helpful to break out the specific register updates here for the mode
> configuration at least.

No, I don't have a datasheet for this sensor.

What's imporatant the sensor controls are similar (identical?) to an old
OV6710 sensor (a guess from chip ID also), and there is a public driver
for that sensor written for the OLPC project, a number of controls may
be reused from that driver, however since it requires such an extensive
testing, it can be done later on.

I kindly ask to review the displayed supported modes/configurations
at the moment. FWIW your guess of mapping the registers to width/height
is correct.

<snip>

>> +static int ov6211_write_reg_list(struct ov6211 *ov6211,
>> +                                const struct ov6211_reg_list *r_list)
>> +{
>> +       struct i2c_client *client = v4l2_get_subdevdata(&ov6211->sd);
>> +       unsigned int i;
>> +       int ret;
>> +
>> +       for (i = 0; i < r_list->num_of_regs; i++) {
>> +               ret = ov6211_write_reg(ov6211, r_list->regs[i].address, 1,
>> +                                      r_list->regs[i].val);
>> +               if (ret) {
>> +                       dev_err_ratelimited(&client->dev,
>> +                                           "failed to write reg 0x%4.4x. error = %d\n",
>> +                                           r_list->regs[i].address, ret);
>> +                       return ret;
>> +               }
>> +       }
>> +
>> +       return 0;
>> +}
>> +
> 
> Please use CCI helpers now.
> 

It makes sense, thank you.

> 
>> +static int ov6211_set_ctrl(struct v4l2_ctrl *ctrl)
>> +{
>> +       struct ov6211 *ov6211 = container_of(ctrl->handler, struct ov6211,
>> +                                            ctrl_handler);
>> +       struct i2c_client *client = v4l2_get_subdevdata(&ov6211->sd);
>> +       int ret;
>> +
>> +       /* V4L2 controls values will be applied only when power is already up */
>> +       if (!pm_runtime_get_if_in_use(&client->dev))
>> +               return 0;
>> +
>> +       switch (ctrl->id) {
>> +       case V4L2_CID_ANALOGUE_GAIN:
>> +               ret = ov6211_write_reg(ov6211, OV6211_REG_ANALOGUE_GAIN,
>> +                                      OV6211_REG_VALUE_16BIT, ctrl->val);
>> +               break;
>> +       case V4L2_CID_EXPOSURE:
>> +               ret = ov6211_write_reg(ov6211, OV6211_REG_EXPOSURE,
>> +                                      OV6211_REG_VALUE_24BIT, ctrl->val << 4);
>> +               break;
> 
> What about V4L2_CID_HBLANK and V4L2_CID_VBLANK ?
> 

I don't have any information how to set/get this setting, the OV6710 driver
also does not provide any hints, so it should be omitted, I believe.

>> +       default:
>> +               ret = -EINVAL;
>> +               break;
>> +       }
>> +
>> +       pm_runtime_put(&client->dev);
>> +
>> +       return ret;
>> +}
>> +
>> +static const struct v4l2_ctrl_ops ov6211_ctrl_ops = {
>> +       .s_ctrl = ov6211_set_ctrl,
>> +};
>> +
>> +static int ov6211_init_controls(struct ov6211 *ov6211)
>> +{
>> +       struct v4l2_ctrl_handler *ctrl_hdlr;
>> +       s64 exposure_max;
>> +       int ret;
>> +
>> +       ctrl_hdlr = &ov6211->ctrl_handler;
>> +       ret = v4l2_ctrl_handler_init(ctrl_hdlr, 3);
>> +       if (ret)
>> +               return ret;
>> +
>> +       ctrl_hdlr->lock = &ov6211->mutex;
>> +
>> +       ov6211->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov6211_ctrl_ops,
>> +                                       V4L2_CID_LINK_FREQ,
>> +                                       ARRAY_SIZE(link_freq_menu_items) - 1,
>> +                                       0, link_freq_menu_items);
>> +       if (ov6211->link_freq)
>> +               ov6211->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>> +
>> +       v4l2_ctrl_new_std(ctrl_hdlr, &ov6211_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
>> +                         OV6211_ANALOGUE_GAIN_MIN, OV6211_ANALOGUE_GAIN_MAX,
>> +                         OV6211_ANALOGUE_GAIN_STEP,
>> +                         OV6211_ANALOGUE_GAIN_DEFAULT);
>> +
>> +       exposure_max = (ov6211->cur_mode->vts - OV6211_EXPOSURE_MAX_MARGIN);
>> +       ov6211->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov6211_ctrl_ops,
>> +                                            V4L2_CID_EXPOSURE,
>> +                                            OV6211_EXPOSURE_MIN, exposure_max,
>> +                                            OV6211_EXPOSURE_STEP,
>> +                                            OV6211_EXPOSURE_DEFAULT);
>> +
> 
> As well as the blanking - I think this driver is missing reporting the
> crop selection implementation to report the sensor crops.
> 

To the best of my knowledge there is no crops, so I believe this is irrelevant.

This particular sensor is extremely simple.

-- 
Best wishes,
Vladimir

  reply	other threads:[~2025-07-17 15:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 12:39 [PATCH 0/2] media: i2c: Add OmniVision OV6211 image sensor driver Vladimir Zapolskiy
2025-07-17 12:40 ` [PATCH 1/2] dt-bindings: media: i2c: Add OmniVision OV6211 image sensor Vladimir Zapolskiy
2025-07-18  7:01   ` Krzysztof Kozlowski
2025-07-17 12:40 ` [PATCH 2/2] media: i2c: Add OmniVision OV6211 image sensor driver Vladimir Zapolskiy
2025-07-17 14:09   ` Kieran Bingham
2025-07-17 15:00     ` Vladimir Zapolskiy [this message]
2025-07-17 15:07     ` Dave Stevenson
2025-07-18 15:27       ` Vladimir Zapolskiy
2025-07-21 10:38         ` Mehdi Djait
2025-07-21 11:48           ` Sakari Ailus
2025-07-21 12:37         ` Dave Stevenson
2025-07-18  7:07   ` Krzysztof Kozlowski
2025-07-18 14:47     ` Vladimir Zapolskiy

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=7d1ee0d8-0ffc-4aae-8531-852ce8c8b4c0@linaro.org \
    --to=vladimir.zapolskiy@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).