From patchwork Fri Jan 24 20:25:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Helen Koike X-Patchwork-Id: 2732 Return-Path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D1BC0608B7 for ; Fri, 24 Jan 2020 21:25:50 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id D6D342842B4 From: Helen Koike To: libcamera-devel@lists.libcamera.org Cc: laurent.pinchart@ideasonboard.com, kernel@collabora.com, heiko@sntech.de, tfiga@chromium.org, niklas.soderlund@ragnatech.se, joacim.zetterling@gmail.com Date: Fri, 24 Jan 2020 17:25:37 -0300 Message-Id: <20200124202538.764733-1-helen.koike@collabora.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/2] libcamera: pipeline: rkisp1: sync topology with upstream driver X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2020 20:25:51 -0000 rkisp1 kernel driver was merged upstream with minor changes in the topology from the original driver libcamera based it's first support to rkisp1. Adapt libcamera pipeline to work with upstream driver. * Remove subdevice dphy from the pipeline. * Add resizer in the pipeline. * Fix links. * Update entity names. Signed-off-by: Helen Koike Reviewed-by: Niklas Söderlund --- Hi, I'm resending this patch ignoring the immutable patch in the rkisp1 driver[1], since media tree is already frozen and it will only be merged for kernel 5.7 only. [1] https://patchwork.linuxtv.org/patch/61213/ Thanks Changes in v3: * Added Reviewed-by: Niklas Söderlund * No changes in this patch Changes in v2: * Update rkisp1-capture.sh in a different patch * Fix typos in commit message. * Remove "receiver" and "CSI-2" reference at: << " link from sensor '" << link->source()->entity()->name() - << "' to CSI-2 receiver"; + << "' to ISP"; ... - * Enumerate all sensors connected to the ISP receiver and create one + * Enumerate all sensors connected to the ISP and create one --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 65 +++++++++++++----------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 0b3dd97..403c85e 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -207,8 +207,8 @@ private: int freeBuffers(Camera *camera); MediaDevice *media_; - V4L2Subdevice *dphy_; V4L2Subdevice *isp_; + V4L2Subdevice *resizer_; V4L2VideoDevice *video_; V4L2VideoDevice *param_; V4L2VideoDevice *stat_; @@ -513,7 +513,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() } PipelineHandlerRkISP1::PipelineHandlerRkISP1(CameraManager *manager) - : PipelineHandler(manager), dphy_(nullptr), isp_(nullptr), + : PipelineHandler(manager), isp_(nullptr), resizer_(nullptr), video_(nullptr), param_(nullptr), stat_(nullptr) { } @@ -523,8 +523,8 @@ PipelineHandlerRkISP1::~PipelineHandlerRkISP1() delete param_; delete stat_; delete video_; + delete resizer_; delete isp_; - delete dphy_; } /* ----------------------------------------------------------------------------- @@ -564,7 +564,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) * Configure the sensor links: enable the link corresponding to this * camera and disable all the other sensor links. */ - const MediaPad *pad = dphy_->entity()->getPadByIndex(0); + const MediaPad *pad = isp_->entity()->getPadByIndex(0); for (MediaLink *link : pad->links()) { bool enable = link->source()->entity() == sensor->entity(); @@ -576,7 +576,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) << (enable ? "Enabling" : "Disabling") << " link from sensor '" << link->source()->entity()->name() - << "' to CSI-2 receiver"; + << "' to ISP"; ret = link->setEnabled(enable); if (ret < 0) @@ -596,16 +596,6 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "Sensor configured with " << format.toString(); - ret = dphy_->setFormat(0, &format); - if (ret < 0) - return ret; - - LOG(RkISP1, Debug) << "Configuring ISP input pad with " << format.toString(); - - ret = dphy_->getFormat(1, &format); - if (ret < 0) - return ret; - ret = isp_->setFormat(0, &format); if (ret < 0) return ret; @@ -622,6 +612,22 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "ISP output pad configured with " << format.toString(); + ret = resizer_->setFormat(0, &format); + if (ret < 0) + return ret; + + LOG(RkISP1, Debug) << "Resizer input pad configured with " << format.toString(); + + format.size = cfg.size; + + LOG(RkISP1, Debug) << "Configuring resizer output pad with " << format.toString(); + + ret = resizer_->setFormat(1, &format); + if (ret < 0) + return ret; + + LOG(RkISP1, Debug) << "Resizer output pad configured with " << format.toString(); + V4L2DeviceFormat outputFormat = {}; outputFormat.fourcc = video_->toV4L2Fourcc(cfg.pixelFormat); outputFormat.size = cfg.size; @@ -868,7 +874,7 @@ int PipelineHandlerRkISP1::initLinks() if (ret < 0) return ret; - link = media_->link("rockchip-sy-mipi-dphy", 1, "rkisp1-isp-subdev", 0); + link = media_->link("rkisp1_isp", 2, "rkisp1_resizer_mainpath", 0); if (!link) return -ENODEV; @@ -876,7 +882,7 @@ int PipelineHandlerRkISP1::initLinks() if (ret < 0) return ret; - link = media_->link("rkisp1-isp-subdev", 2, "rkisp1_mainpath", 0); + link = media_->link("rkisp1_resizer_mainpath", 1, "rkisp1_mainpath", 0); if (!link) return -ENODEV; @@ -923,24 +929,25 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) const MediaPad *pad; DeviceMatch dm("rkisp1"); - dm.add("rkisp1-isp-subdev"); + dm.add("rkisp1_isp"); + dm.add("rkisp1_resizer_selfpath"); + dm.add("rkisp1_resizer_mainpath"); dm.add("rkisp1_selfpath"); dm.add("rkisp1_mainpath"); - dm.add("rkisp1-statistics"); - dm.add("rkisp1-input-params"); - dm.add("rockchip-sy-mipi-dphy"); + dm.add("rkisp1_stats"); + dm.add("rkisp1_params"); media_ = acquireMediaDevice(enumerator, dm); if (!media_) return false; /* Create the V4L2 subdevices we will need. */ - dphy_ = V4L2Subdevice::fromEntityName(media_, "rockchip-sy-mipi-dphy"); - if (dphy_->open() < 0) + isp_ = V4L2Subdevice::fromEntityName(media_, "rkisp1_isp"); + if (isp_->open() < 0) return false; - isp_ = V4L2Subdevice::fromEntityName(media_, "rkisp1-isp-subdev"); - if (isp_->open() < 0) + resizer_ = V4L2Subdevice::fromEntityName(media_, "rkisp1_resizer_mainpath"); + if (resizer_->open() < 0) return false; /* Locate and open the capture video node. */ @@ -948,11 +955,11 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) if (video_->open() < 0) return false; - stat_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1-statistics"); + stat_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1_stats"); if (stat_->open() < 0) return false; - param_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1-input-params"); + param_ = V4L2VideoDevice::fromEntityName(media_, "rkisp1_params"); if (param_->open() < 0) return false; @@ -967,10 +974,10 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator) } /* - * Enumerate all sensors connected to the CSI-2 receiver and create one + * Enumerate all sensors connected to the ISP and create one * camera instance for each of them. */ - pad = dphy_->entity()->getPadByIndex(0); + pad = isp_->entity()->getPadByIndex(0); if (!pad) return false; From patchwork Fri Jan 24 20:25:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Helen Koike X-Patchwork-Id: 2733 Return-Path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 097F3608B9 for ; Fri, 24 Jan 2020 21:25:53 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id 94AFD294878 From: Helen Koike To: libcamera-devel@lists.libcamera.org Cc: laurent.pinchart@ideasonboard.com, kernel@collabora.com, heiko@sntech.de, tfiga@chromium.org, niklas.soderlund@ragnatech.se, joacim.zetterling@gmail.com Date: Fri, 24 Jan 2020 17:25:38 -0300 Message-Id: <20200124202538.764733-2-helen.koike@collabora.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200124202538.764733-1-helen.koike@collabora.com> References: <20200124202538.764733-1-helen.koike@collabora.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/2] utils: rkisp1: sync topology with upstream driver in capture script X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2020 20:25:53 -0000 rkisp1 kernel driver was merged upstream with minor changes in the topology from the original driver libcamera based it's first support to rkisp1. Adapt libcamera capture script to work with upstream driver. * Remove subdevice dphy from the pipeline. * Add resizer in the pipeline. * Fix links. * Update entity names. Signed-off-by: Helen Koike Reviewed-by: Niklas Söderlund --- changes in v3: * Enable link between resizer and capture in mainpath changes in v2: * New commit (splitted from previous one) --- utils/rkisp1/rkisp1-capture.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/utils/rkisp1/rkisp1-capture.sh b/utils/rkisp1/rkisp1-capture.sh index cffe9fe..4b789b6 100755 --- a/utils/rkisp1/rkisp1-capture.sh +++ b/utils/rkisp1/rkisp1-capture.sh @@ -68,14 +68,15 @@ configure_pipeline() { $mediactl -r - $mediactl -l "'$sensor':0 -> 'rockchip-sy-mipi-dphy':0 [1]" - $mediactl -l "'rockchip-sy-mipi-dphy':1 -> 'rkisp1-isp-subdev':0 [1]" - $mediactl -l "'rkisp1-isp-subdev':2 -> 'rkisp1_mainpath':0 [1]" + $mediactl -l "'$sensor':0 -> 'rkisp1_isp':0 [1]" + $mediactl -l "'rkisp1_isp':2 -> 'rkisp1_resizer_mainpath':0 [1]" + $mediactl -l "'rkisp1_resizer_mainpath':1 -> 'rkisp1_mainpath':0 [1]" $mediactl -V "\"$sensor\":0 [$format]" - $mediactl -V "'rockchip-sy-mipi-dphy':1 [$format]" - $mediactl -V "'rkisp1-isp-subdev':0 [$format crop:(0,0)/$sensor_size]" - $mediactl -V "'rkisp1-isp-subdev':2 [fmt:$capture_mbus_code/$capture_size crop:(0,0)/$capture_size]" + $mediactl -V "'rkisp1_isp':0 [$format crop:(0,0)/$sensor_size]" + $mediactl -V "'rkisp1_isp':2 [fmt:$capture_mbus_code/$sensor_size crop:(0,0)/$sensor_size]" + $mediactl -V "'rkisp1_resizer_mainpath':0 [fmt:$capture_mbus_code/$sensor_size crop:(0,0)/$sensor_size]" + $mediactl -V "'rkisp1_resizer_mainpath':1 [fmt:$capture_mbus_code/$capture_size]" } # Capture frames @@ -161,8 +162,8 @@ fi sensor_name=$1 -modprobe mipi_dphy_sy -modprobe video_rkisp1 +modprobe phy_rockchip_dphy_rx0 +modprobe rockchip_isp1 sensor=$(find_sensor $sensor_name) || exit mdev=$(find_media_device rkisp1) || exit