From patchwork Thu Oct 6 13:17:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17548 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 EBDA2C3286 for ; Thu, 6 Oct 2022 13:18:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8751B62D19; Thu, 6 Oct 2022 15:18:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665062282; bh=oIfN2bhrPLhi8sqa1hMKCz/V8u/e6tzLk1rhkG5IU8A=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NilKDrt8PzOgewSn25n9Z94x8UyyrYDI+pUfUpGYyE1Ti2BsdHXL+0RviRGuIfkME LLcrGcUvt6/SGMIlGBPzfs4noth+8JYoLEkj3QpJQz5WkViSJUFupWAf9ljvJsFl4M RZkAfLKLJKEmFBps9iFXdkZEME6ocivv6bam1rsCiKmk7cQ79TINOFQ2dD/pL/m4o1 ItspwwwMJyTs/2RHpyO5hUCQvnC+gGbbRoChV5EqVKimUzdpihes+F5MeKaaCnAUaV jHPfIrckwo0WR7c0IiJiJElF8jW5/esv1WEmk0HU1JG1aGrR3CuvKb/MDyTz0Ftzhw UZ2z9eL9srR3w== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ABF5162CFE for ; Thu, 6 Oct 2022 15:17:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qSEQP85D"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id ay36so1036626wmb.0 for ; Thu, 06 Oct 2022 06:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0Gqu8R6R2OicBQ0UOmq1eJlfI5JuYCILNc7IuRsY9DU=; b=qSEQP85D9R08Pc9h7eXgjuwRWW4NEpyKtjOP0NkdbrNi/3JUtSKZvQ4W1FEq2LUy7k dHd5ggvslsLq+yf3OK8FAEYFqWIRcOGouQoWIkG8JTqYJFoVwmLc+40DSunAVhAtp03u mdBePH89NxpKHVqFJdYkzkacZPK+HGfcmyRG6t166s6OMo1odszbjtbwZJk7N3lJL9H0 p4YwFyMHyleK4X7rXBMDi8ssxVg1J7LbUvSUpuT/uulvKb7wODKscjmorMV2bKEzHSf9 hEPWJoCCO9OGjdcpON+7WZdGN2gN7USQEw2yLR0IPI/q0aWhS3hTU2D7J6IuGsQ2ksmK Ge4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=0Gqu8R6R2OicBQ0UOmq1eJlfI5JuYCILNc7IuRsY9DU=; b=Eer5X9Um0S2F1aQcTvLaFCiVJRJ218dVKe6ex6QWVQ57NT2G9Mc7rEob65kPb/g30j WyhLmixP7HiU/mJ37s6mWfipbNNzcOzFv4Z9TImtZiWzusD5K99boGHj9C2FOlAVg9+Q 9WX9QIU/qkKsp6b5sTFVA7TpArp39Mnc+7NzEduvThJBZWDn3GhUCVppkc0h9u27jS+h 1TDbwsCGknri69zmsi2Hk2j/QDHBjRBOfOodxY/WY1HgKG1sH3YrSIMaPJF3w3Md0Ih4 bBdIV7FHzkJ41yr0WVlV0IwrQf55SKRSYBc1boLTCQeSLVOxHTtkr2T2EHF4y3cFsCzE 3V1g== X-Gm-Message-State: ACrzQf0lH/m+7Fkf7fVcZS8wFtPVxrErGDXM6s23DbxfW1v/u5T2iUH7 pyo0ojHM1HHhR15CwmBm+L5qDxh6vYJcig== X-Google-Smtp-Source: AMsMyM6FNtWm2EmWPbKqs1q0SSGP+qneP6mxBf/7CzIB+AfT72MvyhzXYmNckUxcJ3OXmZhLHTky4Q== X-Received: by 2002:a05:600c:4109:b0:3c1:b50e:b5ea with SMTP id j9-20020a05600c410900b003c1b50eb5eamr2216117wmi.71.1665062279154; Thu, 06 Oct 2022 06:17:59 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 06:17:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Oct 2022 14:17:41 +0100 Message-Id: <20221006131744.5179-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221006131744.5179-1-naush@raspberrypi.com> References: <20221006131744.5179-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/10] ipa: raspberrypi: Add line length calculations helper functions 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add CamHelper::hblankToLineLength() to calculate the line length duration from the horizontal blanking (in pixels) value. Add CamHelper::lineLengthToHblank() to calculate the horizontal blanking (in pixels) value from the line length duration. Add CamHelper::lineLengthPckToDuration() to calculate the line length duration from the line length in pixels. Signed-off-by: Naushir Patuck Tested-by: Dave Stevenson Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 16 ++++++++++++++++ src/ipa/raspberrypi/cam_helper.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index dd7236f1b693..bc3f66a51254 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -18,6 +18,7 @@ using namespace RPiController; using namespace libcamera; using libcamera::utils::Duration; +using namespace std::literals::chrono_literals; namespace libcamera { LOG_DECLARE_CATEGORY(IPARPI) @@ -96,6 +97,21 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, return vblank; } +Duration CamHelper::hblankToLineLength(uint32_t hblank) const +{ + return (mode_.width + hblank) * (1.0s / mode_.pixelRate); +} + +uint32_t CamHelper::lineLengthToHblank(const Duration &lineLength) const +{ + return (lineLength * mode_.pixelRate / 1.0s) - mode_.width; +} + +Duration CamHelper::lineLengthPckToDuration(uint32_t lineLengthPck) const +{ + return lineLengthPck * (1.0s / mode_.pixelRate); +} + void CamHelper::setCameraMode(const CameraMode &mode) { mode_ = mode; diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h index db2387afc993..6cd1dd397b91 100644 --- a/src/ipa/raspberrypi/cam_helper.h +++ b/src/ipa/raspberrypi/cam_helper.h @@ -85,6 +85,9 @@ public: virtual uint32_t getVBlanking(libcamera::utils::Duration &exposure, libcamera::utils::Duration minFrameDuration, libcamera::utils::Duration maxFrameDuration) const; + libcamera::utils::Duration hblankToLineLength(uint32_t hblank) const; + uint32_t lineLengthToHblank(const libcamera::utils::Duration &duration) const; + libcamera::utils::Duration lineLengthPckToDuration(uint32_t lineLengthPck) const; virtual uint32_t gainCode(double gain) const = 0; virtual double gain(uint32_t gainCode) const = 0; virtual void getDelays(int &exposureDelay, int &gainDelay,