{"id":12309,"url":"https://patchwork.libcamera.org/api/patches/12309/?format=json","web_url":"https://patchwork.libcamera.org/patch/12309/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210518100706.578526-2-naush@raspberrypi.com>","date":"2021-05-18T10:07:03","name":"[libcamera-devel,1/4] ipa: raspberrypi: Add helper macros for std::chrono::duration","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"de3e48bb9d7072e36baf22db91b7225b0c49e498","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12309/mbox/","series":[{"id":2034,"url":"https://patchwork.libcamera.org/api/series/2034/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2034","date":"2021-05-18T10:07:02","name":"Switch RaspberryPi IPA to use std::chrono::duration","version":1,"mbox":"https://patchwork.libcamera.org/series/2034/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12309/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12309/checks/","tags":{},"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 1EAE0C31FF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 May 2021 10:09:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF3AD68923;\n\tTue, 18 May 2021 12:09:14 +0200 (CEST)","from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30B8F68918\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 May 2021 12:09:12 +0200 (CEST)","by mail-wr1-x435.google.com with SMTP id j14so7804056wrq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 May 2021 03:09:12 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:34e4:187b:f2:ed28])\n\tby smtp.gmail.com with ESMTPSA id\n\to11sm6566682wrq.93.2021.05.18.03.09.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 18 May 2021 03:09:10 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"ipvv506i\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=pc4bXwGv6lhgm9H31iNKrGOKtTpaANgZvy51COpEY2A=;\n\tb=ipvv506irWktLmwQdw3/pZsiiSKvDUwI6Tr9eKOROdV2zZ2NgG0BvW+bPZrceLq0RL\n\tLNEP7uwEKERQuAu0UDXqxgWQHsD3i75SRVQwV5ifdZ4/prDd5lNf4kCfG39yymiWYNm7\n\tLCXC+K+TeWIEr7CMT1ofK0jU4mQ4UyFh3rVncPp0Brz3qy0fNth/UxzqH96mu2VquVLS\n\tCtKxPgbc/AkrBgINXMzEWk9fywX2VtW2GEsUe/TA4U7bnixm6ufbo27+LEX0+H8LW7O/\n\tuYRLPhK6KptYoTB3kceFU08jULYB1g9tpl6NUnfgH/44DM8SRwxbjpSyg05Bj1Nf5HKL\n\tl0BQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=pc4bXwGv6lhgm9H31iNKrGOKtTpaANgZvy51COpEY2A=;\n\tb=MgihViYRqUXSMgeTMMhfFybbreDYdhazSCCBguYn64m5vqYy9nf86SzkAtk40aVLtc\n\tUMl0RoMC1B1TG11FNgxEW3GuFABcnkS0Jo85EWsdyWKtUR8hUNKkErLCRSr11C+pFAQy\n\t43Yz2BJRmS4orgFhlYMBQjL2WzNlTmwDB0F7FgH2uiaDjqWKqVgAQnlUJ6j3EtmGuO1W\n\tOGfvFnXNQzzXm5b2J/DJ+wkCvDLcbd0KCe2QeHrmSGVT+zzPps8Z1PUTnqmjcn7cM22r\n\tcv/q6I8+d/YdPX984De8K2RZYIJn11y02YA4jx8ykwS/3ge6WLHRp1Ok/57Cp9E6ItNE\n\tfpUA==","X-Gm-Message-State":"AOAM532AtT663BtuYkMnZLVe+hh73PS1Ot3JK3Hfit1kUXZW6SBwogj/\n\tke2kO/kLq2Dlhs9xqPasXOjsMxdVZIpCRQ==","X-Google-Smtp-Source":"ABdhPJz39hxjWULjwuwYawdOPhgcgxRFR7wsgKwphQK6Ncs8t1vQk03hsItTBgM5d0VfvnPthyb5Qg==","X-Received":"by 2002:a5d:6804:: with SMTP id w4mr5983183wru.363.1621332551493;\n\tTue, 18 May 2021 03:09:11 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 18 May 2021 11:07:03 +0100","Message-Id":"<20210518100706.578526-2-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20210518100706.578526-1-naush@raspberrypi.com>","References":"<20210518100706.578526-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/4] ipa: raspberrypi: Add helper macros\n\tfor std::chrono::duration","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A new RPiController::Duration typedef is defined to represent a\nstd::chrono::duration type with double precision nanosecond timebase\nthat will be used throughout. This minimises the loss of precision when\nconverting timebases. A function for returning the duration count in any\ntimebase is also provided.\n\nAn operator << overload is define to help with displaying\nRPiController::Duration value in stream objects.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/duration.hpp | 33 +++++++++++++++++++++\n 1 file changed, 33 insertions(+)\n create mode 100644 src/ipa/raspberrypi/controller/duration.hpp","diff":"diff --git a/src/ipa/raspberrypi/controller/duration.hpp b/src/ipa/raspberrypi/controller/duration.hpp\nnew file mode 100644\nindex 000000000000..98aa3d78f52f\n--- /dev/null\n+++ b/src/ipa/raspberrypi/controller/duration.hpp\n@@ -0,0 +1,33 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n+ *\n+ * duration.hpp - Helper macros for std::chrono::duration handling.\n+ */\n+#pragma once\n+\n+#include <chrono>\n+#include <iomanip>\n+#include <iostream>\n+\n+namespace RPiController {\n+\n+using Duration = std::chrono::duration<double, std::nano>;\n+\n+// Helper to convert and return the count of any std::chrono::duration type to\n+// another timebase.  Use a double rep type to try and preserve precision.\n+template <typename P, typename T>\n+static constexpr double DurationValue(T const &d)\n+{\n+\treturn std::chrono::duration_cast<std::chrono::duration<double, P>>(d).count();\n+};\n+\n+static inline std::ostream &operator<<(std::ostream &os, const Duration &duration)\n+{\n+        std::streamsize ss = os.precision();\n+        os << std::fixed << std::setprecision(2) << DurationValue<std::micro>(duration) << \" us\";\n+        os << std::setprecision(ss) << std::defaultfloat;\n+        return os;\n+}\n+\n+} // namespace RPiController\n","prefixes":["libcamera-devel","1/4"]}