Skip to main content

SDK Related - Modify Frame Rate

Navigation bar

Warning

CAM126 / CAM126B-P note the difference

Go to CAM126 SDK | Go to CAM126B-P SDK

This board uses MIPI CSI, not LVDS. Only changing src_frame_rate_num in rkipc.ini will not pull the sensor to 60fps; you must replace the driver with one containing the 60fps register table.

For IMX307, this driver is authoritative (the imx307.c in the repository root); do not piece together tables from the SDK original kernel-6.1/drivers/media/i2c/imx307.c.

SensorStatus in this driverDescription
IMX307MIPI 1080p@60 registers added; the default mode loads this tableJust replace the kernel driver
IMX415SDK original is still 4K / 1080p binning 30fpsSee the end; no modified driver yet

IMX307: How to Use the Driver​

Information

Download address

In the left Resource Download homepage / RV1126BP / 02.Software Resources / Driver_imx307

1. Replace the kernel driver​

Overwrite imx307.c into the SDK:

# In the SDK root
cp /path/to/imx307.c kernel-6.1/drivers/media/i2c/imx307.c

If kernel/ is an independent tree rather than a symlink to kernel-6.1, replace both sides with the same copy.

Then rebuild the kernel and flash boot.img:

make kernel

2. What this driver changes relative to the SDK original​

The SDK original MIPI only has 30fps linear + HDR2. 60fps registers were added on the MIPI side and mounted as the default mode (array item 0).

New table: imx307_linear_1920x1080_60fps_mipi_regs

The comment says:

  • Xclk 37.125MHz
  • max_framerate 60fps
  • mipi_datarate per lane 445.5Mbps, 4-lane

In probe(), MIPI goes through mipi_supported_modes, and:

imx307->cur_mode = &imx307->support_modes[0];

find_best_fit() matches by resolution, and for the same resolution selects the first one. So board-side MIPI 1080p linear actually loads the 60fps register set.

3. Which registers changed for 60fps relative to 30fps​

The 30fps base table is the original imx307_linear_1920x1080_mipi_regs (222.75Mbps). The 60fps table changes FRSEL, HMAX, and the MIPI 445.5Mbps CSI timing on top of it (aligned with the HDR2 MIPI level).

Register30fps MIPI60fps MIPIMeaning
0x30090x020x01FRSEL: 30 → 60
0x301C / 0x301D0x30 / 0x11 (HMAX=0x1130=4400)0x98 / 0x08 (HMAX=0x0898=2200)Line length halved, frame rate doubled
0x3018 / 0x30190x65 / 0x04 (VMAX=0x0465=1125)unchangedVertical unchanged
0x34050x200x10MIPI rate level: 222 → 445.5Mbps
0x34460x470x57CSI global timing
0x34480x1F0x37Same as above
0x344A0x170x1FSame as above
0x344C0x0F0x1FSame as above
0x344E0x170x1FSame as above
0x34500x470x77Same as above
0x34520x0F0x1FSame as above

0x3443=0x03 (4-lane), 0x3441/0x3442=0x0A (RAW10), 0x3046=0x00 (MIPI) are unchanged.

The complete 60fps table in the driver looks like this:

/*
* Xclk 37.125Mhz
* max_framerate 60fps
* mipi_datarate per lane 445.5Mbps 4 lane
*/
static const struct regval imx307_linear_1920x1080_60fps_mipi_regs[] = {
{0x3003, 0x01},
{REG_DELAY, 0x10},
{0x3000, 0x01},
{0x3001, 0x00},
{0x3002, 0x01},
{0x3005, 0x00},
{0x3007, 0x00},
{0x3009, 0x01},
{0x300A, 0x3c},
{0x3010, 0x21},
{0x3011, 0x0a},
{0x3018, 0x65},
{0x3019, 0x04},
{0x301C, 0x98},
{0x301D, 0x08},
{0x3046, 0x00},
{0x304B, 0x0A},
/* ... INCK / analog same as 30fps ... */
{0x3405, 0x10},
{0x3407, 0x03},
{0x3414, 0x0A},
{0x3418, 0x49},
{0x3419, 0x04},
{0x3441, 0x0a},
{0x3442, 0x0a},
{0x3443, 0x03},
{0x3444, 0x20},
{0x3445, 0x25},
{0x3446, 0x57},
{0x3447, 0x00},
{0x3448, 0x37},
{0x3449, 0x00},
{0x344A, 0x1F},
{0x344B, 0x00},
{0x344C, 0x1F},
{0x344D, 0x00},
{0x344E, 0x1F},
{0x344F, 0x00},
{0x3450, 0x77},
{0x3451, 0x00},
{0x3452, 0x1F},
{0x3453, 0x00},
{0x3454, 0x17},
{0x3455, 0x00},
{0x3472, 0x9c},
{0x3473, 0x07},
{0x3480, 0x49},
{0x3002, 0x00},
{REG_NULL, 0x00},
};

