Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tuan Kiet Huynh" <huynhtuankiet33@gmail.com>,
	devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v2 2/2] media: i2c: Add Samsung S5K5E8YX camera sensor driver
Date: Sat, 21 Nov 2026 12:31:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-227013@kernel.org> (raw)
In-Reply-To: <20261121120731.2028810-3-huynhtuankiet33@gmail.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] media: s5k5e8yx: stale mode and unchecked ctrls in
  s5k5e8yx_set_pad_format()
- [Medium] media: s5k5e8yx: missing 0x3307 and 0x3308 writes in 1304x980
  mode table
- [Medium] media: s5k5e8yx: pad format code not updated on flip in
  s5k5e8yx_set_ctrl()
- [Medium] media: s5k5e8yx: missing streaming check in
  s5k5e8yx_set_pad_format()
- [Low] media: s5k5e8yx: unused macro definition S5K5E8YX_AGAIN_SHIFT
--

commit 4982bbedacda1f130bf60b5814bdb3330ccbf970
Author: Andrii Cherniavskyi <chernyav.a@gmail.com>

media: i2c: Add Samsung S5K5E8YX camera sensor driver

This commit adds a V4L2 subdev driver for the Samsung S5K5E8YX 5MP CMOS
image sensor supporting 2592x1944 (30 fps) and 1304x980 (60 fps) RAW10 GRBG
modes.

> diff --git a/drivers/media/i2c/s5k5e8yx.c b/drivers/media/i2c/s5k5e8yx.c
> new file mode 100644
> index 0000000000000..5ad42e2fc7e14
> --- /dev/null
> +++ b/drivers/media/i2c/s5k5e8yx.c
> @@ -0,0 +1,972 @@

[ ... ]

> +#define S5K5E8YX_REG_AGAIN		CCI_REG16(0x0204)
> +#define S5K5E8YX_AGAIN_MIN		0x020
> +#define S5K5E8YX_AGAIN_MAX		0x200
> +#define S5K5E8YX_AGAIN_STEP		1
> +#define S5K5E8YX_AGAIN_DEFAULT		0x020
> +#define S5K5E8YX_AGAIN_SHIFT		5

[Severity: Low]
S5K5E8YX_AGAIN_SHIFT is unused since S5K5E8YX_AGAIN_MIN and
S5K5E8YX_AGAIN_MAX are already pre-shifted and written directly to
S5K5E8YX_REG_AGAIN.

[ ... ]

> +static const struct cci_reg_sequence s5k5e8yx_2592x1944_30fps_mode[] = {

[ ... ]

> +	{ CCI_REG8(0x3306), 0x00 },
> +	{ CCI_REG8(0x3307), 0x08 },
> +	{ CCI_REG8(0x3308), 0x0a },
> +	{ CCI_REG8(0x3309), 0x27 },
> +	{ CCI_REG8(0x330a), 0x01 },
> +	{ CCI_REG8(0x330b), 0x01 },
> +	{ CCI_REG8(0x330e), 0x00 },
> +	{ CCI_REG8(0x330f), 0x08 },
> +	{ CCI_REG8(0x3310), 0x07 },
> +	{ CCI_REG8(0x3311), 0x9f },
> +	{ CCI_REG8(0x3312), 0x01 },
> +	{ CCI_REG8(0x3313), 0x01 },
> +};
> +
> +static const struct cci_reg_sequence s5k5e8yx_1304x980_60fps_mode[] = {

[ ... ]

> +	{ CCI_REG8(0x3306), 0x00 },
> +	{ CCI_REG8(0x3309), 0x2f },
> +	{ CCI_REG8(0x330a), 0x01 },
> +	{ CCI_REG8(0x330b), 0x01 },
> +	{ CCI_REG8(0x330e), 0x00 },
> +	{ CCI_REG8(0x330f), 0x00 },
> +	{ CCI_REG8(0x3310), 0x07 },
> +	{ CCI_REG8(0x3311), 0xa7 },
> +	{ CCI_REG8(0x3312), 0x03 },
> +	{ CCI_REG8(0x3313), 0x01 },
> +};

[Severity: Medium]
Should s5k5e8yx_1304x980_60fps_mode[] also program registers 0x3307 (0x00)
and 0x3308 (0x0a)?

s5k5e8yx_2592x1944_30fps_mode[] writes 0x08 to 0x3307 and init_array_setting
does not touch 0x3307 or 0x3308.  If streaming is restarted in 1304x980
mode before runtime-PM autosuspend powers down the sensor (or when optional
reset/standby GPIOs are absent), 0x3307 retains 0x08 from the 2592x1944
mode instead of 0x00.

[ ... ]

> +static int s5k5e8yx_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> +	struct s5k5e8yx *s5k5e8yx =
> +		container_of(ctrl->handler, struct s5k5e8yx, ctrl_handler);
> +	const struct s5k5e8yx_mode *mode = s5k5e8yx->mode;
> +	s64 exposure_max;
> +	int ret;
> +
> +	/* Propagate change of current control to all related controls */
> +	switch (ctrl->id) {
> +	case V4L2_CID_VBLANK:
> +		/* Update max exposure while meeting expected vblanking */
> +		exposure_max =
> +			mode->height + ctrl->val - S5K5E8YX_EXPOSURE_MARGIN;
> +		__v4l2_ctrl_modify_range(s5k5e8yx->exposure,
> +					 s5k5e8yx->exposure->minimum,
> +					 exposure_max, s5k5e8yx->exposure->step,
> +					 s5k5e8yx->exposure->default_value);
> +		break;
> +	}

