Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/3] media: Add support for the Sony IMX681
@ 2026-09-09 17:42 Sergey Lebedev
  2026-09-09 17:42 ` [PATCH 1/3] dt-bindings: media: Add " Sergey Lebedev
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sergey Lebedev @ 2026-09-09 17:42 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, Andre Gilerson, Dan Scally
  Cc: Hans de Goede, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	German, linux-media, devicetree, linux-kernel

The Sony IMX681 is the user-facing camera on the Microsoft Surface Pro 11 for
Business (Intel Lunar Lake, IPU7), enumerated as ACPI device SONY0681. Without
a driver the camera does not appear at all.

  1/3  dt-bindings: media: Add Sony IMX681            (mine)
  2/3  media: i2c: Add Sony IMX681 sensor driver      (Andre Gilerson's)
  3/3  media: ipu-bridge: Add Sony IMX681             (mine)

The driver is Andre's work, reverse-engineered from I2C traces taken under
Windows. I am carrying the submission, not the code: his Signed-off-by is on
2/3 with mine beneath it as the person passing it on. He is away until 28
September, so replies to review in the next few weeks will come from me. I have
the hardware and the instrumentation is scripted, so anything you want measured
I can measure.

Where the numbers come from
===========================

The parts taken from traces are labelled as such and not dressed up.
imx681_init_regs[] is 21 register writes whose individual meaning is not known.

What is derived is written down. The link frequency comes from the PLL
configuration visible in the same traces - 19.2 MHz EXCK, PLL2_MUL 303,
PLL2_PRE_DIV 3, giving 1939.2 MHz on the bus and therefore 969.6 MHz per lane -
and the pixel rate follows from that, the lane count and the bit depth. The
gain law and the black level were measured against the sensor rather than read
off a datasheet, because there is no public datasheet for this part.

Three things we know are arguable, raised here rather than left for review
=========================================================================

V4L2_CID_ANALOGUE_GAIN advertises 0..1020, which under the 1024/(1024-code)
law reads as up to 256x, while the analogue stage stops at code 960. Above that
the driver makes up the difference digitally, so the total gain still follows
the formula and an AGC's arithmetic is correct - it is buying noise instead of
exposure at the top of the range. Splitting it between ANALOGUE_GAIN and
DIGITAL_GAIN is the obvious alternative. Andre has not given a view on that one,
so if you want it, I will prepare it and put it to him rather than answer for
him - which may mean it waits for his return at the end of September.

The chip-ID read is a single cci_read with no retry. This machine has failed it
twice, once as 0x0081 and once as 0x0000 against 0x0681 - a sensor answering
before it is ready. A retry absorbs that without inventing a longer reset delay.
Andre would rather land the driver as written and add this afterwards, and I
have kept it that way rather than editing his patch.

It may not be this sensor's fault: the ov13858 on the same board has now
returned a wrong chip id once too, 0x1000 against 0xd855, reading it the same
unretried way. Two events are not a conclusion, but a retry is cheap.

The input clock rate is read and logged but never checked against the 19.2 MHz
the register sequence assumes. Same disposition: a follow-up, not a silent edit.

Testing
=======

On a Surface Pro 11, front camera, with all three patches applied - and on a
kernel built from this base, not backported into a distro one:

  # uname -r
  7.3.0-rc1-imx681-medianext+
  # dmesg
  intel-ipu7 0000:00:05.0: Found supported sensor SONY0681:00 (\_SB.PC00.I2C5.CAMF)
  imx681 i2c-SONY0681:00: IMX681 probed successfully: 3844x2640 @ 969600000 Hz link freq
  intel_ipu7_isys.isys intel_ipu7.isys.40: bind imx681 3-0010 nlanes is 2 port is 2

The first of those lines is 3/3 doing its job: without the ipu-bridge entry the
IPU does not recognise SONY0681 and nothing binds. No errors or warnings from
the driver at all.

  streams                  3844x2640 SGRBG10, 30.01 fps
  brightness vs gain       10.4 / 13.1 / 20.0 / 47.0 for codes 0 / 300 / 700 / 960

The second line is there because a mean brightness on its own cannot tell a
dark room from a dead pipeline. Driving the gain and watching the frames follow
it settles that; the captured frames are a recognisable room, right way up. The
same sweep on a 7.0.0 kernel with the same driver source gives 11.8 / 14.7 /
22.7 / 52.8 - the difference is the room, an hour later.

  checkpatch --strict      clean on 2/3 and 3/3; on 1/3 only "does MAINTAINERS
                           need updating?", which 2/3 answers
  make dt_binding_check    passes, example extracted and compiled
  build, W=1               imx681.o and ipu-bridge.o, no warnings

Based on media/next at f9536a8065 ("media: ipu-bridge: Add support additional
link frequency").

German reported this HID as a bug on this list on 3 September and has had no
reply since; he is on Cc here. He reaches IPU7 through the staging driver rather
than ipu-bridge, so if this goes anywhere there is a second machine on a second
path ready to try it.

  https://lore.kernel.org/linux-media/20260903080854.16266-1-germanpapulindez@gmail.com/

Andre Gilerson (1):
  media: i2c: Add Sony IMX681 sensor driver

Sergey Lebedev (2):
  dt-bindings: media: Add Sony IMX681
  media: ipu-bridge: Add Sony IMX681

 .../bindings/media/i2c/sony,imx681.yaml       | 107 +++
 MAINTAINERS                                   |   8 +
 drivers/media/i2c/Kconfig                     |  10 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/imx681.c                    | 900 ++++++++++++++++++
 drivers/media/pci/intel/ipu-bridge.c          |   2 +
 6 files changed, 1028 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx681.yaml
 create mode 100644 drivers/media/i2c/imx681.c

-- 
2.53.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-09 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 17:42 [PATCH 0/3] media: Add support for the Sony IMX681 Sergey Lebedev
2026-09-09 17:42 ` [PATCH 1/3] dt-bindings: media: Add " Sergey Lebedev
2026-09-09 17:43 ` [PATCH 2/3] media: i2c: Add Sony IMX681 sensor driver Sergey Lebedev
2026-09-09 17:59   ` sashiko-bot
2026-09-09 19:36   ` Sergey Lebedev
2026-09-09 17:43 ` [PATCH 3/3] media: ipu-bridge: Add Sony IMX681 Sergey Lebedev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox