[{"id":25271,"web_url":"https://patchwork.libcamera.org/comment/25271/","msgid":"<YzxpTL2Ve2mKf7gT@pendragon.ideasonboard.com>","date":"2022-10-04T17:11:40","subject":"Re: [libcamera-devel] [PATCH v1 7/9] ipa: raspberrypi: Add line\n\tlength calculations helper functions","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Mon, Oct 03, 2022 at 09:39:33AM +0100, Naushir Patuck via libcamera-devel wrote:\n> Add CamHelper::hblankToLineLength() to calculate the line length duration\n> from the horizontal blanking (in pixels) value.\n> \n> Add CamHelper::LineLengthToHblank() to calculate the horizontal blanking (in\n\ns/Line/line/\n\n> pixels) value from the line length duration.\n> \n> Add CamHelper::lineLengthPckToDuration() to calculate the line length duration\n> from the line length in pixels.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp | 16 ++++++++++++++++\n>  src/ipa/raspberrypi/cam_helper.h   |  3 +++\n>  2 files changed, 19 insertions(+)\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\n> index 916632f83037..c255ab0cb53f 100644\n> --- a/src/ipa/raspberrypi/cam_helper.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper.cpp\n> @@ -19,6 +19,7 @@\n>  using namespace RPiController;\n>  using namespace libcamera;\n>  using libcamera::utils::Duration;\n> +using namespace std::literals::chrono_literals;\n>  \n>  namespace libcamera {\n>  LOG_DECLARE_CATEGORY(IPARPI)\n> @@ -102,6 +103,21 @@ uint32_t CamHelper::getVBlanking(Duration &exposure,\n>  \treturn vblank;\n>  }\n>  \n> +Duration CamHelper::hblankToLineLength(uint32_t hblank) const\n> +{\n> +\treturn (mode_.width + hblank) * (1.0s / mode_.pixelRate);\n\nThe previous patch performs the exact same calculation in\nIPARPi::fillDeviceStatus(). The next patch then replaces that code with\nthis function. Could this patch be moved before 6/9, and this function\nbe used there already ?\n\n> +}\n> +\n> +uint32_t CamHelper::lineLengthToHblank(const Duration &lineLength) const\n> +{\n> +\treturn (lineLength * mode_.pixelRate / 1.0s) - mode_.width;\n> +}\n> +\n> +Duration CamHelper::lineLengthPckToDuration(uint32_t lineLengthPck) const\n> +{\n> +\treturn hblankToLineLength(lineLengthPck - mode_.width);\n\nI would have written\n\n\treturn lineLengthPck * (1.0s / mode_.pixelRate);\n\nto avoid subtracting mode_.width to add it back in hblankToLineLength().\nI don't mind much either way.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +}\n> +\n>  void CamHelper::setCameraMode(const CameraMode &mode)\n>  {\n>  \tmode_ = mode;\n> diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h\n> index 1bbdd715d2b1..b5c0726ff00e 100644\n> --- a/src/ipa/raspberrypi/cam_helper.h\n> +++ b/src/ipa/raspberrypi/cam_helper.h\n> @@ -85,6 +85,9 @@ public:\n>  \tvirtual uint32_t getVBlanking(libcamera::utils::Duration &exposure,\n>  \t\t\t\t      libcamera::utils::Duration minFrameDuration,\n>  \t\t\t\t      libcamera::utils::Duration maxFrameDuration) const;\n> +\tlibcamera::utils::Duration hblankToLineLength(uint32_t hblank) const;\n> +\tuint32_t lineLengthToHblank(const libcamera::utils::Duration &duration) const;\n> +\tlibcamera::utils::Duration lineLengthPckToDuration(uint32_t lineLengthPck) const;\n>  \tvirtual uint32_t gainCode(double gain) const = 0;\n>  \tvirtual double gain(uint32_t gainCode) const = 0;\n>  \tvirtual void getDelays(int &exposureDelay, int &gainDelay,","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D1EFCBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Oct 2022 17:11:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 422AD60AB5;\n\tTue,  4 Oct 2022 19:11:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 41EF760AAC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Oct 2022 19:11:44 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 91BD02D9;\n\tTue,  4 Oct 2022 19:11:43 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664903505;\n\tbh=kZdLtAQEeoUKiAsVu+gUaM65ETRW5e6SrfYs8nfpiLo=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=NyCP9zI7iexJCra1alNNtL9MxaCpa5fYxR2SFa1geXTlYu7Xd+3/J7VYDkWMM7x99\n\t0IAKr2ogKWE3dCATYELQwU0emnFlQTZGPgbsxNfUrdbwxmFkcu3GLCMupSixlefqIy\n\tSlQyI3o4MjZNke+uHJycRVYOnHxkiBy3SOc8vTgUC7Rw+g9Eny2cMatTmT8nK/QoBJ\n\tbsTkM6AMQK1LOu2RIAbwBwdUbIrq0T8qa6rONuTKKfg0dYxILSFJaeEcGGZfZVKbSz\n\ttVUUSpW7Kppxj3bQ8uU/LTgmR4ZPBFoHkw+Amc11+Jmjt3eRZPZDxr5KlU8/Re4mPP\n\tm1k1X25umZ2Lg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664903503;\n\tbh=kZdLtAQEeoUKiAsVu+gUaM65ETRW5e6SrfYs8nfpiLo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fS2LJuaCATG5//0qiiY+3Y/y1D11ec/94erKkmiBM47Jrlf6yMkBWkWa2GtcLxx0o\n\tF0e0vlJ/Iss+Uyg+FXw72DItjbZbu2SuCRMJamXSKW7pqA1WUHEyilT4f+/RZwYQOr\n\tQ4YkIzoZeXfQ93lKLm2NHO3lGvLA0WJ/FVO9MVrs="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"fS2LJuaC\"; dkim-atps=neutral","Date":"Tue, 4 Oct 2022 20:11:40 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YzxpTL2Ve2mKf7gT@pendragon.ideasonboard.com>","References":"<20221003083934.31629-1-naush@raspberrypi.com>\n\t<20221003083934.31629-8-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221003083934.31629-8-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v1 7/9] ipa: raspberrypi: Add line\n\tlength calculations helper functions","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]