Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pengyu Luo" <mitltlatltl@gmail.com>
Cc: krzk+dt@kernel.org, robh@kernel.org, Frank.Li@kernel.org,
	conor+dt@kernel.org, devicetree@vger.kernel.org,
	imx@lists.linux.dev
Subject: Re: [PATCH v3 4/5] media: hi846: Add 6MP and 8MP modes support
Date: Tue, 12 May 2026 03:22:19 +0000	[thread overview]
Message-ID: <20260512032219.AFFD6C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511090924.269106-5-mitltlatltl@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Mismatch between hardware registers and V4L2 Selection API bounds for new 6MP/8MP modes.
- [Low] Brittle array size math for mode iteration depending on hardcoded array layout.
--

commit 6d3bd49fa87b78bd49f2c7ba2cecba16a37a6a83
Author: Pengyu Luo <mitltlatltl@gmail.com>

media: hi846: Add 6MP and 8MP modes support

This patch adds 6MP and 8MP modes for the hi846 sensor using 4-lane MIPI
CSI-2. It extracts register sequences from a downstream driver to maximize
sensor utilization.

> diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c
> index 9decfda747876..68302d0b7ca5f 100644
> --- a/drivers/media/i2c/hi846.c
> +++ b/drivers/media/i2c/hi846.c

[ ... ]

> @@ -1028,6 +1028,106 @@ static const struct hi846_reg mode_1632x1224_mipi_4lane[] = {
>  	{HI846_REG_TG_ENABLE,			0x0100},
>  };
>  
> +static const struct hi846_reg mode_3264x1836_config[] = {
> +	{HI846_REG_MODE_SELECT,			0x0000},
> +	{HI846_REG_Y_ODD_INC_FOBP,		0x1111},
> +	{HI846_REG_Y_ODD_INC_VACT,		0x1111},
> +	{HI846_REG_Y_ADDR_START_VACT_H,		0x0172},
> +	{HI846_REG_Y_ADDR_END_VACT_H,		0x089d},
> +	{HI846_REG_UNKNOWN_005C,		0x2101},
> +	{HI846_REG_FLL,				0x09de},
> +	{HI846_REG_LLP,				0x0ed8},
> +	{HI846_REG_BINNING_MODE,		0x0022},
> +	{HI846_REG_HBIN_MODE,			0x0000},
> +	{HI846_REG_UNKNOWN_0A24,		0x0000},
> +	{HI846_REG_X_START_H,			0x0000},

[ ... ]

> @@ -1128,9 +1228,59 @@ static const struct hi846_mode supported_modes[] = {
>  			.width = 1632 * 2,
>  			.height = 1224 * 2,
>  		},
> -	}
> +	},
> +	{
> +		.width = 3264,
> +		.height = 1836,

[ ... ]

> +		.crop = {
> +			.left = 0x46,
> +			.top = 0x172,
> +			.width = 3264,
> +			.height = 1836,
> +		},

Does this crop configuration exceed the V4L2 Selection API bounds?

In hi846_get_selection(), V4L2_SEL_TGT_CROP_BOUNDS and
V4L2_SEL_TGT_NATIVE_SIZE are hardcoded to width 3264 and height 2448 with
left and top set to 0. Here, crop.left is 0x46 and crop.width is 3264,
resulting in a right bound of 3334, which exceeds the native size.

Also, there appears to be a contradiction in the hardware registers. The
crop.left is set to 0x46 here, but HI846_REG_X_START_H is explicitly set to
0x0000 in the mode_3264x1836_config array.

Should crop.left be 0x00, or do the V4L2 hardware bounds and X_START_H need
to be updated to match the physical pixel array?

> +	},
> +	{
> +		.width = 3264,
> +		.height = 2448,

[ ... ]

> +		.crop = {
> +			.left = 0x46,
> +			.top = 0x40,
> +			.width = 3264,
> +			.height = 2448,
> +		},
> +	},
>  };
> -#define NUM_MODES_2LANE		ARRAY_SIZE(supported_modes)
> +#define NUM_MODES_2LANE		(ARRAY_SIZE(supported_modes) - 2)

Is it safe to rely on this array index arithmetic for mode support?

This implicitly assumes the supported_modes array is strictly ordered so
that the last two modes lack 2-lane support. If modes are added, removed,
or reordered in the future, these macros could silently produce incorrect
array boundaries.

Would it be safer to dynamically filter modes based on
reg_list_2lane.num_of_regs instead?

>  #define NUM_MODES_4LANE		(ARRAY_SIZE(supported_modes) - 1)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260511090924.269106-1-mitltlatltl@gmail.com?part=4

  reply	other threads:[~2026-05-12  3:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  9:09 [PATCH v3 0/5] fix and improve for Hi846 Pengyu Luo
2026-05-11  9:09 ` [PATCH v3 1/5] media: hi846: fix hi846_write_reg_16 handling Pengyu Luo
2026-05-11  9:36   ` Markus Elfring
2026-05-12  1:24   ` sashiko-bot
2026-05-11  9:09 ` [PATCH v3 2/5] media: hi846: fix link frequency handling Pengyu Luo
2026-05-11 10:42   ` Markus Elfring
2026-05-12  1:56   ` sashiko-bot
2026-05-11  9:09 ` [PATCH v3 3/5] media: hi846: fix modes handling for different lane cases Pengyu Luo
2026-05-12  2:35   ` sashiko-bot
2026-05-11  9:09 ` [PATCH v3 4/5] media: hi846: Add 6MP and 8MP modes support Pengyu Luo
2026-05-12  3:22   ` sashiko-bot [this message]
2026-05-11  9:09 ` [PATCH v3 5/5] arm64: dts: imx8mq-librem5: Correct link frequency list Pengyu Luo
2026-05-12  3:48   ` 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=20260512032219.AFFD6C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=krzk+dt@kernel.org \
    --cc=mitltlatltl@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko@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