From: sashiko-bot@kernel.org
To: "Pengyu Luo" <mitltlatltl@gmail.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
Frank.Li@kernel.org, imx@lists.linux.dev, krzk+dt@kernel.org
Subject: Re: [PATCH v4 4/5] media: hi846: Add 6MP and 8MP modes support
Date: Tue, 12 May 2026 05:13:03 +0000 [thread overview]
Message-ID: <20260512051303.7D4F1C2BCB8@smtp.kernel.org> (raw)
In-Reply-To: <20260511103927.279550-5-mitltlatltl@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The V4L2 crop rectangles for the newly added 6MP and 8MP modes exceed the static V4L2 crop bounds returned by `hi846_get_selection()` and contradict the hardware register configurations.
--
commit ba8b377e2d211a8774704df370bcbc25d095a60c
Author: Pengyu Luo <mitltlatltl@gmail.com>
media: hi846: Add 6MP and 8MP modes support
This patch adds 6MP and 8MP modes to maximize sensor utilization on the
hi846 sensor. These modes require 4-lane MIPI CSI-2 and use register
sequences extracted from the downstream Windows driver.
> diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c
> index c77b34a5e1662..12df1dc96163e 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[] = {
[ ... ]
> +static const struct hi846_reg mode_3264x2448_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, 0x0040},
> + {HI846_REG_Y_ADDR_END_VACT_H, 0x09cf},
> + {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},
Does this register configuration contradict the crop configuration below?
HI846_REG_X_START_H is configured to 0x0000, meaning the hardware reads
from column 0. However, the crop left offset is set to 0x46 (70). Exposing
a left crop offset to userspace while the hardware is programmed to read
from 0 seems contradictory.
> + {HI846_REG_X_OUTPUT_SIZE_H, 0x0cc0},
> + {HI846_REG_Y_OUTPUT_SIZE_H, 0x0990},
[ ... ]
> @@ -1128,9 +1228,59 @@ static const struct hi846_mode supported_modes[] = {
> .width = 1632 * 2,
> .height = 1224 * 2,
> },
> - }
> + },
[ ... ]
> + {
> + .width = 3264,
> + .height = 2448,
> + .pll_cfg_4lane = 0x4124, /* HI846_REG_PLL_CFG_MIPI2_H */
> + .fps = 30,
> + .frame_len = 2526,
> + .llp = HI846_LINE_LENGTH,
> + .reg_list_config = {
> + .num_of_regs = ARRAY_SIZE(mode_3264x2448_config),
> + .regs = mode_3264x2448_config,
> + },
> + .reg_list_2lane = {
> + .num_of_regs = 0,
> + },
> + .reg_list_4lane = {
> + .num_of_regs = ARRAY_SIZE(mode_3264x2448_mipi_4lane),
> + .regs = mode_3264x2448_mipi_4lane,
> + },
> + .crop = {
> + .left = 0x46,
> + .top = 0x40,
> + .width = 3264,
> + .height = 2448,
Could this crop configuration break userspace boundary checks?
In hi846_get_selection(), V4L2_SEL_TGT_CROP_BOUNDS unconditionally returns a
hardcoded rectangle:
static int hi846_get_selection(...)
{
...
case V4L2_SEL_TGT_CROP_BOUNDS:
case V4L2_SEL_TGT_NATIVE_SIZE:
sel->r.top = 0;
sel->r.left = 0;
sel->r.width = 3264;
sel->r.height = 2448;
return 0;
...
}
With the newly introduced 3264x2448 mode defining its active crop rectangle
with .left = 70 and .top = 64, the right boundary becomes 3334 and the bottom
boundary becomes 2512.
These values strictly exceed the crop bounds. According to the V4L2
specification, any valid crop rectangle must fit completely inside the crop
bounds. Returning a crop bound that is physically smaller than the allowed
crop geometries breaks boundary checks in applications like libcamera.
> + },
> + },
> };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511103927.279550-1-mitltlatltl@gmail.com?part=4
next prev parent reply other threads:[~2026-05-12 5:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 10:39 [PATCH v4 0/5] fix and improve for Hi846 Pengyu Luo
2026-05-11 10:39 ` [PATCH v4 1/5] media: hi846: fix hi846_write_reg_16 handling Pengyu Luo
2026-05-12 3:38 ` sashiko-bot
2026-05-11 10:39 ` [PATCH v4 2/5] media: hi846: fix link frequency handling Pengyu Luo
2026-05-12 4:08 ` sashiko-bot
2026-05-11 10:39 ` [PATCH v4 3/5] media: hi846: fix modes handling for different lane cases Pengyu Luo
2026-05-12 4:43 ` sashiko-bot
2026-05-11 10:39 ` [PATCH v4 4/5] media: hi846: Add 6MP and 8MP modes support Pengyu Luo
2026-05-12 5:13 ` sashiko-bot [this message]
2026-05-11 10:39 ` [PATCH v4 5/5] arm64: dts: imx8mq-librem5: Correct link frequency list Pengyu Luo
2026-05-12 5: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=20260512051303.7D4F1C2BCB8@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