Skip to content

RPi5 CSI2 stride issue (with IMX335) #6896

Open
@jailuthra

Description

@jailuthra

Describe the bug

When capturing IMX335 binned mode, with resolution 1320x972, the stride is off once the image passes through FE, leading to corrupt looking captures like in [1].

If I perform a raw CSI2-only capture, ignoring FE and BE in the media graph, the capture looks okay with RAW10P and RAW12P memory format, but has an 8-pixel wide column of image data missing (so only 1312x972 is valid) if the CSI2 remaps the data to RAW16 before writing to memory. [2] [3] [4]

I believe this error introduced while remapping is what messes up the image stride completely once it goes through FE, where it is unrecoverable.

The capture looks okay with the same sensor and sensor driver on a different platform (TI AM62A).

A different issue occurs if we configure the sensor to output 1296x972 instead, where the last few pixels in each row are repeated. This happens even in the RAW12P/RAW10P CSI2 only capture, but does not occur with other platforms.

The image looks okay only if the sensor is configured to output 1312x972 as the binned resolution.

Out of all these resolutions, only 1312 % 32 == 0, so am I correct in assuming that RPi5's CSI2 hardware block is unable to handle strides that are not divisible by 32? If not, can this be fixed in the driver?

Steps to reproduce the behaviour

  1. Clone and build this branch with IMX335 binned mode: https://github.com/jailuthra/linux/commits/rpi-imx335-binned-1320/
  2. Capture images using this libcamera branch: https://git.uk.ideasonboard.com/kbingham/libcamera/src/branch/kbingham/imx238_imx335 or manual raw v4l2 captures.

Device (s)

Raspberry Pi 5

System

Raspberry Pi reference 2024-07-04
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 0b115f302a8f1e5bd3523614d7f45b9d447434c7, stage4

2025/05/08 15:13:17
Copyright (c) 2012 Broadcom
version 69471177 (release) (embedded)

Linux rpios 6.12.32-v8+ #4 SMP PREEMPT Tue Jun 10 23:57:18 IST 2025 aarch64 GNU/Linux

Logs

No response

Additional context

[1] Broken 1320 capture with FE + BE:

Image

[2][3][4] Raw CSI2 only capture with RAW10P, RAW12P and RAW16 (with black bar):

Image
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions