From patchwork Wed Sep 2 19:15:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Neiva de Carvalho X-Patchwork-Id: 28173 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 D5BF0C3344 for ; Wed, 2 Sep 2026 20:04:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E713685DA; Wed, 2 Sep 2026 22:04:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FS2rP+AQ"; dkim-atps=neutral Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E897683E4 for ; Wed, 2 Sep 2026 21:16:03 +0200 (CEST) Received: by mail-vs1-xe29.google.com with SMTP id ada2fe7eead31-789fef9422fso631343137.2 for ; Wed, 02 Sep 2026 12:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788376562; x=1788981362; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=6oIkI/rs8RXLu5TaKyseu1JFKsflxGGwn7y1mIssQ3s=; b=FS2rP+AQ9jnvW9aZVBgW3XAMwVJ7MhWyfuStTOouM547W/+hwXDMaWcdylLgH33NiN JjKtMTPCQ/Mse969vfbYTW9CwM08LGm7icZ+AtWPmbjXnig0Lgqm9KOeFvDT8JdSsD6Q XFZlZI8h1iSNXhgyXf2sp3ZysiFEx4L8L0t5+spsvbTqy6l5tExiEoeGgDfLIfmL6fWI 2cDRG1XhfEjv5GxyYzH3NNLKQQ5GSfpu8Y7yIlht/euUEtVSvApbZKLurlknjkBj1vBm ar7NUhiti1/nIa0VgMV80hLoZr6zkKZ7b9xfamXOKwhbSWS/1O7mkIazZGrmHfjFOG0B V1nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788376562; x=1788981362; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6oIkI/rs8RXLu5TaKyseu1JFKsflxGGwn7y1mIssQ3s=; b=G4W8ntd/38WPLg7gWjHuzwlEf67M3msLffAdcUwZiaJ4VkRRqzGaR/QMHT5HAfS3dL wiIlfbCI80KwtFgnzppGu3KZp0BlLunaqZ4jMBSi+v2EAhvzPx88GkRXQUf+6Irn0IGh cuXP1Sq1KkUzqf0cLvLf1l4S/qGfZDzhZdivozVDpG0gPTuOz/Wsk+ONumBXyrKgWLNF wMdRKze1YQl73lV02olcseF7am9W6P47IChMJvdNXfQDX/a4xEqUXGJjR5ivOpABEtai WyMNYTbuql9g/yULmE6OBaRRO8qUptl7bGJpxxZ8KCGo3h47mtB4AVj+sOjmgVheaf86 Ti8w== X-Gm-Message-State: AFuF++k+Dq3rwlPB4C2j9thgTeUY60keoYF4yKywMbLYNrb61KwnktBc x17rdxx+ulwH5itEk0pyqx1w4+1ZthxSitfv4X+b9a4F4ToeSf9XhQ05JMTgKU4pb2Y= X-Gm-Gg: AYBFou2oqZH5fH+sx42t2tKI2JbsOaZJMVMSa8sBauP82gP+D6Wy7VOyOgX+lx4kNrh 994V3g77udFOnEsb1FTvGaVkYjhjZXRSNXy/mXubx7ghWsw5VjJPDE/UOaFO67QQwOoTdToNgAk a4d8mhGo3HJRQ+EyyOMgrLd5Kn4upuqUben3Rb5Gdya6ugJUQaQ/E/g/GZV3wjuXGLnfhYtS3tD t+MO7Kd1HksF3zrSSF3qDejCf43zByyqgXJo7tigQp5sWucPxdVfT/0iHX/xUwjVANvuBdNZQGH +0xscLgIsg1gAYqrnpXe28zfA3zMGiT99BzEVqO+7mHyAT2pGld+iBcgBmWZg0t+H3FjXmGc0Cw MuHrbxyXO7k4PJvGQXErVohJn7+RcNaxq+AifhwXUGj8aPV32MX3B2+T21s433GjxxdXGXubUU3 yqiRkprtEOGd2K5ngZlIue1PU1ybz6glyWtWr10tXDGsk56I8n9hmAp1ZaNO0= X-Received: by 2002:a05:6102:3a06:b0:780:5605:743f with SMTP id ada2fe7eead31-78a1f15755cmr2711655137.3.1788376561896; Wed, 02 Sep 2026 12:16:01 -0700 (PDT) Received: from laptop ([45.184.68.165]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-78a1a1feac0sm3003754137.2.2026.09.02.12.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2026 12:16:01 -0700 (PDT) From: Martin Neiva de Carvalho To: libcamera-devel@lists.libcamera.org Cc: Martin Neiva de Carvalho Subject: [PATCH 0/5] softisp: Five fixes found on a camera with no hardware ISP Date: Wed, 2 Sep 2026 16:15:49 -0300 Message-ID: <20260902191554.84922-1-martincarvalho@gmail.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 02 Sep 2026 22:04:26 +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" Five independent improvements to the software ISP, found while making the camera on an Intel IPU6 laptop usable. That platform has no open driver for the hardware ISP, so everything the picture gets, it gets from softisp - which makes it a fairly demanding test of it. Each patch stands alone and each carries its own measurement. Two of them are about the same underlying problem: statistics gathered before the gains are applied do not describe what the user will actually see. 1/5 adds a sensor helper for the OV02C10. Without it the AGC reads the sensor's gain codes as multipliers - a code of 16 taken for 16x rather than 1.0x - so it believes it already has all the gain it could want and never asks for more. The picture stays dark. 2/5 excludes saturated pixels from the colour sums. A clipped pixel has lost the ratio between its channels, so it can only pull the white balance towards grey. Measured facing a bright window, the linear R/G rose from 0.855 to 0.944 and B/G from 0.942 to 0.986. 3/5 estimates white balance from the pixels that already look neutral rather than from the whole frame. Grey world reads the average of the scene as the colour of the light, so one large coloured object is taken for the light and balanced away. On a scene with a blue door the walls came out five percent short of red; restricting the estimate brought that to one and a half. 4/5 takes the AGC's minimum gain step from the sensor instead of from a fraction of its gain range. The two are unrelated: on a sensor whose range runs from 1 to 248 the fraction is 2.47, so the smallest correction the loop can make is around 12% at a typical indoor gain, and it can never settle - every step crosses the target. Measured with the two settings interleaved so that changing light could not favour either, the brightness ripple falls from 2.80 to 0.38 DN RMS. 5/5 centres the crop the GPU debayer applies to a stream whose aspect ratio differs from the sensor's. It was taken entirely off one side, so a 640x480 stream showed the sensor from x=48 instead of from x=240, and the framing moved with the resolution the application picked. The last two were found by registering streams of different sizes against each other, which measures framing rather than noise and so works in a dark room. 4/5 is the one I would most like reviewed carefully: it changes the meaning of a configuration value that other sensors also use, and while a step taken from the sensor is correct for a linear gain law, I have only been able to test it on one. Martin Neiva de Carvalho (5): ipa: libipa: camera_sensor_helper: Add OV02C10 libcamera: software_isp: Exclude saturated pixels from colour sums libcamera: software_isp: Estimate white balance from neutral pixels ipa: softisp: Derive the minimum gain step from the sensor libcamera: software_isp: Centre the crop the GPU debayer applies .../internal/software_isp/swisp_stats.h | 21 +++ .../internal/software_isp/swstats_cpu.h | 5 + src/ipa/libipa/camera_sensor_helper.cpp | 12 ++ src/ipa/softisp/algorithms/awb.cpp | 33 ++++- src/ipa/softisp/softisp.cpp | 22 +++- src/libcamera/software_isp/debayer_cpu.cpp | 7 + src/libcamera/software_isp/debayer_egl.cpp | 30 ++++- src/libcamera/software_isp/swstats_cpu.cpp | 120 ++++++++++++++++-- 8 files changed, 226 insertions(+), 24 deletions(-)