From patchwork Fri Sep 2 12:08:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17274 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 A467CC327D for ; Fri, 2 Sep 2022 12:08:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6826C61FDF; Fri, 2 Sep 2022 14:08:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662120498; 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=fWCCFafZMDV1UWnq0PTXMMEdCpKUz6HIuRFOsNAR8ls9Gz45b0HHGbIkayRxfXj13 rULVhpp93EjRn0ZQmPUaQorVseQ2mRUSyv2/YQg8kkzFaCgWaNJorcVhQC5og/1+6n 2N7V9cyRcb9Pjjw7/Ad4CzJWTJjSGBtirdJ0XHsamo6ShpzYm1K6do+eXuzoK0gDty 5s0KqCVskrHd3yksck+alb4avHFu9HtLX/JlT/vuRUZ1jwLtWjZW40AdeIkFH4Hhxe tbs8YTenjZvvSWuEXh5ggiXDYfN3b+mxXgVI3FpE8+cD0XqG3z9EcRHxhyt4ooA8vK 40TiPkmj1sN4w== Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D62FF603E1 for ; Fri, 2 Sep 2022 14:08:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NILdb5al"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id k17so1132858wmr.2 for ; Fri, 02 Sep 2022 05:08:16 -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=NILdb5aloWYnTaJCZrGezyD2nxg5OB5WjEW5Rbqrh1qpeHIhHtKQdIO2aXjd1Mp6hx OZUbp8BIUBZW9+cA7Y/Tu9tJXZlcXCJooJNczXbTjoNC5TtCZVPJ7J6gm3hgZlLDYOos loNJMAtbll91VV0JZLtZ7/Zn7kvTHwIEBDejSOaE/AbwCuOeAWesZlKgtFmYEiWAy49J uIf3cC9riGDGBvV+nFMN6//w4MQ+NBKu8p8dbICR/xyEFM8ipWy8CUxUIr4y+jDYNhPY pykPquEaQh1wQkmGWVW6rpdhPmEkqWpY1WG2YO6pCMsj/K93j5j7SAuyjwRoUpcaWknr tAzw== 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=X7gRv8LqzHBmJNqNYjFjno091BiJOEsUCat2GeUL4XOPNNcCcoocb9weltzTj2o7J0 kTAjFW1TxVQiZw8khaDQ51d5VucSfVUCpr+j391bm8k9mnWko4Y93/ARR0SC6Yyl/Z5C xiO254m8IO1yCWDiyy11Gjl+RPyFOYg4/jSK3SgUAHdRbcV6xsij9JQfw76wTpxl5ykH kphz6M2c4Q3rXNV8l7+bmTpJyfcG+hukU2C7BXsPnu3w49NdJ6ljNoUWssUuEs6v3KLj hZ5pWRoWLM5XfGVGCa5arNVviR2JcPdmsRn7esXTXFuLlSBHylqTy5FH3wo1wC7fLEez sP4Q== X-Gm-Message-State: ACgBeo06cojEOskGw4MyP9888X8ebYpWR5l3N21B7oi64Q4mLY3CY9FT D0ECQTkaMbEFPLXuWaMD3onTMNLD5f2oFqWU X-Google-Smtp-Source: AA6agR7syQlFPTT+++I5hyugMczTA0UncrZSmQ5a5wQu9QL++DgSflU7WqrfX1YWSlo2UFsJHnhCxg== X-Received: by 2002:a05:600c:4e8d:b0:3a5:f7ed:873 with SMTP id f13-20020a05600c4e8d00b003a5f7ed0873mr2703331wmq.170.1662120496217; Fri, 02 Sep 2022 05:08:16 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h2-20020a5d4302000000b0021e51c039c5sm1397809wrq.80.2022.09.02.05.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 05:08:15 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Sep 2022 13:08:03 +0100 Message-Id: <20220902120808.842-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220902120808.842-1-naush@raspberrypi.com> References: <20220902120808.842-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/6] 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 --- 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 */