Skip to content

Starvis2 sensor driver support (IMX662) - #7615

Draft
6by9 wants to merge 20 commits into
raspberrypi:rpi-6.18.yfrom
6by9:rpi-6.18.y-starvis2
Draft

6by9 wants to merge 20 commits into
raspberrypi:rpi-6.18.yfrom
6by9:rpi-6.18.y-starvis2

Conversation

@6by9

@6by9 6by9 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

6.18 backport of IMX678 driver from 7.3 (needs upstream commit hashes), and then amend to become a generic Starvis 2 driver supporting IMX678 (8MPix), IMX675 (5MPix), IMX662 (2MPix), and eventually IMX585 and IMX832. Includes overlays for each of the supported sensors.

@6by9
6by9 force-pushed the rpi-6.18.y-starvis2 branch 2 times, most recently from 244579d to 5338a48 Compare September 9, 2026 16:13
@6by9 6by9 mentioned this pull request Sep 9, 2026
@6by9

6by9 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Working with IMX662, although only at 32.86fps at present (doubling HMAX for all link frequencies is erroneous), and missing HGC selection (won't be acceptable to upstream in current form).

@naushir

@6by9
6by9 force-pushed the rpi-6.18.y-starvis2 branch 2 times, most recently from 2af2c5d to 9376ae2 Compare September 10, 2026 17:55
jailuthra and others added 4 commits September 16, 2026 16:45
Commit 447ea0c upstream.

Sony IMX678 is an 8.4 Megapixel (3856x2180) CMOS sensor, that can output
pixels over MIPI CSI-2 bus. Add bindings for it.

Runtime detection for mono vs color variant of this sensor is feasible
by reading a register, but it's not always desirable given the sensor
needs to be powered on for it, potentially flashing a privacy LED or
wasting precious boot time.

The manufacturer or vendor knows which sensor variant they are putting
on their board, so we define the compatible property to expect the
(color/mono) specific name of the sensor, along with a generic fallback.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Commit bf40cc5 upstream.

Add a V4L2 subdev driver for the Sony IMX678 image sensor.

IMX678 is a diagonal 8.86 mm (Type 1/1.8) CMOS active pixel type
solid-state image sensor with a square pixel array and 8.40 M effective
pixels.

The following features are supported by this driver:
- MIPI RAW12 output
- Monochrome and Color (Bayer filter) variants
- Multiple input clock frequencies
- Multiple link frequencies
- VBLANK and HBLANK control for variable framerate
- VFLIP and HFLIP control for flipping readout
- Exposure and analogue gain control
- Test pattern control

Following features are not currently supported:
- MIPI RAW10 output
- Pixel-perfect crop reporting, accounting for the shift-by-1 when
  doing HFLIP/VFLIP where the sensor maintains RGGB bayer ordering

Along with the ones below which depend on the new raw sensor model:
- Embedded data stream
- Freely configurable cropping
- Increased framerate when cropping
- 2x2 binning support

Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
Reviewed-by: Tarang Raval <tarang.raval@siliconsignals.io>
[Sakari Ailus: Add an extra newline to the enum_mbus_code op.]
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
The register layout and programming model for multiple of the
Sony Starvis2 sensors is identical, so prepare for supporting
those by renaming all common parts of the driver to a starvis2_
prefix, and renaming the driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
link_freqs_reg_value is table that just reverses the order of the
link frequency enum.

Reverse the order of the link frequencies so that the table is
redundant, and remove it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9
6by9 force-pushed the rpi-6.18.y-starvis2 branch 2 times, most recently from 82e31c1 to 80ca024 Compare September 16, 2026 15:54
@6by9

6by9 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Updated.
Fixed so it supports 66fps.
Also includes downstream patches for HCG mode (module parameter read only at module load time), and to increase the gain to allow for on-sensor digital gain.

@naushir @davidplowman Please make sure it does what you need. I'll be looking to send the main patches upstream next week.

@naushir

naushir commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Any chance the HCG param can be changed at runtime (stream off) like the previous iteration of the driver? this will be useful for demo purposes.

@6by9

6by9 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

I'm trying to find a previous iteration that allowed dynamic HGC setting - it doesn't appear to be #7315 or #7239.
The issue is that it changes the minimum gain, so it can scramble gain settings.

We could reread the module parameter at enable_streams and update the control minimum. If the current value is out of range (realistically only if in the 0-34 band when switching to HCG) then it'll adopt the default which will be the minimum. The IPA should adapt to that fairly quickly.

@6by9
6by9 force-pushed the rpi-6.18.y-starvis2 branch from 80ca024 to e8d068a Compare September 16, 2026 17:15
@6by9

6by9 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Updated to allow dynamic HCG control. On changing it you may get a startup glitch, but it shouldn't be an issue between runs if left alone.
Also added imx832 specific registers.

6by9 added 13 commits September 17, 2026 10:01
If the requested region matched the defined active area then
the driver switched to all-pixel mode. This left the possibility
that the activeare was incorrect and not reading out the area
expected.

Switch to always requesting window mode.

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

Several of the Sony Starvis 2 sensors are identical in the
majority of their programming, but differ largely only in the
size of pixel array and some timing parameters.

Parameterise those parameters in preparation for supporting other
variants.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
With some Starvis 2 sensors, the link frequency on 2 lanes is sufficient
to achieve a lower line time than the 4 lane divided by 2, effectively
that it hits the minimum that the pixel array can handle.
That can't easily be handled with the way the values are currently stored.

Storing the 2 lane hmax alongside the pixel array's minimum allows the
4 lane support to divide the value by 2, and then clip to the pixel
array value as a minimum.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
DT allows configuration of multiple link frequencies.
V4L2_CID_LINK_FREQ allows read write control.

Join these up so that link frequency can be configured at run time,
as long, as the sensor isn't streaming.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
IMX662 is a 1080p Starvis 2 sensor that follows the same programming
pattern as IMX678, so add it to the newly parameterised common
driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
The IMX675 is a 5MPix Starvis2 sensor that follows the same
programming pattern as IMX678 and IMX662, so add it into the
driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
HCG (High Conversion Gain) adds additional gain within the sensor,
but also requires that the minimum analogue gain is 34 rather than
0 when in the default LCG mode.

Add a module parameter that is read during probe and at the start
of enable_streams, and adjust settings accordingly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Whilst normally digital gain would be applied in the ISP, there
are some situations where it is an advantage to allow the use of
the on-sensor digital gain too. Allow it.

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>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
IMX832 is replacing IMX662, and it follows the same pattern as all the
Starvis2 sensors.

Add the sensor specific configuration for it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9
6by9 force-pushed the rpi-6.18.y-starvis2 branch from e8d068a to d79eb05 Compare September 17, 2026 09:19
IMX585 is an 8MPix Starvis 2 sensor, so add support for it.

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>
@6by9
6by9 force-pushed the rpi-6.18.y-starvis2 branch from d79eb05 to c185412 Compare September 17, 2026 10:06
@6by9

6by9 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

More changes coming. We can do a full autodetect of all Starvis2 sensors within the kernel driver, so it only needs one overlay.

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.

3 participants