devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hikmah Gumelar" <hikmahgumelar@gmail.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v4 5/7] media: i2c: add ov12a10 image sensor driver
Date: Wed, 25 Nov 2026 12:50:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-233395@kernel.org> (raw)
In-Reply-To: <20261125123146.379057-6-hikmahgumelar@gmail.com>

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] media: i2c: ov12a10: missing v4l2_subdev_cleanup() in
  ov12a10_probe()
- [Medium] media: i2c: ov12a10: async subdev registered before enabling
  runtime PM
- [Medium] media: i2c: ov12a10: missing streaming check and state update
  in ov12a10_set_format()
- [Medium] media: i2c: ov12a10: Kconfig and Makefile entries misplaced
  into earlier commit
- [Low] media: i2c: ov12a10: inconsistent initial V4L2_CID_EXPOSURE
  maximum in ov12a10_init_controls()
- [Low] media: i2c: ov12a10: missing post-powerdown delay in
  ov12a10_power_on()
--

commit 470fcc60c01175d16a98461402ebe19e658c65b4
Author: Hikmah Gumelar <hikmahgumelar@gmail.com>

media: i2c: add ov12a10 image sensor driver

This commit adds a V4L2 subdevice driver for the OmniVision OV12A10 MIPI
CSI-2 CMOS image sensor supporting 1280x720 binned 10-bit Bayer output.

> diff --git a/drivers/media/i2c/ov12a10.c b/drivers/media/i2c/ov12a10.c
> new file mode 100644
> index 0000000000000..e314b0e2eba7e
> --- /dev/null
> +++ b/drivers/media/i2c/ov12a10.c
[ ... ]
> +static int ov12a10_power_on(struct device *dev)
> +{
> +	struct ov12a10 *ov12a10 = to_ov12a10(dev_get_drvdata(dev));
> +	int ret;
> +
> +	ret = regulator_bulk_enable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
> +	if (ret)
> +		return ret;
> +
> +	ret = clk_prepare_enable(ov12a10->xvclk);
> +	if (ret) {
> +		regulator_bulk_disable(OV12A10_NUM_SUPPLIES, ov12a10->supplies);
> +		return ret;
> +	}
> +
> +	msleep(35);
> +	if (ov12a10->pwdn_gpio)
> +		gpiod_set_value_cansleep(ov12a10->pwdn_gpio, 0);
> +	if (ov12a10->reset_gpio) {
> +		gpiod_set_value_cansleep(ov12a10->reset_gpio, 1);
> +		usleep_range(3000, 5000);
> +		gpiod_set_value_cansleep(ov12a10->reset_gpio, 0);
> +		msleep(35);
> +	}
> +	return 0;
> +}

[Severity: Low]
Does ov12a10_power_on() skip the post-deassertion startup delay when
pwdn_gpio is present without reset_gpio?  The initial msleep(35) runs while
pwdn_gpio is still asserted, and the second msleep(35) is gated on
ov12a10->reset_gpio, so on boards without reset-gpios the driver issues I2C
transactions immediately after deasserting powerdown.

[ ... ]

> +static int ov12a10_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> +	struct ov12a10 *ov12a10 = container_of(ctrl->handler, struct ov12a10, ctrl_handler);
> +	int ret = 0;
> +
> +	if (ctrl->id == V4L2_CID_VBLANK) {
> +		s64 exp_max = ov12a10->cur_mode->height + ctrl->val - 4;
> +
> +		ret = __v4l2_ctrl_modify_range(ov12a10->exposure, 4, exp_max, 1,
> +					       min_t(s64, 2400, exp_max));
> +		if (ret)
> +			return ret;
> +	}
[ ... ]
> +static int ov12a10_init_controls(struct ov12a10 *ov12a10)
> +{
[ ... ]
> +	v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_VBLANK, 124,
> +			  0x7fff - ov12a10->cur_mode->height, 1, 2656);
> +	ov12a10->hblank = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_HBLANK, hblank,
> +					    hblank, 1, hblank);
> +	if (ov12a10->hblank)
> +		ov12a10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> +	v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, 0x80, 0x7ff, 1, 0x300);
> +	ov12a10->exposure = v4l2_ctrl_new_std(hdl, &ov12a10_ctrl_ops, V4L2_CID_EXPOSURE, 4,
> +					      3360, 1, 2400);

[Severity: Low]
Should the initial V4L2_CID_EXPOSURE maximum in ov12a10_init_controls() be
3372 instead of 3360?  With default_mode.height = 720 and the default
V4L2_CID_VBLANK of 2656, ov12a10_set_ctrl() computes exp_max = 720 + 2656 -
4 = 3372, so the exposure maximum reported after probe changes from 3360 to
3372 on the first stream start when __v4l2_ctrl_handler_setup() runs.

