From patchwork Thu Jun 18 11:48:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 26932 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 BED9DBF415 for ; Thu, 18 Jun 2026 11:49:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 76CE2629DF; Thu, 18 Jun 2026 13:49:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UANy+Yr6"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 912E162980 for ; Thu, 18 Jun 2026 13:49:11 +0200 (CEST) Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c68:bcf2:9325:a9bd:32b:e71]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 47F77741; Thu, 18 Jun 2026 13:48:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1781783316; bh=LPgz76ddpT2JNEF2/Xmzw0geV9dOyTDvMznp3O8e3fM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UANy+Yr6khUEzvNipkJZz7zf7alS46T/KYltOcu46OmA4tmykCQ3AL2kqTqbRyhFQ WbYspAd63UJTxRAMhelCwdtzvd3OubH2JqAo012e6BZhmmQUK+orEF0uYg878OfAQg +vuvOwbU4tXLyJ43lGmTX5D1/xhmtNOXvUika7Zc= From: Jai Luthra Date: Thu, 18 Jun 2026 17:18:40 +0530 Subject: [PATCH 2/2] ipa: rpi: Add cam_helper for Sony IMX678 MIME-Version: 1.0 Message-Id: <20260618-imx678-v1-2-646e09a63692@ideasonboard.com> References: <20260618-imx678-v1-0-646e09a63692@ideasonboard.com> In-Reply-To: <20260618-imx678-v1-0-646e09a63692@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Jai Luthra , will whang X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2839; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=uy4+uYyp2Soft2iFzyiUKkc07xlanfxVKAZSQtYLIwQ=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBqM9sl9nulGAeyIniMoXZDPPd8KetjO/pO8pYwg T1YxZ19DCKJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCajPbJQAKCRBD3pH5JJpx RdsoD/9MuBkJJLWkMenfww7uvw6hqrKcpfV/X/uWo1IbG2eB5/tmCQBfEz+a2mbbbtoqv8SjpQF o7FakwlZZrBgWOfiZyRWuuBcnZ6JhPSXQtNm7dPOXggMXALbg13LBSclc4tBTg2+CJQLlXYRGzD 7y1VqocxrYNleefiCzNhYnQ7JAc22JZ34icRjeGhGgccPDUIrU3LVNx3x3b9f1UPyuXncDD45Ig akpfi2HL3GhYpvwssLBQUMxmEX9VCZ5FskOnrludlJ4Lzw5SRMUNVGqRKLX18jOB+fs6Pq2wq1p HvWZTmkpE8b1QITjNWsn8/Vme2s5/0W15dBwmKqWTL37LjL6rFVERMNxi8AqTZjCMqQEWda81EP xvmppg99E6EYGUKn/TIHRpgM3jhB9WrfYVCOFMH4A09mj6ocJQjlIYsZ1YNtFY3EvGwb5FdsZNm tWfOURzJJ2XIpXMW+RUuU0pJZtcUo7HCrVyrLjNyhtXQ0MRPGbtDlY2lj7z0SQVVI51Ca/Tul2F 3voa2+hRVu64ioBdk+SGlbulMIhEmtBcb/vRKoL1V2xEtjXHW0V0IbBChQT+NQ/LCW4SVHJg5f5 u9qDVfyw0Dk3ZIIb1HvIy9yd08N2+6alb3rJ/6TJecZzGAQdAtr5VR17lkcgT1KybCyJEcDk/O1 ppOBXGPplKbwrJw== X-Developer-Key: i=jai.luthra@ideasonboard.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 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" From: will whang This adds a basic cam helper for Sony IMX678, taken from Will Whang's github. Link: https://github.com/will127534/libcamera/commit/619459e7c70306ba18476 Signed-off-by: will whang [fix copyright notice, comments and whitespace] Signed-off-by: Jai Luthra --- src/ipa/rpi/cam_helper/cam_helper_imx678.cpp | 69 ++++++++++++++++++++++++++++ src/ipa/rpi/cam_helper/meson.build | 1 + 2 files changed, 70 insertions(+) diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp new file mode 100644 index 000000000..43fc6ae54 --- /dev/null +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2026, Will Whang + * + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor + */ + +#include + +#include "cam_helper.h" +#include "math.h" +using namespace RPiController; + +class CamHelperImx678 : public CamHelper +{ +public: + CamHelperImx678(); + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + unsigned int hideFramesStartup() const override; + unsigned int hideFramesModeSwitch() const override; + +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 4; +}; + +/* + * IMX678 doesn't output metadata, so we have to use the "unicam parser" which + * works by counting frames. + */ + +CamHelperImx678::CamHelperImx678() + : CamHelper({}, frameIntegrationDiff) +{ +} + +uint32_t CamHelperImx678::gainCode(double gain) const +{ + int code = 66.6667 * log10(gain); + return std::max(0, std::min(code, 0xf0)); +} + +double CamHelperImx678::gain(uint32_t gainCode) const +{ + return pow(10, 0.015 * gainCode); +} + +unsigned int CamHelperImx678::hideFramesStartup() const +{ + /* On startup, we seem to get 1 bad frame. */ + return 1; +} + +unsigned int CamHelperImx678::hideFramesModeSwitch() const +{ + /* After a mode switch, we seem to get 1 bad frame. */ + return 1; +} + +static CamHelper *create() +{ + return new CamHelperImx678(); +} + +static RegisterCamHelper reg("imx678", &create); diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build index 87b6a3600..eabd55dce 100644 --- a/src/ipa/rpi/cam_helper/meson.build +++ b/src/ipa/rpi/cam_helper/meson.build @@ -10,6 +10,7 @@ rpi_ipa_cam_helper_sources = files([ 'cam_helper_imx415.cpp', 'cam_helper_imx477.cpp', 'cam_helper_imx519.cpp', + 'cam_helper_imx678.cpp', 'cam_helper_imx708.cpp', 'cam_helper_ov64a40.cpp', 'cam_helper_ov7251.cpp',