[Severity: Medium]
Does changing V4L2_CID_HFLIP or V4L2_CID_VFLIP leave the active subdev state
pad format code out of sync with the hardware Bayer order?

Flipping immediately changes the Bayer media bus code returned by
s5k5e8yx_get_format_code(), which s5k5e8yx_enum_mbus_code() and
s5k5e8yx_enum_frame_size() use, and both controls carry
V4L2_CTRL_FLAG_MODIFY_LAYOUT.  However, s5k5e8yx_set_ctrl() never updates
v4l2_subdev_state_get_format(state, 0)->code, so v4l2_subdev_get_fmt() and
v4l2_subdev_link_validate() continue to report the old Bayer format code
unless VIDIOC_SUBDEV_S_FMT is called again.

[ ... ]

> +static int s5k5e8yx_set_pad_format(struct v4l2_subdev *sd,
> +				   const struct v4l2_subdev_client_info *ci,
> +				   struct v4l2_subdev_state *state,
> +				   struct v4l2_subdev_format *fmt)
> +{
> +	struct s5k5e8yx *s5k5e8yx = to_s5k5e8yx(sd);
> +	s64 hblank, vblank, exposure_max;
> +	const struct s5k5e8yx_mode *mode;
> +
> +	mode = v4l2_find_nearest_size(s5k5e8yx_supported_modes,
> +				      ARRAY_SIZE(s5k5e8yx_supported_modes),
> +				      width, height, fmt->format.width,
> +				      fmt->format.height);
> +
> +	s5k5e8yx_update_pad_format(s5k5e8yx, mode, &fmt->format);
> +
> +	/* Format code could be updated with respect to flip controls */
> +	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY || s5k5e8yx->mode == mode)
> +		goto set_format;

[Severity: Medium]
Should s5k5e8yx_set_pad_format() reject V4L2_SUBDEV_FORMAT_ACTIVE changes
with -EBUSY when v4l2_subdev_is_streaming(sd) is true?

The V4L2 subdev core does not block VIDIOC_SUBDEV_S_FMT while streaming.
Without that check, changing the active format mid-stream updates
s5k5e8yx->mode, control ranges, and the active pad format, and writes the
new mode's VTS and exposure registers to the running sensor while its PLL,
binning, HTS, and output size registers remain configured for the old mode.

> +
> +	hblank = mode->hts - mode->width;
> +	__v4l2_ctrl_modify_range(s5k5e8yx->hblank, hblank, hblank, 1, hblank);
> +
> +	vblank = mode->vts - mode->height;
> +	__v4l2_ctrl_modify_range(s5k5e8yx->vblank, vblank,
> +				 S5K5E8YX_VTS_MAX - mode->height, 1, vblank);
> +	__v4l2_ctrl_s_ctrl(s5k5e8yx->vblank, vblank);
> +
> +	exposure_max = mode->vts - S5K5E8YX_EXPOSURE_MARGIN;
> +	__v4l2_ctrl_modify_range(s5k5e8yx->exposure, S5K5E8YX_EXPOSURE_MIN,
> +				 exposure_max, S5K5E8YX_EXPOSURE_STEP,
> +				 mode->exposure);
> +	__v4l2_ctrl_s_ctrl(s5k5e8yx->exposure, mode->exposure);
> +
> +	if (s5k5e8yx->sd.ctrl_handler->error)
> +		return s5k5e8yx->sd.ctrl_handler->error;
> +
> +	s5k5e8yx->mode = mode;

[Severity: Medium]
Should s5k5e8yx->mode be updated before updating the vblank and exposure
controls?

__v4l2_ctrl_modify_range() and __v4l2_ctrl_s_ctrl() on s5k5e8yx->vblank
synchronously invoke s5k5e8yx_set_ctrl(), which reads s5k5e8yx->mode->height.
Because s5k5e8yx->mode still points to the previous mode here,
s5k5e8yx_set_ctrl() computes exposure_max with the old mode height and, if
the device is runtime-PM active (such as during the 1000 ms autosuspend
window after probe or stream stop), writes ctrl->val + old_mode->height to
S5K5E8YX_REG_VTS.

In addition, __v4l2_ctrl_modify_range() and __v4l2_ctrl_s_ctrl() return
their error code directly and do not set ctrl_handler->error, so checking
s5k5e8yx->sd.ctrl_handler->error never catches control or I2C failures here.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121120731.2028810-1-huynhtuankiet33@gmail.com?part=2

      reply	other threads:[~2026-11-21 12:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  9:19 [PATCH 1/2] dt-bindings: media: i2c: Add Samsung S5K5E8YX image sensor Tuan Kiet Huynh
2026-11-21  9:19 ` [PATCH 2/2] media: i2c: Add Samsung S5K5E8YX camera sensor driver Tuan Kiet Huynh
2026-11-21 12:07 ` [PATCH v2 0/2] " Tuan Kiet Huynh
2026-11-21 12:07   ` [PATCH v2 1/2] dt-bindings: media: i2c: Add Samsung S5K5E8YX image sensor Tuan Kiet Huynh
2026-11-21 12:07   ` [PATCH v2 2/2] media: i2c: Add Samsung S5K5E8YX camera sensor driver Tuan Kiet Huynh
2026-11-21 12:31     ` sashiko-bot [this message]

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-227013@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=huynhtuankiet33@gmail.com \
    --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