From patchwork Mon Sep 5 07:39:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17297 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 0118BC327D for ; Mon, 5 Sep 2022 07:40:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BD25862055; Mon, 5 Sep 2022 09:40:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662363603; bh=gBEVAsghRyLUxKvoBP8RRSW7iyAeDStcB1KGpH1JaZU=; 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=J88yF96sIEub2NPucSFvrXEkQ0gJm7SyBJc13ut7QQ3MwMWCWbMqS2T/bedPkOOcw Y6DV/G+8xg2x+w+qiJfYpy56pYpu2Hgi3fHTJQTIqd1f8GRYeBKFxK6aSbCt+w13Do jUEogmvIp9eZHxSmV5mHJVg1VUs0m8Cj5FySqn5L53lu8SlMCw6dfItZ435NiKUG2N S07kQkNm02hUcx1khLSNgcuFlkd1+B43gTxbi1qPXdITuXlI2euYdMsbtqr6LqfUg0 bZ4Xs6OaiHShKp7NCBb5ZzEoVb0mDXxLR25z9QCYBGkz3anLFdW+oHcYSGvBQqvs4h lZYPlIPkgioUw== Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7132C6201C for ; Mon, 5 Sep 2022 09: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="RzxeWYAT"; dkim-atps=neutral Received: by mail-wr1-x435.google.com with SMTP id b5so10129234wrr.5 for ; Mon, 05 Sep 2022 00: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=YJjap5Vlhvd2qi+OflmsVt8uhRG4R/2mis0V9sewWMk=; b=RzxeWYATs6sjM/vmO+31Ea/XFnqKmFOpXsEHXj7RnC/iBxhII707W19NOs5R+Wy+E0 XUcM3cHmR8XLMk9yeikOWkVienUav9IEkgG7izLCDJGIyknfPfYMZsTvKl2FxPZknq3g ReziLa//SIf71obNCDHAjKDf5cxnQ3VuHmsrpfx5KFtJskKT+w6ZrVZCECFesgpncyso u52dEmIR7yjCQOl8IoBlqMOayk3lvlzq991jAFl0VtYfnRXarsKfvisHBKjvLcssxasc SoQ7v0zPSdnJ/Na3fltVIY+0mfjJbOzwh9mKZVfO2uw1H13S+wJV5JsaznGRM0ACbofp 9X6g== 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=YJjap5Vlhvd2qi+OflmsVt8uhRG4R/2mis0V9sewWMk=; b=soLZj4n4uIjMcc1665RDulmq0dcAJinlXurmHxeRyFNuNRAfXfI0DLSkAXjHM3OBXr SWTYptheDW1n/0PziCvan6IIMNbHnNgnv0Vd2nPsjwF7459QRJdjrTdY2go0bDdNgBVc vIksbAJ9colCoBIOp6yDGnqGxgIQRkkt2MUwxKGUR+tfZyl5UzUknCCWklONJEKmiTKU GELf38WBmHLuSuHsdMjap0ZFIEM0evaNQkjqtkn++k/gC9VUdURQRsWL+wZNk9OcG1zw LQFJUaIgvZAiQR3Cfs9TwfGekadZlZo+AxdqtSg4GnEeJ625tXmNSLPmo74EcDzf9ArX HIlQ== X-Gm-Message-State: ACgBeo2BIjQRJiBWKXLB+zXbAukZA3Tje8FWC9bjcWAH3ui8LESRrq5x 4JU2B0OSsW6dyNvt9Lv6IGtOCTFSoTH6v6PZ X-Google-Smtp-Source: AA6agR7V7/MW2dRe3hW7BuI3LhiiDqF6fWsmHnQgxyZZN8251xNSJi1xETsg3mBlZlH7J6uhhVAOHw== X-Received: by 2002:a5d:588d:0:b0:225:6e1a:8696 with SMTP id n13-20020a5d588d000000b002256e1a8696mr23374023wrf.512.1662363601833; Mon, 05 Sep 2022 00:40:01 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id v16-20020a5d5910000000b00228a6ce17b4sm1342841wrd.37.2022.09.05.00.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:40:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Sep 2022 08:39:50 +0100 Message-Id: <20220905073956.7342-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905073956.7342-1-naush@raspberrypi.com> References: <20220905073956.7342-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/7] delayed_controls: Template the ControlRingBuffer class 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" Convert ControlRingBuffer to a templated class to allow arbitrary ring buffer array types to be defined. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Tested-by: David Plowman --- include/libcamera/internal/delayed_controls.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index aef37077103c..f6e622f1dfba 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -53,17 +53,18 @@ private: /* \todo Make the listSize configurable at instance creation time. */ static constexpr int listSize = 16; - class ControlRingBuffer : public std::array + template + class ControlRingBuffer : public std::array { public: - Info &operator[](unsigned int index) + T &operator[](unsigned int index) { - return std::array::operator[](index % listSize); + return std::array::operator[](index % listSize); } - const Info &operator[](unsigned int index) const + const T &operator[](unsigned int index) const { - return std::array::operator[](index % listSize); + return std::array::operator[](index % listSize); } }; @@ -75,7 +76,7 @@ private: uint32_t queueCount_; uint32_t writeCount_; /* \todo Evaluate if we should index on ControlId * or unsigned int */ - std::unordered_map values_; + std::unordered_map> values_; }; } /* namespace libcamera */