Skip to content

IMX355 driver updates#7466

Merged
pelwell merged 27 commits into
raspberrypi:rpi-6.18.yfrom
6by9:rpi-6.18.y-imx355
Jul 7, 2026
Merged

IMX355 driver updates#7466
pelwell merged 27 commits into
raspberrypi:rpi-6.18.yfrom
6by9:rpi-6.18.y-imx355

Conversation

@6by9

@6by9 6by9 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This should be what I send as V2 to linux-media, although on 6.18.

@6by9 6by9 requested a review from naushir June 30, 2026 17:41
@6by9

6by9 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Note that exposureDelay and gainDelay both appear to be 2.
I initially copied imx219 with 2 and 1, but got brightness oscillation on startup.

@pelwell

pelwell commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Are you holding out for a review from @naushir?

@6by9 6by9 requested a review from njhollinghurst July 2, 2026 10:49
@6by9

6by9 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Are you holding out for a review from @naushir?

I was hoping he would.
I've just requested one from Nick as an alternate.

@njhollinghurst

Copy link
Copy Markdown
Contributor

It's a lot of changes but I can give it a look through, and a test.

@naushir

naushir commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Sorry, I've also tested but not had a chance to code review yet.

@njhollinghurst

njhollinghurst commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Briefly tested this build with 2 lanes on Pi 5 just now. Yes I did need to change the gainDelay to 2.


#include "imx355.dtsi"

