Show a patch.

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

{
    "id": 15268,
    "url": "https://patchwork.libcamera.org/api/patches/15268/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15268/",
    "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": "<20220110165524.72978-4-jacopo@jmondi.org>",
    "date": "2022-01-10T16:55:22",
    "name": "[libcamera-devel,3/5] android: camera_device: Post-pone mapped streams handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "364cc23977d3c91baeca404250fe8eb9508b67aa",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/15268/mbox/",
    "series": [
        {
            "id": 2887,
            "url": "https://patchwork.libcamera.org/api/series/2887/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2887",
            "date": "2022-01-10T16:55:19",
            "name": "android: Plumb the YUV processor in",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2887/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15268/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15268/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 5FC4FC325A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Jan 2022 16:54:36 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B43B2604F8;\n\tMon, 10 Jan 2022 17:54:35 +0100 (CET)",
            "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C573A604F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jan 2022 17:54:31 +0100 (CET)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 96E93240005;\n\tMon, 10 Jan 2022 16:54:30 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 10 Jan 2022 17:55:22 +0100",
        "Message-Id": "<20220110165524.72978-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220110165524.72978-1-jacopo@jmondi.org>",
        "References": "<20220110165524.72978-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 3/5] android: camera_device: Post-pone\n\tmapped streams handling",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Mapped streams are generated by post-processing and always require a\nsource buffer from where to process image data from.\n\nIn case a Mapped stream is requested but its source stream is not, it\nis required to allocate a buffer on the fly and add it to the\nlibcamera::Request.\n\nMake sure a source stream is available for all mapped streams, and if\nthat's not the case, add a dedicated buffer to the request for that\npurpose.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 81 +++++++++++++++++++++++++++++++----\n 1 file changed, 73 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 005d95b51a0c..a44f199d25d8 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -9,6 +9,7 @@\n \n #include <algorithm>\n #include <fstream>\n+#include <set>\n #include <sys/mman.h>\n #include <unistd.h>\n #include <vector>\n@@ -924,6 +925,32 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \tLOG(HAL, Debug) << \"Queueing request \" << descriptor->request_->cookie()\n \t\t\t<< \" with \" << descriptor->buffers_.size() << \" streams\";\n \n+\t/*\n+\t * Collect the CameraStream associated to each requested capture stream.\n+\t * Being requestedStreams an std::set<> no duplications can happen.\n+\t */\n+\tstd::set<CameraStream *> requestedStreams;\n+\tfor (const auto &[i, buffer] : utils::enumerate(descriptor->buffers_)) {\n+\t\tCameraStream *cameraStream = buffer.stream;\n+\n+\t\tswitch (cameraStream->type()) {\n+\t\tcase CameraStream::Type::Mapped:\n+\t\t\trequestedStreams.insert(cameraStream->sourceStream());\n+\t\t\tbreak;\n+\n+\t\tcase CameraStream::Type::Direct:\n+\t\tcase CameraStream::Type::Internal:\n+\t\t\trequestedStreams.insert(cameraStream);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\t/*\n+\t * Process all the Direct and Internal streams, for which the CameraStream\n+\t * they refer to is the one that points to the right libcamera::Stream.\n+\t *\n+\t * Streams of type Mapped will be handled later.\n+\t */\n \tfor (const auto &[i, buffer] : utils::enumerate(descriptor->buffers_)) {\n \t\tCameraStream *cameraStream = buffer.stream;\n \t\tcamera3_stream_t *camera3Stream = cameraStream->camera3Stream();\n@@ -946,14 +973,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \n \t\tswitch (cameraStream->type()) {\n \t\tcase CameraStream::Type::Mapped:\n-\t\t\t/*\n-\t\t\t * Mapped streams don't need buffers added to the\n-\t\t\t * Request.\n-\t\t\t */\n-\t\t\tLOG(HAL, Debug) << ss.str() << \" (mapped)\";\n-\n-\t\t\tdescriptor->pendingStreamsToProcess_.insert(\n-\t\t\t\t{ cameraStream, &buffer });\n \t\t\tcontinue;\n \n \t\tcase CameraStream::Type::Direct:\n@@ -997,6 +1016,52 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \t\tauto fence = std::make_unique<Fence>(std::move(acquireFence));\n \t\tdescriptor->request_->addBuffer(cameraStream->stream(),\n \t\t\t\t\t\tframeBuffer, std::move(fence));\n+\n+\t\trequestedStreams.erase(cameraStream);\n+\t}\n+\n+\t/*\n+\t * Now handle the mapped streams. If no buffer has been addded for them\n+\t * as their corresponding direct source stream has not been requested,\n+\t * add it here.\n+\t */\n+\tfor (const auto &[i, buffer] : utils::enumerate(descriptor->buffers_)) {\n+\t\tCameraStream *cameraStream = buffer.stream;\n+\t\tcamera3_stream_t *camera3Stream = cameraStream->camera3Stream();\n+\t\tCameraStream *sourceStream = cameraStream->sourceStream();\n+\t\tFrameBuffer *frameBuffer = nullptr;\n+\n+\t\tif (cameraStream->type() != CameraStream::Type::Mapped)\n+\t\t\tcontinue;\n+\n+\t\tLOG(HAL, Debug) << i << \" - (\" << camera3Stream->width << \"x\"\n+\t\t\t\t<< camera3Stream->height << \")\"\n+\t\t\t\t<< \"[\" << utils::hex(camera3Stream->format) << \"] -> \"\n+\t\t\t\t<< \"(\" << cameraStream->configuration().size.toString() << \")[\"\n+\t\t\t\t<< cameraStream->configuration().pixelFormat.toString() << \"]\"\n+\t\t\t\t<< \" (mapped)\";\n+\n+\t\tMutexLocker lock(descriptor->streamsProcessMutex_);\n+\t\tdescriptor->pendingStreamsToProcess_.insert({ cameraStream, &buffer });\n+\n+\t\t/*\n+\t\t * Make sure the CameraStream this stream is mapped on has been\n+\t\t * added to the request.\n+\t\t */\n+\t\tif (requestedStreams.find(sourceStream) == requestedStreams.end())\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * If that's not the case, we need to add a buffer to the request\n+\t\t * for this stream.\n+\t\t */\n+\t\tframeBuffer = cameraStream->getBuffer();\n+\t\tbuffer.internalBuffer = frameBuffer;\n+\n+\t\tdescriptor->request_->addBuffer(sourceStream->stream(),\n+\t\t\t\t\t\tframeBuffer, nullptr);\n+\n+\t\trequestedStreams.erase(sourceStream);\n \t}\n \n \t/*\n",
    "prefixes": [
        "libcamera-devel",
        "3/5"
    ]
}