Skip to content

Conversation

@naushir
Copy link
Contributor

@naushir naushir commented Sep 12, 2025

When the analog binning mode is used for high framerate operation, the pixel rate is effectively doubled. Account for this when setting up the pixel clock rate, and applying the vblank and exposure controls.

The previous logic only used analog binning for RAW8, but normal binning limits the framerate on RAW10 480p 1. So with this patch we switch to using special binning (with 2x pixel rate) wherever possible.

Co-developed-by: Naushir Patuck naush@raspberrypi.com

Co-developed-by: Vinay Varma varmavinaym@gmail.com

@naushir
Copy link
Contributor Author

naushir commented Sep 22, 2025

@6by9 @pelwell

Any objections to merging this?

@pelwell
Copy link
Contributor

pelwell commented Sep 22, 2025

I didn't understand the benefit of adding the binning_mode enumeration, but no objections.

@naushir
Copy link
Contributor Author

naushir commented Sep 22, 2025

I didn't understand the benefit of adding the binning_mode enumeration, but no objections.

Neither do I TBH - it was an upstream thing 😃

@6by9
Copy link
Contributor

6by9 commented Sep 22, 2025

Adding "Commit f513997 upstream" would help Dom for rebasing onto 6.15 and above.
But I have no issues with backporting this commit.

When the analog binning mode is used for high framerate operation, the
pixel rate is effectively doubled. Account for this when setting up the
pixel clock rate, and applying the vblank and exposure controls.

The previous logic only used analog binning for RAW8, but normal binning
limits the framerate on RAW10 480p [1]. So with this patch we switch to
using special binning (with 2x pixel rate) wherever possible.

Backport of commit f513997 upstream.

[1]: raspberrypi#5493

Co-developed-by: Naushir Patuck <naush@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Co-developed-by: Vinay Varma <varmavinaym@gmail.com>
Signed-off-by: Vinay Varma <varmavinaym@gmail.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
@naushir
Copy link
Contributor Author

naushir commented Sep 22, 2025

Adding "Commit f513997 upstream" would help Dom for rebasing onto 6.15 and above.

Done!

@naushir naushir merged commit 552c16b into raspberrypi:rpi-6.12.y Sep 22, 2025
12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Sep 22, 2025
kernel: dtoverlays: adjust inbound windows for MIP1 on Pi 5 with 32-bit PCIe DMA
See: raspberrypi/linux#7049

kernel: drm/vc4: hvs: Populate YUV to RGB matrices for GEN_6D
See: raspberrypi/linux#7043

kernel: DRM command line parser fix
See: raspberrypi/linux#7051

kernel: Overlays: rpi-power-hat i2c_arm enable
See: raspberrypi/linux#7055

kernel: configs: Add CONFIG_W1_SLAVE_DS2430=m
See: raspberrypi/linux#7056

kernel: media: i2c: imx219: Scale the pixel rate for analog binning
See: raspberrypi/linux#7045
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Sep 23, 2025
kernel: dtoverlays: adjust inbound windows for MIP1 on Pi 5 with 32-bit PCIe DMA
See: raspberrypi/linux#7049

kernel: drm/vc4: hvs: Populate YUV to RGB matrices for GEN_6D
See: raspberrypi/linux#7043

kernel: DRM command line parser fix
See: raspberrypi/linux#7051

kernel: Overlays: rpi-power-hat i2c_arm enable
See: raspberrypi/linux#7055

kernel: configs: Add CONFIG_W1_SLAVE_DS2430=m
See: raspberrypi/linux#7056

kernel: media: i2c: imx219: Scale the pixel rate for analog binning
See: raspberrypi/linux#7045
@Alexei-Kornienko
Copy link

@naushir Hello. I've tried reading camera with kernel version of 6.12.48. And it seems that this fix causes another issue. FPS seems to be fixed however I get my images with horizontal stipes of 64 pixels high that are misaligned. (attached example image)
image

When I revert to a stable kernel this issue is not present.

@naushir
Copy link
Contributor Author

naushir commented Sep 24, 2025

What command line are you using for the above capture?

@Alexei-Kornienko
Copy link

I don't use a command line directly. I read frames using libcamera bindings to Rust... but basically here is my settings that I get from the sensor:

StreamConfigurationRef {
            pixel_format: SBGGR16,
            size: Size {
                width: 1640,
                height: 1232,
            },
            stride: 3328,
            frame_size: 4100096,
            buffer_count: 6,
        },

And I read a Plane from a FrameBuffer.

I've tried running exactly the same code on different kernel versions and on a Linux rpi 6.12.34+rpt-rpi-2712 everything is fine.

