From patchwork Fri May 8 16:51:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26698 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 5D6D1BE173 for ; Fri, 8 May 2026 17:17:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D83386301A; Fri, 8 May 2026 19:17:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="S6hOQHRD"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="W4KMnp58"; dkim-atps=neutral Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9982862FD3 for ; Fri, 8 May 2026 19:17:21 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id BE71EEC031B; Fri, 8 May 2026 13:17:20 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Fri, 08 May 2026 13:17:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778260640; x=1778347040; bh=WGp5pPWv3ZJWioyHVGrRotRTUE9E6dv0omfYBxarq/I=; b= S6hOQHRDq9mI9pjmNqspJbBR47p6ZYc/k3NZGud9ZKxdd+XuYKtB5NFaPsfZ4a4C TZcWR0Q0Ieyshcm5l4+XpDOCza+2KB/BHbcA4DJ0v20fOKUNw/r6pl6bIncEqkCQ t4kIywLkOidpRIodupxLkOMdT3aNbA7r+uvPn9P7FYl4VqkDU5NG0uo4MAYsp2NM snqCi1guX3zkgUofckbZ1JmDAuHLf5jOgKOFguQWKeK+pvw1JB7+ty9fq8o9G9Qa WLHljtibIj4xaUFHEwMh0/G24AVhpapoWmmy8/fTjqqd0NcfGiv2GQqsEAMraceT s97F97/Ujk8U9651klCWAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778260640; x= 1778347040; bh=WGp5pPWv3ZJWioyHVGrRotRTUE9E6dv0omfYBxarq/I=; b=W 4KMnp58XNw7Z50aqKAJQ1f3RxPGfmMjxLyAUNQduEk7aJgptq1tug/GU+VhB5Z5A R+4bufewh2TdfwV8KYMBBLmW1KLGhWfGo5KUbyUQFfZ01qtJO40xHUEVxci0ChVM NYCU4GK74Cmvu1kTRLYzJT3dLOIk8k7APcuAGXBuKKbA59gTUv8LGisMxyQKT9Qo cDl8o92Z2dO7r6rQZiDJHqkBmDfRUlgjiMqnxGeSBPIK4Fmh+AiutZof/JGu+MfS yjDAwzaFRZlzocZHcBEy/Jxv9sm7E1GYVjLMkzQfyjVAxiQGFEQTg/lzspmSacOL 6XIs3/BUdiyuVILK5Q/5A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduuddtledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehrohgsvghrthdr mhgruggvrhestgholhhlrggsohhrrgdrtghomhdprhgtphhtthhopegsrghrnhgrsggrsh drphhotgiivgesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtohepkhhivghr rghnrdgsihhnghhhrghmsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhope hlrghurhgvnhhtrdhpihhntghhrghrthesihguvggrshhonhgsohgrrhgurdgtohhmpdhr tghpthhtoheplhhisggtrghmvghrrgdquggvvhgvlheslhhishhtshdrlhhisggtrghmvg hrrgdrohhrghdprhgtphhtthhopehjohhhrghnnhgvshdrghhovgguvgesohhsshdrqhhu rghltghomhhmrdgtohhmpdhrtghpthhtohepmhiirghmrgiirghlsehrvgguhhgrthdrtg homh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 9B9D61EA006C; Fri, 8 May 2026 13:17:20 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Fri, 08 May 2026 10:51:31 -0600 Subject: [PATCH v2 1/3] libcamera: software_isp: Drop redundant sumShift_ guard in finishFrame Cc: mzamazal@redhat.com, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, barnabas.pocze@ideasonboard.com, johannes.goede@oss.qualcomm.com, robert.mader@collabora.com In-Reply-To: <177826063718.39714.13674874482653763631@jetm.me> References: <177826063718.39714.13674874482653763631@jetm.me> Message-Id: <20260508171720.9B9D61EA006C@mailuser.phl.internal> 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" Right-shifting by zero is a no-op, so the if (sumShift_) check before the three >>= sumShift_ assignments is unnecessary. Remove it. Suggested-by: Laurent Pinchart Suggested-by: Barnabas Pocze Signed-off-by: Javier Tia Reviewed-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze --- src/libcamera/software_isp/swstats_cpu.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index b40d3334..2e020e62 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -362,11 +362,10 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId) for (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++) sharedStats_->yHistogram[j] += s.yHistogram[j]; } - if (sumShift_) { - sharedStats_->sum_.r() >>= sumShift_; - sharedStats_->sum_.g() >>= sumShift_; - sharedStats_->sum_.b() >>= sumShift_; - } + + sharedStats_->sum_.r() >>= sumShift_; + sharedStats_->sum_.g() >>= sumShift_; + sharedStats_->sum_.b() >>= sumShift_; } sharedStats_->valid = valid; From patchwork Fri May 8 16:51:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26699 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 113A6BE173 for ; Fri, 8 May 2026 17:17:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A4B6063030; Fri, 8 May 2026 19:17:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="sho2JYJU"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="FE/55NtE"; dkim-atps=neutral Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A16663024 for ; Fri, 8 May 2026 19:17:23 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 7354AEC032B; Fri, 8 May 2026 13:17:22 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Fri, 08 May 2026 13:17:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778260642; x=1778347042; bh=tB6DowHUtYxV1IWRWYuUf2t4ClDgxd/hhuIQ8tW1r4E=; b= sho2JYJU+/5jrfd9cbo8C1+EUZgVar0FxG2Kj63kZOYd9ymQsZVpz1GvxwjZ9oIG 8dO7vy43+DBwFOtIr1AWNRb42gcf8QaLCuzWQGXLLHoGMbzAe9tZOZUvIyKZbKHk 9bMNjAU0XEyBL3qoj2o1+bWCG8vLp8XxJIVUaHo4joXpMaPSWplMbagjUaudD7Bq jrt7ohrYA7kNvmAeeYnx5/s0QQeB0IYiyUd2DTCut1upb5b270OT07rxmwpdveOK QmvsmdkNg6KSLci+lrcNfdFe+RgjuQZ07+hYbyjEwWFoA3lLqISld4mRv55V8/VY kaz9Y7wxiYAAf2yuIDTYtw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778260642; x= 1778347042; bh=tB6DowHUtYxV1IWRWYuUf2t4ClDgxd/hhuIQ8tW1r4E=; b=F E/55NtE039Vuu55IHDTU6qr+ozGI5DaSibZ0+mVXXr9wF2jFD5kEpZcG613XjNgp n+/6OyUmloS3uf4A6Vdo8f+fgxlcYzvCFBGoa127ibk4MUhOcCuKUuonwsndkfma iBorUK84F3Z5pRliM+xxF6+Fa7KYxdxHZJESJJIuE/uHm3QOk+IdFN/KNIrVd2lJ dCav1gETZhfydW6syXyg8kmoONDJ/P6YQCdyyH9bUhQg0CPEWJueS0GlpjNi7FPX iwFx2m4LGNk0DmfU94YQTt89ZD4i5cIGSUbXoLsEpVQK2iUsxC/6Yza85h04+aa/ vMySdpFtQqi0rlHM0MdWQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduuddtledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedu necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehrohgsvghrthdr mhgruggvrhestgholhhlrggsohhrrgdrtghomhdprhgtphhtthhopegsrghrnhgrsggrsh drphhotgiivgesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtohepkhhivghr rghnrdgsihhnghhhrghmsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhope hlrghurhgvnhhtrdhpihhntghhrghrthesihguvggrshhonhgsohgrrhgurdgtohhmpdhr tghpthhtoheplhhisggtrghmvghrrgdquggvvhgvlheslhhishhtshdrlhhisggtrghmvg hrrgdrohhrghdprhgtphhtthhopehjohhhrghnnhgvshdrghhovgguvgesohhsshdrqhhu rghltghomhhmrdgtohhmpdhrtghpthhtohepmhiirghmrgiirghlsehrvgguhhgrthdrtg homh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 53AD71EA0070; Fri, 8 May 2026 13:17:22 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Fri, 08 May 2026 10:51:51 -0600 Subject: [PATCH v2 2/3] ipa: simple: data: Add OV2740 tuning file Cc: mzamazal@redhat.com, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, barnabas.pocze@ideasonboard.com, johannes.goede@oss.qualcomm.com, robert.mader@collabora.com In-Reply-To: <177826063718.39714.13674874482653763631@jetm.me> References: <177826063718.39714.13674874482653763631@jetm.me> Message-Id: <20260508171722.53AD71EA0070@mailuser.phl.internal> 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" Add a tuning file for the OV2740 sensor calibrated from the Intel IPU6 AIQB binary (OV2740_CJFLE23_ADL.aiqb) shipped with the Lenovo ThinkPad X1 Carbon Gen 10 (Alder Lake, JP2 module, Chicony CJFLE23 camera). Black level is 0x40 at 10-bit (64 ADU), stored as the 16-bit value 4096 per the BlackLevel algorithm convention (value >> 8 = 16 at 8-bit scale). AWB gain limits are derived from the minimum R/G and B/G chromaticities across the 8 calibrated illuminants (2319 K to 6302 K), with a 10% headroom margin: maxGainR=2.49, maxGainB=3.07. Eight CCMs are extracted from the AIQB advanced color matrix records (record id=25, float format), covering illuminants from 2319 K (incandescent) to 6302 K (daylight). Signed-off-by: Javier Tia --- src/ipa/simple/data/meson.build | 1 + src/ipa/simple/data/ov2740.yaml | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/ipa/simple/data/ov2740.yaml diff --git a/src/ipa/simple/data/meson.build b/src/ipa/simple/data/meson.build index 92795ee4..e3e4de74 100644 --- a/src/ipa/simple/data/meson.build +++ b/src/ipa/simple/data/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 conf_files = files([ + 'ov2740.yaml', 'uncalibrated.yaml', ]) diff --git a/src/ipa/simple/data/ov2740.yaml b/src/ipa/simple/data/ov2740.yaml new file mode 100644 index 00000000..da7e1efe --- /dev/null +++ b/src/ipa/simple/data/ov2740.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: CC0-1.0 +# Calibrated from OV2740_CJFLE23_ADL.aiqb (Lenovo JP2 module, IPU6 ADL) +%YAML 1.1 +--- +version: 1 +algorithms: + - BlackLevel: + blackLevel: 4096 + - Awb: + maxGainR: 2.49 + maxGainB: 3.07 + speed: 0.25 + - Ccm: + ccms: + - ct: 2319 + ccm: [ 1.5938, -0.1714, -0.4224, + -0.6134, 1.9612, -0.3478, + -0.4710, -1.8500, 3.3210 ] + - ct: 2854 + ccm: [ 1.6119, -0.3132, -0.2987, + -0.4418, 1.8227, -0.3809, + -0.1017, -1.3958, 2.4975 ] + - ct: 2884 + ccm: [ 1.7739, -0.6655, -0.1085, + -0.4113, 1.6619, -0.2506, + -0.0150, -1.1661, 2.1811 ] + - ct: 3239 + ccm: [ 1.8298, -0.6636, -0.1662, + -0.4086, 1.7373, -0.3287, + -0.0500, -1.0836, 2.1335 ] + - ct: 3865 + ccm: [ 1.8836, -0.7430, -0.1406, + -0.3653, 1.7000, -0.3348, + -0.0542, -0.8442, 1.8984 ] + - ct: 4136 + ccm: [ 1.9043, -0.8348, -0.0695, + -0.3241, 1.6389, -0.3148, + 0.0262, -0.9593, 1.9332 ] + - ct: 4939 + ccm: [ 1.6371, -0.4490, -0.1881, + -0.2675, 1.6494, -0.3819, + -0.0245, -0.7782, 1.8026 ] + - ct: 6302 + ccm: [ 1.6401, -0.4418, -0.1984, + -0.2360, 1.7191, -0.4832, + -0.0248, -0.7221, 1.7469 ] + - Adjust: + gamma: 2.2 + contrast: 1.0 + saturation: 1.0 + - Agc: +... From patchwork Fri May 8 16:53:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26700 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 CB650BE173 for ; Fri, 8 May 2026 17:17:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 777AE6302B; Fri, 8 May 2026 19:17:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="UECLH6VT"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="E81jVt9X"; dkim-atps=neutral Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E647362FE1 for ; Fri, 8 May 2026 19:17:24 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 42B95EC0073; Fri, 8 May 2026 13:17:24 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Fri, 08 May 2026 13:17:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778260644; x=1778347044; bh=kmhZ2W1joAZD6ZezUaeHUltkj832ri3xQUgTXtRh59k=; b= UECLH6VTAGZWc6xF+2INKBSTWlkzVbpxQhvNpJFJYaZ5EHbYqNR1QlO7SpRvqlfi k06V3AK0zuVAWYSCGlDEqlr+kRz77qsDyHvHSv1TLMnok+sT9IG03pU26sep0JZH 0R4sIScqEEk5a0IABFfB18dEqA7M5Wkhn4TwmgLBXYkKd4FkGWkAVaRNOUIjqJFo +Lz1rbgXbdN1YFYVU/IrtL6b8RxCyFlIoTNpBELGZOnd4U8ZYXEdJ06CW9/FCn/E MZnczcUjuXUrpUmvLv39ChRRX/pOLgJWwicPehTir0oIOHujC1875D3Amh3TneIE /uVyEB3BnYfpFo6kVHfDDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778260644; x= 1778347044; bh=kmhZ2W1joAZD6ZezUaeHUltkj832ri3xQUgTXtRh59k=; b=E 81jVt9XGGSS1ssVB1vXdQqU8KjISn+ZwUgOzTO597Z/PjUe6ENbZ2iXnP8HjX2ii SyOCeiveHgiUFyCpffiuSsgV8m1cyW96/qPdqgpKMuNUQ9VWfDuF4E3bKtdE9gSl j2tnmoYGyIDwLq+/ZlYStyRwd+BM6Jn5Rk1BPn2E8ifYxXDBJS9qDVja+r0yaT0p H3OG0T5/OWZ6XbhHCskqvPwSWrtCwOMN9LiW7qUDBbm8qbhu9z9fyOpkdVH9/Z+N lsB+WDG/36p2uW/J/Iva7uz1IkhBvC2TAte+XkGi6Zhsb/wE+nnzPsUPWwAiV3Na Sp+1wexfwvUElNDEZP8IA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduuddtledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedu necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehrohgsvghrthdr mhgruggvrhestgholhhlrggsohhrrgdrtghomhdprhgtphhtthhopegsrghrnhgrsggrsh drphhotgiivgesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtohepkhhivghr rghnrdgsihhnghhhrghmsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhope hlrghurhgvnhhtrdhpihhntghhrghrthesihguvggrshhonhgsohgrrhgurdgtohhmpdhr tghpthhtoheplhhisggtrghmvghrrgdquggvvhgvlheslhhishhtshdrlhhisggtrghmvg hrrgdrohhrghdprhgtphhtthhopehjohhhrghnnhgvshdrghhovgguvgesohhsshdrqhhu rghltghomhhmrdgtohhmpdhrtghpthhtohepmhiirghmrgiirghlsehrvgguhhgrthdrtg homh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 201811EA006C; Fri, 8 May 2026 13:17:24 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Fri, 08 May 2026 10:53:36 -0600 Subject: [PATCH v2 3/3] utils: tuning: Add AIQB parser for Intel IPU6 sensors Cc: mzamazal@redhat.com, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, barnabas.pocze@ideasonboard.com, johannes.goede@oss.qualcomm.com, robert.mader@collabora.com In-Reply-To: <177826063718.39714.13674874482653763631@jetm.me> References: <177826063718.39714.13674874482653763631@jetm.me> Message-Id: <20260508171724.201811EA006C@mailuser.phl.internal> 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" Add a Python script to extract CCMs and AWB chromaticity limits from Intel AIQB binary calibration files, producing a ready-to-use libcamera Simple IPA tuning YAML. AIQB is Intel's proprietary calibration format shipped with Windows camera drivers for Intel IPU6 sensors. Files for Alder Lake and Tiger Lake sensors are available in the ipu6-camera-hal repository under config/linux/ipu6ep/, or can be extracted from OEM Windows driver installers using p7zip and innoextract. The script supports record id=25 (advanced color matrices, float format with CCT in Kelvin directly) and falls back to record id=18 (integer matrices with autodetected scale). Record id=25 is preferred and present in all Alder Lake AIQB files examined. Tested against OV2740_CJFLE23_ADL.aiqb (Lenovo ThinkPad X1 Carbon Gen 10, extracted from n3ace31w.exe). Other AIQB files may require adjustments if the record layout differs. Signed-off-by: Javier Tia --- utils/tuning/parse_aiqb.py | 276 +++++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 utils/tuning/parse_aiqb.py diff --git a/utils/tuning/parse_aiqb.py b/utils/tuning/parse_aiqb.py new file mode 100644 index 00000000..12948f75 --- /dev/null +++ b/utils/tuning/parse_aiqb.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Parse an Intel AIQB (CPFF) binary to extract CCMs and AWB chromaticity +# limits for use in a libcamera Simple IPA tuning YAML file. +# +# Tested against OV2740_CJFLE23_ADL.aiqb (Alder Lake, Intel ipu6-camera-hal). +# Other sensors and AIQB versions may require adjustments to the record +# layout assumptions. +# +# AIQB files for Intel IPU6 sensors are available in the ipu6-camera-hal +# repository at config/linux/ipu6ep/. Alternatively, extract from the OEM +# Windows camera driver installer using p7zip and innoextract. +# +# Usage: +# python3 parse_aiqb.py .aiqb [--sensor-name ] \ +# [--black-level ] +# +# The black level is NOT extracted from the AIQB. Pass --black-level with the +# sensor's black level in 16-bit convention (value >> 8 = 8-bit black level). +# Check the sensor datasheet or kernel driver for the correct value. +# Example: OV2740 has 0x40 at 10-bit (64 ADU), which is 4096 in 16-bit conv. + +import argparse +import os +import struct +import sys + +# ia_mkn_record_header: size(u32), fmt_id(u8), key_id(u8), name_id(u16) +REC_HDR = struct.Struct(' approximate CCT in Kelvin +LIGHT_SOURCE_CCT = { + 1: 2856, # A - Incandescent/Tungsten + 4: 5003, # D50 + 5: 5503, # D55 + 6: 6504, # D65 + 7: 7504, # D75 + 8: 5454, # E (equal energy) + 9: 6430, # F1 daylight fluorescent + 10: 4230, # F2 cool white + 11: 3450, # F3 white + 12: 3000, # F4 warm white + 13: 6350, # F5 + 14: 4150, # F6 + 15: 6500, # F7 D65 sim + 16: 5000, # F8 D50 sim + 17: 4150, # F9 + 18: 5000, # F10 + 19: 4000, # F11 + 20: 3000, # F12 + 22: 2300, # HZ horizon +} + +# Record chain starts here in all AIQB files checked so far +FIRST_RECORD_OFFSET = 0x50 + +def walk_records(data): + records = {} + offset = FIRST_RECORD_OFFSET + while offset + REC_HDR_SIZE <= len(data): + size, fmt_id, key_id, name_id = REC_HDR.unpack_from(data, offset) + if size < REC_HDR_SIZE or offset + size > len(data): + break + records[name_id] = (offset, size) + offset += size + return records + +def extract_general_data(data, offset): + w, h, bd, co = struct.unpack_from(' 0.05: + print(f" WARNING: CCT={cct}K row sums {[round(s, 4) for s in row_sums]}") + print(f" CCT={cct}K R/G={rg:.4f} B/G={bg:.4f}") + valid_matrices.append((cct, vals, rg, bg)) + + max_gain_r = max_gain_b = None + if valid_matrices: + min_rg = min(m[2] for m in valid_matrices) + min_bg = min(m[3] for m in valid_matrices) + max_gain_r = round((1.0 / min_rg) * 1.1, 2) if min_rg > 0 else 2.5 + max_gain_b = round((1.0 / min_bg) * 1.1, 2) if min_bg > 0 else 3.2 + print(f"\nSuggested AWB maxGainR={max_gain_r}, maxGainB={max_gain_b} " + f"(from min R/G={min_rg:.4f}, min B/G={min_bg:.4f})") + + aiqb_name = os.path.basename(args.aiqb) + print("\n" + "=" * 60) + print(f"# {sensor_name}.yaml for libcamera Simple IPA") + print("# SPDX-License-Identifier: CC0-1.0") + print(f"# Calibrated from {aiqb_name}") + print("%YAML 1.1") + print("---") + print("version: 1") + print("algorithms:") + print(" - BlackLevel:") + if args.black_level: + print(f" blackLevel: {args.black_level}") + else: + print(" blackLevel: 0 # TODO: set correct value from sensor datasheet") + print(" - Awb:") + print(f" maxGainR: {max_gain_r}") + print(f" maxGainB: {max_gain_b}") + print(" speed: 0.25") + print(" - Ccm:") + print(" ccms:") + for cct, vals, rg, bg in sorted(valid_matrices): + print(f" - ct: {cct}") + print(f" ccm: {format_ccm(vals)}") + print(" - Adjust:") + print(" gamma: 2.2") + print(" contrast: 1.0") + print(" saturation: 1.0") + print(" - Agc:") + print("...") + +if __name__ == '__main__': + main()