From 045f16a0f3c4893fe64670f5b75368af94fc8d58 Mon Sep 17 00:00:00 2001
From: Christophe Schleicher <crissc.linux@gmail.com>
Date: Thu, 5 Nov 2026 21:06:34 +0100
Subject: [PATCH] ipa: libipa: camera_sensor_helper: Add OV2680 support

Add a camera sensor helper and static sensor properties for the
OmniVision OV2680, as found as the front camera of the CHUWI UBook XPro
(Intel IPU3, ACPI HID OVTI2680).

The OV2680 analogue gain is programmed in registers 0x350a/0x350b with
a 1/16 step (0x10 = 1x), which maps to a linear gain model of
{ 1, 0, 0, 16 }. The pixel size is 1.75um. The test pattern menu
indices follow the upstream kernel ov2680 driver.

Without the helper, the IPU3 IPA fails to initialise with
"Failed to create camera sensor helper for ov2680" and the camera is not
exposed.

Tested on a CHUWI UBook XPro with Linux 7.0 and a backport of this
change to libcamera 0.2.0: the IPU3 pipeline exposes the camera and
streams 1280x720 NV12 at 30 fps (cam, GStreamer libcamerasrc,
PipeWire).

This patch was written with the help of an AI coding assistant
(Claude Code, Anthropic), which did the analysis and wrote the code.
I tested the result on my hardware, reviewed it and submit it under my
responsibility.

Signed-off-by: Christophe Schleicher <crissc.linux@gmail.com>
---
 src/ipa/libipa/camera_sensor_helper.cpp           | 11 +++++++++++
 src/libcamera/sensor/camera_sensor_properties.cpp | 14 ++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
index 359040e..ded0bf1 100644
--- a/src/ipa/libipa/camera_sensor_helper.cpp
+++ b/src/ipa/libipa/camera_sensor_helper.cpp
@@ -748,6 +748,17 @@ public:
 };
 REGISTER_CAMERA_SENSOR_HELPER("mira220", CameraSensorHelperMira220)
 
+class CameraSensorHelperOv2680 : public CameraSensorHelper
+{
+public:
+	CameraSensorHelperOv2680()
+	{
+		/* Analogue gain register 0x350a/0x350b, 1/16 step (0x10 = 1x). */
+		gain_ = AnalogueGainLinear{ 1, 0, 0, 16 };
+	}
+};
+REGISTER_CAMERA_SENSOR_HELPER("ov2680", CameraSensorHelperOv2680)
+
 class CameraSensorHelperOv2685 : public CameraSensorHelper
 {
 public:
diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
index 20cfd0b..5cf824c 100644
--- a/src/libcamera/sensor/camera_sensor_properties.cpp
+++ b/src/libcamera/sensor/camera_sensor_properties.cpp
@@ -403,6 +403,20 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
 				.hblankDelay = 1
 			},
 		} },
+		{ "ov2680", {
+			.unitCellSize = { 1750, 1750 },
+			.testPatternModes = {
+				{ controls::draft::TestPatternModeOff, 0 },
+				{ controls::draft::TestPatternModeColorBars, 1 },
+				/*
+				 * No corresponding test pattern mode for:
+				 * 2: "Random Data"
+				 * 3: "Square"
+				 * 4: "Black Image"
+				 */
+			},
+			.sensorDelays = { },
+		} },
 		{ "ov2685", {
 			.unitCellSize = { 1750, 1750 },
 			.testPatternModes = {
-- 
2.43.0

