Show a patch.

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

{
    "id": 9850,
    "url": "https://patchwork.libcamera.org/api/patches/9850/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9850/",
    "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": "<20200929014334.49719-6-niklas.soderlund@ragnatech.se>",
    "date": "2020-09-29T01:43:32",
    "name": "[libcamera-devel,v4,5/7] libcamera: pipeline: rkisp1: Move start and stop of path to RkISP1Path",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "65c7751db76f857c40787eba559f4c627f9402da",
    "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/9850/mbox/",
    "series": [
        {
            "id": 1333,
            "url": "https://patchwork.libcamera.org/api/series/1333/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1333",
            "date": "2020-09-29T01:43:27",
            "name": "libcamera: pipeline: rkisp1: Create RkISP1Path helper",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/1333/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9850/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9850/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 8696AC3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Sep 2020 01:43:56 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 30F276215B;\n\tTue, 29 Sep 2020 03:43:56 +0200 (CEST)",
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B491D6213B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Sep 2020 03:43:54 +0200 (CEST)",
            "from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de\n\t[84.172.82.168]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 3962f9f0-01f5-11eb-b295-0050569116f7;\n\tTue, 29 Sep 2020 03:43:50 +0200 (CEST)"
        ],
        "X-Halon-ID": "3962f9f0-01f5-11eb-b295-0050569116f7",
        "Authorized-sender": "niklas.soderlund@fsdn.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 29 Sep 2020 03:43:32 +0200",
        "Message-Id": "<20200929014334.49719-6-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.28.0",
        "In-Reply-To": "<20200929014334.49719-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200929014334.49719-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v4 5/7] libcamera: pipeline: rkisp1: Move\n\tstart and stop of path to RkISP1Path",
        "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": "Move the start and stop of a path to RkISP1Path. This allows the\nimporting of buffers to be moved closer the path start/stop simplifying\nthe code. Also by adding a simple running tracker the error logic in\nPipelineHandlerRkISP1 can be simplified as stop() can always be called.\n\nThis also removes all external users of RkISP1Path::video_ so it can be\nmade private.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n* Changes since v3\n- Add missing space in Error message.\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 53 ++-----------------\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 42 ++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1_path.h   |  8 +--\n 3 files changed, 50 insertions(+), 53 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 7823fd91866a473a..2eaf7b491d13397b 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -765,20 +765,6 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n \t\tdata->selfPathStream_.configuration().bufferCount,\n \t});\n \n-\tif (data->mainPathActive_) {\n-\t\tret = mainPath_.video_->importBuffers(\n-\t\t\tdata->mainPathStream_.configuration().bufferCount);\n-\t\tif (ret < 0)\n-\t\t\tgoto error;\n-\t}\n-\n-\tif (data->selfPathActive_) {\n-\t\tret = selfPath_.video_->importBuffers(\n-\t\t\tdata->selfPathStream_.configuration().bufferCount);\n-\t\tif (ret < 0)\n-\t\t\tgoto error;\n-\t}\n-\n \tret = param_->allocateBuffers(maxCount, &paramBuffers_);\n \tif (ret < 0)\n \t\tgoto error;\n@@ -808,8 +794,6 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n error:\n \tparamBuffers_.clear();\n \tstatBuffers_.clear();\n-\tmainPath_.video_->releaseBuffers();\n-\tselfPath_.video_->releaseBuffers();\n \n \treturn ret;\n }\n@@ -840,12 +824,6 @@ int PipelineHandlerRkISP1::freeBuffers(Camera *camera)\n \tif (stat_->releaseBuffers())\n \t\tLOG(RkISP1, Error) << \"Failed to release stat buffers\";\n \n-\tif (mainPath_.video_->releaseBuffers())\n-\t\tLOG(RkISP1, Error) << \"Failed to release main path buffers\";\n-\n-\tif (selfPath_.video_->releaseBuffers())\n-\t\tLOG(RkISP1, Error) << \"Failed to release self path buffers\";\n-\n \treturn 0;\n }\n \n@@ -891,15 +869,12 @@ int PipelineHandlerRkISP1::start(Camera *camera)\n \tstd::map<unsigned int, IPAStream> streamConfig;\n \n \tif (data->mainPathActive_) {\n-\t\tret = mainPath_.video_->streamOn();\n+\t\tret = mainPath_.start();\n \t\tif (ret) {\n \t\t\tparam_->streamOff();\n \t\t\tstat_->streamOff();\n \t\t\tdata->ipa_->stop();\n \t\t\tfreeBuffers(camera);\n-\n-\t\t\tLOG(RkISP1, Error)\n-\t\t\t\t<< \"Failed to start main path \" << camera->id();\n \t\t\treturn ret;\n \t\t}\n \n@@ -910,18 +885,13 @@ int PipelineHandlerRkISP1::start(Camera *camera)\n \t}\n \n \tif (data->selfPathActive_) {\n-\t\tret = selfPath_.video_->streamOn();\n+\t\tret = selfPath_.start();\n \t\tif (ret) {\n-\t\t\tif (data->mainPathActive_)\n-\t\t\t\tmainPath_.video_->streamOff();\n-\n+\t\t\tmainPath_.stop();\n \t\t\tparam_->streamOff();\n \t\t\tstat_->streamOff();\n \t\t\tdata->ipa_->stop();\n \t\t\tfreeBuffers(camera);\n-\n-\t\t\tLOG(RkISP1, Error)\n-\t\t\t\t<< \"Failed to start self path \" << camera->id();\n \t\t\treturn ret;\n \t\t}\n \n@@ -958,21 +928,8 @@ void PipelineHandlerRkISP1::stop(Camera *camera)\n \tRkISP1CameraData *data = cameraData(camera);\n \tint ret;\n \n-\tif (data->selfPathActive_) {\n-\t\tret = selfPath_.video_->streamOff();\n-\t\tif (ret)\n-\t\t\tLOG(RkISP1, Warning)\n-\t\t\t\t<< \"Failed to stop self path for \"\n-\t\t\t\t<< camera->id();\n-\t}\n-\n-\tif (data->mainPathActive_) {\n-\t\tret = mainPath_.video_->streamOff();\n-\t\tif (ret)\n-\t\t\tLOG(RkISP1, Warning)\n-\t\t\t\t<< \"Failed to stop main path for \"\n-\t\t\t\t<< camera->id();\n-\t}\n+\tselfPath_.stop();\n+\tmainPath_.stop();\n \n \tret = stat_->streamOff();\n \tif (ret)\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex 96c18b352472a417..9f1706c78f41465b 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -20,9 +20,9 @@ LOG_DECLARE_CATEGORY(RkISP1)\n \n RkISP1Path::RkISP1Path(const char *name, const Span<const PixelFormat> &formats,\n \t\t       const Size &minResolution, const Size &maxResolution)\n-\t: video_(nullptr), name_(name), formats_(formats),\n+\t: name_(name), running_(false), formats_(formats),\n \t  minResolution_(minResolution), maxResolution_(maxResolution),\n-\t  resizer_(nullptr)\n+\t  resizer_(nullptr), video_(nullptr)\n {\n }\n \n@@ -149,6 +149,44 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n \treturn 0;\n }\n \n+int RkISP1Path::start()\n+{\n+\tint ret;\n+\n+\tif (running_)\n+\t\treturn -EBUSY;\n+\n+\tret = video_->importBuffers(RKISP1_BUFFER_COUNT);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = video_->streamOn();\n+\tif (ret) {\n+\t\tLOG(RkISP1, Error)\n+\t\t\t<< \"Failed to start \" << name_ << \" path\";\n+\n+\t\tvideo_->releaseBuffers();\n+\t\treturn ret;\n+\t}\n+\n+\trunning_ = true;\n+\n+\treturn 0;\n+}\n+\n+void RkISP1Path::stop()\n+{\n+\tif (!running_)\n+\t\treturn;\n+\n+\tif (video_->streamOff())\n+\t\tLOG(RkISP1, Warning) << \"Failed to stop \" << name_ << \" path\";\n+\n+\tvideo_->releaseBuffers();\n+\n+\trunning_ = false;\n+}\n+\n namespace {\n constexpr Size RKISP1_RSZ_MP_SRC_MIN{ 32, 16 };\n constexpr Size RKISP1_RSZ_MP_SRC_MAX{ 4416, 3312 };\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\nindex 377772ca73877702..e2eb1be9a445ba41 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n@@ -45,22 +45,24 @@ public:\n \t\treturn video_->exportBuffers(bufferCount, buffers);\n \t}\n \n+\tint start();\n+\tvoid stop();\n+\n \tint queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }\n \tSignal<FrameBuffer *> &bufferReady() { return video_->bufferReady; }\n \n-\t/* \\todo Make video private. */\n-\tV4L2VideoDevice *video_;\n-\n private:\n \tstatic constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n \n \tconst char *name_;\n+\tbool running_;\n \n \tconst Span<const PixelFormat> formats_;\n \tconst Size minResolution_;\n \tconst Size maxResolution_;\n \n \tV4L2Subdevice *resizer_;\n+\tV4L2VideoDevice *video_;\n };\n \n class RkISP1MainPath : public RkISP1Path\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "5/7"
    ]
}