[ ... ]

> +static int ov12a10_set_format(struct v4l2_subdev *sd,
> +			      const struct v4l2_subdev_client_info *ci,
> +			      struct v4l2_subdev_state *sd_state,
> +			      struct v4l2_subdev_format *fmt)
> +{
> +	struct ov12a10 *ov12a10 = to_ov12a10(sd);
> +
> +	ov12a10_update_pad_format(&default_mode, &fmt->format);
> +	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
> +		*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
> +	else
> +		ov12a10->cur_mode = &default_mode;
> +
> +	return 0;
> +}

[Severity: Medium]
Should ov12a10_set_format() return -EBUSY when fmt->which ==
V4L2_SUBDEV_FORMAT_ACTIVE and ov12a10->streaming is true, and update
*v4l2_subdev_state_get_format(sd_state, fmt->pad) for active formats as
well?  Because this driver implements .s_stream rather than
.enable_streams, the V4L2 core does not block active format updates while
streaming, and only updating sd_state on the V4L2_SUBDEV_FORMAT_TRY branch
leaves the active pad state stale for v4l2_subdev_get_fmt() and
v4l2_subdev_link_validate().

[ ... ]

> +	ov12a10->sd.state_lock = &ov12a10->mutex;
> +	ret = v4l2_subdev_init_finalize(&ov12a10->sd);
> +	if (ret)
> +		goto err_media;
> +	ret = v4l2_async_register_subdev_sensor(&ov12a10->sd);
> +	if (ret)
> +		goto err_media;
> +	pm_runtime_set_active(dev);
> +	pm_runtime_enable(dev);
> +	pm_runtime_idle(dev);
> +	return 0;
> +err_media:
> +	media_entity_cleanup(&ov12a10->sd.entity);
> +err_ctrl:
> +	v4l2_ctrl_handler_free(ov12a10->sd.ctrl_handler);
> +err_mutex:
> +	mutex_destroy(&ov12a10->mutex);
> +err_power:
> +	ov12a10_power_off(dev);
> +	return ret;
> +}

[Severity: Medium]
Does the err_media path in ov12a10_probe() leak the subdev active state
allocated by v4l2_subdev_init_finalize() when
v4l2_async_register_subdev_sensor() fails?  Unlike ov12a10_remove(), the
error unwind does not call v4l2_subdev_cleanup(&ov12a10->sd).

[Severity: Medium]
Can registering the async subdev before enabling runtime PM cause streaming
or control setup to fail if the receiver driver's async notifier is already
waiting?  v4l2_async_register_subdev_sensor() can immediately bind and
expose the subdevice while runtime PM is still disabled and marked
suspended, causing pm_runtime_resume_and_get() in ov12a10_set_stream() to
fail with -EACCES and pm_runtime_get_if_active() in ov12a10_set_ctrl() to
return -EINVAL and skip register writes.

[ ... ]

> +static struct i2c_driver ov12a10_i2c_driver = {
> +	.driver = {
> +		.name = "ov12a10",
> +		.pm = pm_ptr(&ov12a10_pm_ops),
> +		.of_match_table = ov12a10_of_match,
> +	},
> +	.probe = ov12a10_probe, .remove = ov12a10_remove,
> +};
> +module_i2c_driver(ov12a10_i2c_driver);
> +MODULE_DESCRIPTION("OmniVision OV12A10 12MP sensor driver");
> +MODULE_LICENSE("GPL");

[Severity: Medium]
Should the VIDEO_OV12A10 Kconfig and ov12a10.o Makefile entries be moved
into this commit from earlier commit "media: i2c: add s5k5e8 image sensor
driver" in this series?  Adding obj-$(CONFIG_VIDEO_OV12A10) += ov12a10.o in
the earlier commit breaks the build during git bisect whenever
CONFIG_VIDEO_OV12A10 is enabled before drivers/media/i2c/ov12a10.c exists.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125123146.379057-1-hikmahgumelar@gmail.com?part=5

  reply	other threads:[~2026-11-25 12:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 12:31 [PATCH v4 0/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-25 12:31 ` [PATCH v4 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-25 12:31 ` [PATCH v4 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-25 12:31 ` [PATCH v4 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-25 12:44   ` sashiko-bot
2026-11-25 12:31 ` [PATCH v4 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-25 12:31 ` [PATCH v4 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-25 12:50   ` sashiko-bot [this message]
2026-11-25 12:31 ` [PATCH v4 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-25 12:31 ` [PATCH v4 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-25 12:45   ` sashiko-bot

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=sashiko-outbox-233395@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hikmahgumelar@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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).