Show a patch.

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

{
    "id": 19072,
    "url": "https://patchwork.libcamera.org/api/patches/19072/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19072/",
    "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": "<20230921165550.50956-9-jacopo.mondi@ideasonboard.com>",
    "date": "2023-09-21T16:55:45",
    "name": "[libcamera-devel,v5,08/13] libcamera: rpi: Cache rawStreams and outStreams",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "fcdec5fb65d83eccf28ba83513cc49101e599260",
    "submitter": {
        "id": 143,
        "url": "https://patchwork.libcamera.org/api/people/143/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo.mondi@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19072/mbox/",
    "series": [
        {
            "id": 4034,
            "url": "https://patchwork.libcamera.org/api/series/4034/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4034",
            "date": "2023-09-21T16:55:37",
            "name": "libcamera: Introduce SensorConfiguration",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/4034/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19072/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19072/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 8F1C4C32B1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Sep 2023 16:56:12 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0E61D6295D;\n\tThu, 21 Sep 2023 18:56:11 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D04BE628D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Sep 2023 18:56:04 +0200 (CEST)",
            "from uno.lan (93-46-82-201.ip106.fastwebnet.it [93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 479731257;\n\tThu, 21 Sep 2023 18:54:27 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695315371;\n\tbh=B3JHUkJABLI1JS0ycBDxHndMePy5rJNFEtVnPjofGvg=;\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=NWgn/W7IvBpHIFG+9LBwk/kxT5PG1RokG1Iqu0a1opcbKBgLblO8se+FRe1EEWWiJ\n\tnP6JuaJXBvfmQh/5SF9aZ0CBPE98SnM5CVPzxNtG9Bv+3hVNhKM3OawPVvAabXDuTS\n\tVyJqOUoirTiyQkwTOxpEi40Xr0CgwSLIR/BYsgHIkBNcsa78qkXvTPnqlUFwUisS7q\n\t4BayyH31R6ZskgdsRPsb11UIAgwCxDuJLgYFCTART/Dd7eZqo/9QdLGcKKfsFAo6Zr\n\tT2i5yDA2/zV+mOj1sjPaTo09bs3ejTvyCzOs9bRgsL/dNl4ugkJ1R15ODc1yvK1z28\n\t7WN7i3iVXtatg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695315267;\n\tbh=B3JHUkJABLI1JS0ycBDxHndMePy5rJNFEtVnPjofGvg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=XwQYD3k8ooPlizOIDLpnznXbKOsmYXqq9wM0AJ26IvREPYZJy3U9DC+KkT3zLi/hW\n\tvNz267e5swKOd+dTIzyvPuEE9IMY26rR4uLyTlUvSHTe6p6iG/BHrINw3Avpjf31su\n\tXyR3k7rZvlM3YKhKQDVAMBN4mBLci06Y7/4r/Vrk="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"XwQYD3k8\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 21 Sep 2023 18:55:45 +0200",
        "Message-ID": "<20230921165550.50956-9-jacopo.mondi@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.42.0",
        "In-Reply-To": "<20230921165550.50956-1-jacopo.mondi@ideasonboard.com>",
        "References": "<20230921165550.50956-1-jacopo.mondi@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 08/13] libcamera: rpi: Cache rawStreams\n\tand outStreams",
        "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": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.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": "From: Naushir Patuck <naush@raspberrypi.com>\n\nCurrently, the stream configuration is stored in two vectors, rawStreams\nand outStreams for convenience. However, these vectors are constructed\nin both platformValidate() and platformConfigure().\n\nThis change caches these vectors in the RPiCameraConfiguration class to\nconstruct them only once in platformValidate().\n\nPass a pointer to the current configuration to platformValidate() and\nplatformConfigure() so that they can access the streams vectors.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 50 +++++++------------\n .../pipeline/rpi/common/pipeline_base.h       | 42 ++++++++--------\n src/libcamera/pipeline/rpi/vc4/vc4.cpp        | 20 ++++----\n 3 files changed, 48 insertions(+), 64 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex f6f6185cbfef..e36bdce229b6 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -179,19 +179,21 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \tif (transform != requestedTransform)\n \t\tstatus = Adjusted;\n \n-\tstd::vector<CameraData::StreamParams> rawStreams, outStreams;\n+\trawStreams_.clear();\n+\toutStreams_.clear();\n+\n \tfor (const auto &[index, cfg] : utils::enumerate(config_)) {\n \t\tif (PipelineHandlerBase::isRaw(cfg.pixelFormat))\n-\t\t\trawStreams.emplace_back(index, &cfg);\n+\t\t\trawStreams_.emplace_back(index, &cfg);\n \t\telse\n-\t\t\toutStreams.emplace_back(index, &cfg);\n+\t\t\toutStreams_.emplace_back(index, &cfg);\n \t}\n \n \t/* Sort the streams so the highest resolution is first. */\n-\tstd::sort(rawStreams.begin(), rawStreams.end(),\n+\tstd::sort(rawStreams_.begin(), rawStreams_.end(),\n \t\t  [](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });\n \n-\tstd::sort(outStreams.begin(), outStreams.end(),\n+\tstd::sort(outStreams_.begin(), outStreams_.end(),\n \t\t  [](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });\n \n \t/* Compute the sensor's format then do any platform specific fixups. */\n@@ -202,14 +204,14 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t/* Use the application provided sensor configuration. */\n \t\tbitDepth = sensorConfig->bitDepth;\n \t\tsensorSize = sensorConfig->outputSize;\n-\t} else if (!rawStreams.empty()) {\n+\t} else if (!rawStreams_.empty()) {\n \t\t/* Use the RAW stream format and size. */\n-\t\tBayerFormat bayerFormat = BayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);\n+\t\tBayerFormat bayerFormat = BayerFormat::fromPixelFormat(rawStreams_[0].cfg->pixelFormat);\n \t\tbitDepth = bayerFormat.bitDepth;\n-\t\tsensorSize = rawStreams[0].cfg->size;\n+\t\tsensorSize = rawStreams_[0].cfg->size;\n \t} else {\n \t\tbitDepth = defaultRawBitDepth;\n-\t\tsensorSize = outStreams[0].cfg->size;\n+\t\tsensorSize = outStreams_[0].cfg->size;\n \t}\n \n \tsensorFormat_ = data_->findBestFormat(sensorSize, bitDepth);\n@@ -230,12 +232,12 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t}\n \n \t/* Do any platform specific fixups. */\n-\tstatus = data_->platformValidate(this, rawStreams, outStreams);\n+\tstatus = data_->platformValidate(this);\n \tif (status == Invalid)\n \t\treturn Invalid;\n \n \t/* Further fixups on the RAW streams. */\n-\tfor (auto &raw : rawStreams) {\n+\tfor (auto &raw : rawStreams_) {\n \t\tStreamConfiguration &cfg = config_.at(raw.index);\n \n \t\tV4L2DeviceFormat rawFormat;\n@@ -273,7 +275,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t}\n \n \t/* Further fixups on the ISP output streams. */\n-\tfor (auto &out : outStreams) {\n+\tfor (auto &out : outStreams_) {\n \t\tStreamConfiguration &cfg = config_.at(out.index);\n \t\tPixelFormat &cfgPixFmt = cfg.pixelFormat;\n \t\tV4L2VideoDevice::Formats fmts = out.dev->formats();\n@@ -493,24 +495,6 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n \tfor (auto const stream : data->streams_)\n \t\tstream->clearFlags(StreamFlag::External);\n \n-\tstd::vector<CameraData::StreamParams> rawStreams, ispStreams;\n-\n-\tfor (unsigned i = 0; i < config->size(); i++) {\n-\t\tStreamConfiguration *cfg = &config->at(i);\n-\n-\t\tif (isRaw(cfg->pixelFormat))\n-\t\t\trawStreams.emplace_back(i, cfg);\n-\t\telse\n-\t\t\tispStreams.emplace_back(i, cfg);\n-\t}\n-\n-\t/* Sort the streams so the highest resolution is first. */\n-\tstd::sort(rawStreams.begin(), rawStreams.end(),\n-\t\t  [](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });\n-\n-\tstd::sort(ispStreams.begin(), ispStreams.end(),\n-\t\t  [](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });\n-\n \t/*\n \t * Apply the format on the sensor with any cached transform.\n \t *\n@@ -535,9 +519,9 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n \n \t/* Use the user requested packing/bit-depth. */\n \tstd::optional<BayerFormat::Packing> packing;\n-\tif (!rawStreams.empty()) {\n+\tif (!rpiConfig->rawStreams_.empty()) {\n \t\tBayerFormat bayerFormat =\n-\t\t\tBayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);\n+\t\t\tBayerFormat::fromPixelFormat(rpiConfig->rawStreams_[0].cfg->pixelFormat);\n \t\tpacking = bayerFormat.packing;\n \t}\n \n@@ -545,7 +529,7 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)\n \t * Platform specific internal stream configuration. This also assigns\n \t * external streams which get configured below.\n \t */\n-\tret = data->platformConfigure(sensorFormat, packing, rawStreams, ispStreams);\n+\tret = data->platformConfigure(sensorFormat, packing, rpiConfig);\n \tif (ret)\n \t\treturn ret;\n \ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h\nindex 135b74392140..1a3a13dbb6cf 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h\n@@ -57,29 +57,10 @@ public:\n \t{\n \t}\n \n-\tstruct StreamParams {\n-\t\tStreamParams()\n-\t\t\t: index(0), cfg(nullptr), dev(nullptr)\n-\t\t{\n-\t\t}\n-\n-\t\tStreamParams(unsigned int index_, StreamConfiguration *cfg_)\n-\t\t\t: index(index_), cfg(cfg_), dev(nullptr)\n-\t\t{\n-\t\t}\n-\n-\t\tunsigned int index;\n-\t\tStreamConfiguration *cfg;\n-\t\tV4L2VideoDevice *dev;\n-\t};\n-\n-\tvirtual CameraConfiguration::Status platformValidate(RPiCameraConfiguration *rpiConfig,\n-\t\t\t\t\t\t\t     std::vector<StreamParams> &rawStreams,\n-\t\t\t\t\t\t\t     std::vector<StreamParams> &outStreams) const = 0;\n+\tvirtual CameraConfiguration::Status platformValidate(RPiCameraConfiguration *rpiConfig) const = 0;\n \tvirtual int platformConfigure(const V4L2SubdeviceFormat &sensorFormat,\n \t\t\t\t      std::optional<BayerFormat::Packing> packing,\n-\t\t\t\t      std::vector<StreamParams> &rawStreams,\n-\t\t\t\t      std::vector<StreamParams> &outStreams) = 0;\n+\t\t\t\t      const RPiCameraConfiguration *rpiConfig) = 0;\n \tvirtual void platformStart() = 0;\n \tvirtual void platformStop() = 0;\n \n@@ -270,6 +251,25 @@ public:\n \t/* The sensor format computed in validate() */\n \tV4L2SubdeviceFormat sensorFormat_;\n \n+\tstruct StreamParams {\n+\t\tStreamParams()\n+\t\t\t: index(0), cfg(nullptr), dev(nullptr)\n+\t\t{\n+\t\t}\n+\n+\t\tStreamParams(unsigned int index_, StreamConfiguration *cfg_)\n+\t\t\t: index(index_), cfg(cfg_), dev(nullptr)\n+\t\t{\n+\t\t}\n+\n+\t\tunsigned int index;\n+\t\tStreamConfiguration *cfg;\n+\t\tV4L2VideoDevice *dev;\n+\t};\n+\n+\tstd::vector<StreamParams> rawStreams_;\n+\tstd::vector<StreamParams> outStreams_;\n+\n private:\n \tconst CameraData *data_;\n \ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex 2670eb8c4bbc..2308577a613b 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -25,6 +25,7 @@ namespace libcamera {\n LOG_DECLARE_CATEGORY(RPI)\n \n using StreamFlag = RPi::Stream::StreamFlag;\n+using StreamParams = RPi::RPiCameraConfiguration::StreamParams;\n \n namespace {\n \n@@ -65,9 +66,7 @@ public:\n \t{\n \t}\n \n-\tCameraConfiguration::Status platformValidate(RPi::RPiCameraConfiguration *rpiConfig,\n-\t\t\t\t\t\t     std::vector<StreamParams> &rawStreams,\n-\t\t\t\t\t\t     std::vector<StreamParams> &outStreams) const override;\n+\tCameraConfiguration::Status platformValidate(RPi::RPiCameraConfiguration *rpiConfig) const override;\n \n \tint platformPipelineConfigure(const std::unique_ptr<YamlObject> &root) override;\n \n@@ -118,8 +117,7 @@ private:\n \n \tint platformConfigure(const V4L2SubdeviceFormat &sensorFormat,\n \t\t\t      std::optional<BayerFormat::Packing> packing,\n-\t\t\t      std::vector<StreamParams> &rawStreams,\n-\t\t\t      std::vector<StreamParams> &outStreams) override;\n+\t\t\t      const RPi::RPiCameraConfiguration *rpiConfig) override;\n \tint platformConfigureIpa(ipa::RPi::ConfigParams &params) override;\n \n \tint platformInitIpa([[maybe_unused]] ipa::RPi::InitParams &params) override\n@@ -395,10 +393,11 @@ int PipelineHandlerVc4::platformRegister(std::unique_ptr<RPi::CameraData> &camer\n \treturn 0;\n }\n \n-CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfiguration *rpiConfig,\n-\t\t\t\t\t\t\t    std::vector<StreamParams> &rawStreams,\n-\t\t\t\t\t\t\t    std::vector<StreamParams> &outStreams) const\n+CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfiguration *rpiConfig) const\n {\n+\tstd::vector<StreamParams> &rawStreams = rpiConfig->rawStreams_;\n+\tstd::vector<StreamParams> &outStreams = rpiConfig->outStreams_;\n+\n \tCameraConfiguration::Status status = CameraConfiguration::Status::Valid;\n \n \t/* Can only output 1 RAW stream, or 2 YUV/RGB streams. */\n@@ -503,9 +502,10 @@ int Vc4CameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject> &\n \n int Vc4CameraData::platformConfigure(const V4L2SubdeviceFormat &sensorFormat,\n \t\t\t\t     std::optional<BayerFormat::Packing> packing,\n-\t\t\t\t     std::vector<StreamParams> &rawStreams,\n-\t\t\t\t     std::vector<StreamParams> &outStreams)\n+\t\t\t\t     const RPi::RPiCameraConfiguration *rpiConfig)\n {\n+\tconst std::vector<StreamParams> &rawStreams = rpiConfig->rawStreams_;\n+\tconst std::vector<StreamParams> &outStreams = rpiConfig->outStreams_;\n \tint ret;\n \n \tif (!packing)\n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "08/13"
    ]
}