@naushir
Copy link
Contributor Author

naushir commented Sep 24, 2025

Thanks - confirmed that this breaks the 1640x1232 mode. Annoyingly I did not test this one as 640x480 is the only mode that is applicable for the rate change.

Sign, this is again upstream trying to achieve modeless settings that now break some modes :(

@pelwell
Copy link
Contributor

pelwell commented Sep 24, 2025

upstream trying to achieve modeless settings that now break some modes :(

Fewer modes = more modeless.

@Alexei-Kornienko
Copy link

Alexei-Kornienko commented Sep 24, 2025

640x480 is the only mode that is applicable for the rate change.

1640x1232 with this patch also changes to 83.7 fps (which is what I'm trying to use)

@naushir
Copy link
Contributor Author

naushir commented Sep 24, 2025

1640x1232 with this patch also changes to 83.7 fps (which is what I'm trying to use)

That may not be a functional mode/framerate on this sensor.

@Alexei-Kornienko
Copy link

I've mentioned it in raspberrypi/libcamera#308
I used 8 bit mode in an old kernel version and it seems to work fine.
'SRGGB8' : 1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]

At that time I used just a python picamera2 module (which internally uses libcamera) and was able to read 80 fps without any issues.
So for an old kernel I got:

rpicam-hello --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/axi/pcie@120000/rp1/i2c@88000/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                             1640x1232 [41.85 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                             3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]
           'SRGGB8' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                      1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]
                      1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                      3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]

and for a new:
uname -a
Linux rpi 6.12.48-v8-16k+ #1905 SMP PREEMPT Mon Sep 22 13:35:50 BST 2025 aarch64 GNU/Linux

rpicam-hello --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/axi/pcie@1000120000/rp1/i2c@88000/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                             1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                             3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]
           'SRGGB8' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                      1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]
                      1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                      3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]

So newer version makes SRGGB10_CSI2P mode to work on 83 fps.

@6by9
Copy link
Contributor

6by9 commented Sep 24, 2025

So newer version makes SRGGB10_CSI2P mode to work on 83 fps.

The new version lists that it works at 83fps. That doesn't necessarily mean it actually works.
The fix is going to be revert the 10bit 1640x1232 mode to supporting up to 41.85 fps.

@Alexei-Kornienko
Copy link

I understand that. However I would like to use at least 8 bit SRGGB8 in 80fps mode. And on latest stable kernel it only exposes 40 fps. And this seems like a regression to me

@naushir
Copy link
Contributor Author

naushir commented Sep 24, 2025

#7063 updates another downstream patch from 6.6 to fix the mode specific binning factors.

popcornmix added a commit to raspberrypi/firmware that referenced this pull request Sep 27, 2025
See: raspberrypi/linux#6945

kernel: net: phy: broadcom: Add led-swap property support
See: raspberrypi/linux#7060

kernel: Select internal MSI target for 32-bit DMA on Pi 5 PCIe
See: raspberrypi/linux#7059

kernel: configs: Add CONFIG_VEML6030=m
See: raspberrypi/linux#7052

kernel: media: i2c: imx219: Scale the pixel rate for analog binning
See: raspberrypi/linux#7045

kernel: staging: vc-sm-cma: Fix field-spanning write warning
See: raspberrypi/linux#7064

kernel: drm/rp1: rp1-dsi: Add support for inverting lane polarities
See: raspberrypi/linux#7065

kernel: ARM: dts: Select the PL011 platform driver
See: raspberrypi/linux#7023

kernel: media: i2c: imx219: fix binning and rate_factor for 480p and 1232p
See: raspberrypi/linux#7063
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Sep 27, 2025
See: raspberrypi/linux#6945

kernel: net: phy: broadcom: Add led-swap property support
See: raspberrypi/linux#7060

kernel: Select internal MSI target for 32-bit DMA on Pi 5 PCIe
See: raspberrypi/linux#7059

kernel: configs: Add CONFIG_VEML6030=m
See: raspberrypi/linux#7052

kernel: media: i2c: imx219: Scale the pixel rate for analog binning
See: raspberrypi/linux#7045

kernel: staging: vc-sm-cma: Fix field-spanning write warning
See: raspberrypi/linux#7064

kernel: drm/rp1: rp1-dsi: Add support for inverting lane polarities
See: raspberrypi/linux#7065

kernel: ARM: dts: Select the PL011 platform driver
See: raspberrypi/linux#7023

kernel: media: i2c: imx219: fix binning and rate_factor for 480p and 1232p
See: raspberrypi/linux#7063
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.

5 participants