Show a patch.

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

{
    "id": 9809,
    "url": "https://patchwork.libcamera.org/api/patches/9809/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9809/",
    "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": "<20200925014207.1455796-12-niklas.soderlund@ragnatech.se>",
    "date": "2020-09-25T01:41:56",
    "name": "[libcamera-devel,v3,11/22] libcamera: pipeline: rkisp1: Configure self path",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f2cfebfcac1fe5ef53fd67bfcde70981f24bc44f",
    "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/9809/mbox/",
    "series": [
        {
            "id": 1325,
            "url": "https://patchwork.libcamera.org/api/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/9809/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9809/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 E5158C3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Sep 2020 01:42:53 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A04BD6301D;\n\tFri, 25 Sep 2020 03:42:53 +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 0FBE060576\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Sep 2020 03:42:50 +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 6a9799cf-fed0-11ea-92dc-005056917a89;\n\tFri, 25 Sep 2020 03:42:48 +0200 (CEST)"
        ],
        "X-Halon-ID": "6a9799cf-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:41:56 +0200",
        "Message-Id": "<20200925014207.1455796-12-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 11/22] libcamera: pipeline: rkisp1:\n\tConfigure self path",
        "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": "Allow for both the main and self path streams to be configured. This\nchange adds the self path as an internal stream to the pipeline handler.\nIt is not exposed as a Camera stream so it can not yet be used.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n* Changes since v2\n- Print which resizer is configured\n- Use if ...; else if; ... instead of if ...; if ...; in\n  exportFrameBuffers()\n- Configure main and self streams with separate numbers of buffers while\n  still allocating the max of the two for stats and params.\n- Improve Warning logs in stop()`\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 227 ++++++++++++++++-------\n 1 file changed, 161 insertions(+), 66 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex fef4fa813190056e..28e99129498e4a0a 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -135,7 +135,8 @@ public:\n \t\t\t V4L2VideoDevice *selfPathVideo)\n \t\t: CameraData(pipe), sensor_(nullptr), frame_(0),\n \t\t  frameInfo_(pipe), mainPathVideo_(mainPathVideo),\n-\t\t  selfPathVideo_(selfPathVideo)\n+\t\t  selfPathVideo_(selfPathVideo), mainPathActive_(false),\n+\t\t  selfPathActive_(false)\n \t{\n \t}\n \n@@ -147,6 +148,7 @@ public:\n \tint loadIPA();\n \n \tStream mainPathStream_;\n+\tStream selfPathStream_;\n \tCameraSensor *sensor_;\n \tunsigned int frame_;\n \tstd::vector<IPABuffer> ipaBuffers_;\n@@ -156,6 +158,9 @@ public:\n \tV4L2VideoDevice *mainPathVideo_;\n \tV4L2VideoDevice *selfPathVideo_;\n \n+\tbool mainPathActive_;\n+\tbool selfPathActive_;\n+\n private:\n \tvoid queueFrameAction(unsigned int frame,\n \t\t\t      const IPAOperationData &action);\n@@ -612,7 +617,6 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \tRkISP1CameraConfiguration *config =\n \t\tstatic_cast<RkISP1CameraConfiguration *>(c);\n \tRkISP1CameraData *data = cameraData(camera);\n-\tStreamConfiguration &cfg = config->at(0);\n \tCameraSensor *sensor = data->sensor_;\n \tint ret;\n \n@@ -654,37 +658,63 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \n \tLOG(RkISP1, Debug) << \"ISP output pad configured with \" << format.toString();\n \n-\tret = mainPathResizer_->setFormat(0, &format);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tLOG(RkISP1, Debug) << \"Resizer input pad configured with \" << format.toString();\n-\n-\tformat.size = cfg.size;\n-\n-\tLOG(RkISP1, Debug) << \"Configuring resizer output pad with \" << format.toString();\n-\n-\tret = mainPathResizer_->setFormat(1, &format);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tLOG(RkISP1, Debug) << \"Resizer output pad configured with \" << format.toString();\n-\n-\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n-\tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.fourcc = mainPathVideo_->toV4L2PixelFormat(cfg.pixelFormat);\n-\toutputFormat.size = cfg.size;\n-\toutputFormat.planesCount = info.numPlanes();\n-\n-\tret = mainPathVideo_->setFormat(&outputFormat);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tif (outputFormat.size != cfg.size ||\n-\t    outputFormat.fourcc != mainPathVideo_->toV4L2PixelFormat(cfg.pixelFormat)) {\n-\t\tLOG(RkISP1, Error)\n-\t\t\t<< \"Unable to configure capture in \" << cfg.toString();\n-\t\treturn -EINVAL;\n+\tdata->mainPathActive_ = false;\n+\tdata->selfPathActive_ = false;\n+\tfor (const StreamConfiguration &cfg : *config) {\n+\t\tV4L2SubdeviceFormat ispFormat = format;\n+\t\tV4L2Subdevice *resizer;\n+\t\tV4L2VideoDevice *video;\n+\n+\t\tif (cfg.stream() == &data->mainPathStream_) {\n+\t\t\tresizer = mainPathResizer_;\n+\t\t\tvideo = mainPathVideo_;\n+\t\t\tdata->mainPathActive_ = true;\n+\t\t} else {\n+\t\t\tresizer = selfPathResizer_;\n+\t\t\tvideo = selfPathVideo_;\n+\t\t\tdata->selfPathActive_ = true;\n+\t\t}\n+\n+\t\tret = resizer->setFormat(0, &ispFormat);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\n+\t\tconst char *name = resizer == mainPathResizer_ ? \"main\" : \"self\";\n+\n+\t\tLOG(RkISP1, Debug)\n+\t\t\t<< \"Configured \" << name << \" resizer input pad with \"\n+\t\t\t<< ispFormat.toString();\n+\n+\t\tispFormat.size = cfg.size;\n+\n+\t\tLOG(RkISP1, Debug)\n+\t\t\t<< \"Configuring \" << name << \" resizer output pad with \"\n+\t\t\t<< ispFormat.toString();\n+\n+\t\tret = resizer->setFormat(1, &ispFormat);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\n+\t\tLOG(RkISP1, Debug)\n+\t\t\t<< \"Configured \" << name << \" resizer output pad with \"\n+\t\t\t<< ispFormat.toString();\n+\n+\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n+\t\tV4L2DeviceFormat outputFormat = {};\n+\t\toutputFormat.fourcc = video->toV4L2PixelFormat(cfg.pixelFormat);\n+\t\toutputFormat.size = cfg.size;\n+\t\toutputFormat.planesCount = info.numPlanes();\n+\n+\t\tret = video->setFormat(&outputFormat);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tif (outputFormat.size != cfg.size ||\n+\t\t    outputFormat.fourcc != video->toV4L2PixelFormat(cfg.pixelFormat)) {\n+\t\t\tLOG(RkISP1, Error)\n+\t\t\t\t<< \"Unable to configure capture in \" << cfg.toString();\n+\t\t\treturn -EINVAL;\n+\t\t}\n \t}\n \n \tV4L2DeviceFormat paramFormat = {};\n@@ -699,34 +729,53 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \tif (ret)\n \t\treturn ret;\n \n-\tcfg.setStream(&data->mainPathStream_);\n-\n \treturn 0;\n }\n \n int PipelineHandlerRkISP1::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n \t\t\t\t\t      std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n {\n+\tRkISP1CameraData *data = cameraData(camera);\n \tunsigned int count = stream->configuration().bufferCount;\n-\treturn mainPathVideo_->exportBuffers(count, buffers);\n+\n+\tif (stream == &data->mainPathStream_)\n+\t\treturn mainPathVideo_->exportBuffers(count, buffers);\n+\telse if (stream == &data->selfPathStream_)\n+\t\treturn selfPathVideo_->exportBuffers(count, buffers);\n+\n+\treturn -EINVAL;\n }\n \n int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n {\n \tRkISP1CameraData *data = cameraData(camera);\n-\tunsigned int count = data->mainPathStream_.configuration().bufferCount;\n \tunsigned int ipaBufferId = 1;\n \tint ret;\n \n-\tret = mainPathVideo_->importBuffers(count);\n-\tif (ret < 0)\n-\t\tgoto error;\n+\tunsigned int maxCount = std::max({\n+\t\tdata->mainPathStream_.configuration().bufferCount,\n+\t\tdata->selfPathStream_.configuration().bufferCount,\n+\t});\n+\n+\tif (data->mainPathActive_) {\n+\t\tret = mainPathVideo_->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 = selfPathVideo_->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(count, &paramBuffers_);\n+\tret = param_->allocateBuffers(maxCount, &paramBuffers_);\n \tif (ret < 0)\n \t\tgoto error;\n \n-\tret = stat_->allocateBuffers(count, &statBuffers_);\n+\tret = stat_->allocateBuffers(maxCount, &statBuffers_);\n \tif (ret < 0)\n \t\tgoto error;\n \n@@ -752,6 +801,7 @@ error:\n \tparamBuffers_.clear();\n \tstatBuffers_.clear();\n \tmainPathVideo_->releaseBuffers();\n+\tselfPathVideo_->releaseBuffers();\n \n \treturn ret;\n }\n@@ -785,6 +835,9 @@ int PipelineHandlerRkISP1::freeBuffers(Camera *camera)\n \tif (mainPathVideo_->releaseBuffers())\n \t\tLOG(RkISP1, Error) << \"Failed to release main path buffers\";\n \n+\tif (selfPathVideo_->releaseBuffers())\n+\t\tLOG(RkISP1, Error) << \"Failed to release self path buffers\";\n+\n \treturn 0;\n }\n \n@@ -827,15 +880,47 @@ int PipelineHandlerRkISP1::start(Camera *camera)\n \t\treturn ret;\n \t}\n \n-\tret = mainPathVideo_->streamOn();\n-\tif (ret) {\n-\t\tparam_->streamOff();\n-\t\tstat_->streamOff();\n-\t\tdata->ipa_->stop();\n-\t\tfreeBuffers(camera);\n-\n-\t\tLOG(RkISP1, Error)\n-\t\t\t<< \"Failed to start camera \" << camera->id();\n+\tstd::map<unsigned int, IPAStream> streamConfig;\n+\n+\tif (data->mainPathActive_) {\n+\t\tret = mainPathVideo_->streamOn();\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+\t\tstreamConfig[0] = {\n+\t\t\t.pixelFormat = data->mainPathStream_.configuration().pixelFormat,\n+\t\t\t.size = data->mainPathStream_.configuration().size,\n+\t\t};\n+\t}\n+\n+\tif (data->selfPathActive_) {\n+\t\tret = selfPathVideo_->streamOn();\n+\t\tif (ret) {\n+\t\t\tif (data->mainPathActive_)\n+\t\t\t\tmainPathVideo_->streamOff();\n+\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+\t\tstreamConfig[1] = {\n+\t\t\t.pixelFormat = data->selfPathStream_.configuration().pixelFormat,\n+\t\t\t.size = data->selfPathStream_.configuration().size,\n+\t\t};\n \t}\n \n \tactiveCamera_ = camera;\n@@ -850,12 +935,6 @@ int PipelineHandlerRkISP1::start(Camera *camera)\n \t\tret = 0;\n \t}\n \n-\tstd::map<unsigned int, IPAStream> streamConfig;\n-\tstreamConfig[0] = {\n-\t\t.pixelFormat = data->mainPathStream_.configuration().pixelFormat,\n-\t\t.size = data->mainPathStream_.configuration().size,\n-\t};\n-\n \tstd::map<unsigned int, const ControlInfoMap &> entityControls;\n \tentityControls.emplace(0, data->sensor_->controls());\n \n@@ -871,20 +950,31 @@ void PipelineHandlerRkISP1::stop(Camera *camera)\n \tRkISP1CameraData *data = cameraData(camera);\n \tint ret;\n \n-\tret = mainPathVideo_->streamOff();\n-\tif (ret)\n-\t\tLOG(RkISP1, Warning)\n-\t\t\t<< \"Failed to stop camera \" << camera->id();\n+\tif (data->selfPathActive_) {\n+\t\tret = selfPathVideo_->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 = mainPathVideo_->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 \n \tret = stat_->streamOff();\n \tif (ret)\n \t\tLOG(RkISP1, Warning)\n-\t\t\t<< \"Failed to stop statistics \" << camera->id();\n+\t\t\t<< \"Failed to stop statistics for \" << camera->id();\n \n \tret = param_->streamOff();\n \tif (ret)\n \t\tLOG(RkISP1, Warning)\n-\t\t\t<< \"Failed to stop parameters \" << camera->id();\n+\t\t\t<< \"Failed to stop parameters for \" << camera->id();\n \n \tdata->ipa_->stop();\n \n@@ -955,11 +1045,16 @@ int PipelineHandlerRkISP1::initLinks(const Camera *camera,\n \t}\n \n \tfor (const StreamConfiguration &cfg : config) {\n-\t\tif (cfg.stream() != &data->mainPathStream_)\n+\t\tMediaLink *link;\n+\t\tif (cfg.stream() == &data->mainPathStream_)\n+\t\t\tlink = media_->link(\"rkisp1_isp\", 2,\n+\t\t\t\t\t    \"rkisp1_resizer_mainpath\", 0);\n+\t\telse if (cfg.stream() == &data->selfPathStream_)\n+\t\t\tlink = media_->link(\"rkisp1_isp\", 2,\n+\t\t\t\t\t    \"rkisp1_resizer_selfpath\", 0);\n+\t\telse\n \t\t\treturn -EINVAL;\n \n-\t\tMediaLink *link = media_->link(\"rkisp1_isp\", 2,\n-\t\t\t\t\t       \"rkisp1_resizer_mainpath\", 0);\n \t\tif (!link)\n \t\t\treturn -ENODEV;\n \n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "11/22"
    ]
}