From patchwork Mon Aug 31 18:08:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Lebedev X-Patchwork-Id: 28155 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 657BFC3260 for ; Mon, 31 Aug 2026 18:25:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4078168564; Mon, 31 Aug 2026 20:25:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=pm.me header.i=@pm.me header.b="J7kFMnpC"; dkim-atps=neutral Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 996CE68450 for ; Mon, 31 Aug 2026 20:08:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1788199703; x=1788458903; bh=QcdAiMSqCqwR/zdAft5cJ4tsWX6KWK8zgeXoF/YBRX0=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=J7kFMnpCUKmZVWrPk/iw4A7ZIr7GPnJugtrtBTxeFJfFl+fO5YnpXtxlh1jDlD/uS 7md06cBR0hnWhL7vhB48ItU8uHZhDn5INM9ZCbwgH8R8Jc11IIcglGLlAVU3rOBfz7 yEJtWE5ajKiiScXzteT190WEG3PiHmjO7piF9kxeJyftZ7RMuhTbi2087ym6QGLnPS 0b6WYiPg47DZGfJjuExPVprnVR5Q4qOT14ecnGGINMlbcSkzKtnNMw+xQi9TYLiYkr 7dreYyoIXxe91lwTyMlIQxXZ6Y+x5Wi7aSOjwcS/+kyw4hGQ7PVM9EBXeWYmQ4ITna WCETAOu+bSSaw== Date: Mon, 31 Aug 2026 18:08:21 +0000 To: libcamera-devel@lists.libcamera.org From: Sergey Lebedev Subject: [PATCH] libipa: camera_sensor_helper: add imx681 Message-ID: <20260831180812.68940-1-lsa.uz@pm.me> Feedback-ID: 113843758:user:proton X-Pm-Message-ID: b86bb597536593a7964c46887d2f4b811a1beffc MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 31 Aug 2026 20:25:43 +0200 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Without a helper the Sony IMX681 front camera on the Microsoft Surface Pro 11 is unusable in the soft ISP: libcamera logs IPASoftIsp: Failed to create camera sensor helper for imx681 and then takes the raw V4L2 gain code for the gain itself. The AGC sees an analogue gain of 1020, concludes the sensor is enormously over-amplified and holds the exposure down. Same scene, same build, only this helper differing: AGC believes mean luma without analogue-gain: 1020 23.8 with analogue-gain: 21.3 110.7 The gain model is the usual Sony form, and the driver states it: /* Gain formula: gain = 1024/(1024-code). */ Verified against the sensor rather than taken on trust, at fixed exposure, on raw Bayer from the CSI-2 receiver: code 1024/(1024-code) measured 0 1.00 1.00 512 2.00 1.91 768 4.00 3.79 896 8.00 7.51 960 16.00 15.05 Black level measured the same way, at minimum exposure and minimum gain: median and mode both exactly 64 at 10 bits, so 4096. Signed-off-by: Sergey Lebedev --- src/ipa/libipa/camera_sensor_helper.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -691,6 +691,18 @@ public: }; REGISTER_CAMERA_SENSOR_HELPER("imx678", CameraSensorHelperImx678) +class CameraSensorHelperImx681 : public CameraSensorHelper +{ +public: + CameraSensorHelperImx681() + { + /* Measured on the sensor: 64 at 10bits. */ + blackLevel_ = 4096; + gain_ = AnalogueGainLinear{ 0, 1024, -1, 1024 }; + } +}; +REGISTER_CAMERA_SENSOR_HELPER("imx681", CameraSensorHelperImx681) + class CameraSensorHelperImx708 : public CameraSensorHelper { public: