Patch Detail
Show a patch.
GET /api/1.1/patches/11309/?format=api
{ "id": 11309, "url": "https://patchwork.libcamera.org/api/1.1/patches/11309/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11309/", "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": "<20210216103140.1077307-4-naush@raspberrypi.com>", "date": "2021-02-16T10:31:39", "name": "[libcamera-devel,3/4] pipeline: raspberrypi: Only enabled embedded stream when available", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "fdb0f3ce86e31415bbb2b4565d8043db539e3b34", "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/11309/mbox/", "series": [ { "id": 1696, "url": "https://patchwork.libcamera.org/api/1.1/series/1696/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1696", "date": "2021-02-16T10:31:36", "name": "Raspberry Pi: Embedded data usage", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1696/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/11309/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11309/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 0B704BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Feb 2021 10:32:17 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C7408637EA;\n\tTue, 16 Feb 2021 11:32:16 +0100 (CET)", "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 A9302637E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Feb 2021 11:32:13 +0100 (CET)", "by mail-wm1-x32a.google.com with SMTP id v62so4416520wmg.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Feb 2021 02:32:13 -0800 (PST)", "from naush-laptop.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\ta186sm3018054wme.17.2021.02.16.02.32.12\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 16 Feb 2021 02:32:12 -0800 (PST)" ], "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=\"bZbmMYVV\"; 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=X+yw7DYbSrwMABbJpyfIkob1Kdhd5yi2bvfKEpqoZoM=;\n\tb=bZbmMYVVa5c6V9VqVMr2W2Z3twwdaf4y1fIDvEtqvqQ6guk4hSXf94m7DP8amf+xE8\n\tkXou8oolKoJXRlXAU6M67vRKAu7fksWsjxxzvpjcEj5iDzy1W559mE3yZe8Q9n630h1G\n\t42NM1vijoEIAjyNZuYnYv3jggd6rhdbC5ESPY/uteq+xGhNJSP/RbcL+pOpkj/fPAKXh\n\t5dzM0y13cXM0ZabMxb590Xr4wbtMbN2T6M4+6p0bZUKHuxyUQhDIuXkoRUVYjgqOn2CT\n\tiQOV1peWrBpPE79FlfmBJn/XJ510vgBY/bAOmTbFDCWHMbCT4jQvbRjmIvv1sMiV6U3V\n\t/X7g==", "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=X+yw7DYbSrwMABbJpyfIkob1Kdhd5yi2bvfKEpqoZoM=;\n\tb=VWW53gMfA5MQGLU0P54UHCwWqFBOfr15GCl2B+7IhI3edJ33fxhmQo5sx2p5XdkS3i\n\tF6L2Yksgle0Gr9LJobRfdTq62gEOaSdF9k0xMDTPRmqpqI1SPMvl03bSXk/mwr+BG2/e\n\tLPbG3Mn0nRjSPgjVnSDgjPILRD0uWIa/ldPMEKahQm0EnCdA5ZPP7KHORPq9A9sRr5su\n\tSnDTmP2rKCgoAVZQQtHFsav34FVRi0UYG8a9T41OoWt/Ym9LY2pCQfJUU9qk0RHhmXhy\n\tU3WE2YRMvfJ0TlxRQZuVdwkWu7xcp87iLgEwWSnVb1jToP/j3t5uZPfpkGFybM1ljgEZ\n\tPIcw==", "X-Gm-Message-State": "AOAM531v/9lI2a2Bsw1goPgsxXoUwrzZxIE2QG/qsZ7i3CapwcqWJEJQ\n\tHu2K9k//+f6d+e40zRfAZFqAUVhDjOYQAWPE", "X-Google-Smtp-Source": "ABdhPJxJUiNQEK4bKwuds7TRJhcXtsE+2ZJs/bmO3hD4JTpySG5nO4TKHcDSu71Sqay/p5da5y8PMg==", "X-Received": "by 2002:a7b:c8cc:: with SMTP id f12mr1146676wml.1.1613471533059; \n\tTue, 16 Feb 2021 02:32:13 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 16 Feb 2021 10:31:39 +0000", "Message-Id": "<20210216103140.1077307-4-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20210216103140.1077307-1-naush@raspberrypi.com>", "References": "<20210216103140.1077307-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 3/4] pipeline: raspberrypi: Only enabled\n\tembedded stream when available", "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": "The pipeline handler would enable and use the Unicam embedded data stream\neven if the sensor did not support it. This was to allow a means to\npass exposure and gain values for the frame to the IPA in a synchronised\nway.\n\nThe recent changes to get the pipeline handler to pass a ControlList\nwith exposure and gain values means this is no longer required. Disable\nthe use of the embedded data stream when a sensor does not support it.\n\nThis change also removes the mappedEmbeddedBuffers_ map as it is no\nlonger used.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp | 109 +++++++++++-------\n 1 file changed, 68 insertions(+), 41 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 7e744ce13172..b6ee014b620e 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -168,12 +168,6 @@ public:\n \t/* Stores the ids of the buffers mapped in the IPA. */\n \tstd::unordered_set<unsigned int> ipaBuffers_;\n \n-\t/*\n-\t * Map of (internal) mmaped embedded data buffers, to avoid having to\n-\t * map/unmap on every frame.\n-\t */\n-\tstd::map<unsigned int, MappedFrameBuffer> mappedEmbeddedBuffers_;\n-\n \t/* DMAHEAP allocation helper. */\n \tRPi::DmaHeap dmaHeap_;\n \tFileDescriptor lsTable_;\n@@ -627,14 +621,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \n \t\tif (isRaw(cfg.pixelFormat)) {\n \t\t\tcfg.setStream(&data->unicam_[Unicam::Image]);\n-\t\t\t/*\n-\t\t\t * We must set both Unicam streams as external, even\n-\t\t\t * though the application may only request RAW frames.\n-\t\t\t * This is because we match timestamps on both streams\n-\t\t\t * to synchronise buffers.\n-\t\t\t */\n \t\t\tdata->unicam_[Unicam::Image].setExternal(true);\n-\t\t\tdata->unicam_[Unicam::Embedded].setExternal(true);\n \t\t\tcontinue;\n \t\t}\n \n@@ -706,17 +693,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t\treturn ret;\n \t}\n \n-\t/* Unicam embedded data output format. */\n-\tformat = {};\n-\tformat.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA);\n-\tLOG(RPI, Debug) << \"Setting embedded data format.\";\n-\tret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format);\n-\tif (ret) {\n-\t\tLOG(RPI, Error) << \"Failed to set format on Unicam embedded: \"\n-\t\t\t\t<< format.toString();\n-\t\treturn ret;\n-\t}\n-\n \t/* Figure out the smallest selection the ISP will allow. */\n \tRectangle testCrop(0, 0, 1, 1);\n \tdata->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &testCrop);\n@@ -733,6 +709,41 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \tif (ret)\n \t\tLOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n \n+\t/*\n+\t * The IPA will set data->sensorMetadata_ to true if embedded data is\n+\t * supported on this sensor. If so, open the Unicam embedded data\n+\t * node and configure the output format.\n+\t */\n+\tif (data->sensorMetadata_) {\n+\t\tformat = {};\n+\t\tformat.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA);\n+\t\tLOG(RPI, Debug) << \"Setting embedded data format.\";\n+\t\tdata->unicam_[Unicam::Embedded].dev()->open();\n+\t\tret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format);\n+\t\tif (ret) {\n+\t\t\tLOG(RPI, Error) << \"Failed to set format on Unicam embedded: \"\n+\t\t\t\t\t<< format.toString();\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\t/*\n+\t\t * If a RAW/Bayer stream has been requested by the application,\n+\t\t * we must set both Unicam streams as external, even though the\n+\t\t * application may only request RAW frames. This is because we\n+\t\t * match timestamps on both streams to synchronise buffers.\n+\t\t */\n+\t\tif (rawStream)\n+\t\t\tdata->unicam_[Unicam::Embedded].setExternal(true);\n+\t} else {\n+\t\t/*\n+\t\t * No embedded data present, so we do not want to iterate over\n+\t\t * the embedded data stream when starting and stopping.\n+\t\t */\n+\t\tdata->streams_.erase(std::remove(data->streams_.begin(), data->streams_.end(),\n+\t\t\t\t\t\t &data->unicam_[Unicam::Embedded]),\n+\t\t\t\t data->streams_.end());\n+\t}\n+\n \t/*\n \t * Update the ScalerCropMaximum to the correct value for this camera mode.\n \t * For us, it's the same as the \"analogue crop\".\n@@ -950,10 +961,16 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \tfor (auto &stream : data->isp_)\n \t\tdata->streams_.push_back(&stream);\n \n-\t/* Open all Unicam and ISP streams. */\n+\t/*\n+\t * Open all Unicam and ISP streams. The exception is the embedded data\n+\t * stream, which only gets opened if the IPA reports that the sensor\n+\t * supports embedded data. This happens in RPiCameraData::configureIPA().\n+\t */\n \tfor (auto const stream : data->streams_) {\n-\t\tif (stream->dev()->open())\n-\t\t\treturn false;\n+\t\tif (stream != &data->unicam_[Unicam::Embedded]) {\n+\t\t\tif (stream->dev()->open())\n+\t\t\t\treturn false;\n+\t\t}\n \t}\n \n \t/* Wire up all the buffer connections. */\n@@ -1110,19 +1127,13 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\treturn ret;\n \t}\n \n-\tif (!data->sensorMetadata_) {\n-\t\tfor (auto const &it : data->unicam_[Unicam::Embedded].getBuffers()) {\n-\t\t\tMappedFrameBuffer fb(it.second, PROT_READ | PROT_WRITE);\n-\t\t\tdata->mappedEmbeddedBuffers_.emplace(it.first, std::move(fb));\n-\t\t}\n-\t}\n-\n \t/*\n \t * Pass the stats and embedded data buffers to the IPA. No other\n \t * buffers need to be passed.\n \t */\n \tmapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), RPi::BufferMask::STATS);\n-\tmapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), RPi::BufferMask::EMBEDDED_DATA);\n+\tif (data->sensorMetadata_)\n+\t\tmapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), RPi::BufferMask::EMBEDDED_DATA);\n \n \treturn 0;\n }\n@@ -1155,7 +1166,6 @@ void PipelineHandlerRPi::freeBuffers(Camera *camera)\n \tstd::vector<unsigned int> ipaBuffers(data->ipaBuffers_.begin(), data->ipaBuffers_.end());\n \tdata->ipa_->unmapBuffers(ipaBuffers);\n \tdata->ipaBuffers_.clear();\n-\tdata->mappedEmbeddedBuffers_.clear();\n \n \tfor (auto const stream : data->streams_)\n \t\tstream->releaseBuffers();\n@@ -1659,7 +1669,7 @@ void RPiCameraData::tryRunPipeline()\n \n \t/* If any of our request or buffer queues are empty, we cannot proceed. */\n \tif (state_ != State::Idle || requestQueue_.empty() ||\n-\t bayerQueue_.empty() || embeddedQueue_.empty())\n+\t bayerQueue_.empty() || (embeddedQueue_.empty() && sensorMetadata_))\n \t\treturn;\n \n \tif (!findMatchingBuffers(bayerFrame, embeddedBuffer))\n@@ -1684,17 +1694,23 @@ void RPiCameraData::tryRunPipeline()\n \tstate_ = State::Busy;\n \n \tunsigned int bayerId = unicam_[Unicam::Image].getBufferId(bayerFrame.buffer);\n-\tunsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer);\n \n \tLOG(RPI, Debug) << \"Signalling RPi::IPA_EVENT_SIGNAL_ISP_PREPARE:\"\n-\t\t\t<< \" Bayer buffer id: \" << bayerId\n-\t\t\t<< \" Embedded buffer id: \" << embeddedId;\n+\t\t\t<< \" Bayer buffer id: \" << bayerId;\n \n+\top = {};\n \top.operation = RPi::IPA_EVENT_SIGNAL_ISP_PREPARE;\n \top.data.push_back(RPi::BufferMask::BAYER_DATA | bayerId);\n-\top.data.push_back(RPi::BufferMask::EMBEDDED_DATA | embeddedId);\n \top.controls.emplace_back(std::move(bayerFrame.controls));\n \n+\tif (embeddedBuffer) {\n+\t\tunsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer);\n+\n+\t\top.data.push_back(RPi::BufferMask::EMBEDDED_DATA | embeddedId);\n+\t\tLOG(RPI, Debug) << \"Signalling RPi::IPA_EVENT_SIGNAL_ISP_PREPARE:\"\n+\t\t\t\t<< \" Embedded buffer id: \" << embeddedId;\n+\t}\n+\n \tipa_->processEvent(op);\n }\n \n@@ -1736,6 +1752,17 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em\n \n \t\t\tLOG(RPI, Debug) << \"Could not find matching embedded buffer\";\n \n+\t\t\tif (!sensorMetadata_) {\n+\t\t\t\t/*\n+\t\t\t\t * If there is no sensor metadata, simply return the\n+\t\t\t\t * first bayer frame in the queue.\n+\t\t\t\t */\n+\t\t\t\tLOG(RPI, Debug) << \"Returning bayer frame without a match\";\n+\t\t\t\tbayerQueue_.pop();\n+\t\t\t\tembeddedBuffer = nullptr;\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n \t\t\tif (!embeddedQueue_.empty()) {\n \t\t\t\t/*\n \t\t\t\t * Not found a matching embedded buffer for the bayer buffer in\n", "prefixes": [ "libcamera-devel", "3/4" ] }