Show a patch.

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

{
    "id": 2467,
    "url": "https://patchwork.libcamera.org/api/patches/2467/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2467/",
    "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": "<20191230120510.938333-18-niklas.soderlund@ragnatech.se>",
    "date": "2019-12-30T12:05:02",
    "name": "[libcamera-devel,v2,17/25] libcamera: pipeline: ipu3: Switch to FrameBuffer interface for cio2 and stat",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "7d1b1bc2362ba432f7dcf4a4fa2546d3d6600044",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2467/mbox/",
    "series": [
        {
            "id": 593,
            "url": "https://patchwork.libcamera.org/api/series/593/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=593",
            "date": "2019-12-30T12:04:45",
            "name": "libcamera: Rework buffer API",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/593/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2467/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2467/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C23F56046B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Dec 2019 13:06:04 +0100 (CET)",
            "from bismarck.berto.se (p4fca2fd0.dip0.t-ipconnect.de\n\t[79.202.47.208]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid c060cc51-2afc-11ea-a00b-005056917a89;\n\tMon, 30 Dec 2019 13:06:03 +0100 (CET)"
        ],
        "X-Halon-ID": "c060cc51-2afc-11ea-a00b-005056917a89",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 30 Dec 2019 13:05:02 +0100",
        "Message-Id": "<20191230120510.938333-18-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20191230120510.938333-1-niklas.soderlund@ragnatech.se>",
        "References": "<20191230120510.938333-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 17/25] libcamera: pipeline: ipu3:\n\tSwitch to FrameBuffer interface for cio2 and stat",
        "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>",
        "X-List-Received-Date": "Mon, 30 Dec 2019 12:06:05 -0000"
    },
    "content": "The V4L2VideoDevice class can now operate using a FrameBuffer interface,\nswitch the IPU3 CIO2 and statistic buffer to use it. We can not yet\nconvert the application facing buffers yet.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 103 ++++++++++++---------------\n 1 file changed, 44 insertions(+), 59 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 34fc792977d151be..030ba2b6a0df2e0b 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -45,6 +45,7 @@ public:\n \t\tunsigned int pad;\n \t\tstd::string name;\n \t\tBufferPool *pool;\n+\t\tstd::vector<std::unique_ptr<FrameBuffer>> buffers;\n \t};\n \n \tImgUDevice()\n@@ -70,7 +71,6 @@ public:\n \tint configureOutput(ImgUOutput *output,\n \t\t\t    const StreamConfiguration &cfg);\n \n-\tint importInputBuffers(BufferPool *pool);\n \tint importOutputBuffers(ImgUOutput *output, BufferPool *pool);\n \tint exportOutputBuffers(ImgUOutput *output, BufferPool *pool);\n \tvoid freeBuffers();\n@@ -95,7 +95,6 @@ public:\n \t/* \\todo Add param video device for 3A tuning */\n \n \tBufferPool vfPool_;\n-\tBufferPool statPool_;\n \tBufferPool outPool_;\n };\n \n@@ -120,10 +119,10 @@ public:\n \tint configure(const Size &size,\n \t\t      V4L2DeviceFormat *outputFormat);\n \n-\tBufferPool *exportBuffers();\n+\tint allocateBuffers();\n \tvoid freeBuffers();\n \n-\tint start(std::vector<std::unique_ptr<Buffer>> *buffers);\n+\tint start();\n \tint stop();\n \n \tstatic int mediaBusToFormat(unsigned int code);\n@@ -132,7 +131,8 @@ public:\n \tV4L2Subdevice *csi2_;\n \tCameraSensor *sensor_;\n \n-\tBufferPool pool_;\n+private:\n+\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n };\n \n class IPU3Stream : public Stream\n@@ -157,16 +157,14 @@ public:\n \t}\n \n \tvoid imguOutputBufferReady(Buffer *buffer);\n-\tvoid imguInputBufferReady(Buffer *buffer);\n-\tvoid cio2BufferReady(Buffer *buffer);\n+\tvoid imguInputBufferReady(FrameBuffer *buffer);\n+\tvoid cio2BufferReady(FrameBuffer *buffer);\n \n \tCIO2Device cio2_;\n \tImgUDevice *imgu_;\n \n \tIPU3Stream outStream_;\n \tIPU3Stream vfStream_;\n-\n-\tstd::vector<std::unique_ptr<Buffer>> rawBuffers_;\n };\n \n class IPU3CameraConfiguration : public CameraConfiguration\n@@ -638,24 +636,28 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tint ret;\n \n \t/* Share buffers between CIO2 output and ImgU input. */\n-\tBufferPool *pool = cio2->exportBuffers();\n-\tif (!pool)\n-\t\treturn -ENOMEM;\n+\tret = cio2->allocateBuffers();\n+\tif (ret < 0)\n+\t\treturn ret;\n \n-\tret = imgu->importInputBuffers(pool);\n-\tif (ret)\n+\tbufferCount = ret;\n+\n+\tret = imgu->input_->importBuffers(bufferCount);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to import ImgU input buffers\";\n \t\tgoto error;\n+\t}\n \n \t/*\n \t * Use for the stat's internal pool the same number of buffer as\n \t * for the input pool.\n \t * \\todo To be revised when we'll actually use the stat node.\n \t */\n-\tbufferCount = pool->count();\n-\timgu->stat_.pool->createBuffers(bufferCount);\n-\tret = imgu->exportOutputBuffers(&imgu->stat_, imgu->stat_.pool);\n-\tif (ret)\n+\tret = imgu->stat_.dev->exportBuffers(bufferCount, &imgu->stat_.buffers);\n+\tif (ret < 0) {\n+\t\tLOG(IPU3, Error) << \"Failed to allocate ImgU stat buffers\";\n \t\tgoto error;\n+\t}\n \n \t/* Allocate buffers for each active stream. */\n \tfor (Stream *s : streams) {\n@@ -722,7 +724,7 @@ int PipelineHandlerIPU3::start(Camera *camera)\n \t * Start the ImgU video devices, buffers will be queued to the\n \t * ImgU output and viewfinder when requests will be queued.\n \t */\n-\tret = cio2->start(&data->rawBuffers_);\n+\tret = cio2->start();\n \tif (ret)\n \t\tgoto error;\n \n@@ -738,7 +740,6 @@ int PipelineHandlerIPU3::start(Camera *camera)\n error:\n \tLOG(IPU3, Error) << \"Failed to start camera \" << camera->name();\n \n-\tdata->rawBuffers_.clear();\n \treturn ret;\n }\n \n@@ -752,8 +753,6 @@ void PipelineHandlerIPU3::stop(Camera *camera)\n \tif (ret)\n \t\tLOG(IPU3, Warning) << \"Failed to stop camera \"\n \t\t\t\t   << camera->name();\n-\n-\tdata->rawBuffers_.clear();\n }\n \n int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)\n@@ -885,9 +884,9 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t * associated ImgU input where they get processed and\n \t\t * returned through the ImgU main and secondary outputs.\n \t\t */\n-\t\tdata->cio2_.output_->bufferReady.connect(data.get(),\n+\t\tdata->cio2_.output_->frameBufferReady.connect(data.get(),\n \t\t\t\t\t&IPU3CameraData::cio2BufferReady);\n-\t\tdata->imgu_->input_->bufferReady.connect(data.get(),\n+\t\tdata->imgu_->input_->frameBufferReady.connect(data.get(),\n \t\t\t\t\t&IPU3CameraData::imguInputBufferReady);\n \t\tdata->imgu_->output_.dev->bufferReady.connect(data.get(),\n \t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n@@ -925,7 +924,7 @@ int PipelineHandlerIPU3::registerCameras()\n  * Buffers completed from the ImgU input are immediately queued back to the\n  * CIO2 unit to continue frame capture.\n  */\n-void IPU3CameraData::imguInputBufferReady(Buffer *buffer)\n+void IPU3CameraData::imguInputBufferReady(FrameBuffer *buffer)\n {\n \t/* \\todo Handle buffer failures when state is set to BufferError. */\n \tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n@@ -959,7 +958,7 @@ void IPU3CameraData::imguOutputBufferReady(Buffer *buffer)\n  * Buffers completed from the CIO2 are immediately queued to the ImgU unit\n  * for further processing.\n  */\n-void IPU3CameraData::cio2BufferReady(Buffer *buffer)\n+void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer)\n {\n \t/* \\todo Handle buffer failures when state is set to BufferError. */\n \tif (buffer->metadata().status == FrameMetadata::FrameCancelled)\n@@ -1034,7 +1033,6 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)\n \n \tstat_.pad = PAD_STAT;\n \tstat_.name = \"stat\";\n-\tstat_.pool = &statPool_;\n \n \treturn 0;\n }\n@@ -1134,22 +1132,6 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n \treturn 0;\n }\n \n-/**\n- * \\brief Import buffers from \\a pool into the ImgU input\n- * \\param[in] pool The buffer pool to import\n- * \\return 0 on success or a negative error code otherwise\n- */\n-int ImgUDevice::importInputBuffers(BufferPool *pool)\n-{\n-\tint ret = input_->importBuffers(pool);\n-\tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to import ImgU input buffers\";\n-\t\treturn ret;\n-\t}\n-\n-\treturn 0;\n-}\n-\n /**\n  * \\brief Export buffers from \\a output to the provided \\a pool\n  * \\param[in] output The ImgU output device\n@@ -1448,37 +1430,40 @@ int CIO2Device::configure(const Size &size,\n }\n \n /**\n- * \\brief Allocate CIO2 memory buffers and export them in a BufferPool\n+ * \\brief Allocate frame buffers for the CIO2 output\n  *\n- * Allocate memory buffers in the CIO2 video device and export them to\n- * a buffer pool that can be imported by another device.\n+ * Allocate frame buffers in the CIO2 video device to be used to capture frames\n+ * from the CIO2 output. The buffers are stored in the CIO2Device::buffers_\n+ * vector.\n  *\n- * \\return The buffer pool with export buffers on success or nullptr otherwise\n+ * \\return Number of buffers allocated or negative error code\n  */\n-BufferPool *CIO2Device::exportBuffers()\n+int CIO2Device::allocateBuffers()\n {\n-\tpool_.createBuffers(CIO2_BUFFER_COUNT);\n-\n-\tint ret = output_->exportBuffers(&pool_);\n-\tif (ret) {\n+\tint ret = output_->exportBuffers(CIO2_BUFFER_COUNT, &buffers_);\n+\tif (ret < 0)\n \t\tLOG(IPU3, Error) << \"Failed to export CIO2 buffers\";\n-\t\treturn nullptr;\n-\t}\n \n-\treturn &pool_;\n+\treturn ret;\n }\n \n void CIO2Device::freeBuffers()\n {\n+\tbuffers_.clear();\n+\n \tif (output_->releaseBuffers())\n \t\tLOG(IPU3, Error) << \"Failed to release CIO2 buffers\";\n }\n \n-int CIO2Device::start(std::vector<std::unique_ptr<Buffer>> *buffers)\n+int CIO2Device::start()\n {\n-\t*buffers = output_->queueAllBuffers();\n-\tif (buffers->empty())\n-\t\treturn -EINVAL;\n+\tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers_) {\n+\t\tint ret = output_->queueBuffer(buffer.get());\n+\t\tif (ret) {\n+\t\t\tLOG(IPU3, Error) << \"Failed to queue CIO2 buffer\";\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n \n \treturn output_->streamOn();\n }\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "17/25"
    ]
}