Show a patch.

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

{
    "id": 8915,
    "url": "https://patchwork.libcamera.org/api/patches/8915/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8915/",
    "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": "<20200721220126.202065-7-kieran.bingham@ideasonboard.com>",
    "date": "2020-07-21T22:01:26",
    "name": "[libcamera-devel,RFC,6/6] android: camera_device: Provide a MappedCamera3Buffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": false,
    "hash": "be3ada67b7f697148dd81d28c4772202dcd0bc43",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/8915/mbox/",
    "series": [
        {
            "id": 1125,
            "url": "https://patchwork.libcamera.org/api/series/1125/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1125",
            "date": "2020-07-21T22:01:20",
            "name": "android: jpeg / software streams",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1125/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8915/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8915/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 1CC23C2E68\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Jul 2020 22:01:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E20D160998;\n\tWed, 22 Jul 2020 00:01:38 +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 61D7760987\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 00:01:33 +0200 (CEST)",
            "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E4D521414;\n\tWed, 22 Jul 2020 00:01:32 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nzOYwopN\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595368893;\n\tbh=eW+PNbRr/LnRbFeT+LVAIiVoD7/UNRFIwYJMGKGYfKY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=nzOYwopN2QoeKr64kP1TE/94KLP+NRxscTBKY75s/Axqvf59m6ntKwEVr0iuzHlly\n\tE1u+s1zYrMMlpL2lEFPF2650SKzQ5TuUyvshxTOJEZ8tBT+8JlXEGVohVegGfH9RD7\n\t/sw6TNueF/so/pF9t+RYTMjzi7dtsp6DUTY/M9O8=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Tue, 21 Jul 2020 23:01:26 +0100",
        "Message-Id": "<20200721220126.202065-7-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200721220126.202065-1-kieran.bingham@ideasonboard.com>",
        "References": "<20200721220126.202065-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [RFC PATCH 6/6] android: camera_device: Provide a\n\tMappedCamera3Buffer",
        "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": "Utilise the MappedBuffer interface to map each of the planes provided\nin the Camera3 buffer to facilitate use in software streams.\n\nThe buffers will be automatically unmapped when the object goes out of\nscope or is deleted.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nThis shows how the MappedCamera3Buffer which was posted as part of the\nMappedBuffer series can get used.\n\nOriginally my aim was to pass a MappedBuffer in place of creating a\nCompressedImage object, but passing in a MappedBuffer alone restricts\npassing back how many bytes were consumed, and I expect other meta-data\nmight be needed, so I anticipate needing more than just a function\nreturn value soon.\n\n(i.e. so I don't yet think I can just return the compressed image size\nin the return value, but maybe it might end up being possible/cleaner to\ndo that...)\n\n src/android/camera_device.cpp | 35 +++++++----------------------------\n 1 file changed, 7 insertions(+), 28 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 23dde1cfaf98..34c60556e5fa 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1281,30 +1281,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \treturn 0;\n }\n \n-static CompressedImage mapAndroidBlobBuffer(const buffer_handle_t camera3buffer)\n-{\n-\tCompressedImage img;\n-\n-\t/* ANDROID_JPEG_MAX_SIZE */\n-\tunsigned int length = int32_t{13 << 20};\n-\n-\t/* Take only the first plane */\n-\tvoid *memory = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_SHARED,\n-\t\t\t    camera3buffer->data[0], 0);\n-\n-\timg.length = length;\n-\timg.data = static_cast<unsigned char*>(memory);\n-\n-\treturn img;\n-}\n-\n-static void unmapAndroidBlobBuffer(CompressedImage *img)\n-{\n-\tmunmap(img->data, img->length);\n-\timg->data = nullptr;\n-\timg->length = 0;\n-}\n-\n void CameraDevice::requestComplete(Request *request)\n {\n \tconst std::map<Stream *, FrameBuffer *> &buffers = request->buffers();\n@@ -1341,19 +1317,22 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tCompressedImage output = mapAndroidBlobBuffer(*descriptor->buffers[i].buffer);\n-\t\tif (output.data == MAP_FAILED) {\n-\t\t\tLOG(HAL, Error) << \"Failed to mmap android blob buffer of length \" << output.length;\n+\t\tMappedCamera3Buffer mapped(*descriptor->buffers[i].buffer, PROT_READ|PROT_WRITE);\n+\t\tif (!mapped.isValid()) {\n+\t\t\tLOG(HAL, Error) << \"Failed to mmap android blob buffer\";\n \t\t\tcontinue;\n \t\t}\n \n+\t\tCompressedImage output;\n+\t\toutput.data = static_cast<unsigned char *>(mapped.maps()[0].address);\n+\t\toutput.length = mapped.maps()[0].length;\n+\n \t\tint ret = compressor->compress(buffer, &output);\n \t\tif (ret) {\n \t\t\tLOG(HAL, Error) << \"Failed to compress stream image\";\n \t\t\tstatus = CAMERA3_BUFFER_STATUS_ERROR;\n \t\t}\n \n-\t\tunmapAndroidBlobBuffer(&output);\n \t}\n \n \t/* Prepare to call back the Android camera stack. */\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "6/6"
    ]
}