linux icon indicating copy to clipboard operation
linux copied to clipboard

Camera Module v2 (imx219) missing 206FPS mode

Open mbway opened this issue 4 months ago • 6 comments

Describe the bug

The documentation for the camera modules lists 640×480p 206fps as a supported mode for the camera module v2 but when I use rpicam-vid --list-cameras the 206FPS mode is not available, replaced with 103FPS instead:

pi@pi3:~/camera $ uname -a
Linux pi3 6.12.41-v8+ #1897 SMP PREEMPT Fri Aug  1 12:20:46 BST 2025 aarch64 GNU/Linux
pi@pi3:~/camera $ rpicam-vid --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/soc/i2c0mux/i2c@1/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [103.33 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 [103.33 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]

I found this bug report https://github.com/raspberrypi/linux/issues/5438 that was resolved around the time of the 6.1 kernel. So I built that version and booted into it. With that kernel version the 206FPS mode was listed:

pi@pi3:~/camera $ uname -a
Linux pi3 6.1.93-v8+ #1 SMP PREEMPT Mon Aug 11 03:31:21 BST 2025 aarch64 GNU/Linux
pi@pi3:~/camera $ rpicam-vid --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/soc/i2c0mux/i2c@1/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]

So it looks like there has been a regression since that issue was originally fixed.

Steps to reproduce the behaviour

boot into the latest Raspberry Pi OS with kernel 6.12, plug in a Camera v2 module and run rpicam-vid --list-cameras. Observe that the 206FPS mode is not listed.

Device (s)

Raspberry Pi 3 Mod. B

System

pi@pi3:~/camera $ cat /etc/rpi-issue
Raspberry Pi reference 2025-05-13
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 5dabc7dc940059dfbc46af5d97b60a1e812523dd, stage4

pi@pi3:~/camera $ vcgencmd version
Jul 17 2025 17:32:49 
Copyright (c) 2012 Broadcom
version a668b6e6edce3274de221324b93cb8741e4a7f7c (clean) (release) (start)

pi@pi3:~/camera $ uname -a
Linux pi3 6.1.93-v8+ #1 SMP PREEMPT Mon Aug 11 03:31:21 BST 2025 aarch64 GNU/Linux

Logs

No response

Additional context

No response

mbway avatar Aug 24 '25 12:08 mbway

Looking for a solution to this also. On pi 4b bullseye

NWalker4483 avatar Aug 24 '25 19:08 NWalker4483

Some further investigation:

Support was first added to version 5.15 in https://github.com/raspberrypi/linux/pull/4880 and based on https://github.com/raspberrypi/linux/pull/5439 I think there was a regression between 6.0 and 6.1 that was fixed before the end of 6.1, then 6.7 is the first branch where the fix can no longer be found. So versions 5.15 to 6.6 all have the fix.

I'm not sure how much of the driver is developed in upstream Linux vs here. The rpi-6.12.y version of imx219.c looks fairly different to the upstream 6.12 version. The upstream 6.12 version also does not contain the fix. This commit https://github.com/torvalds/linux/commit/f513997119f481a3a3bb9a0a8fc55b6cd50a0940 implements the fix into the upstream driver which is present for for versions 6.15 onwards.

It looks like this fix could be back-ported to the raspberry pi 6.12 version of the driver. Also the rpi-6.15.y branch contains the fix so I might try building and running that.

mbway avatar Sep 04 '25 21:09 mbway

I built and ran the rpi-6.15.y branch (b07d612aae961e99fdb0b828ce6d54c183d1833d) and that gives a slightly different frame rate:

$ rpicam-vid --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/soc/i2c0mux/i2c@1/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [200.16 fps - (1000, 752)/1280x960 crop]
                             1640x1232 [81.07 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                             3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]
           'SRGGB8' : 640x480 [200.16 fps - (1000, 752)/1280x960 crop]
                      1640x1232 [81.07 fps - (0, 0)/3280x2464 crop]
                      1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                      3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]

(200.16 instead of 206.65) and when actually recording, there seems to be many more frame skips than the driver in 6.1

rpicam-vid --level 4.2 --denoise cdn_off --framerate 300 --width 640 --height 480 --save-pts d.pts -o d.h264 --shutter 1000 --timeout 10000  -n

then running ptsanalyze from here

# kernel Linux pi3 6.15.11-v8+
1829 frame skips (48%)
average framerate 193fps

compared to

# kernel Linux pi3 6.1.93-v8+
96 frame skips (4%)
average framerate 197fps

mbway avatar Sep 12 '25 09:09 mbway

cc @naushir since it seems you added the handling of the double frame rate in the upstream driver https://github.com/torvalds/linux/commit/f513997119f481a3a3bb9a0a8fc55b6cd50a0940

mbway avatar Sep 12 '25 09:09 mbway

https://github.com/raspberrypi/linux/pull/7045 backports the commit in question back to the 6.12 tree. Looks to be working fine with my limited testing.

naushir avatar Sep 12 '25 11:09 naushir

thanks @naushir for the fast fix :) I tested for myself and it also seems to work.

There is a difference between the 6.12 behaviour and the 6.15 behaviour because on 6.12 I get the correct FPS and a low number of frame skips:

pi@pi3:~/camera $ uname -a
Linux pi3 6.12.45-v8+ #2 SMP PREEMPT Fri Sep 12 20:40:21 BST 2025 aarch64 GNU/Linux
pi@pi3:~/camera $ rpicam-vid --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/soc/i2c0mux/i2c@1/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]

122 frame skips (5%)
average framerate 194fps

mbway avatar Sep 12 '25 22:09 mbway