Patch Detail
Show a patch.
GET /api/1.1/patches/9300/?format=api
{ "id": 9300, "url": "https://patchwork.libcamera.org/api/1.1/patches/9300/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9300/", "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": "<20200813005246.3265807-11-niklas.soderlund@ragnatech.se>", "date": "2020-08-13T00:52:43", "name": "[libcamera-devel,10/13] libcamera: pipeline: rkisp1: Configure self path", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "382636997b7607f0e5d5f0c5f094bcdae2a520e0", "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/9300/mbox/", "series": [ { "id": 1215, "url": "https://patchwork.libcamera.org/api/1.1/series/1215/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1215", "date": "2020-08-13T00:52:33", "name": "libcamera: pipeline: rkisp1: Extend to support two streams", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1215/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9300/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9300/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 13096BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 13 Aug 2020 00:53:48 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D0217613B4;\n\tThu, 13 Aug 2020 02:53:47 +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 87A52613A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Aug 2020 02:53:44 +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 6e6fd853-dcff-11ea-92dc-005056917a89;\n\tThu, 13 Aug 2020 02:53:42 +0200 (CEST)" ], "X-Halon-ID": "6e6fd853-dcff-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": "Thu, 13 Aug 2020 02:52:43 +0200", "Message-Id": "<20200813005246.3265807-11-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20200813005246.3265807-1-niklas.soderlund@ragnatech.se>", "References": "<20200813005246.3265807-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 10/13] 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 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 197 ++++++++++++++++-------\n 1 file changed, 139 insertions(+), 58 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 132878c13b10b555..671098e11a2e2750 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -133,7 +133,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@@ -145,6 +146,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@@ -154,6 +156,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@@ -615,7 +620,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@@ -657,36 +661,54 @@ 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-\tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.fourcc = mainPathVideo_->toV4L2PixelFormat(cfg.pixelFormat);\n-\toutputFormat.size = cfg.size;\n-\toutputFormat.planesCount = 2;\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\tLOG(RkISP1, Debug) << \"Resizer input pad configured with \" << ispFormat.toString();\n+\n+\t\tispFormat.size = cfg.size;\n+\n+\t\tLOG(RkISP1, Debug) << \"Configuring resizer output pad with \" << 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) << \"Resizer output pad configured with \" << ispFormat.toString();\n+\n+\t\tV4L2DeviceFormat outputFormat = {};\n+\t\toutputFormat.fourcc = video->toV4L2PixelFormat(cfg.pixelFormat);\n+\t\toutputFormat.size = cfg.size;\n+\t\toutputFormat.planesCount = 2;\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@@ -701,28 +723,46 @@ 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(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+\n+\tif (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 count = 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(count);\n+\t\tif (ret < 0)\n+\t\t\tgoto error;\n+\t}\n+\n+\tif (data->selfPathActive_) {\n+\t\tret = selfPathVideo_->importBuffers(count);\n+\t\tif (ret < 0)\n+\t\t\tgoto error;\n+\t}\n \n \tret = param_->allocateBuffers(count, ¶mBuffers_);\n \tif (ret < 0)\n@@ -754,6 +794,7 @@ error:\n \tparamBuffers_.clear();\n \tstatBuffers_.clear();\n \tmainPathVideo_->releaseBuffers();\n+\tselfPathVideo_->releaseBuffers();\n \n \treturn ret;\n }\n@@ -787,6 +828,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@@ -829,15 +873,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@@ -852,12 +928,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@@ -873,10 +943,19 @@ 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 \" << 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 \" << camera->id();\n+\t}\n \n \tret = stat_->streamOff();\n \tif (ret)\n@@ -960,6 +1039,8 @@ int PipelineHandlerRkISP1::initLinks(const Camera *camera,\n \t\tstd::string resizer;\n \t\tif (cfg.stream() == &data->mainPathStream_)\n \t\t\tresizer = \"rkisp1_resizer_mainpath\";\n+\t\telse if (cfg.stream() == &data->selfPathStream_)\n+\t\t\tresizer = \"rkisp1_resizer_selfpath\";\n \t\telse\n \t\t\treturn -EINVAL;\n \n", "prefixes": [ "libcamera-devel", "10/13" ] }