Show a patch.

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

{
    "id": 9817,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/9817/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9817/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200925014207.1455796-20-niklas.soderlund@ragnatech.se>",
    "date": "2020-09-25T01:42:04",
    "name": "[libcamera-devel,v3,19/22] libcamera: pipeline: rkisp1: Move start and stop of path to RkISP1Path",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "1ca6a6877c2e9fb970837bfceaf230ae47838b22",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9817/mbox/",
    "series": [
        {
            "id": 1325,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1325/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1325",
            "date": "2020-09-25T01:41:45",
            "name": "libcamera: pipeline: rkisp1: Extend to support two streams",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1325/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9817/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9817/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 A140DC3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Sep 2020 01:43:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 60F186304E;\n\tFri, 25 Sep 2020 03:43:01 +0200 (CEST)",
            "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7667F6301F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Sep 2020 03:42:56 +0200 (CEST)",
            "from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de\n\t[84.172.82.168]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 6e866392-fed0-11ea-92dc-005056917a89;\n\tFri, 25 Sep 2020 03:42:55 +0200 (CEST)"
        ],
        "X-Halon-ID": "6e866392-fed0-11ea-92dc-005056917a89",
        "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": "Fri, 25 Sep 2020 03:42:04 +0200",
        "Message-Id": "<20200925014207.1455796-20-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.28.0",
        "In-Reply-To": "<20200925014207.1455796-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200925014207.1455796-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 19/22] libcamera: pipeline: rkisp1:\n\tMove start 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 src/libcamera/pipeline/rkisp1/rkisp1.cpp     | 53 ++------------------\n src/libcamera/pipeline/rkisp1/rkisp1path.cpp | 42 +++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1path.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 7dd4fb11c39dd811..6158fbee41339c32 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -770,20 +770,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@@ -813,8 +799,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@@ -845,12 +829,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@@ -896,15 +874,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@@ -915,18 +890,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@@ -963,21 +933,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/rkisp1path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1path.cpp\nindex 74eaa5d32388184b..b2dd669f4caf3269 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1path.cpp\n@@ -20,9 +20,9 @@ LOG_DECLARE_CATEGORY(RkISP1)\n \n RkISP1Path::RkISP1Path(const char *name, const std::vector<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@@ -155,6 +155,44 @@ int RkISP1Path::exportBuffers(unsigned int bufferCount,\n \treturn video_->exportBuffers(bufferCount, buffers);\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 RkISP1MainPath::RkISP1MainPath()\n \t: RkISP1Path(\"main\",\n \t\t     {\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1path.h b/src/libcamera/pipeline/rkisp1/rkisp1path.h\nindex 1315b2c64feac681..9c2ecb620375683b 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1path.h\n@@ -41,22 +41,24 @@ public:\n \tint exportBuffers(unsigned int bufferCount,\n \t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\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 std::vector<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",
        "v3",
        "19/22"
    ]
}