media: i2c: imx471: Add line length PCK setting
Kate Hsuan
maintainerPATCH 1/1 media: i2c: imx471: Add line length PCK setting
Add the line length PCK setting to the IMX471 driver. This parameter determines the horizontal line scan duration and is used for controlling the frame rate.
--- drivers/media/i2c/imx471.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/imx471.c +2 -0
@@ -91,6 +91,7 @@#define IMX471_CSI_2_LANE_MODE 1#define IMX471_CSI_4_LANE_MODE 3 +#define IMX471_REG_LINE_LENGTH_PCK CCI_REG16(0x0342)#define IMX471_REG_X_ADD_STA CCI_REG16(0x0344)#define IMX471_REG_Y_ADD_STA CCI_REG16(0x0346)#define IMX471_REG_X_ADD_END CCI_REG16(0x0348)
@@ -240,6 +241,7 @@ static const struct cci_reg_sequence mode_1928x1088_regs[] = { { CCI_REG8(0x030d), 0x02 }, { CCI_REG8(0x030e), 0x00 }, { CCI_REG8(0x030f), 0x53 }, + { IMX471_REG_LINE_LENGTH_PCK, 5008 }, { IMX471_REG_PLL_MULT_DRIV, IMX471_PLL_DUAL }, { CCI_REG8(0x3f4c), 0x81 }, { CCI_REG8(0x3f4d), 0x81 },
Signature · 1 line
2.55.0
Hi Kate,
Thank you for the patch.
Quoting Kate Hsuan (2026-07-28 09:50:13)
Quoted 22 lines
Add the line length PCK setting to the IMX471 driver. This parameter determines the horizontal line scan duration and is used for controlling the frame rate.
Signed-off-by Kate Hsuan <[email protected]>--- drivers/media/i2c/imx471.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/imx471.c +1
-0@@ -91,6 +91,7 @@#define IMX471_CSI_2_LANE_MODE 1#define IMX471_CSI_4_LANE_MODE 3 +#define IMX471_REG_LINE_LENGTH_PCK CCI_REG16(0x0342)#define IMX471_REG_X_ADD_STA CCI_REG16(0x0344)#define IMX471_REG_Y_ADD_STA CCI_REG16(0x0346)#define IMX471_REG_X_ADD_END CCI_REG16(0x0348)
drivers/media/i2c/imx471.c static const struct cci_reg_sequence mode_1928x1088_regs[] = { · line 244
Quoted 4 lines
drivers/media/i2c/imx471.c +1
-0@@ -240,6 +241,7 @@ static const struct cci_reg_sequence mode_1928x1088_regs[] = { { CCI_REG8(0x030d), 0x02 }, { CCI_REG8(0x030e), 0x00 }, { CCI_REG8(0x030f), 0x53 }, + { IMX471_REG_LINE_LENGTH_PCK, 5008 },
This does not match the mode->llp value (2328) used for 1928x1088, any idea why?
Aside from the patch, I also see that the value for the PIXEL_RATE control is derived using the link-frequency and output bit-depth.
It is likely that the sensor's frame rate depends solely on the LLP and FLL timing registers, so it should be possible to derive a constant pixel rate value (for a given PLL configuration) that is independent of link-freq and bit-depth.
Thanks,
Jai
Quoted 7 lines
drivers/media/i2c/imx471.c +0
-0{ IMX471_REG_PLL_MULT_DRIV, IMX471_PLL_DUAL }, { CCI_REG8(0x3f4c), 0x81 }, { CCI_REG8(0x3f4d), 0x81 },Signature · 1 line
2.55.0
Kate Hsuan
maintainerHi Jai,
Thank you for the review.
Quoted 23 lines · Jai Luthra
Hi Kate,
Thank you for the patch.
Quoting Kate Hsuan (2026-07-28 09:50:13)
Quoted 17 lines
Add the line length PCK setting to the IMX471 driver. This parameter determines the horizontal line scan duration and is used for controlling the frame rate.
Signed-off-by Kate Hsuan <[email protected]>--- drivers/media/i2c/imx471.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/imx471.c +0
-0@@ -91,6 +91,7 @@#define IMX471_CSI_2_LANE_MODE 1#define IMX471_CSI_4_LANE_MODE 3
Quoted 12 lines
drivers/media/i2c/imx471.c static const struct cci_reg_sequence mode_1928x1088_regs[] = { · line 244
Quoted 9 lines
drivers/media/i2c/imx471.c +2
-0+#define IMX471_REG_LINE_LENGTH_PCK CCI_REG16(0x0342)#define IMX471_REG_X_ADD_STA CCI_REG16(0x0344)#define IMX471_REG_Y_ADD_STA CCI_REG16(0x0346)#define IMX471_REG_X_ADD_END CCI_REG16(0x0348)@@ -240,6 +241,7 @@ static const struct cci_reg_sequence mode_1928x1088_regs[] = { { CCI_REG8(0x030d), 0x02 }, { CCI_REG8(0x030e), 0x00 }, { CCI_REG8(0x030f), 0x53 }, + { IMX471_REG_LINE_LENGTH_PCK, 5008 },This does not match the
mode->llpvalue (2328) used for 1928x1088, any idea why?
I tried to resolve the horizontal line pattern on the moving objects when the sensor runs with libcamera. (The image is better for 0.7.2 and more horizontal noise for 0.7.1)
https://bugzilla.redhat.com/show_bug.cgi?id=2502786
I guess the horizontal line pattern can be mitigated by reducing the frame rate. (image is better but the issue still happens.) I'm trying to figure out if the root cause is in the driver or SoftISP. If this is not the right direction for the solution, this patch can be drop. I'll try another way to resolve it.
Quoted 8 lines
Aside from the patch, I also see that the value for the
PIXEL_RATEcontrol is derived using the link-frequency and output bit-depth.It is likely that the sensor's frame rate depends solely on the LLP and FLL timing registers, so it should be possible to derive a constant pixel rate value (for a given PLL configuration) that is independent of link-freq and bit-depth.
The datasheet mentioned the the link frequency determines the pixel rate so that is why pixel rate is based on link frequency.
Quoted 12 lines
Thanks,
JaiQuoted 7 lines
drivers/media/i2c/imx471.c +0
-1{ IMX471_REG_PLL_MULT_DRIV, IMX471_PLL_DUAL }, { CCI_REG8(0x3f4c), 0x81 }, { CCI_REG8(0x3f4d), 0x81 }, --2.55.0
Signature · 2 lines
BR, Kate
Sakari Ailus
maintainerHi Kate,
Quoted 41 lines · Kate Hsuan
Hi Jai,
Thank you for the review.
Quoted 23 lines · Jai Luthra
Hi Kate,
Thank you for the patch.
Quoting Kate Hsuan (2026-07-28 09:50:13)
Quoted 17 lines
Add the line length PCK setting to the IMX471 driver. This parameter determines the horizontal line scan duration and is used for controlling the frame rate.
Signed-off-by Kate Hsuan <[email protected]>--- drivers/media/i2c/imx471.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/imx471.c +0
-0@@ -91,6 +91,7 @@#define IMX471_CSI_2_LANE_MODE 1#define IMX471_CSI_4_LANE_MODE 3Quoted 12 lines
drivers/media/i2c/imx471.c static const struct cci_reg_sequence mode_1928x1088_regs[] = { · line 244
Quoted 9 lines
drivers/media/i2c/imx471.c +2
-0+#define IMX471_REG_LINE_LENGTH_PCK CCI_REG16(0x0342)#define IMX471_REG_X_ADD_STA CCI_REG16(0x0344)#define IMX471_REG_Y_ADD_STA CCI_REG16(0x0346)#define IMX471_REG_X_ADD_END CCI_REG16(0x0348)@@ -240,6 +241,7 @@ static const struct cci_reg_sequence mode_1928x1088_regs[] = { { CCI_REG8(0x030d), 0x02 }, { CCI_REG8(0x030e), 0x00 }, { CCI_REG8(0x030f), 0x53 }, + { IMX471_REG_LINE_LENGTH_PCK, 5008 },This does not match the
mode->llpvalue (2328) used for 1928x1088, any idea why?
Quoted 9 lines
I tried to resolve the horizontal line pattern on the moving objects when the sensor runs with libcamera. (The image is better for 0.7.2 and more horizontal noise for 0.7.1)
https://bugzilla.redhat.com/show_bug.cgi?id=2502786
I guess the horizontal line pattern can be mitigated by reducing the frame rate. (image is better but the issue still happens.) I'm trying to figure out if the root cause is in the driver or SoftISP. If this is not the right direction for the solution, this patch can be drop. I'll try another way to resolve it.
My guess is that there's something wrong with the sensor configuration if there are obvious systematic image defects that don't exist on other sensor, given the same SoftISP. Something to check indeed is the horizontal blanking as you've already found out. Very likely the other parameters such as vertical blanking could still be changed without affecting the issue.
Quoted 11 lines
Quoted 9 lines
Aside from the patch, I also see that the value for the
PIXEL_RATEcontrol is derived using the link-frequency and output bit-depth.It is likely that the sensor's frame rate depends solely on the LLP and FLL timing registers, so it should be possible to derive a constant pixel rate value (for a given PLL configuration) that is independent of link-freq and bit-depth.
The datasheet mentioned the the link frequency determines the pixel rate so that is why pixel rate is based on link frequency.
The PIXEL_RATE control refers to the pixel read rate in the pixel array and configurations where pixel rate on the CSI-2 bus differs from that are possible on all but the most trivial sensors (typically VGA).
In this case the PLL configuration could be used to find the actual PIXEL_RATE (on the pixel array) as Jai mentioned.
Signature · 3 lines
Regards, Sakari Ailus
Kate Hsuan
maintainerHi Sakari,
Quoted 55 lines · Sakari Ailus
Hi Kate,
Quoted 41 lines · Kate Hsuan
Hi Jai,
Thank you for the review.
Quoted 23 lines · Jai Luthra
Hi Kate,
Thank you for the patch.
Quoting Kate Hsuan (2026-07-28 09:50:13)
Quoted 17 lines
Add the line length PCK setting to the IMX471 driver. This parameter determines the horizontal line scan duration and is used for controlling the frame rate.
Signed-off-by Kate Hsuan <[email protected]>--- drivers/media/i2c/imx471.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/i2c/imx471.c +0
-0@@ -91,6 +91,7 @@#define IMX471_CSI_2_LANE_MODE 1#define IMX471_CSI_4_LANE_MODE 3Quoted 12 lines
drivers/media/i2c/imx471.c static const struct cci_reg_sequence mode_1928x1088_regs[] = { · line 244
Quoted 9 lines
drivers/media/i2c/imx471.c +2
-0+#define IMX471_REG_LINE_LENGTH_PCK CCI_REG16(0x0342)#define IMX471_REG_X_ADD_STA CCI_REG16(0x0344)#define IMX471_REG_Y_ADD_STA CCI_REG16(0x0346)#define IMX471_REG_X_ADD_END CCI_REG16(0x0348)@@ -240,6 +241,7 @@ static const struct cci_reg_sequence mode_1928x1088_regs[] = { { CCI_REG8(0x030d), 0x02 }, { CCI_REG8(0x030e), 0x00 }, { CCI_REG8(0x030f), 0x53 }, + { IMX471_REG_LINE_LENGTH_PCK, 5008 },This does not match the
mode->llpvalue (2328) used for 1928x1088, any idea why?Quoted 9 lines
I tried to resolve the horizontal line pattern on the moving objects when the sensor runs with libcamera. (The image is better for 0.7.2 and more horizontal noise for 0.7.1)
https://bugzilla.redhat.com/show_bug.cgi?id=2502786
I guess the horizontal line pattern can be mitigated by reducing the frame rate. (image is better but the issue still happens.) I'm trying to figure out if the root cause is in the driver or SoftISP. If this is not the right direction for the solution, this patch can be drop. I'll try another way to resolve it.
Quoted 5 lines
My guess is that there's something wrong with the sensor configuration if there are obvious systematic image defects that don't exist on other sensor, given the same SoftISP. Something to check indeed is the horizontal blanking as you've already found out. Very likely the other parameters such as vertical blanking could still be changed without affecting the issue.
Good suggestion. I'll try to tune vblank and possible configs and hope it works. I scratched my head trying to find the solutions and now I can focus on tuning the parameter to fix the issue.
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
Aside from the patch, I also see that the value for the
PIXEL_RATEcontrol is derived using the link-frequency and output bit-depth.Quoted 6 lines
Quoted 4 lines
It is likely that the sensor's frame rate depends solely on the LLP and FLL timing registers, so it should be possible to derive a constant pixel rate value (for a given PLL configuration) that is independent of link-freq and bit-depth.
The datasheet mentioned the the link frequency determines the pixel rate so that is why pixel rate is based on link frequency.
Quoted 6 lines
The
PIXEL_RATEcontrol refers to the pixel read rate in the pixel array and configurations where pixel rate on the CSI-2 bus differs from that are possible on all but the most trivial sensors (typically VGA).In this case the PLL configuration could be used to find the actual
PIXEL_RATE(on the pixel array) as Jai mentioned.
Got it. I'll try to find a pixel rate based on the PLL settings. Perhaps that can resolve the issue.
Thank you :)
Quoted 6 lines
--
Regards,Sakari Ailus
Signature · 2 lines
BR, Kate
Sakari Ailus
maintainerHi Kate,
Quoted 3 lines · Kate Hsuan
Good suggestion. I'll try to tune vblank and possible configs and hope it works. I scratched my head trying to find the solutions and now I can focus on tuning the parameter to fix the issue.
Horizontal blanking is likely to affect image defects whereas vertical blanking can be used to adjust the frame rate. If changing the horizontal blanking does have that effect, we should probably think of using a fixed value for it. Then the question is what is that value and what does it depend on (likely PLL configuration and external clock frequency, possibly binning etc.).
Signature · 3 lines
Regards, Sakari Ailus
Hi all,
Quoted 4 lines · Sakari Ailus
If changing the horizontal blanking does have that effect, we should probably think of using a fixed value for it. Then the question is what is that value and what does it depend on (likely PLL configuration and external clock frequency, possibly binning etc.).
The pixel rate and line length fix is on the list:
https://lore.kernel.org/linux-media/[email protected]/
LINE_LENGTH_PCK is never written and reads back 5120, so 2328 was never the line length, and 5008 would raise the frame rate rather than lower it. The pixel rate is 387.2 MHz from the VT PLL, confirmed by timing frames at several written line lengths.
The horizontal lines turned out to be a missing cache sync in the IPU7 ISYS driver (fix under review:
https://lore.kernel.org/linux-media/[email protected]/),
so a lower frame rate should not be needed here.
Christian