From patchwork Mon Oct 3 08:39:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17494 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 225A5C3285 for ; Mon, 3 Oct 2022 08:40:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF60D62CEC; Mon, 3 Oct 2022 10:40:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786408; bh=t1UCF8Q7mQ1fCcwA8Uu0vQ+Qnx4V99ck8EbaIkOuaX0=; 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=baJPatHHfPA3TJSBM52IRMm8msjX0geFrNUUX5L8DN/qL/7cOnaPFPhvIXonmQRfb f7mBWqMmHWmBZsVT+2UMcMSPiJ3VNYHqBFJnFXY2F7OymljbzMEj7uX0G9RoxXMKEx Gfc7oEPBxGMzHMiiuhFJrY0RnH2KoiYjNf4LxRt/6ti71/R4eXMuMtC58MoGv/Vh0C OXfYNiFdvS85NrW0NMm7y6BjPhTRTrg2g+gOPEEHN0wnCvaPpaOkr/e45z2srf5PuC s43xo63JxAPGxzw4AbhOInmNZbwoQUkvL7kAyUNRfWldGlhuKxO+aKJ+0X44WJ3XKV DHaSletA6/PiA== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DC16D62CE3 for ; Mon, 3 Oct 2022 10:40:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="SMjEMFm/"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id 130-20020a1c0288000000b003b494ffc00bso8065064wmc.0 for ; Mon, 03 Oct 2022 01:40:02 -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=PVBXrAWjZI0UrO8LOKOH/Cj3AAKHluADuH/8z3r3jUc=; b=SMjEMFm/C0aAIIwbEdIZlFb6L9ESxkegbgi3/BH4+KSRZVIAQ9AKdB9pf716LJhRdn eZ06fsWby1mojT79EyUbyzylZyF2DuPDL5y42W4ABQlbiTgSDHfENWtBU832qpW/Rfsi Z17IGr2Kwm+BdwUi7Ht0MWc1ywDJB8Uk0LRKFO3Tlee8oN5E7zy1DAdxZb20aYAwm5ty JxKRrBsMZRNRSmSwXVU9e/GyRPfabp3yPc7A/rtkSCq0rxHmiJKuhp2Pi0rkKvMt7DgF o/7OXPtzZytJ3wD2B324da3FlDvhsbQozwUtujR+u1MjuvtMhSMTw/6cAoow2a7DkJKP C1pQ== 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=PVBXrAWjZI0UrO8LOKOH/Cj3AAKHluADuH/8z3r3jUc=; b=rcMvUb674JHJupsN/8xIAlRJL6D/4o/LB25njg86NydJc7VgKHSucdu+7/LQOMJY91 uTKoqz8l4rNZHM+MJqwl/1KrlQUaELZ6B0HRSzlohInEOQ55eio9wyE6TuY6B9KuHtBg jhfdRIhCNNnwrZVUgL2JopCvsg7CFgHb4Z625unzmm6iTSx6b4MlXDad+aEiJLa0mvhm 3yCoXEP6TsKPlX3ADxFhf6ZShUHQB7aDVl0p3LouQFNb0ve7lRNOVGZchJMeRfYdaa37 +orEtDZ9TgQjIRwWI4+ipEXr52oEum5s44JZh8s1eoWT7x+dKUM2oCD003ETbmBEs/36 vEjA== X-Gm-Message-State: ACrzQf3mIwmJt/UExxdyzEFjSBDpyNkrdrKHtU39Vuw9zISvGgOWoN5S 31ZdhznqkcDSG0Zt2nsakoFe4xRlYJQVwg== X-Google-Smtp-Source: AMsMyM52tu5sNhzRPwgS6BPagflG9Qm5SqiPVngp+X8ZEXBLyqpJgbcXwC3Cg4zvZlRU4TTQaRc+rg== X-Received: by 2002:a7b:c417:0:b0:3b4:5c94:24c1 with SMTP id k23-20020a7bc417000000b003b45c9424c1mr6049361wmi.86.1664786402189; Mon, 03 Oct 2022 01:40:02 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:40:01 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:33 +0100 Message-Id: <20221003083934.31629-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 7/9] 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 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 916632f83037..c255ab0cb53f 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -19,6 +19,7 @@ using namespace RPiController; using namespace libcamera; using libcamera::utils::Duration; +using namespace std::literals::chrono_literals; namespace libcamera { LOG_DECLARE_CATEGORY(IPARPI) @@ -102,6 +103,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 hblankToLineLength(lineLengthPck - mode_.width); +} + 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 1bbdd715d2b1..b5c0726ff00e 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,