4. MIPI mode table (driver is authoritative)​

static const struct imx307_mode mipi_supported_modes[] = {
{
/* Default: load 60fps registers */
.bus_fmt = MEDIA_BUS_FMT_SRGGB10_1X10,
.width = 1948,
.height = 1097,
.max_fps = {
.numerator = 10000,
.denominator = 300000,
},
.exp_def = 0x03fe,
.hts_def = 0x1130,
.vts_def = 0x0465,
.reg_list = imx307_linear_1920x1080_60fps_mipi_regs,
.hdr_mode = NO_HDR,
.lanes = 4,
.freq_idx = 0,
.bpp = 10,
}, {
/* Original 30fps MIPI linear */
.reg_list = imx307_linear_1920x1080_mipi_regs,
.hdr_mode = NO_HDR,
.freq_idx = 0,
/* The resolution is also 1948x1097, so it will not be selected by find_best_fit */
}, {
/* HDR2 30fps */
.reg_list = imx307_hdr2_1920x1080_mipi_regs,
.hdr_mode = HDR_X2,
.freq_idx = 1,
},
};

The driver also contains an imx307_linear_1920x1080_30fps_mipi_regs, which is not mounted in the mode table and is not actually used.

Fields inconsistent with the register table

The reg_list of the first mode is already 60fps, but max_fps is still 300000/10000 (reports 30fps externally), hts_def is still 0x1130 (the 30fps HMAX), and freq_idx is still 0 (111.37MHz / about 222Mbps).

The sensor outputs at 60fps + 445.5Mbps; V4L2 / AE still calculate as 30fps, 222Mbps. When the application layer needs to change the stream to 60, just rely on this driver; there is no need to change registers again. If you later want v4l2-ctl --list-frameintervals to also report 60, change the first item to:

.max_fps = { .numerator = 10000, .denominator = 600000 },
.hts_def = 0x0898,
.freq_idx = 1, /* IMX307_LINK_FREQ_222M */

5. Application layer rkipc.ini​

After replacing the driver, the stream frame rate still depends on the ini. The effective one on the board is /userdata/rkipc.ini (if it already exists in RkLunch.sh, it is no longer copied from /oem).

The IMX307 corresponding configuration is usually rkipc-imx307.ini; change:

[video.0]
src_frame_rate_den = 1
src_frame_rate_num = 60
dst_frame_rate_den = 1
dst_frame_rate_num = 60
gop = 120

For the sub stream [video.1], similarly change src/dst_frame_rate_num to 60. Do not change only the IQ json; IQ does not determine the sensor frame rate.

After changing resolution / frame rate in the web backend, it is also written back to /userdata/rkipc.ini.

6. How to confirm after flashing​

dmesg | grep imx307
# should see Detected imx307 / driver version: 00.01.06

v4l2-ctl -d /dev/v4l-subdev0 --list-frameintervals

After the picture comes out, check the actual frame rate (RTSP / rkipc log / ISP statistics). When the registers are already 60fps, the picture outputs at 60; if the stream is still 30, it is most likely that the ini was not changed to /userdata/rkipc.ini.


IMX415 (SDK Original, Driver Not Yet Replaced)​

IMX415 still uses the SDK kernel-6.1/drivers/media/i2c/imx415.c:

modeResolutionFrame rateMIPI
linear 10/12bit3864x219230891Mbps
HDR2 / HDR33864x219220/301485/1782Mbps
2x2 binning 12bit1944x109730594Mbps

The VMAX of 4K linear is already at the bottom (2250, minimum about 2238); reducing vblank cannot reach 60. For 60fps:

  • 1080p binning (more stable): change the VMAX 0x0C5D(3165) of the existing imx415_linear_12bit_1932x1096_594M_regs to about 0x062E(1582), and place the new mode before the 30fps one with the same resolution.
  • 4K@60: HMAX 1100→550, MIPI 891→1485Mbps, copy the PHY timing from the HDR2 1485Mbps set, and keep linear (do not enable DOL). RV1126B ISP35 is designed for about 8M@30; 4K@60 easily saturates ISP / encoding.

The application layer likewise changes src_frame_rate_num / dst_frame_rate_num in /userdata/rkipc.ini.


Implementation Order​

  1. IMX307: replace the kernel driver with imx307.c, rebuild boot.img, change the ini to 60fps.
  2. IMX415 1080p binning@60: wait until a corresponding driver is available; do not change only the ini.
  3. IMX415 4K@60: first confirm whether ISP/VENC drops frames, then add the mode.
AI Translation Notice

This page was translated into English by AI and is provided for reference only. The original document is written in Chinese. If there is any discrepancy, the Chinese version prevails.

本页英文内容由 AI 自动翻译生成,仅供参考;原文为中文,如有差异请以中文原文为准。

查看中文原文 / View the Chinese original →