Repository navigation
sony_imx335: mirror and flip in the sensor, every mode - #257
Conversation
pfnMirrorFlip was NULL, so applications fell back to flipping in VPSS, which costs low delay and YUV compression with mirror. The IMX335 can invert its own readout: HREVERSE (0x304E) mirrors, VREVERSE (0x304F) flips. Unlike SP2305 the colour order survives inversion. Measured on a gk7205v300 + IMX335 by comparing raw frames against the normal raw turned round: in every orientation of every mode below, the best match is at a colour-preserving offset and the per-CFA means are unchanged, so the ISP's RGGB stays as it is. What moves is the field of view, typically 25 px or lines per inverted axis, 12 in 2/2 binning, up to 33 in the 4M WDR windows, and none for mirror in the 2592x1520 crop: the readout is larger than the picture and the capture keeps the part that arrives first. Mirror is the one register. Flip needs the datasheet's per-mode set: - AREA3_ST_ADR_1 moves to the other end of the window, start + width + 8 for every all-pixel, window-crop and WDR mode (0x00B0 -> 0x1010 at full height, 0x0410 -> 0x0CB0 for the 1080p crop); - 0x3081 and 0x3083 go 0x02 -> 0xFE; left alone the raw saturates; - 2/2 binning uses its own table: start 0x1018, 0x3080-0x3087, 0x30AD. Each mode init notes its window. imx335_orientation_init() writes the group between REGHOLD (0x3001) = 1 and 0 so the switch lands on one frame, retries a failed group once and always releases the hold. It runs at the end of IMX335_init, since every init writes 0x304E/0x304F back to normal, and from the callback once the sensor is up. Unregister resets the orientation, so a new session starts unflipped. Verified on a gk7205v300 + IMX335 and an hi3516ev300 + IMX335 side by side, in 5M 30 fps, 5M 40 fps, the 2592x1520 crop, the 1080p crop, the flexible crop (1280x720), 2/2 binning, and 5M, 4M and 2560x1440 line WDR, each in all four orientations under a 6500 K LED panel, 3000 K bulbs and the bulbs dimmed to 10%: registers read back as intended, the hold is released, and against the same orientation done in VPSS the picture matches apart from the field-of-view shift above, with the raw per-CFA means within about 1% (4% in the 1280x720 crop, where the shift is a larger share of the window). No new encoder timeouts. Low delay now stays on with flip. Both SDK codes (0x3516E200, 0x7205200) build. Right after an orientation change AWB can land a few hundred kelvin away and settles within seconds; the raw colour does not move.
PR Summary by QodoEnable sensor-side mirror and flip for all IMX335 modes
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. A failed release can freeze sensor updates
|
IMX335_write_register() took any non-negative write() as success, so a transfer cut short passed as a register set, and the orientation group, which retries on failure, could not see it. It now wants the whole address-plus-data length. Checked on a gk7205v300 + IMX335: the sensor initialises, streams and flips live as before.
.pfnMirrorFlipwasNULLin the IMX335 driver, so applications flipped in VPSS instead. That costs low delay with flip and YUV compression with mirror. Majestic hands orientation to the sensor wheneverpfnMirrorFlipis non-NULL, so with this change both features stay available.The IMX335 can invert its own readout:
HREVERSE(0x304E) mirrors andVREVERSE(0x304F) flips.Unlike SP2305 (#244), the Bayer order is unchanged
Measured by comparing raw frames against the normal raw turned round. In every orientation of every mode, the best match is at an offset that keeps the colour order, and the per-CFA means don't change. So the ISP keeps RGGB, and nothing here touches
SetPubAttr.What does move is the field of view. The readout is larger than the picture, and the capture keeps the part that arrives first:
Registers
0x304E0x304FAREA3_ST_ADR_1(0x3074/75), all-pixel / crop / WDR0x00B0→0x1010full height,0x0410→0x0CB01080p crop)0x3081,0x30830x020xFE(left alone, the raw saturates)0x00A8, its own0x3080–0x3087,0x30AD0x1018, the datasheet's inverted tableimx335_orientation_init()writes the group betweenREGHOLD(0x3001) = 1 and 0, so the switch lands on one frame. It retries a failed group once and always releases the hold.IMX335_init, because every init writes0x304E/0x304Fback to normal. It also runs from the callback once the sensor is up.Verified
A gk7205v300 + IMX335 and an hi3516ev300 + IMX335 were tested side by side, in the same room.
Modes: 5M 30 fps, 5M 40 fps, the 2592x1520 crop, the 1080p crop, the 1280x720 flexible crop, 2/2 binning, and line WDR at 5M, 4M and 2560x1440.
Coverage: every mode in all four orientations, set at start-up and toggled live, under three lights: a 6500 K LED panel, 3000 K bulbs, and the bulbs dimmed to 10 %.
Results:
Both SDK codes (
0x3516E200,0x7205200) build.