Patch Detail
Show a patch.
GET /api/1.1/patches/18592/?format=api
{ "id": 18592, "url": "https://patchwork.libcamera.org/api/1.1/patches/18592/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18592/", "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": "<20230503122035.32026-8-naush@raspberrypi.com>", "date": "2023-05-03T12:20:29", "name": "[libcamera-devel,07/13] pipeline: raspberrypi: rpi_stream: Set invalid buffer to id == 0", "commit_ref": null, "pull_url": null, "state": "accepted", "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/18592/mbox/", "series": [ { "id": 3863, "url": "https://patchwork.libcamera.org/api/1.1/series/3863/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3863", "date": "2023-05-03T12:20:22", "name": "Raspberry Pi: Code refactoring", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3863/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18592/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18592/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 DFA66C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 3 May 2023 12:20:47 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1037633B8;\n\tWed, 3 May 2023 14:20:46 +0200 (CEST)", "from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 64370633BA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 3 May 2023 14:20:42 +0200 (CEST)", "by mail-wm1-x32e.google.com with SMTP id\n\t5b1f17b1804b1-3f18dacd392so32165355e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 03 May 2023 05:20:42 -0700 (PDT)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tf23-20020a7bcd17000000b003ee443bf0c7sm1736785wmj.16.2023.05.03.05.20.41\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 03 May 2023 05:20:41 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1683116447;\n\tbh=gDPuWDR/FP8/Bt2bGbP2yMnGTelSriSCxRaC5mk3gxw=;\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:Cc:\n\tFrom;\n\tb=aeLhMJ1dAU2cBbdbe6bJHaL5XUUNj3lAEg9ovyVoeqik9rkXFJeyHMi6MEvR2qYMN\n\tjmNq+3R1iw7wEbLVQMrGBEALFPfglaKaD1Vx6vSmdrcLxke6z+683cR003lPknvK3v\n\tBa54Gcki+hldSPAdoXSRZdELrnSbuOGsOfbDrxuEmU1vbvWdG+2xi98qgyCtAJRU58\n\tPgEGYj1YsyMBAR7uuXceWny/v9E9tx0s3+M+9Io3J5AyNyu+OZrtdi2ChHoRdRIeVS\n\tGfBO6ejnzI+R1TuOrHDmdjWT7NOQBTZVTCLrnPOiv/7nithhxXKfau6ureEkYhU0BP\n\tfcTcjc+pb+vEQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1683116441; x=1685708441;\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=clZyTVs1q3LNKsG/a/hXCidK6h8JM4hhBxtTJnVMTYQ=;\n\tb=W7pfy2kInTTXH4mRpbxTUR2ETGOilhbCjgHFjt4ga/bGj2qtzbMH+ls/WVvDbcqM4D\n\tcEQwSL1JlZ+GQKW4lnBlbImTprn4Bnt4YMAC5jl8dQp3s6KnX1E5tRuvUybDrvIkJzaK\n\tQVXfYIoPGYi+Gdv4XRKB7pujDcOCNY1HU3Y6UkH5dhLFMyseGAxMYmZiDf7BmbD/SJS3\n\t1da2FDh44pu16weJy+L9s2oRbZ1y82hZoNvgmlOLw+XVxcxJr32Od41tOiz+HYwl8QeJ\n\tmq1o1U9Shji6PhhodreW70eQ0cFroefp/KynJ3oc4VRscThPm2MXnVxWDkvlwsl/GF3j\n\toR7A==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"W7pfy2kI\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1683116441; x=1685708441;\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=clZyTVs1q3LNKsG/a/hXCidK6h8JM4hhBxtTJnVMTYQ=;\n\tb=HT0sSlMSYj8bse+oaXyV3U9GVU4qhqCJ8BvcB2UYB6rw5T5LmLeh2h0/4gi4oYsEts\n\t6F3GqNUTqMPfnoENRpWMkhWNsZcE7c79hooKFyYNA3CyrRu3C6daQNgl/ataNk3bqyT3\n\ta0C8hfLg9eZ5zFs4dm4RBCkV46cX0XeAL1od1+dMZ3dWu2Ku2gToG5zex7bXniwiPW/s\n\tkqY76AIKeHCrMUJeOxAyxi3aExWcv2YHVfT/OX5BHkA4QEuZhFvLWszewJ0LGXtnf/KF\n\tBi5opGFmDT51nwTp3i3RzjS4J88wb/AHfQQzKeAxpQDNli3b60v/eKspURcPI+w9Yw/q\n\twjfw==", "X-Gm-Message-State": "AC+VfDxHGPf/xFeKDwC5yp6kipMULtWMU9QYcCX+faHDOE35n8rjlD9k\n\tSGSZMdfAgwDfSoXfWzfAaG8WGtIFC83fI5bkgez9cg==", "X-Google-Smtp-Source": "ACHHUZ4TDCoOQMemFjoGofESQv/SdV76KrjshHCMLMKZGssgm/Mx/aiSqpSitV4zfJj3XqitgxuT6w==", "X-Received": "by 2002:a1c:4b1a:0:b0:3f1:954f:82e3 with SMTP id\n\ty26-20020a1c4b1a000000b003f1954f82e3mr14926947wma.24.1683116441672; \n\tWed, 03 May 2023 05:20:41 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 3 May 2023 13:20:29 +0100", "Message-Id": "<20230503122035.32026-8-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20230503122035.32026-1-naush@raspberrypi.com>", "References": "<20230503122035.32026-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 07/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>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.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>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.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 af464d153f28..96749c0d1318 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", "07/13" ] }