vcm: ad5398@c {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this likely to exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but not now. Removing.

@njhollinghurst

Copy link
Copy Markdown
Contributor

Would it be possible or desirable to add a faster 640x480 mode?
For comparison, imx219 can do 640x480 (albeit heavily cropped) at 200fps.

@naushir

naushir commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Driver looks good to me.

flamingradian and others added 19 commits July 7, 2026 15:29
The IMX355 camera sensor is a camera sensor that can be found as the
front camera in some smartphones, such as the Pixel 3, Pixel 3 XL, Pixel
3a, and Pixel 3a XL. It already has a driver, but needs support for
device tree. Document the IMX355 to support defining it in device tree.

Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Richard Acayan <mailingradian@gmail.com>
A device tree compatible makes it possible for this driver to be used on
Open Firmware devices. Initialization of power-managed resources such as
the reset GPIO and voltage regulators can be specified in the device
tree and handled by the driver. Add support for this so the Pixel 3a can
use the driver.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Richard Acayan <mailingradian@gmail.com>
The IMX355 sensor driver currently supports having 4 data lanes. There
can't be more or less, so check if the firmware specifies 4 lanes.

Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/aW3uFcT1zmiF4GUP@kekkonen.localdomain
Signed-off-by: Richard Acayan <mailingradian@gmail.com>
The IMX355 sensor supports multiple external clock frequencies,
including 19.2 MHz and 24 MHz. The driver currently supports only
fixed 19.2 MHz input clock.

Refactor the clock handling to make the PLL configuration dependent
on the external clock frequency and add support for 24 MHz. Introduce
a table of clock parameter sets and program the corresponding EXTCLK
frequency and PLL multipliers to maintain consistent internal VCO
frequencies across supported inputs.

The PLL settings are adjusted so that OP VCO remains at 720 MHz

This preserves existing timing characteristics while allowing systems
using a 24 MHz clock to operate correctly.

No functional change for existing 19.2 MHz users.

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The sensor supports output over either 2 or 4 CSI2 data
lanes. The binding only permitted the 4 lane configuration.

Add the 2 lane configuration as an option.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
A large number of registers are identical within all the modes.
Move those to imx355_global_regs.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Registers 0x0340 and 0x0341 (FRM_LENGTH_LINES) are already written
from the set_ctrl(V4L2_CID_VBLANK) handler, so don't write them
from the mode register list.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Currently the cropping is set via register entries in the per mode
register lists. Add the crop information to the mode structure as
a v4l2_rect, and set the registers programmatically.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The driver already has the LLP value stored in the mode structure,
but also had the same value set via register writes in the mode's
register list. Remove this duplication.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
Compute the binning registers based on the difference between
the mode width/height vs the crop width/height.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The link_freq_index value in imx355_mode is unused, so remove it.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The pixel rate is always the same, so there is no need to try and
recompute it in imx355_set_pad_format, and then no need to have the
pointer to it stored.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
fll_min (Frame Length Lines) is set to the same value as fll_def
for all modes, which makes it redundant.

The actual value is also erroneous as the sensor works in all
the defined modes with FLL set at the mode height + 20 lines,
so set the vblank control minimum to 20 rather than varying it.
This also improves the maximum frame rate achievable.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Provide all the cropping information via get_selection.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Avoid powering the sensor up and down unnecessarily by using
pm_runtime's autosuspend_delay feature.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Use the new comon CCI register access helpers to replace the private
register access helpers in the imx355 driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The colorspace fields were left set to 0 when they should be
set appropriately for a raw image sensor. Add those values.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The difference between frame length and max exposure time in
lines is 10. That had been used as a bare value in calculations.

Move it to a define, and use that define.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
This avoids the set_ctrl handler being called under any
circumstances, as it will return an error for the unhandled
ctrl.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
6by9 added 7 commits July 7, 2026 15:29
In preparation for additional options in the PLL setup, compute
the link frequency rather than using a hardcoded value.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The sensor supports 2 or 4 lane readout, but the driver only allowed
for 4 lanes. Add 2 lane support.

The clock tree only supports single PLL mode to feed both IOP (MIPI)
and IVT (Pixel array).
2 lane mode supports a MIPI link frequency of up to 445MHz (890Mbit/s)
cf 360MHz (720Mbit/s) for 4lane. Update clock setup and pixel rates to
match.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The subdev state is now preferred rather than handling crop
and format within the driver state, so switch the driver to
using it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
All the information for the mode is now stored within
the subdev state, so configure the sensor based on that.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
V4L2_CID_HBLANK / LLP was a read-only control that set min/
max/default all to the same value.

The datasheet does state "H-sync timing is fixed in order to
avoid the sensor internal interference (FPN) in IMX355 by
line_length". No interference has currently been observed,
and the default is always to leave it at the minimum (and
approved) value. Allowing it to be controllable therefore
has no effect unless a frame period longer than can be
achieved just through VBLANK is requested.

Exposure times up to 14.9s/frame can be achieved when combined
with the max FLL / VBLANK value.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

#include "imx355.dtsi"

vcm: ad5398@c {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but not now. Removing.

Comment thread arch/arm/boot/dts/overlays/imx355.dtsi Outdated
@@ -0,0 +1,26 @@
// Fragment that configures an imx355

cam_node: imx219@1a {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this copy/paste issue saying imx219. Fixing.

@6by9

6by9 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Would it be possible or desirable to add a faster 640x480 mode? For comparison, imx219 can do 640x480 (albeit heavily cropped) at 200fps.

This sensor has fixed values for line_length_pix, so cropping horizontally doesn't help. 4x4 binning is actually slower than 2x2 binning as well!

The current modes list on 2 lanes is

0 : imx355 [3280x2464 10-bit RGGB] (/base/axi/pcie@1000120000/rp1/i2c@80000/imx355@1a)
    Modes: 'SRGGB10_CSI2P' : 820x616 [76.05 fps - (0, 0)/3280x2464 crop]
                             1280x720 [130.72 fps - (360, 512)/2560x1440 crop]
                             1284x720 [130.72 fps - (360, 512)/2568x1440 crop]
                             1296x736 [127.96 fps - (344, 496)/2592x1472 crop]
                             1300x736 [127.96 fps - (344, 496)/2600x1472 crop]
                             1640x922 [102.69 fps - (0, 304)/3280x1844 crop]
                             1640x1232 [77.27 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [43.97 fps - (680, 692)/1920x1080 crop]
                             1924x1080 [43.97 fps - (680, 692)/1924x1080 crop]
                             1936x1096 [43.34 fps - (672, 684)/1936x1096 crop]
                             1940x1096 [43.34 fps - (672, 684)/1940x1096 crop]
                             3264x2448 [19.60 fps - (8, 8)/3264x2448 crop]
                             3268x2448 [19.60 fps - (8, 8)/3268x2448 crop]
                             3280x2464 [19.47 fps - (0, 0)/3280x2464 crop]

You need to be down to a 1280x460 2x2 binned mode in order to get 200fps (claimed 201.5).

We can add it, but I doubt upstream will want it (even though it's just another table entry).
Whether to make it 4:3, 16:9, or as many pixels as we can deliver would be up for debate.
Required diff is along the lines of:

index 6ccb087da4f0..49c74814221d 100644
--- a/drivers/media/i2c/imx355.c
+++ b/drivers/media/i2c/imx355.c
@@ -323,6 +323,11 @@ static const struct cci_reg_sequence mode_1280x720_regs[] = {
        { CCI_REG8(0x0701), 0x10 },
 };
 
+static const struct cci_reg_sequence mode_1280x468_regs[] = {
+       { CCI_REG8(0x0700), 0x00 },
+       { CCI_REG8(0x0701), 0x10 },
+};
+
 static const struct cci_reg_sequence mode_820x616_regs[] = {
        { CCI_REG8(0x0700), 0x02 },
        { CCI_REG8(0x0701), 0x78 },
@@ -546,6 +551,22 @@ static const struct imx355_mode supported_modes[] = {
                        .regs = mode_1280x720_regs,
                },
        },
+       {
+               .width = 1280,
+               .height = 460,
+               .crop = {
+                       .width = 1280 * 2,
+                       .height = 460 * 2,
+                       .left = (3280 - (1280 * 2)) / 2,
+                       .top = (2464 - (460 * 2)) / 2,
+               },
+               .fll_def = 1306,
+               .llp = 1836,
+               .reg_list = {
+                       .num_of_regs = ARRAY_SIZE(mode_1280x468_regs),
+                       .regs = mode_1280x468_regs,
+               },
+       },
        {
                .width = 820,
                .height = 616,

It looks quite jagged though, almost as if there is a programming error. I think I'd prefer to merge what we have and investigate later.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9 6by9 force-pushed the rpi-6.18.y-imx355 branch from 3fa26be to b558cab Compare July 7, 2026 15:06
@pelwell pelwell merged commit a96eaa6 into raspberrypi:rpi-6.18.y Jul 7, 2026
11 of 12 checks passed
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.

6 participants