From patchwork Tue Nov 14 10:21:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 19211 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 5EF37C3213 for ; Tue, 14 Nov 2023 10:21:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55A95629BF; Tue, 14 Nov 2023 11:21:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1699957299; bh=/YHNOxGZSYLHC/qbYZETeeHhoEQiefxmAtEjkaLjk3M=; 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=G7kTF++RkBNGpo+q6zd3GmXJQ3DP7apT4x0W9Voh99iOhwIjHv8KMsyWeeGBchd4i A8jz0Zr0I/GysSVauAMcx7ObK2LgszMHUjeNoMZMLkX921T5mASnFDA+ORHWBMDiqf 75VZBi8T9nc3Aj6ctvuMprPJiYAJQa2LPPdB5FrSFuMKG/ggFXT6s1CSNYhP+61gmt bgpUcNrMpXVrrH+oyUDRchaGt1+Z07SKLJS07ixC6T1R+yJ1jMPajkDOpQ0xjoHNxy HCRepFKwBNLZBJgtkjNu+25yb+ip2j/KNdEf+BCStLfcy2H9SUZis99/5+/PSnxAXt vJkbrWd9/IA7g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F36C61DB3 for ; Tue, 14 Nov 2023 11:21:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rdChoW40"; 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 D1507D49; Tue, 14 Nov 2023 11:21:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699957271; bh=/YHNOxGZSYLHC/qbYZETeeHhoEQiefxmAtEjkaLjk3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rdChoW40bmpW3xLPx+eCck7jPVDuq8nJmXwugCZ/bXlF8skObAdTgTSm27QXhpQQe LfXvT3Xw/uH9LIrqNrCndxkrQ5s+F9SIg4C2YrwCK3D+y55zhlNJ7Xa155fMv3sAEe 9N9af5QLiiywLQ9aies8VPK9bM0n+Bs+sHhZBzbg= To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Nov 2023 11:21:21 +0100 Message-ID: <20231114102122.19712-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231114102122.19712-1-jacopo.mondi@ideasonboard.com> References: <20231114102122.19712-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] 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 --- 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', ])