Show a patch.

GET /api/patches/8759/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 8759,
    "url": "https://patchwork.libcamera.org/api/patches/8759/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8759/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20200713084727.232422-10-naush@raspberrypi.com>",
    "date": "2020-07-13T08:47:28",
    "name": "[libcamera-devel,9/9] libcamera: pipeline: raspberrypi: Move RPiStream methods to a cpp file",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c0b9db791f0dca5fd0e23434f90e6f7cfb985ec1",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/8759/mbox/",
    "series": [
        {
            "id": 1100,
            "url": "https://patchwork.libcamera.org/api/series/1100/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1100",
            "date": "2020-07-13T08:47:18",
            "name": "Zero-copy RAW stream work",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1100/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8759/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8759/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 B12BEBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jul 2020 08:48:09 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F45A605B4;\n\tMon, 13 Jul 2020 10:48:09 +0200 (CEST)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 57D60605B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jul 2020 10:48:07 +0200 (CEST)",
            "by mail-wm1-x32a.google.com with SMTP id q15so12483576wmj.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jul 2020 01:48:07 -0700 (PDT)",
            "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tg14sm23203357wrm.93.2020.07.13.01.48.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 13 Jul 2020 01:48:05 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"i6Rw1VbW\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=by0PDKAUD7j60C7WR+Teh6crYrQuh/f0Gxq6tC3Qaks=;\n\tb=i6Rw1VbWKAjivS5YZ3X240LGgVOdr8qknqaJ3goISljbo+liLMSV7eN5SeaJeG6nwa\n\tqaizeHjdlOMM54RpZnTGHE/fk2dh6FJhEkqXcWga4FUg2AzSuKUVodju4Y5v7F183giW\n\tTSBGd80naUzkWOvXz5Cy0OilKa8qNZDDWBuo85GfD2Z1QoodykV6VFsH2RYeG3417SRD\n\t2SvrE129hqDuWFay2xe2yzUEvGPmxfuCn5p+UGcrGo/wcuJTQRJY9AQXDGVK4yJhyqWJ\n\tInJyvrkx4kAYZF4jJrokYYpbXg4LzekM0CSGu2+vEvt0SKJe5y/UYk1xaGJ0RrjpLqyj\n\tBcOQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=by0PDKAUD7j60C7WR+Teh6crYrQuh/f0Gxq6tC3Qaks=;\n\tb=q5CQj8M9/q8KeGP58TkBuObNC0QMY80iP+Pq2rIrkePdDmB2TFsmtoJn9s8mvQyCEQ\n\tJMaQM6Zehn6k4AnTOUb0gZsGHbKEzSxFAMeSCgPaIDMuG9lQEuYs8Cy30D8wSpkpkYJ8\n\t0t9nwR9MDC4eMrfiTBjP4jnTwYyavdQMYHm/truF59/BC27NxBCdqqX1JU11/xW7yR+P\n\tNATTugnwpSm2ATdTFNyoQbounVlxU4sUC2s5YY8d/KB2jn6uaZY7jQMzfCSzKYNkfKEI\n\tHgQaVs4R9CXBKN0gRgiZcPSC7oQDt2ehgEbp8jH6IR7tTE7Lew8Z+RTrWAPfDMlgyfdb\n\teesQ==",
        "X-Gm-Message-State": "AOAM531MN4GnAs/dnPLResNshwsPDrqQ7bRP5l3L0gZyaA6opN4EFJEw\n\t/yXH7CSeEgAnWz7mw2xzGPzcaLc39wQ=",
        "X-Google-Smtp-Source": "ABdhPJz6M6n2CqznAgrr0LbViX/Lw4t5cOgo+P5aTw5QvBvN0aGqT8nSJim2Yupf9nfIuQAbeIx/uQ==",
        "X-Received": "by 2002:a1c:bc54:: with SMTP id\n\tm81mr17599599wmf.22.1594630086451; \n\tMon, 13 Jul 2020 01:48:06 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 13 Jul 2020 09:47:28 +0100",
        "Message-Id": "<20200713084727.232422-10-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200713084727.232422-1-naush@raspberrypi.com>",
        "References": "<20200713084727.232422-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 9/9] libcamera: pipeline: raspberrypi:\n\tMove RPiStream methods to a cpp file",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Some of the RPiStream methods have grown considerably in code size.\nMove those functions into a cpp file to stop inlining.\n\nNo other functional changes in this commit.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/meson.build          |   1 +\n .../pipeline/raspberrypi/rpi_stream.cpp       | 167 ++++++++++++++++++\n .../pipeline/raspberrypi/rpi_stream.h         | 155 +---------------\n 3 files changed, 174 insertions(+), 149 deletions(-)\n create mode 100644 src/libcamera/pipeline/raspberrypi/rpi_stream.cpp",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/meson.build b/src/libcamera/pipeline/raspberrypi/meson.build\nindex dcfe07c5..4cdfd8e1 100644\n--- a/src/libcamera/pipeline/raspberrypi/meson.build\n+++ b/src/libcamera/pipeline/raspberrypi/meson.build\n@@ -3,4 +3,5 @@\n libcamera_sources += files([\n     'raspberrypi.cpp',\n     'staggered_ctrl.cpp',\n+    'rpi_stream.cpp'\n ])\ndiff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\nnew file mode 100644\nindex 00000000..4eaa0686\n--- /dev/null\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n@@ -0,0 +1,167 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.\n+ *\n+ * rpi_stream.cpp - Raspberry Pi device stream abstraction class.\n+ */\n+\n+#include \"rpi_stream.h\"\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(RPISTREAM)\n+\n+namespace RPi {\n+\n+int RPiStream::prepareBuffers(unsigned int count)\n+{\n+\tint ret;\n+\n+\tif (!importOnly_) {\n+\t\tif (count) {\n+\t\t\t/* Export some frame buffers for internal use. */\n+\t\t\tret = dev_->exportBuffers(count, &internalBuffers_);\n+\t\t\tif (ret < 0)\n+\t\t\t\treturn ret;\n+\n+\t\t\t/* Add these exported buffers to the internal/external buffer list. */\n+\t\t\tstd::transform(internalBuffers_.begin(), internalBuffers_.end(),\n+\t\t\t\t       std::back_inserter(bufferList_),\n+\t\t\t\t       [](std::unique_ptr<FrameBuffer> &b) { return b.get(); });\n+\n+\t\t\t/* Add these buffers to the queue of internal usable buffers. */\n+\t\t\tfor (auto const &buffer : internalBuffers_)\n+\t\t\t\tavailableBuffers_.push(buffer.get());\n+\t\t}\n+\n+\t\t/* We must import all internal/external exported buffers. */\n+\t\tcount = bufferList_.size();\n+\t}\n+\n+\treturn dev_->importBuffers(count);\n+}\n+\n+int RPiStream::queueAllBuffers()\n+{\n+\tint ret;\n+\n+\tif (external_)\n+\t\treturn 0;\n+\n+\twhile (!availableBuffers_.empty()) {\n+\t\tret = queueBuffer(availableBuffers_.front());\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\n+\t\tavailableBuffers_.pop();\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int RPiStream::queueBuffer(FrameBuffer *buffer)\n+{\n+\t/*\n+\t * A nullptr buffer implies an external stream, but no external\n+\t * buffer has been supplied. So, pick one from the availableBuffers_\n+\t * queue.\n+\t */\n+\tif (!buffer) {\n+\t\tif (availableBuffers_.empty()) {\n+\t\t\tLOG(RPISTREAM, Warning) << \"No buffers available for \"\n+\t\t\t\t\t\t<< name_;\n+\t\t\t/*\n+\t\t\t * Note that we need to requeue an internal buffer as soon\n+\t\t\t * as one becomes available.\n+\t\t\t */\n+\t\t\trequeueBuffers_.push(nullptr);\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\n+\t\tbuffer = availableBuffers_.front();\n+\t\tavailableBuffers_.pop();\n+\t}\n+\n+\tif (requeueBuffers_.empty()) {\n+\t\t/*\n+\t\t * No earlier requests are pending to be queued, so we can\n+\t\t * go ahead and queue the buffer into the device.\n+\t\t */\n+\t\tLOG(RPISTREAM, Debug) << \"Queuing buffer \" << buffer->cookie()\n+\t\t\t\t      << \" for \" << name_;\n+\n+\t\tint ret = dev_->queueBuffer(buffer);\n+\t\tif (ret)\n+\t\t\tLOG(RPISTREAM, Error) << \"Failed to queue buffer for \"\n+\t\t\t\t\t      << name_;\n+\t\treturn ret;\n+\t} else {\n+\t\t/*\n+\t\t * There are earlier buffers to be queued, so this buffer must\n+\t\t * go on the waiting list.\n+\t\t */\n+\t\trequeueBuffers_.push(buffer);\n+\t\treturn 0;\n+\t}\n+}\n+\n+void RPiStream::returnBuffer(FrameBuffer *buffer)\n+{\n+\t/* Push this buffer back into the queue to be used again. */\n+\tavailableBuffers_.push(buffer);\n+\n+\t/*\n+\t * Do we have any buffers that are waiting to be queued?\n+\t * If so, do it now as availableBuffers_ will not be empty.\n+\t */\n+\twhile (!requeueBuffers_.empty()) {\n+\t\tFrameBuffer *buffer = requeueBuffers_.front();\n+\t\trequeueBuffers_.pop();\n+\n+\t\tif (!buffer && !availableBuffers_.empty()) {\n+\t\t\t/*\n+\t\t\t * We want to queue an internal buffer, and at\n+\t\t\t * least one is available.\n+\t\t\t */\n+\t\t\tbuffer = availableBuffers_.front();\n+\t\t\tavailableBuffers_.pop();\n+\t\t} else if (!buffer && !availableBuffers_.empty()) {\n+\t\t\t/*\n+\t\t\t * We want to queue an internal buffer, but none\n+\t\t\t * are available.\n+\t\t\t */\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tLOG(RPISTREAM, Debug) << \"Queuing buffer \" << buffer->cookie()\n+\t\t\t\t      << \" for \" << name_ << \" from returnBuffer\";\n+\n+\t\tint ret = dev_->queueBuffer(buffer);\n+\t\tif (ret)\n+\t\t\tLOG(RPISTREAM, Error) << \"Failed to queue buffer for \"\n+\t\t\t\t\t      << name_ << \" from returnBuffer\";\n+\t}\n+}\n+\n+bool RPiStream::findFrameBuffer(FrameBuffer *buffer) const\n+{\n+\tif (importOnly_)\n+\t\treturn false;\n+\n+\tif (std::find(bufferList_.begin(), bufferList_.end(), buffer) != bufferList_.end())\n+\t\treturn true;\n+\n+\treturn false;\n+}\n+\n+void RPiStream::clearBuffers()\n+{\n+\tavailableBuffers_ = std::queue<FrameBuffer *>{};\n+\trequeueBuffers_ = std::queue<FrameBuffer *>{};\n+\tinternalBuffers_.clear();\n+\tbufferList_.clear();\n+}\n+\n+} /* namespace RPi */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h\nindex 3309edfb..dbbff70b 100644\n--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h\n@@ -16,8 +16,6 @@\n \n namespace libcamera {\n \n-LOG_DEFINE_CATEGORY(RPISTREAM)\n-\n namespace RPi {\n \n /*\n@@ -82,155 +80,14 @@ public:\n \t\tclearBuffers();\n \t}\n \n-\tint prepareBuffers(unsigned int count)\n-\t{\n-\t\tint ret;\n-\n-\t\tif (!importOnly_) {\n-\t\t\tif (count) {\n-\t\t\t\t/* Export some frame buffers for internal use. */\n-\t\t\t\tret = dev_->exportBuffers(count, &internalBuffers_);\n-\t\t\t\tif (ret < 0)\n-\t\t\t\t\treturn ret;\n-\n-\t\t\t\t/* Add these exported buffers to the internal/external buffer list. */\n-\t\t\t\tstd::transform(internalBuffers_.begin(), internalBuffers_.end(),\n-\t\t\t\t\t       std::back_inserter(bufferList_),\n-\t\t\t\t\t       [](std::unique_ptr<FrameBuffer> &b) { return b.get(); });\n-\n-\t\t\t\t/* Add these buffers to the queue of internal usable buffers. */\n-\t\t\t\tfor (auto const &buffer : internalBuffers_)\n-\t\t\t\t\tavailableBuffers_.push(buffer.get());\n-\t\t\t}\n-\n-\t\t\t/* We must import all internal/external exported buffers. */\n-\t\t\tcount = bufferList_.size();\n-\t\t}\n-\n-\t\treturn dev_->importBuffers(count);\n-\t}\n-\n-\tint queueAllBuffers()\n-\t{\n-\t\tint ret;\n-\n-\t\tif (external_)\n-\t\t\treturn 0;\n-\n-\t\twhile (!availableBuffers_.empty()) {\n-\t\t\tret = queueBuffer(availableBuffers_.front());\n-\t\t\tif (ret < 0)\n-\t\t\t\treturn ret;\n-\n-\t\t\tavailableBuffers_.pop();\n-\t\t}\n-\n-\t\treturn 0;\n-\t}\n-\n-\tint queueBuffer(FrameBuffer *buffer)\n-\t{\n-\t\t/*\n-\t\t * A nullptr buffer implies an external stream, but no external\n-\t\t * buffer has been supplied. So, pick one from the availableBuffers_\n-\t\t * queue.\n-\t\t */\n-\t\tif (!buffer) {\n-\t\t\tif (availableBuffers_.empty()) {\n-\t\t\t\tLOG(RPISTREAM, Warning) << \"No buffers available for \"\n-\t\t\t\t\t\t\t<< name_;\n-\t\t\t\t/*\n-\t\t\t\t * Note that we need to requeue an internal buffer as soon\n-\t\t\t\t * as one becomes available.\n-\t\t\t\t */\n-\t\t\t\trequeueBuffers_.push(nullptr);\n-\t\t\t\treturn -ENOMEM;\n-\t\t\t}\n-\n-\t\t\tbuffer = availableBuffers_.front();\n-\t\t\tavailableBuffers_.pop();\n-\t\t}\n-\n-\t\tif (requeueBuffers_.empty()) {\n-\t\t\t/*\n-\t\t\t* No earlier requests are pending to be queued, so we can\n-\t\t\t* go ahead and queue the buffer into the device.\n-\t\t\t*/\n-\t\t\tLOG(RPISTREAM, Debug) << \"Queuing buffer \" << buffer->cookie()\n-\t\t\t\t\t      << \" for \" << name_;\n-\n-\t\t\tint ret = dev_->queueBuffer(buffer);\n-\t\t\tif (ret)\n-\t\t\t\tLOG(RPISTREAM, Error) << \"Failed to queue buffer for \"\n-\t\t\t\t\t\t      << name_;\n-\t\t\treturn ret;\n-\t\t} else {\n-\t\t\t/*\n-\t\t\t * There are earlier buffers to be queued, so this buffer\n-\t\t\t * must go on the waiting list.\n-\t\t\t */\n-\t\t\trequeueBuffers_.push(buffer);\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\n-\tvoid returnBuffer(FrameBuffer *buffer)\n-\t{\n-\t\t/* Push this buffer back into the queue to be used again. */\n-\t\tavailableBuffers_.push(buffer);\n-\n-\t\t/*\n-\t\t * Do we have any buffers that are waiting to be queued?\n-\t\t * If so, do it now as availableBuffers_ will not be empty.\n-\t\t */\n-\t\twhile (!requeueBuffers_.empty()) {\n-\t\t\tFrameBuffer *buffer = requeueBuffers_.front();\n-\t\t\trequeueBuffers_.pop();\n-\n-\t\t\tif (!buffer && !availableBuffers_.empty()) {\n-\t\t\t\t/*\n-\t\t\t\t * We want to queue an internal buffer, and at\n-\t\t\t\t * least one is available.\n-\t\t\t\t */\n-\t\t\t\tbuffer = availableBuffers_.front();\n-\t\t\t\tavailableBuffers_.pop();\n-\t\t\t} else if (!buffer && !availableBuffers_.empty()) {\n-\t\t\t\t/*\n-\t\t\t\t * We want to queue an internal buffer, but none\n-\t\t\t\t * are available.\n-\t\t\t\t */\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\tLOG(RPISTREAM, Debug) << \"Queuing buffer \" << buffer->cookie()\n-\t\t\t\t\t      << \" for \" << name_ << \" from returnBuffer\";\n-\n-\t\t\tint ret = dev_->queueBuffer(buffer);\n-\t\t\tif (ret)\n-\t\t\t\tLOG(RPISTREAM, Error) << \"Failed to queue buffer for \"\n-\t\t\t\t\t\t      << name_ << \" from returnBuffer\";\n-\t\t}\n-\t}\n-\n-\tbool findFrameBuffer(FrameBuffer *buffer) const\n-\t{\n-\t\tif (importOnly_)\n-\t\t\treturn false;\n-\n-\t\tif (std::find(bufferList_.begin(), bufferList_.end(), buffer) != bufferList_.end())\n-\t\t\treturn true;\n-\n-\t\treturn false;\n-\t}\n+\tint prepareBuffers(unsigned int count);\n+\tint queueAllBuffers();\n+\tint queueBuffer(FrameBuffer *buffer);\n+\tvoid returnBuffer(FrameBuffer *buffer);\n+\tbool findFrameBuffer(FrameBuffer *buffer) const;\n \n private:\n-\tvoid clearBuffers()\n-\t{\n-\t\tavailableBuffers_ = std::queue<FrameBuffer *>{};\n-\t\trequeueBuffers_ = std::queue<FrameBuffer *>{};\n-\t\tinternalBuffers_.clear();\n-\t\tbufferList_.clear();\n-\t}\n+\tvoid clearBuffers();\n \n \t/*\n \t * Indicates that this stream is active externally, i.e. the buffers\n",
    "prefixes": [
        "libcamera-devel",
        "9/9"
    ]
}