{"id":18861,"url":"https://patchwork.libcamera.org/api/patches/18861/?format=json","web_url":"https://patchwork.libcamera.org/patch/18861/","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":"<20230721093759.27700-5-naush@raspberrypi.com>","date":"2023-07-21T09:37:59","name":"[libcamera-devel,v1,4/4] pipeline: rpi: Simplify buffer id generation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"8b5ae9f7299fefd706ad15c2b1e7d05986146bf8","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/18861/mbox/","series":[{"id":3980,"url":"https://patchwork.libcamera.org/api/series/3980/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3980","date":"2023-07-21T09:37:55","name":"Raspberry Pi: External buffer handling","version":1,"mbox":"https://patchwork.libcamera.org/series/3980/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18861/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18861/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 7CEF8BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Jul 2023 09:38:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F9CF628BD;\n\tFri, 21 Jul 2023 11:38:05 +0200 (CEST)","from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5868B628C4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jul 2023 11:38:00 +0200 (CEST)","by mail-wr1-x430.google.com with SMTP id\n\tffacd0b85a97d-3141fa31c2bso1280390f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jul 2023 02:38:00 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tn12-20020a5d6b8c000000b003143c6e09ccsm3674663wrx.16.2023.07.21.02.37.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 21 Jul 2023 02:37:59 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689932285;\n\tbh=3CbGSLrQmTwZnhFjxxJdZwHpkN2gVzhIXN1IK7P3A70=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=pDhgGCCgY97rBf2PWOgADBx+KeqyWfImWae2C+slnvBO2hiNxvNKzRB9cWwKGMSET\n\tDsE6gHE7pppZoPpj+H5lDd6MKa8rihmRNBpJlrC6k+TTADILI1DdtGZsDPf/toucFN\n\t68CEXyW08ArQF2D2QklURletiM3bV4GOlwpta1+nX2Nca9Pcpks81HGjnY2aq32Sio\n\tHMbpsMCVRVmN3OCvGd/HDbkWYLTPSmB22+e+idIv3uKUPi/ItohA7vzllYAPpTe6Ix\n\tlF7qTxKACgqNUmiWE3psWV4nA6pNEUB1YTZKi+yZKVoJhGZgJzMZ1Y4m51ncIhG/7u\n\tyse+0R8/AAiJQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1689932280; x=1690537080;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=DXvCa+21v7+8EeLNesmlzeQop9M4JkysDUnJt+FZOOI=;\n\tb=mqRKKbGB4v543xessxaFNytREX8e9lWKGA1XiDFMuG8atuH+2AMxmIS+5uiU0Pv0ef\n\tbhRkH5oGfmoDICP0sSyv5toGZ3BYXjWpp2CYoQTFlp/wyviSUP4RjGkMyHYGLxDKcaeF\n\tyHc/BcKX3CT1clgJfbvrsA2BYDsDQWvxfaS8qWwFq54Ho624+q9TCZ2lvZgDfW8ITiy/\n\tvYKS6etFlPEPtFlLNXyEyjWEvHRvTuFX1GCFmiGficp2KEMIrVEykaXze92NRZ7gRZYm\n\t/Y/hoaLl0yeseQskIUOw3jFsjGKptzcsWNyUSjbp/EnNvz+s5BxPSmTDy4G1eVwIwdyY\n\tr5WQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"mqRKKbGB\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1689932280; x=1690537080;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=DXvCa+21v7+8EeLNesmlzeQop9M4JkysDUnJt+FZOOI=;\n\tb=eiyWIb5shejm41in3N3nafIqs+F5ShwgU3LmmjJv5vKXQdFY+GzHHOEM8GVzPb47Jo\n\twdprtQhkMXnPJ330eVQB/2eKkcXdLN7zZdonaepWFoukoQvCM6sheY0iSR7M15Encl1s\n\tDHwk4wL4LGTGXELUSqDAaU6CeaQLbyAK8RIG46LvCN5VhT4YlqBgfD0iNu7Sf/4ig0lL\n\t8i6dBwVJuwTPnfkMP6/90cGA4VjfiitihuVYerc7JaB1OSrXzJa3gu43aaZgIoQ4zZVb\n\teuc3gR9FYhoRTBj7MwrKNSkgbMhiPtl+uLr32SAksm3sluDIHeLRuJxaRps/xHsRroaj\n\tIoyg==","X-Gm-Message-State":"ABy/qLaNULKyRnFPzQypkvtcgeT2GtX3q/fq/xI5k9lNliDEuGT2epYb\n\tfZ9eD37bzp4CP7xIJUk0VBB7KpEQweDzgM1yubWANA==","X-Google-Smtp-Source":"APBJJlElhkt/xCcR8mbw9LEJE6ILFrT0G1U1Bt1jN1UmjrWq7EWnunvPFo0ozCy6ikNXWLFuYBCpxQ==","X-Received":"by 2002:a5d:4b42:0:b0:315:ade6:a52d with SMTP id\n\tw2-20020a5d4b42000000b00315ade6a52dmr944574wrs.19.1689932279768; \n\tFri, 21 Jul 2023 02:37:59 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 21 Jul 2023 10:37:59 +0100","Message-Id":"<20230721093759.27700-5-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20230721093759.27700-1-naush@raspberrypi.com>","References":"<20230721093759.27700-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 4/4] pipeline: rpi: Simplify buffer id\n\tgeneration","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Replace the buffer id generation in RPi::Stream with a simple integer\ncounter since ids don't get recycled any more.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/rpi/common/rpi_stream.cpp        |  9 ++--\n .../pipeline/rpi/common/rpi_stream.h          | 42 +------------------\n 2 files changed, 5 insertions(+), 46 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\nindex e24531e171c8..d32163d3fc0f 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\n@@ -53,7 +53,7 @@ void Stream::resetBuffers()\n void Stream::setExportedBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tfor (auto const &buffer : *buffers)\n-\t\tbufferMap_.emplace(id_.get(), buffer.get());\n+\t\tbufferMap_.emplace(++id_, buffer.get());\n }\n \n const BufferMap &Stream::getBuffers() const\n@@ -78,7 +78,7 @@ unsigned int Stream::getBufferId(FrameBuffer *buffer) const\n \n void Stream::setExportedBuffer(FrameBuffer *buffer)\n {\n-\tbufferMap_.emplace(id_.get(), buffer);\n+\tbufferMap_.emplace(++id_, buffer);\n }\n \n int Stream::prepareBuffers(unsigned int count)\n@@ -149,9 +149,6 @@ void Stream::returnBuffer(FrameBuffer *buffer)\n \t/* Push this buffer back into the queue to be used again. */\n \tavailableBuffers_.push(buffer);\n \n-\t/* Allow the buffer id to be reused. */\n-\tid_.release(getBufferId(buffer));\n-\n \t/*\n \t * Do we have any Request buffers that are waiting to be queued?\n \t * If so, do it now as availableBuffers_ will not be empty.\n@@ -210,7 +207,7 @@ void Stream::clearBuffers()\n \trequestBuffers_ = std::queue<FrameBuffer *>{};\n \tinternalBuffers_.clear();\n \tbufferMap_.clear();\n-\tid_.reset();\n+\tid_ = 0;\n }\n \n int Stream::queueToDevice(FrameBuffer *buffer)\ndiff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h\nindex d1289c4679b9..cc5d3f4afad4 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h\n@@ -60,7 +60,7 @@ public:\n \n \tStream(const char *name, MediaEntity *dev, StreamFlags flags = StreamFlag::None)\n \t\t: flags_(flags), name_(name),\n-\t\t  dev_(std::make_unique<V4L2VideoDevice>(dev)), id_(BufferMask::MaskID)\n+\t\t  dev_(std::make_unique<V4L2VideoDevice>(dev)), id_(0)\n \t{\n \t}\n \n@@ -86,44 +86,6 @@ public:\n \tvoid releaseBuffers();\n \n private:\n-\tclass IdGenerator\n-\t{\n-\tpublic:\n-\t\tIdGenerator(unsigned int max)\n-\t\t\t: max_(max), id_(0)\n-\t\t{\n-\t\t}\n-\n-\t\tunsigned int get()\n-\t\t{\n-\t\t\tunsigned int id;\n-\t\t\tif (!recycle_.empty()) {\n-\t\t\t\tid = recycle_.front();\n-\t\t\t\trecycle_.pop();\n-\t\t\t} else {\n-\t\t\t\tid = ++id_;\n-\t\t\t\tASSERT(id_ <= max_);\n-\t\t\t}\n-\t\t\treturn id;\n-\t\t}\n-\n-\t\tvoid release(unsigned int id)\n-\t\t{\n-\t\t\trecycle_.push(id);\n-\t\t}\n-\n-\t\tvoid reset()\n-\t\t{\n-\t\t\tid_ = 0;\n-\t\t\trecycle_ = {};\n-\t\t}\n-\n-\tprivate:\n-\t\tunsigned int max_;\n-\t\tunsigned int id_;\n-\t\tstd::queue<unsigned int> recycle_;\n-\t};\n-\n \tvoid clearBuffers();\n \tint queueToDevice(FrameBuffer *buffer);\n \n@@ -136,7 +98,7 @@ private:\n \tstd::unique_ptr<V4L2VideoDevice> dev_;\n \n \t/* Tracks a unique id key for the bufferMap_ */\n-\tIdGenerator id_;\n+\tunsigned int id_;\n \n \t/* All frame buffers associated with this device stream. */\n \tBufferMap bufferMap_;\n","prefixes":["libcamera-devel","v1","4/4"]}