From patchwork Wed Oct 19 09:01:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17626 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 24902C327C for ; Wed, 19 Oct 2022 09:01:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A167062E3E; Wed, 19 Oct 2022 11:01:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666170078; bh=bR2XcJuN9v/o7WELV1bz1uQ//2GkfmEfO0JjDU9qjxk=; 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=0Ue9THUhpmedFyaLuXpRdIMyNnw2+UjnWoUdil+ZwyLWI7U8MNSVkDBANANtpcvKn Y1smdm7L4i2rHrforawfayOoAPABrnGGhd2USV2jGUPTlSu+Yrg9qkI5uOY68PtIp5 gEzRW3NW02yx5OLCmryHPxhQf+Dz6bUjrrdqVGZJKLrbZP6ger53iw0UKZPtat3GKE Q+g4mLKUMWqL8vwyowIxGX82HKKVPxHOSIGon+Mwpd79CoibVWinxwAvz0za6wk2zz ZY//pQu6i34PYPga6Kvk7gbtg+nNm2D2ZijEPIpzQgeZyQsr7nAto4O0ENVp7Gth6m QZlCZfSaU08Hg== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 89BA462DD7 for ; Wed, 19 Oct 2022 11:01:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="A7HI0cCD"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id l14-20020a05600c1d0e00b003c6ecc94285so420626wms.1 for ; Wed, 19 Oct 2022 02:01:17 -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 :message-id:reply-to; bh=ZPzBiNF1VfWzy9TrECDZS8BLt3LUNp1q4BLHZaXn4hI=; b=A7HI0cCDLgxsQ51FHSxhdQG+JiHsPChwLafwFzSdapY05K6vKZ8K4IdlI1PgXgT28M iPiIFQ2n6Zr+vkzoD6x3nZcyttxZ5KrxEHywtygT/di+CxsjpW1rHY0P3sV0Pju1J5EX 27+PDhaWFWukcU5XCd5ldy2bAswXlCLZj2txPQPpGUKoimMQqKFgS99xxsy/51RPlq3+ O7lDWfHZEx1N7cPsb807qZOVcEV6/jmvs/oVHuNf0LuCUEagIy5fyvK/EDlEis5Xp0YZ 66VYGRKafzys1Asp/w7/5HsOmAcbC45OuhJiq4Wzg99g2Noo2Y20pKmI8MKAQLOzKKqv N6OQ== 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:message-id:reply-to; bh=ZPzBiNF1VfWzy9TrECDZS8BLt3LUNp1q4BLHZaXn4hI=; b=032Mdb/VZGWp/OyLU5G9Qzjp5fM63tL6+BIwVYsnxzEusn5C7Ft74FIZ2moIt2UZ9d lRI8IXaONiTV+kg/KitrTzV9ERMGuovkEqeFZ8zu3Hj5wGF9kRfZyiiupVIkimDkfdBI yv5qzBeYL3Mze/nvEwi7hDUr2qXytl8nviUSr6/yoxoO6R/T1SMa7eQFQCP8HCRwaPqS YQM+2tRq90jIa/mrkW8NQQ7B5Rgr/6dQAMW/5gav7Zcvq6ZUp4g9Jum52Mu390SPI6D3 YlrSXmzpmKv1zLiw34bqwIpVVV2WMfQ/boUn7k38rOJSvyfEN5AAQjbT+F4nz/XmN3YL qiGA== X-Gm-Message-State: ACrzQf3oOwRGgqSDYoRD5wEt10kDOeIpDQ0jSgpPddWdBVZg2oapfq1f XNtfUCYd5z8NsiU1AsmT4/bzeM9CWCzKgw== X-Google-Smtp-Source: AMsMyM6eOCslnk3MdtGr4VLRjX1+jb5e59QrYHUjLcJAMHpWyrOcumpKhg1ypuROGiMHcwHvz/Rd4A== X-Received: by 2002:a05:600c:288:b0:3c6:c44a:1d30 with SMTP id 8-20020a05600c028800b003c6c44a1d30mr25849475wmk.46.1666170077080; Wed, 19 Oct 2022 02:01:17 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r9-20020a05600c458900b003b47b913901sm1017595wmo.1.2022.10.19.02.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 02:01:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 19 Oct 2022 10:01:01 +0100 Message-Id: <20221019090107.19975-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221019090107.19975-1-naush@raspberrypi.com> References: <20221019090107.19975-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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. Rename ControlRingBuffer to RingBuffer to indicate this. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Tested-by: David Plowman Reviewed-by: Kieran Bingham --- 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..de8026e3e4f0 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 RingBuffer : 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 */