From patchwork Mon Dec 4 09:10:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19273 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 F3ACCC3226 for ; Mon, 4 Dec 2023 09:11:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 09A8A629D3; Mon, 4 Dec 2023 10:11:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1701681069; bh=pvbbnQN/XZIgOeooF+nqntnF161gGgEGppgXFvXA9/4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OfmgplZiUXZILNy4NQqynNMK1Nqf/NbEPpuOYq9aymLgTjwk1WkEIP508dojJIsiJ CHvcOR2GBy7DUq55LW+6+474WhiqgQ2kcPVkhDD6icC5WakQmsQcOwq/hygQXonhsX cH2T+TcVm9INtrSXFv2DeHUXAw7p3+es14/Y18n7Ch2Kty0KxEMs7qjD3kLFVeW7x+ 9eMQIFekOVCrurYmDmUPzkv0hYFLsrzF3VorkYjfWU7/0cIJzpmX669IkpSoZNHIxd ZLekk+jpE91KCawKoq34Xq/RBbZe3JUvS4iZgZ/gXo1Jev8dwd+3EOL4Pv5WcMZa9R afPIaojpkrYVw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 61B4A629C2 for ; Mon, 4 Dec 2023 10:11:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GydT02sQ"; dkim-atps=neutral Received: from localhost.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 04579158A; Mon, 4 Dec 2023 10:10:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701681027; bh=pvbbnQN/XZIgOeooF+nqntnF161gGgEGppgXFvXA9/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GydT02sQTF4+2t8Jaia+XCBvdYBavr+TmSyYt1w/bMVMn6jOdxqQsY4S6rv5o6dSh 7+ypr0GHFutZTJG6ffaha20Bo1Z1+ByttG0z7EpnEw3K9U79290ofyYeCGZu2mYmar +KmqH6xIqa2MUWeZRhB6FPGkvRwLsWmjYpjOT4ao= To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Dec 2023 10:10:51 +0100 Message-ID: <20231204091053.22807-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231204091053.22807-1-jacopo.mondi@ideasonboard.com> References: <20231204091053.22807-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] ipa: rpi: Provide a Camera Helper for the OV64A40 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi , lee.jackson@arducam.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Support the OV64A40 sensor with a camera helper to manage the gain model, light sensitivity, and control delays. Signed-off-by: Lee Jackson Signed-off-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- src/ipa/rpi/cam_helper/cam_helper_ov64a40.cpp | 73 +++++++++++++++++++ src/ipa/rpi/cam_helper/meson.build | 1 + 2 files changed, 74 insertions(+) create mode 100644 src/ipa/rpi/cam_helper/cam_helper_ov64a40.cpp diff --git a/src/ipa/rpi/cam_helper/cam_helper_ov64a40.cpp b/src/ipa/rpi/cam_helper/cam_helper_ov64a40.cpp new file mode 100644 index 000000000000..041c32dd9222 --- /dev/null +++ b/src/ipa/rpi/cam_helper/cam_helper_ov64a40.cpp @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2021, Raspberry Pi Ltd + * + * cam_helper_ov64a40.cpp - camera information for ov64a40 sensor + */ + +#include + +#include "cam_helper.h" + +using namespace RPiController; + +class CamHelperOv64a40 : public CamHelper +{ +public: + CamHelperOv64a40(); + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const override; + double getModeSensitivity(const CameraMode &mode) const override; + +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 4; +}; + +CamHelperOv64a40::CamHelperOv64a40() + : CamHelper({}, frameIntegrationDiff) +{ +} + +uint32_t CamHelperOv64a40::gainCode(double gain) const +{ + return static_cast(gain * 128.0); +} + +double CamHelperOv64a40::gain(uint32_t gainCode) const +{ + return static_cast(gainCode) / 128.0; +} + +void CamHelperOv64a40::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const +{ + /* The driver appears to behave as follows: */ + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 2; + hblankDelay = 2; +} + +double CamHelperOv64a40::getModeSensitivity(const CameraMode &mode) const +{ + if (mode.binX >= 2 && mode.scaleX >= 4) { + return 4.0; + } else if (mode.binX >= 2 && mode.scaleX >= 2) { + return 2.0; + } else { + return 1.0; + } +} + +static CamHelper *create() +{ + return new CamHelperOv64a40(); +} + +static RegisterCamHelper reg("ov64a40", &create); diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build index bdf2db8eb742..7262505742f3 100644 --- a/src/ipa/rpi/cam_helper/meson.build +++ b/src/ipa/rpi/cam_helper/meson.build @@ -9,6 +9,7 @@ rpi_ipa_cam_helper_sources = files([ 'cam_helper_imx477.cpp', 'cam_helper_imx519.cpp', 'cam_helper_imx708.cpp', + 'cam_helper_ov64a40.cpp', 'cam_helper_ov9281.cpp', 'md_parser_smia.cpp', ])