Show a patch.

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

{
    "id": 18559,
    "url": "https://patchwork.libcamera.org/api/patches/18559/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18559/",
    "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": "<20230426131057.21550-13-naush@raspberrypi.com>",
    "date": "2023-04-26T13:10:56",
    "name": "[libcamera-devel,12/13] pipeline: raspberrypi: Add stream flags to RPi::Stream",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "3f2cebf17483e86b537de9bec2d50475dfb649c8",
    "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/18559/mbox/",
    "series": [
        {
            "id": 3847,
            "url": "https://patchwork.libcamera.org/api/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/18559/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18559/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 D9E6FBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Apr 2023 13:13:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 921B8627F2;\n\tWed, 26 Apr 2023 15:13:43 +0200 (CEST)",
            "from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8FC8B627E4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Apr 2023 15:13:41 +0200 (CEST)",
            "by mail-wm1-x32d.google.com with SMTP id\n\t5b1f17b1804b1-3f19c473b9eso119335145e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Apr 2023 06:13:41 -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.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 26 Apr 2023 06:13:40 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1682514823;\n\tbh=VJDTMZvXy2RDrlW/OQ+He8sPOCnLdbc1q2yJgjEFg6M=;\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=jlYDcHGZqEi/s2eKR30tXCyjvN0KZ7ZqRdFBTrSA0Clmt1mRUOJLAMpo6n9Qf/IQc\n\tcZbYu76D878HfUw8xcxAdB+PRmP0tvEaOgDYqnGvc9FgorOkt6hEGRQb0Zz28e1bYB\n\tYEeAN840oPqoAgCad5qKiLVteglJDaKtD4Xqf8QJ4QEXwYszPF55ZldbARMEd8Hpzk\n\tGFf7p50MxxGuaJpoPPNu7zazvS0PrFi2NkcrrYUfzGvVEL8OWMHSGO8mYGmtu8Akce\n\tIhn9qI8IFDEne8Qp/qLhVwvjWteEREBHZMrxOJ8RJdiS29WpkXiVYiW6etVbYKKvdq\n\thGd0WjA9yaMlA==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1682514821; x=1685106821;\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=8Y709+XrzI/xOv/zeokIcnbOBDFL0N1omPB0toIeEHI=;\n\tb=ZJsaksclpaDGWaobX4Dk4VuM6sIcXKY8uKKGiNlBuo738FUgBxpZ5oo5wHUxoKVF0I\n\t00PVm5j7gl5RGRGRQHLCjBxpYUSbY9ZOc5vXXoN15N1n0fdQzbZ4Nvcqu/AU2tI3OrzO\n\t+NdnES0dhl805+cOA0o5gE65Ckrdi9Bvkne8gTTlCek47bJ0l7lN5oL5YxoUHuC3HC85\n\tRt/JXLlBd1fE8XEJBL91VfodwBuN2b0dRUhRPU+RlqKYtYXfbatLxfZM1hJzp/4YXIit\n\tf4EJ9JEqIu//0pfdFq6m2sQPXIoiIM3x4hIO36k9Tpw/z5Y2iO7NQX7+ssdGxCeXtqvo\n\te6Eg=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"ZJsakscl\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1682514821; x=1685106821;\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=8Y709+XrzI/xOv/zeokIcnbOBDFL0N1omPB0toIeEHI=;\n\tb=GF8EULNaMrSLi2IFOkOPGh075Gg5TGN1FXMOO1VyajanVeIQNl4NBtNbKdm/KZd6Zf\n\tBE+h166lypzQQLH2wLutu0etHPX0o0siRFN7mn2JGnvcqsH6wzarx09ntsMyYgO5JA1Z\n\tGllLQdmbxDrCLOIZ/0n9YSSAYVwRFCNDxn9xVZxxwF9MEi2eKWXou1E+iNEAC/tO8iR8\n\tFTa3i4Q4WjUe3QaMBeJJDusGM4ZnUFdV4DUUNA1HhU6xuQ3+1ml2uJwXq9a6MeCwu9q5\n\tNgRppxC9cdBe4cJC67pfmKF3Ee8G+FuAM1oD1d7/43QLF8KNI9C1USLGpgNcPKYZA4Qn\n\tr2Dg==",
        "X-Gm-Message-State": "AC+VfDw2noPIUKz7V4WOO9T7y+X38BI+n+GpHH7BafB/prsDDSx3tBvs\n\tb8E7h/0ttnLdlC36/KimWLobmGOonLNI0JO4GyoQsA==",
        "X-Google-Smtp-Source": "ACHHUZ4mWUhLyG/s39B7so48xQSd4xL/eU3Pw0Gyep9vg9l3Vn3xBSNuTNOnPbWZ5OH4WK4WdPOJaA==",
        "X-Received": "by 2002:a5d:6682:0:b0:304:7927:ec65 with SMTP id\n\tl2-20020a5d6682000000b003047927ec65mr1763588wru.16.1682514820869; \n\tWed, 26 Apr 2023 06:13:40 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 26 Apr 2023 14:10:56 +0100",
        "Message-Id": "<20230426131057.21550-13-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 12/13] pipeline: raspberrypi: Add stream\n\tflags to RPi::Stream",
        "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": "Add a flags_ field to indicate stream state information in RPi::Stream.\nThis replaces the existing external_ and importOnly_ boolean flags.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     |  8 ++--\n .../pipeline/rpi/common/rpi_stream.cpp        | 40 ++++++++++--------\n .../pipeline/rpi/common/rpi_stream.h          | 42 ++++++++++++-------\n src/libcamera/pipeline/rpi/vc4/vc4.cpp        |  8 ++--\n 4 files changed, 60 insertions(+), 38 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 012766b38c32..4d38d511c383 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -31,6 +31,8 @@ using namespace RPi;\n \n LOG_DEFINE_CATEGORY(RPI)\n \n+using Flag = RPi::Stream::StreamFlag;\n+\n namespace {\n \n constexpr unsigned int defaultRawBitDepth = 12;\n@@ -504,7 +506,7 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n \t/* Start by freeing all buffers and reset the stream states. */\n \tdata->freeBuffers();\n \tfor (auto const stream : data->streams_)\n-\t\tstream->setExternal(false);\n+\t\tstream->clearFlags(Flag::External);\n \n \tstd::vector<CameraData::StreamParams> rawStreams, ispStreams;\n \tstd::optional<BayerFormat::Packing> packing;\n@@ -752,7 +754,7 @@ int PipelineHandlerBase::queueRequestDevice(Camera *camera, Request *request)\n \n \t/* Push all buffers supplied in the Request to the respective streams. */\n \tfor (auto stream : data->streams_) {\n-\t\tif (!stream->isExternal())\n+\t\tif (!(stream->getFlags() & Flag::External))\n \t\t\tcontinue;\n \n \t\tFrameBuffer *buffer = request->findBuffer(stream);\n@@ -931,7 +933,7 @@ int PipelineHandlerBase::queueAllBuffers(Camera *camera)\n \tint ret;\n \n \tfor (auto const stream : data->streams_) {\n-\t\tif (!stream->isExternal()) {\n+\t\tif (!(stream->getFlags() & Flag::External)) {\n \t\t\tret = stream->queueAllBuffers();\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\ndiff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\nindex b7e4130f5e56..c158843cb0ed 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp\n@@ -14,6 +14,24 @@ LOG_DEFINE_CATEGORY(RPISTREAM)\n \n namespace RPi {\n \n+void Stream::setFlags(StreamFlags flags)\n+{\n+\tflags_ |= flags;\n+\n+\t/* Import streams cannot be external. */\n+\tASSERT(!(flags_ & StreamFlag::External) || !(flags_ & StreamFlag::ImportOnly));\n+}\n+\n+void Stream::clearFlags(StreamFlags flags)\n+{\n+\tflags_ &= ~flags;\n+}\n+\n+RPi::Stream::StreamFlags Stream::getFlags() const\n+{\n+\treturn flags_;\n+}\n+\n V4L2VideoDevice *Stream::dev() const\n {\n \treturn dev_.get();\n@@ -32,18 +50,6 @@ void Stream::resetBuffers()\n \t\tavailableBuffers_.push(buffer.get());\n }\n \n-void Stream::setExternal(bool external)\n-{\n-\t/* Import streams cannot be external. */\n-\tASSERT(!external || !importOnly_);\n-\texternal_ = external;\n-}\n-\n-bool Stream::isExternal() const\n-{\n-\treturn external_;\n-}\n-\n void Stream::setExportedBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n \tfor (auto const &buffer : *buffers)\n@@ -57,7 +63,7 @@ const BufferMap &Stream::getBuffers() const\n \n unsigned int Stream::getBufferId(FrameBuffer *buffer) const\n {\n-\tif (importOnly_)\n+\tif (flags_ & StreamFlag::ImportOnly)\n \t\treturn 0;\n \n \t/* Find the buffer in the map, and return the buffer id. */\n@@ -88,7 +94,7 @@ int Stream::prepareBuffers(unsigned int count)\n {\n \tint ret;\n \n-\tif (!importOnly_) {\n+\tif (!(flags_ & StreamFlag::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@@ -113,7 +119,7 @@ int Stream::prepareBuffers(unsigned int count)\n \t * \\todo Find a better heuristic, or, even better, an exact solution to\n \t * this issue.\n \t */\n-\tif (isExternal() || importOnly_)\n+\tif ((flags_ & StreamFlag::External) || (flags_ & StreamFlag::ImportOnly))\n \t\tcount = count * 2;\n \n \treturn dev_->importBuffers(count);\n@@ -160,7 +166,7 @@ int Stream::queueBuffer(FrameBuffer *buffer)\n \n void Stream::returnBuffer(FrameBuffer *buffer)\n {\n-\tif (!external_) {\n+\tif (!(flags_ & StreamFlag::External)) {\n \t\t/* For internal buffers, simply requeue back to the device. */\n \t\tqueueToDevice(buffer);\n \t\treturn;\n@@ -204,7 +210,7 @@ int Stream::queueAllBuffers()\n {\n \tint ret;\n \n-\tif (external_)\n+\tif (flags_ & StreamFlag::External)\n \t\treturn 0;\n \n \twhile (!availableBuffers_.empty()) {\ndiff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h\nindex b8c74de35863..6edd304bdfe2 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h\n@@ -12,6 +12,7 @@\n #include <unordered_map>\n #include <vector>\n \n+#include <libcamera/base/flags.h>\n #include <libcamera/stream.h>\n \n #include \"libcamera/internal/v4l2_videodevice.h\"\n@@ -37,25 +38,41 @@ enum BufferMask {\n class Stream : public libcamera::Stream\n {\n public:\n+\tenum class StreamFlag {\n+\t\tNone\t\t= 0,\n+\t\t/*\n+\t\t * Indicates that this stream only imports buffers, e.g. the ISP\n+\t\t * input stream.\n+\t\t */\n+\t\tImportOnly\t= (1 << 0),\n+\t\t/*\n+\t\t * Indicates that this stream is active externally, i.e. the\n+\t\t * buffers might be provided by (and returned to) the application.\n+\t\t */\n+\t\tExternal\t= (1 << 1),\n+\t};\n+\n+\tusing StreamFlags = Flags<StreamFlag>;\n+\n \tStream()\n-\t\t: id_(BufferMask::MaskID)\n+\t\t: flags_(StreamFlag::None), id_(BufferMask::MaskID)\n \t{\n \t}\n \n-\tStream(const char *name, MediaEntity *dev, bool importOnly = false)\n-\t\t: external_(false), importOnly_(importOnly), name_(name),\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{\n \t}\n \n+\tvoid setFlags(StreamFlags flags);\n+\tvoid clearFlags(StreamFlags flags);\n+\tStreamFlags getFlags() const;\n+\n \tV4L2VideoDevice *dev() const;\n \tconst std::string &name() const;\n-\tbool isImporter() const;\n \tvoid resetBuffers();\n \n-\tvoid setExternal(bool external);\n-\tbool isExternal() const;\n-\n \tvoid setExportedBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \tconst BufferMap &getBuffers() const;\n \tunsigned int getBufferId(FrameBuffer *buffer) const;\n@@ -112,14 +129,7 @@ private:\n \tvoid clearBuffers();\n \tint queueToDevice(FrameBuffer *buffer);\n \n-\t/*\n-\t * Indicates that this stream is active externally, i.e. the buffers\n-\t * might be provided by (and returned to) the application.\n-\t */\n-\tbool external_;\n-\n-\t/* Indicates that this stream only imports buffers, e.g. ISP input. */\n-\tbool importOnly_;\n+\tStreamFlags flags_;\n \n \t/* Stream name identifier. */\n \tstd::string name_;\n@@ -182,4 +192,6 @@ public:\n \n } /* namespace RPi */\n \n+LIBCAMERA_FLAGS_ENABLE_OPERATORS(RPi::Stream::StreamFlag)\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex a085a06376a8..bd7bfb3a7663 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -23,6 +23,8 @@ namespace libcamera {\n \n LOG_DECLARE_CATEGORY(RPI)\n \n+using Flag = RPi::Stream::StreamFlag;\n+\n namespace {\n \n enum class Unicam : unsigned int { Image, Embedded };\n@@ -320,7 +322,7 @@ int PipelineHandlerVc4::platformRegister(std::unique_ptr<RPi::CameraData> &camer\n \t}\n \n \t/* Tag the ISP input stream as an import stream. */\n-\tdata->isp_[Isp::Input] = RPi::Stream(\"ISP Input\", ispOutput0, true);\n+\tdata->isp_[Isp::Input] = RPi::Stream(\"ISP Input\", ispOutput0, Flag::ImportOnly);\n \tdata->isp_[Isp::Output0] = RPi::Stream(\"ISP Output0\", ispCapture1);\n \tdata->isp_[Isp::Output1] = RPi::Stream(\"ISP Output1\", ispCapture2);\n \tdata->isp_[Isp::Stats] = RPi::Stream(\"ISP Stats\", ispCapture3);\n@@ -502,7 +504,7 @@ int Vc4CameraData::platformConfigure(const V4L2SubdeviceFormat &sensorFormat,\n \t */\n \tif (!rawStreams.empty()) {\n \t\trawStreams[0].cfg->setStream(&unicam_[Unicam::Image]);\n-\t\tunicam_[Unicam::Image].setExternal(true);\n+\t\tunicam_[Unicam::Image].setFlags(Flag::External);\n \t}\n \n \tret = isp_[Isp::Input].dev()->setFormat(&unicamFormat);\n@@ -547,7 +549,7 @@ int Vc4CameraData::platformConfigure(const V4L2SubdeviceFormat &sensorFormat,\n \t\t\t<< ColorSpace::toString(cfg->colorSpace);\n \n \t\tcfg->setStream(stream);\n-\t\tstream->setExternal(true);\n+\t\tstream->setFlags(Flag::External);\n \t}\n \n \tispOutputTotal_ = outStreams.size();\n",
    "prefixes": [
        "libcamera-devel",
        "12/13"
    ]
}