Show a patch.

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

{
    "id": 13280,
    "url": "https://patchwork.libcamera.org/api/patches/13280/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13280/",
    "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": "<tencent_C8182AD9B900945115E9D6DCB7A0012DAD05@qq.com>",
    "date": "2021-08-10T12:17:39",
    "name": "[libcamera-devel,RFC,v2,1/4] pipeline: isp: The software ISP-based pipeline handler",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "2b4cedbe0cebd5fea7955996f074facc3f698d55",
    "submitter": {
        "id": 88,
        "url": "https://patchwork.libcamera.org/api/people/88/?format=api",
        "name": "Siyuan Fan",
        "email": "siyuan.fan@foxmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13280/mbox/",
    "series": [
        {
            "id": 2332,
            "url": "https://patchwork.libcamera.org/api/series/2332/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2332",
            "date": "2021-08-10T12:17:39",
            "name": "[libcamera-devel,RFC,v2,1/4] pipeline: isp: The software ISP-based pipeline handler",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2332/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13280/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13280/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 98C7CBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Aug 2021 12:17:56 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D225168822;\n\tTue, 10 Aug 2021 14:17:55 +0200 (CEST)",
            "from out162-62-57-210.mail.qq.com (out162-62-57-210.mail.qq.com\n\t[162.62.57.210])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 803BA687F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Aug 2021 14:17:51 +0200 (CEST)",
            "from localhost.localdomain ([123.126.82.8])\n\tby newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP\n\tid 46D0AC53; Tue, 10 Aug 2021 20:17:45 +0800"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=foxmail.com header.i=@foxmail.com\n\theader.b=\"gZGZlkGD\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com;\n\ts=s201512; t=1628597868;\n\tbh=mXMXe7CWiDVhtsmqftTQA/LJdcJ3kEt425pMngds3h0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=gZGZlkGDQkPYgDLzYhfqvkMNl+P96xxbUNB5awNS4pvs+w2Ru4pgjo3b+zTLM7WgP\n\tSDnAopS8Z/EKJkL5QjBX+az0Frr/L118KDNMWgWQQcC5vbc4+M6cqLmI3WCeZgif7g\n\tNWjGlWDkKVF9gJ6B7Auidf8mkdos9CneA43wKLyw=",
        "X-QQ-mid": "xmsmtpt1628597866tal6d1nll",
        "Message-ID": "<tencent_C8182AD9B900945115E9D6DCB7A0012DAD05@qq.com>",
        "X-QQ-XMAILINFO": "NCwFnk+fWy3TPq0AMWOCu+Z+f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"From": "Siyuan Fan <siyuan.fan@foxmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 10 Aug 2021 13:17:39 +0100",
        "X-OQ-MSGID": "<20210810121742.11012-2-siyuan.fan@foxmail.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20210810121742.11012-1-siyuan.fan@foxmail.com>",
        "References": "<20210810121742.11012-1-siyuan.fan@foxmail.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC PATCH v2 1/4] pipeline: isp: The software\n\tISP-based pipeline handler",
        "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": "From: Fan Siyuan <siyuan.fan@foxmail.com>\n\n Changes in V2:\n -fix the raw and rgb data flow based queue model in pipeline handler\n -move buffer alloc and thread to ISP class\n -Fill metadata information in dstBuffer\n\nSigned-off-by: Fan Siyuan <siyuan.fan@foxmail.com>\n---\n src/libcamera/pipeline/isp/isp.cpp | 81 ++++++++++++------------------\n 1 file changed, 32 insertions(+), 49 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/isp/isp.cpp b/src/libcamera/pipeline/isp/isp.cpp\nindex e5fbd536..c6b7808c 100644\n--- a/src/libcamera/pipeline/isp/isp.cpp\n+++ b/src/libcamera/pipeline/isp/isp.cpp\n@@ -5,9 +5,10 @@\n  * isp.cpp - The software ISP-based pipeline handler\n  */\n \n-#include \"isp_processing.h\"\n+#include \"../../swisp/isp.h\"\n \n #include <math.h>\n+#include <queue>\n #include <stdlib.h>\n #include <sys/mman.h>\n #include <unistd.h>\n@@ -17,7 +18,6 @@\n #include <libcamera/controls.h>\n #include <libcamera/formats.h>\n \n-#include \"libcamera/base/thread.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n@@ -38,7 +38,6 @@ public:\n        ~ISPCameraData()\n        {\n                delete video_;\n-               delete rawBuffers;\n        }\n \n        int init();\n@@ -46,16 +45,16 @@ public:\n        void ISPCompleted(FrameBuffer *buffer);\n \n        Stream stream_;\n-       ISP isp_;\n-       Thread threadISP_;\n-       int width;\n-       int height;\n+       CPU_ISP isp_;\n+       int width_;\n+       int height_;\n+\n+       std::vector<std::unique_ptr<FrameBuffer>> rawBuffers_;\n+       std::vector<FrameBuffer *> rawQueueBuffers_;\n+       std::vector<FrameBuffer *> rgbQueueBuffers_;\n \n        MediaDevice *media_;\n        V4L2VideoDevice *video_;\n-       std::vector<std::unique_ptr<FrameBuffer>> *tempCopyExportBuffers;\n-       std::vector<std::unique_ptr<FrameBuffer>> *rawBuffers;\n-       std::map<FrameBuffer *, FrameBuffer *>  bufferPair;\n };\n \n \n@@ -158,8 +157,8 @@ int PipelineHandlerISP::configure(Camera *camera, CameraConfiguration *config)\n        format.fourcc = v4l2Format;\n        format.size = cfg.size;\n \n-       data->width = format.size.width;\n-       data->height = format.size.height;\n+       data->width_ = format.size.width;\n+       data->height_ = format.size.height;\n \n        int ret = data->video_->setFormat(&format);\n        if (ret)\n@@ -176,30 +175,8 @@ int PipelineHandlerISP::exportFrameBuffers(Camera *camera, Stream *stream,\n {\n        unsigned int count = stream->configuration().bufferCount;\n        ISPCameraData *data = cameraData(camera);\n-       \n-       for (unsigned int i = 0; i < count; i++) {\n-              std::string name = \"frame-\" + std::to_string(i);\n-              const int isp_fd = memfd_create(name.c_str(), 0);\n-              int ret = ftruncate(isp_fd, data->width * data->height * 3);\n-              if (ret < 0) {\n-                     LOG(ISP, Error)\n-                            << \"truncate: \"\n-                            << strerror(-ret);\n-                     return ret;\n-              }\n-              FileDescriptor temp = FileDescriptor(std::move(isp_fd));\n-\n-              FrameBuffer::Plane rgbPlane;\n-              rgbPlane.fd = std::move(temp);\n-              rgbPlane.length = data->width * data->height * 3;\n-\n-              std::vector<FrameBuffer::Plane> planes;\n-              planes.push_back(std::move(rgbPlane));\n-              std::unique_ptr<FrameBuffer> buffer = std::make_unique<FrameBuffer>(std::move(planes));\n-              buffers->push_back(std::move(buffer));\n-       }\n \n-       data->tempCopyExportBuffers = buffers;\n+       count = data->isp_.exportBuffers(buffers, count, data->width_, data->height_);\n \n        return count;       \n \n@@ -210,15 +187,16 @@ int PipelineHandlerISP::start(Camera *camera, [[maybe_unused]] const ControlList\n        ISPCameraData *data = cameraData(camera);\n        unsigned int count = data->stream_.configuration().bufferCount;\n \n-       data->rawBuffers = new std::vector<std::unique_ptr<FrameBuffer>>;\n-       int ret = data->video_->allocateBuffers(count, data->rawBuffers);\n+       int ret = data->video_->allocateBuffers(count, &data->rawBuffers_);\n        if (ret < 0) {\n               LOG(ISP, Error) << strerror(-ret);\n               return ret;\n        }\n \n-       for (unsigned int i = 0; i < count; i++)\n-              data->bufferPair[data->tempCopyExportBuffers->at(i).get()] = data->rawBuffers->at(i).get();\n+       for (unsigned int i = 0; i < count; i++) {\n+              data->rawQueueBuffers_.push_back(data->rawBuffers_[i].get());\n+       }\n+       \n \n        ret = data->video_->streamOn();\n        if (ret < 0) {\n@@ -226,7 +204,7 @@ int PipelineHandlerISP::start(Camera *camera, [[maybe_unused]] const ControlList\n                return ret;\n        }\n \n-       data->threadISP_.start();\n+       data->isp_.startThreadISP();\n \n        return 0;\n }\n@@ -235,8 +213,11 @@ void PipelineHandlerISP::stop(Camera *camera)\n {\n        ISPCameraData *data = cameraData(camera);\n \n-       data->threadISP_.exit();\n-       data->threadISP_.wait();\n+       if (!(data->rawBuffers_.empty())) {\n+              data->rawBuffers_.clear();\n+       }\n+\n+       data->isp_.stopThreadISP();\n \n        data->video_->streamOff();\n        data->video_->releaseBuffers();\n@@ -246,15 +227,19 @@ int PipelineHandlerISP::queueRequestDevice(Camera *camera, Request *request)\n {\n        ISPCameraData *data = cameraData(camera);\n        FrameBuffer *rgbBuffer = request->findBuffer(&data->stream_);\n+       data->rgbQueueBuffers_.push_back(rgbBuffer);\n        \n        if (!rgbBuffer) {\n                LOG(ISP, Error) << \"Attempt to queue request with invalid stream\";\n                return -ENOENT;\n        }\n \n-       int ret = data->video_->queueBuffer(data->bufferPair[rgbBuffer]);\n+       int ret = data->video_->queueBuffer(data->rawQueueBuffers_[0]);\n        if (ret < 0)\n                return ret;\n+       FrameBuffer *temp = data->rawQueueBuffers_[0];\n+       data->rawQueueBuffers_.erase(data->rawQueueBuffers_.begin());\n+       data->rawQueueBuffers_.push_back(std::move(temp));\n \n        return 0;\n }\n@@ -297,10 +282,10 @@ void ISPCameraData::ISPCompleted(FrameBuffer *buffer)\n \n void ISPCameraData::bufferReady(FrameBuffer *buffer)\n {\n-       for (std::map<FrameBuffer*, FrameBuffer*>::iterator it = bufferPair.begin(); it != bufferPair.end(); it++) {\n-              if (it->second == buffer)\n-                     isp_.invokeMethod(&ISP::processing, ConnectionTypeQueued, buffer, it->first, width, height);\n-       }\n+       LOG(ISP, Debug) << rgbQueueBuffers_[0]->planes()[0].fd.fd();\n+       isp_.invokeMethod(&CPU_ISP::processing, ConnectionTypeQueued, buffer, rgbQueueBuffers_[0], width_, height_);\n+       rgbQueueBuffers_.erase(rgbQueueBuffers_.begin());\n+       rgbQueueBuffers_.shrink_to_fit();\n        \n }\n \n@@ -311,8 +296,6 @@ int ISPCameraData::init()\n                return -ENODEV;\n \n        video_->bufferReady.connect(this, &ISPCameraData::bufferReady);\n-\n-       isp_.moveToThread(&threadISP_);\n        isp_.ispCompleted.connect(this, &ISPCameraData::ISPCompleted);\n \n        return 0;\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "v2",
        "1/4"
    ]
}