From patchwork Thu Jun 18 14:56:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 26994 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 B9C66BF415 for ; Thu, 18 Jun 2026 14:57:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6CAD362C75; Thu, 18 Jun 2026 16:57:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u12XxJP+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A53C6298D for ; Thu, 18 Jun 2026 16:57:02 +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 28A2F227; Thu, 18 Jun 2026 16:56:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1781794587; bh=JsfOTL+qasRiJK4+dljFvLPGJ7p09j/bY124CnG8Qak=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=u12XxJP+4MYjjrmnFGpWu3DyT95qvghfrHvM8eeFwh5RR0nJemg4V7/0SLG25HdtZ qOey7yuZuQTrGSvn3tu8VbM5O2wQGOTYgmsgDITKJ+CVkUEIba3JkQMb2eVcVpMzZO 0Gp1VMxyX+4VCMKnvA/n3O5mWqi06twA75lMlS8w= From: Jai Luthra Date: Thu, 18 Jun 2026 20:26:42 +0530 Subject: [PATCH v2 2/2] ipa: rpi: Add cam_helper for Sony IMX678 MIME-Version: 1.0 Message-Id: <20260618-imx678-v2-2-a288102744c3@ideasonboard.com> References: <20260618-imx678-v2-0-a288102744c3@ideasonboard.com> In-Reply-To: <20260618-imx678-v2-0-a288102744c3@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Laurent Pinchart , Jai Luthra , will whang X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2991; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=CdH63icFtGaqAETY5q9PMVVZ6spYsQD6tH1ENx12DDs=; b=owEBbQKS/ZANAwAKAUPekfkkmnFFAcsmYgBqNAcuBmKgk5+zLdWQR0cNo1eGIIQOvbwso8snO OkPpzHOb3qJAjMEAAEKAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCajQHLgAKCRBD3pH5JJpx RcCjEACMJ2xN8WdgtwGXu0OZm189q+RhjlVOVk2hbxchXW9nyL4McvSpubcJ7MgHqhlgQUXsNXN NFw7XNbLYINZsHh1gQvixFdSpkmjP3OILL9d4FkZS/sa6Uo2JJX1gmJLOx5+Wg3FeW95TuS97Ry GHZuEc1hcscxN2TiEs89anQpJ/gDitd8vD3GK5rqrDYcnEgYs+VkqNT5eu0NcFK8mcIIBT8awXF Aw3OPOMmOpSQJ/mBTfcYaf4+SMySfMTspCSowwp3/ltsPPATiQ0B3gLhRyOIxybYoLmsxRMCV3S qB2DGrq/we76Qq3+5ZJ7ygYMg8ZxQjsfUbWmLFl+r8cYIF5k0HW4rGEahe1n4EsiWHzo8L89EOK 0uy4cKzuvw6hHiLxmQAcKyjA9VtaC06qHMbPGETcI3s/5/kl9kPGz9vSsp8GpQPjIzLyLniwuly zCHiKvlP8goAkuEkHT3pFG4MESBwYvuM2fE9P7EaD8kvAXMu1Nmk3oeloqv41raYRNp8nqiI59q u8cRNiEsBImoYKgRwR/6TX3wYz1YfZIji4OIqwfwgETX1a/K/XdNQooRcCJKmZ+RaR4NMZ/3S/H idRgPs14jeW4Ji6MxW1W3Bsvgsj3fx9/yIXkB7tkcNrF0i0SHCJslGIz6zImbTmMo5dZbMeSYi3 LQTbnTXEcQx/Tcg== 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, modelling the gain curve and the sensor limits for the maximum exposure time. Link: https://github.com/will127534/libcamera/commit/619459e7c70306ba18476 Signed-off-by: will whang Co-developed-by: Jai Luthra Signed-off-by: Jai Luthra Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes in v2: - Drop hideFramesStartup() and hideFramesModeSwitch() - Use std::pow() instead of pow() - Drop unnecessary includes, and include and for std::pow and std::min/max - Reword comment for embedded data, as the sensor supports it but the driver currently does not - Cleanup more issues with whitespace - Add a Co-developed-by tag now that it's not a complete copy-paste - Update commit message --- src/ipa/rpi/cam_helper/cam_helper_imx678.cpp | 56 ++++++++++++++++++++++++++++ src/ipa/rpi/cam_helper/meson.build | 1 + 2 files changed, 57 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..916433bf6 --- /dev/null +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2026, Will Whang + * + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor + */ + +#include +#include + +#include "cam_helper.h" + +using namespace RPiController; + +class CamHelperImx678 : public CamHelper +{ +public: + CamHelperImx678(); + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 4; +}; + +/* + * IMX678 driver currently doesn't expose a metadata stream, 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 std::pow(10, 0.015 * gainCode); +} + +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',