{"id":9814,"url":"https://patchwork.libcamera.org/api/1.1/patches/9814/?format=json","web_url":"https://patchwork.libcamera.org/patch/9814/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","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-17-niklas.soderlund@ragnatech.se>","date":"2020-09-25T01:42:01","name":"[libcamera-devel,v3,16/22] libcamera: pipeline: rkisp1: Move path configuration to RkISP1Path","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"7b6b123b0accdecc69ba5c5db6ffe0af3b7dc7c9","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9814/mbox/","series":[{"id":1325,"url":"https://patchwork.libcamera.org/api/1.1/series/1325/?format=json","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/9814/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9814/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 3BFE1C3B5C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Sep 2020 01:43:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0027A63019;\n\tFri, 25 Sep 2020 03:42:59 +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 0354D6303F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Sep 2020 03:42:53 +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 6d12cf05-fed0-11ea-92dc-005056917a89;\n\tFri, 25 Sep 2020 03:42:52 +0200 (CEST)"],"X-Halon-ID":"6d12cf05-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:01 +0200","Message-Id":"<20200925014207.1455796-17-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 16/22] libcamera: pipeline: rkisp1:\n\tMove path configuration 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 path configuration to RkISP1Path to increase code reuse and\nmake the V4L2 subdevice resizer private to the path. There is no\nfunctional change.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp     | 55 +++-----------------\n src/libcamera/pipeline/rkisp1/rkisp1path.cpp | 55 +++++++++++++++++++-\n src/libcamera/pipeline/rkisp1/rkisp1path.h   | 10 +++-\n 3 files changed, 68 insertions(+), 52 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex e738a7eb19264d79..2403eec4691b5ff6 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -810,60 +810,17 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\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 = mainPath_.resizer_;\n-\t\t\tvideo = mainPath_.video_;\n+\t\t\tret = mainPath_.configure(cfg, format);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n \t\t\tdata->mainPathActive_ = true;\n \t\t} else {\n-\t\t\tresizer = selfPath_.resizer_;\n-\t\t\tvideo = selfPath_.video_;\n+\t\t\tret = selfPath_.configure(cfg, format);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\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 == mainPath_.resizer_ ? \"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 = {};\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1path.cpp\nindex 51a75df86baaaa7b..758580934817ed6a 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1path.cpp\n@@ -7,14 +7,18 @@\n \n #include \"rkisp1path.h\"\n \n+#include <libcamera/stream.h>\n+\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n \n namespace libcamera {\n \n+LOG_DECLARE_CATEGORY(RkISP1)\n+\n RkISP1Path::RkISP1Path(const char *name)\n-\t: resizer_(nullptr), video_(nullptr), name_(name)\n+\t: video_(nullptr), name_(name), resizer_(nullptr)\n {\n }\n \n@@ -40,6 +44,55 @@ bool RkISP1Path::init(MediaDevice *media)\n \treturn true;\n }\n \n+int RkISP1Path::configure(const StreamConfiguration &config,\n+\t\t\t  const V4L2SubdeviceFormat &inputFormat)\n+{\n+\tint ret;\n+\n+\tV4L2SubdeviceFormat ispFormat = inputFormat;\n+\n+\tret = resizer_->setFormat(0, &ispFormat);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tLOG(RkISP1, Debug)\n+\t\t<< \"Configured \" << name_ << \" resizer input pad with \"\n+\t\t<< ispFormat.toString();\n+\n+\tispFormat.size = config.size;\n+\n+\tLOG(RkISP1, Debug)\n+\t\t<< \"Configuring \" << name_ << \" resizer output pad with \"\n+\t\t<< ispFormat.toString();\n+\n+\tret = resizer_->setFormat(1, &ispFormat);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tLOG(RkISP1, Debug)\n+\t\t<< \"Configured \" << name_ << \" resizer output pad with \"\n+\t\t<< ispFormat.toString();\n+\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);\n+\tV4L2DeviceFormat outputFormat = {};\n+\toutputFormat.fourcc = video_->toV4L2PixelFormat(config.pixelFormat);\n+\toutputFormat.size = config.size;\n+\toutputFormat.planesCount = info.numPlanes();\n+\n+\tret = video_->setFormat(&outputFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (outputFormat.size != config.size ||\n+\t    outputFormat.fourcc != video_->toV4L2PixelFormat(config.pixelFormat)) {\n+\t\tLOG(RkISP1, Error)\n+\t\t\t<< \"Unable to configure capture in \" << config.toString();\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n RkISP1MainPath::RkISP1MainPath()\n \t: RkISP1Path(\"main\")\n {\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1path.h b/src/libcamera/pipeline/rkisp1/rkisp1path.h\nindex d3172e228a3f67bf..6eb01529d2fddb1c 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1path.h\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1path.h\n@@ -12,6 +12,8 @@ namespace libcamera {\n class MediaDevice;\n class V4L2Subdevice;\n class V4L2VideoDevice;\n+struct StreamConfiguration;\n+struct V4L2SubdeviceFormat;\n \n class RkISP1Path\n {\n@@ -21,12 +23,16 @@ public:\n \n \tbool init(MediaDevice *media);\n \n-\t/* \\todo Make resizer and video private. */\n-\tV4L2Subdevice *resizer_;\n+\tint configure(const StreamConfiguration &config,\n+\t\t      const V4L2SubdeviceFormat &inputFormat);\n+\n+\t/* \\todo Make video private. */\n \tV4L2VideoDevice *video_;\n \n private:\n \tconst char *name_;\n+\n+\tV4L2Subdevice *resizer_;\n };\n \n class RkISP1MainPath : public RkISP1Path\n","prefixes":["libcamera-devel","v3","16/22"]}