Patch Detail
Show a patch.
GET /api/patches/9602/?format=api
{ "id": 9602, "url": "https://patchwork.libcamera.org/api/patches/9602/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9602/", "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": "<20200914142149.63857-11-niklas.soderlund@ragnatech.se>", "date": "2020-09-14T14:21:46", "name": "[libcamera-devel,v2,10/13] libcamera: pipeline: rkisp1: Configure self path", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "be233ebfccdfd6934d66ba4c6fcb1f8e182b549d", "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/9602/mbox/", "series": [ { "id": 1289, "url": "https://patchwork.libcamera.org/api/series/1289/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1289", "date": "2020-09-14T14:21:36", "name": "libcamera: pipeline: rkisp1: Extend to support two streams", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1289/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9602/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9602/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 4B637BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Sep 2020 14:22:17 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 204BF62E0D;\n\tMon, 14 Sep 2020 16:22:17 +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 2935162DF9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Sep 2020 16:22:14 +0200 (CEST)", "from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de\n\t[84.172.82.168]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid ae99bf3c-f695-11ea-a39b-005056917f90;\n\tMon, 14 Sep 2020 16:22:13 +0200 (CEST)" ], "X-Halon-ID": "ae99bf3c-f695-11ea-a39b-005056917f90", "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": "Mon, 14 Sep 2020 16:21:46 +0200", "Message-Id": "<20200914142149.63857-11-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20200914142149.63857-1-niklas.soderlund@ragnatech.se>", "References": "<20200914142149.63857-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 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 | 200 ++++++++++++++++-------\n 1 file changed, 141 insertions(+), 59 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 5aa01f87afd71183..01cd461427e3a6dc 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@@ -617,7 +622,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@@ -659,37 +663,55 @@ 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\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\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@@ -704,28 +726,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([[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+\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@@ -757,6 +797,7 @@ error:\n \tparamBuffers_.clear();\n \tstatBuffers_.clear();\n \tmainPathVideo_->releaseBuffers();\n+\tselfPathVideo_->releaseBuffers();\n \n \treturn ret;\n }\n@@ -790,6 +831,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@@ -832,15 +876,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@@ -855,12 +931,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@@ -876,10 +946,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@@ -964,6 +1043,9 @@ int PipelineHandlerRkISP1::initLinks(const Camera *camera,\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", "prefixes": [ "libcamera-devel", "v2", "10/13" ] }