Skip to content

isp: crop a centred window with the output's aspect ratio - #338

Open
vrilutza wants to merge 2 commits into
patjak:masterfrom
vrilutza:crop-window
Open

isp: crop a centred window with the output's aspect ratio#338
vrilutza wants to merge 2 commits into
patjak:masterfrom
vrilutza:crop-window

Conversation

@vrilutza

@vrilutza vrilutza commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Sits on top of #330 (merged) — the patch mentioned there as not sent yet.

Commit 1 renames the crop command's fields to match what they hold. Commit 2 is the actual fix: fthd_start_channel() cropped a window the size of the output, leaving nothing for the ISP to scale, so any size below the sensor came back as the top-left corner of the frame.

Verified on a MacBookPro14,1 by recovering the actual crop window from captured frames.

On the & ~1u masks. Measured on a MacBookPro14,1 by driving the crop command directly: the ISP stops delivering frames, and the camera stays dead until the module is reloaded, when x and the width are both odd — at every scale factor tried, 1.0000 through 1.5333 — and also when x alone is odd and the crop has the same width as the output, so the scaler is bypassed. An odd y or an odd height is harmless on this machine, but is masked too rather than relying on one camera. CISP_CMD_CH_CROP_SET returns 0 in all of those cases, so there is nothing to test for at runtime.

CISP_CMD_CH_CROP_SET does not take two corners: the third and fourth values
are the window's width and height, not the coordinates of its far edge, and
the first two are the offset. Rename the fields and the function's
parameters to match; the only existing caller (0, 0, width, height) is
unaffected.

No functional change.

Signed-off-by: Viorel Cernateanu <vrilutza@gmail.com>
fthd_start_channel() cropped a window the size of the negotiated output, at
the sensor origin, then asked for an output of that same size -- leaving
nothing to scale, so any size below the sensor came back as the top-left
corner of the frame.

Crop the largest centred window that has the output's aspect ratio instead,
and let the ISP scale it down. The window and its offset are derived from
the sensor's own reported size, so neither can exceed it -- unlike the old
hardcoded 1280x720, which overflows the 12-inch MacBook's 848x588 sensor and
throws SIF errors.

The masks are not cosmetic. Measured on a MacBookPro14,1 by driving the crop
command directly: the ISP stops delivering frames, and the camera stays dead
until the module is reloaded, when x and the width are both odd -- at every
scale factor tried, 1.0000 through 1.5333 -- and also when x alone is odd and
the crop has the same width as the output, so the scaler is bypassed. An odd
y or an odd height is harmless here, but is masked too rather than relying on
one machine. CISP_CMD_CH_CROP_SET returns 0 in all of those cases, so there is
nothing to test for at runtime.

Signed-off-by: Viorel Cernateanu <vrilutza@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant