Patch Detail
Show a patch.
GET /api/1.1/patches/18553/?format=api
{ "id": 18553, "url": "https://patchwork.libcamera.org/api/1.1/patches/18553/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18553/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20230426131057.21550-6-naush@raspberrypi.com>", "date": "2023-04-26T13:10:49", "name": "[libcamera-devel,05/13] pipeline: raspberrypi: rpi_stream: Set invalid buffer to id == 0", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "74cbcd24dfdb3ebb82234030742239cb8fca2fef", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18553/mbox/", "series": [ { "id": 3847, "url": "https://patchwork.libcamera.org/api/1.1/series/3847/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3847", "date": "2023-04-26T13:10:44", "name": "Raspberry Pi: Code refactoring", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3847/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18553/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18553/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 C949FBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Apr 2023 13:13:20 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 83B38627ED;\n\tWed, 26 Apr 2023 15:13:20 +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 05278627D6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Apr 2023 15:13:16 +0200 (CEST)", "by mail-wr1-x430.google.com with SMTP id\n\tffacd0b85a97d-2f9b9aa9d75so4515476f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Apr 2023 06:13:16 -0700 (PDT)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tk5-20020adff5c5000000b002f103ca90cdsm15780949wrp.101.2023.04.26.06.13.14\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 26 Apr 2023 06:13:14 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1682514800;\n\tbh=PuwVw5sfY27SM6qjnb0dc5kXg13QrdtvEMENojSPR1E=;\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=ia5FwDuTqMvr/QOKsk+W0psAAQ4rjNhUi6fv/KEiD0MbM7FsYCbL+CFW+Y0j9rTUL\n\tQKEoiNDI5/rjuztRiQHnwI/MXYdG/oDngkgUQXkfD6E1ciHfIZKFK0Jh04HUTaHw0d\n\tWmZhVu/Sm8/PFCNoOU3EWngxBkd0Bsslj/CvIpVr3AE30LLXFZZ8aqGhABrt3kS9h1\n\thB7opZT1PC2pkMoU8Yfum6tCKMnDchDT4Za7W+eyOUSeVK3k/oHScnDX+N6BeCgX6M\n\th6BTw38/HiiRySUCvDqhfG8OisOnsnnED8bhMQN74iffmOImjWDP2ZEYxhVPdSohXg\n\taQIxyWtE59x3Q==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1682514795; x=1685106795;\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=Jexy6v+bzoE8dH/G3OuVccEeF4d1I3E44a60uWXBTjE=;\n\tb=p41tga7gx6+ud8CbXlKyZJEf8VVDQATcr2DUzXLivYm/zsOsuumGWdZV5MuQsrdJMS\n\tIqC9WG1krhjM+4jcC/EPDqNGNwpfYGMrlsPnAHV2L+7pU+31XZ6I9vrV00ftWkrEVQoU\n\tibqEeQM7gjb5jB4cUcQcbHDZw/togT22Be4PfgCUA4MT0mijtJcKiykiSz7fJUOIAPDw\n\tZWavCpJ3wYDvsYXpEr0nGLc+LcITj0KYvtx+nUMXvzoMySmMBDw+/G7uwEormuKtT0wU\n\tLbslpUgDagzbKq5Ma0NeXUQurlyG8+wWVs7LKUXsiXeM749ywgKowM9Lzt3kUF9Rr5+u\n\touGA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"p41tga7g\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1682514795; x=1685106795;\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=Jexy6v+bzoE8dH/G3OuVccEeF4d1I3E44a60uWXBTjE=;\n\tb=lOwObQVGh2CuLVTzTAYApOpXTaoWc3YKf0JjWG4hbsaPObZqgQXxXvx6equQdAlTzD\n\tdupIfnIcyhE0RKm9y9FA4dQQ9Ajqtopk3BfvCnp837XLPVyritTbd1DZETnX0M+GRGSp\n\tLXrgKz/LJfhz8y6wpZcD3HgCvP6jMbID29MKPI6R2KhM3oXK845TJB/AevRCCxu7xv+T\n\twTLjgdhnKv8bLShRKpJ6HUGmtKvUiFWEoefIFLG9qQYwgO8L4Vi5j+i3aahWha08P2Ut\n\tFGuH+NobbMW6iIkujLH8Aa92OYc/UJwV2oZ2owQs1cC/6G+ARMMmXvZdss5AKR4i0+fo\n\t/NqA==", "X-Gm-Message-State": "AAQBX9dFROl5mLdSu9auwIsZ+0FbySiB6Ht3kyI6rVbkNngbf3ZBWKEc\n\tQAY+EQtw5WMdlsjGsLYMGqqa22jfl6E4OrmDe/UYxA==", "X-Google-Smtp-Source": "AKy350aXx2/wiPbv1OobzGVccxfmcWeautFYhtRQol+UJ9DP7tzub71Ca8IXnm3QLfMZ7i2Femi5Xw==", "X-Received": "by 2002:adf:f7c5:0:b0:2fb:87f7:3812 with SMTP id\n\ta5-20020adff7c5000000b002fb87f73812mr13930782wrq.1.1682514795045; \n\tWed, 26 Apr 2023 06:13:15 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 26 Apr 2023 14:10:49 +0100", "Message-Id": "<20230426131057.21550-6-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20230426131057.21550-1-naush@raspberrypi.com>", "References": "<20230426131057.21550-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 05/13] pipeline: raspberrypi: rpi_stream:\n\tSet invalid buffer to id == 0", "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": "At present, the RPiStream buffer ids == -1 indicates an invalid value.\nAs a simplification, use id == 0 to indicate an invalid value. This\nallows for better code readability.\n\nAs a consequence of this, use unsigned int for the buffer id values.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/rpi/common/rpi_stream.cpp | 10 +++++-----\n src/libcamera/pipeline/rpi/common/rpi_stream.h | 18 +++++++++---------\n src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp | 6 +++---\n 3 files changed, 17 insertions(+), 17 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\nindex 2bb10f25d6ca..3690667e9aa6 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\n@@ -55,17 +55,17 @@ const BufferMap &Stream::getBuffers() const\n \treturn bufferMap_;\n }\n \n-int Stream::getBufferId(FrameBuffer *buffer) const\n+unsigned int Stream::getBufferId(FrameBuffer *buffer) const\n {\n \tif (importOnly_)\n-\t\treturn -1;\n+\t\treturn 0;\n \n \t/* Find the buffer in the map, and return the buffer id. */\n \tauto it = std::find_if(bufferMap_.begin(), bufferMap_.end(),\n \t\t\t [&buffer](auto const &p) { return p.second == buffer; });\n \n \tif (it == bufferMap_.end())\n-\t\treturn -1;\n+\t\treturn 0;\n \n \treturn it->first;\n }\n@@ -77,10 +77,10 @@ void Stream::setExternalBuffer(FrameBuffer *buffer)\n \n void Stream::removeExternalBuffer(FrameBuffer *buffer)\n {\n-\tint id = getBufferId(buffer);\n+\tunsigned int id = getBufferId(buffer);\n \n \t/* Ensure we have this buffer in the stream, and it is marked external. */\n-\tASSERT(id != -1 && (id & BufferMask::MaskExternalBuffer));\n+\tASSERT(id & BufferMask::MaskExternalBuffer);\n \tbufferMap_.erase(id);\n }\n \ndiff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h\nindex b8bd79cf1535..1aae674967e1 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h\n@@ -58,7 +58,7 @@ public:\n \n \tvoid setExportedBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \tconst BufferMap &getBuffers() const;\n-\tint getBufferId(FrameBuffer *buffer) const;\n+\tunsigned int getBufferId(FrameBuffer *buffer) const;\n \n \tvoid setExternalBuffer(FrameBuffer *buffer);\n \tvoid removeExternalBuffer(FrameBuffer *buffer);\n@@ -74,25 +74,25 @@ private:\n \tclass IdGenerator\n \t{\n \tpublic:\n-\t\tIdGenerator(int max)\n+\t\tIdGenerator(unsigned int max)\n \t\t\t: max_(max), id_(0)\n \t\t{\n \t\t}\n \n-\t\tint get()\n+\t\tunsigned int get()\n \t\t{\n-\t\t\tint id;\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\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(int id)\n+\t\tvoid release(unsigned int id)\n \t\t{\n \t\t\trecycle_.push(id);\n \t\t}\n@@ -104,9 +104,9 @@ private:\n \t\t}\n \n \tprivate:\n-\t\tint max_;\n-\t\tint id_;\n-\t\tstd::queue<int> recycle_;\n+\t\tunsigned int max_;\n+\t\tunsigned int id_;\n+\t\tstd::queue<unsigned int> recycle_;\n \t};\n \n \tvoid clearBuffers();\ndiff --git a/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp b/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp\nindex cfde7f2e2229..e54bf1ef2c17 100644\n--- a/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp\n@@ -1210,7 +1210,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)\n \t\t\tcontinue;\n \n \t\tFrameBuffer *buffer = request->findBuffer(stream);\n-\t\tif (buffer && stream->getBufferId(buffer) == -1) {\n+\t\tif (buffer && !stream->getBufferId(buffer)) {\n \t\t\t/*\n \t\t\t * This buffer is not recognised, so it must have been allocated\n \t\t\t * outside the v4l2 device. Store it in the stream buffer list\n@@ -2042,7 +2042,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \n \tfor (RPi::Stream &s : unicam_) {\n \t\tindex = s.getBufferId(buffer);\n-\t\tif (index != -1) {\n+\t\tif (index) {\n \t\t\tstream = &s;\n \t\t\tbreak;\n \t\t}\n@@ -2098,7 +2098,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)\n \n \tfor (RPi::Stream &s : isp_) {\n \t\tindex = s.getBufferId(buffer);\n-\t\tif (index != -1) {\n+\t\tif (index) {\n \t\t\tstream = &s;\n \t\t\tbreak;\n \t\t}\n", "prefixes": [ "libcamera-devel", "05/13" ] }