Show a patch.

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

{
    "id": 8658,
    "url": "https://patchwork.libcamera.org/api/patches/8658/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8658/",
    "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": "<20200706153808.2340919-8-kieran.bingham@ideasonboard.com>",
    "date": "2020-07-06T15:38:07",
    "name": "[libcamera-devel,v4,7/8] android: camera_device: Add buffers for each stream to Requests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c7798cd30da31f0e3933356665e46e156579f613",
    "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/8658/mbox/",
    "series": [
        {
            "id": 1088,
            "url": "https://patchwork.libcamera.org/api/series/1088/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1088",
            "date": "2020-07-06T15:38:00",
            "name": "android: Multi-stream support",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/1088/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8658/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8658/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 3B47ABD794\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jul 2020 15:38:20 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B57F60E2B;\n\tMon,  6 Jul 2020 17:38:20 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A9A4603AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jul 2020 17:38:15 +0200 (CEST)",
            "from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net\n\t[86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F3287D6E;\n\tMon,  6 Jul 2020 17:38:14 +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=\"SBHo2bJ0\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594049895;\n\tbh=SFmhJM4PiStO69y+rjFhH2oJ7DSqd9i/3GUHXjVI1lA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SBHo2bJ0jc3ZqYbLWP+fln3MPJS4sEvvHF2ljyc3UhcZYx0sIWdqbfHVyFA5OraEn\n\tf/YNDYsw9WedaxAVE04M+s8vqtP73Zdt474HnRfksH+BijWdtKhbzvF/3BU6EtWm/w\n\tupNJt5/dpBl5U+bdpQvSHR8sRu7eYbKQOyLqsbgA=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Mon,  6 Jul 2020 16:38:07 +0100",
        "Message-Id": "<20200706153808.2340919-8-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200706153808.2340919-1-kieran.bingham@ideasonboard.com>",
        "References": "<20200706153808.2340919-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v4 7/8] android: camera_device: Add\n\tbuffers for each stream to Requests",
        "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=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Construct a FrameBuffer for every buffer given in the camera3Request\nand add it to the libcamera Request on the appropriate stream.\n\nThe correct stream is obtained from the private data of the camera3_stream\nassociated with the camera3_buffer.\n\nComments regarding supporting only one buffer are now removed.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 54 +++++++++++++++++++----------------\n src/android/camera_device.h   |  1 +\n 2 files changed, 31 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex b86973959177..f368726091f4 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -98,6 +98,7 @@ CameraDevice::Camera3RequestDescriptor::Camera3RequestDescriptor(\n \t: frameNumber(frameNumber), numBuffers(numBuffers)\n {\n \tbuffers = new camera3_stream_buffer_t[numBuffers];\n+\tframeBuffers.reserve(numBuffers);\n }\n \n CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()\n@@ -990,6 +991,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\tconfig_->addConfiguration(streamConfiguration);\n \n \t\tstreams_[i].index = streamIndex++;\n+\t\tstream->priv = static_cast<void *>(&streams_[i]);\n \t}\n \n \tswitch (config_->validate()) {\n@@ -1048,9 +1050,6 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n \n int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)\n {\n-\tStreamConfiguration *streamConfiguration = &config_->at(0);\n-\tStream *stream = streamConfiguration->stream();\n-\n \tif (camera3Request->num_output_buffers != 1) {\n \t\tLOG(HAL, Error) << \"Invalid number of output buffers: \"\n \t\t\t\t<< camera3Request->num_output_buffers;\n@@ -1090,29 +1089,34 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \tdescriptor->request = std::unique_ptr<Request>(request);\n \n \tfor (unsigned int i = 0; i < descriptor->numBuffers; ++i) {\n+\t\tCameraStream *cameraStream = static_cast<CameraStream *>(camera3Buffers[i].stream->priv);\n+\n \t\t/*\n \t\t * Keep track of which stream the request belongs to and store\n \t\t * the native buffer handles.\n-\t\t *\n-\t\t * \\todo Currently we only support one capture buffer. Copy\n-\t\t * all of them to be ready once we'll support more.\n \t\t */\n \t\tdescriptor->buffers[i].stream = camera3Buffers[i].stream;\n \t\tdescriptor->buffers[i].buffer = camera3Buffers[i].buffer;\n-\t}\n \n-\t/*\n-\t * Create a libcamera buffer using the dmabuf descriptors of the first\n-\t * and (currently) only supported request buffer.\n-\t */\n-\tFrameBuffer *buffer = createFrameBuffer(*camera3Buffers[0].buffer);\n-\tif (!buffer) {\n-\t\tLOG(HAL, Error) << \"Failed to create buffer\";\n-\t\tdelete descriptor;\n-\t\treturn -ENOMEM;\n-\t}\n+\t\t/*\n+\t\t * Create a libcamera buffer using the dmabuf descriptors of the\n+\t\t * first and (currently) only supported request buffer.\n+\t\t * The FrameBuffer is directly associated with the\n+\t\t * Camera3RequestDescriptor for lifetime management only.\n+\t\t */\n+\t\tFrameBuffer *buffer = createFrameBuffer(*camera3Buffers[i].buffer);\n+\t\tif (!buffer) {\n+\t\t\tLOG(HAL, Error) << \"Failed to create buffer\";\n+\t\t\tdelete descriptor;\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\t\tdescriptor->frameBuffers.emplace_back(buffer);\n \n-\trequest->addBuffer(stream, buffer);\n+\t\tStreamConfiguration *streamConfiguration = &config_->at(cameraStream->index);\n+\t\tStream *stream = streamConfiguration->stream();\n+\n+\t\trequest->addBuffer(stream, buffer);\n+\t}\n \n \tint ret = camera_->queueRequest(request);\n \tif (ret) {\n@@ -1127,7 +1131,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n void CameraDevice::requestComplete(Request *request)\n {\n \tconst std::map<Stream *, FrameBuffer *> &buffers = request->buffers();\n-\tFrameBuffer *buffer = buffers.begin()->second;\n \tcamera3_buffer_status status = CAMERA3_BUFFER_STATUS_OK;\n \tstd::unique_ptr<CameraMetadata> resultMetadata;\n \n@@ -1145,10 +1148,6 @@ void CameraDevice::requestComplete(Request *request)\n \tcaptureResult.frame_number = descriptor->frameNumber;\n \tcaptureResult.num_output_buffers = descriptor->numBuffers;\n \tfor (unsigned int i = 0; i < descriptor->numBuffers; ++i) {\n-\t\t/*\n-\t\t * \\todo Currently we only support one capture buffer. Prepare\n-\t\t * all of them to be ready once we'll support more.\n-\t\t */\n \t\tdescriptor->buffers[i].acquire_fence = -1;\n \t\tdescriptor->buffers[i].release_fence = -1;\n \t\tdescriptor->buffers[i].status = status;\n@@ -1156,6 +1155,14 @@ void CameraDevice::requestComplete(Request *request)\n \tcaptureResult.output_buffers =\n \t\tconst_cast<const camera3_stream_buffer_t *>(descriptor->buffers);\n \n+\t/*\n+\t * \\todo The timestamp used for the metadata is currently always taken\n+\t * from the first buffer (which may be the first stream) in the Request.\n+\t * It might be appropriate to return a 'correct' (as determined by\n+\t * pipeline handlers) timestamp in the Request itself.\n+\t */\n+\tFrameBuffer *buffer = buffers.begin()->second;\n+\n \tif (status == CAMERA3_BUFFER_STATUS_OK) {\n \t\tnotifyShutter(descriptor->frameNumber,\n \t\t\t      buffer->metadata().timestamp);\n@@ -1180,7 +1187,6 @@ void CameraDevice::requestComplete(Request *request)\n \tcallbacks_->process_capture_result(callbacks_, &captureResult);\n \n \tdelete descriptor;\n-\tdelete buffer;\n }\n \n std::string CameraDevice::logPrefix() const\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex f23d1b328472..aa828b97d8f0 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -71,6 +71,7 @@ private:\n \t\tuint32_t numBuffers;\n \t\tcamera3_stream_buffer_t *buffers;\n \t\tstd::unique_ptr<libcamera::Request> request;\n+\t\tstd::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers;\n \t};\n \n \tstruct Camera3StreamConfiguration {\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "7/8"
    ]
}