From patchwork Fri Nov 6 20:32:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Helen Koike X-Patchwork-Id: 10392 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C5938BE082 for ; Fri, 6 Nov 2020 20:32:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4491762D24; Fri, 6 Nov 2020 21:32:38 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F062560344 for ; Fri, 6 Nov 2020 21:32:36 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id 1A5CE1F46C0C From: Helen Koike To: libcamera-devel@lists.libcamera.org Date: Fri, 6 Nov 2020 17:32:27 -0300 Message-Id: <20201106203227.1780845-1-helen.koike@collabora.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: pipeline: rkisp1: fix crop configuration 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: , Cc: kernel@collabora.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Crop rectangle was not being configured on the isp output pad nor in the resizer input pad, causing an unecessary crop in the image and an unecessary scaling by the resizer when streaming with a higher resolution then the default 800x600. Example: cam -c 1 -C -s width=3280,height=2464 In the pipeline: sensor->isp->resizer->dma_engine isp output crop is set to 800x600, which limits the output format to 800x600, which is propagated to the resizer input format set to 800x600, and the resizer output format is set to the desired end resolution 3280x2464. Signed-off-by: Helen Koike Tested-by: Niklas Söderlund --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 16 +++++++++++++--- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 7 ++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index c74a2e9b..10d44400 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -698,17 +698,27 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) if (ret < 0) return ret; - LOG(RkISP1, Debug) << "ISP input pad configured with " << format.toString(); + LOG(RkISP1, Debug) + << "ISP input pad configured with " << format.toString() + << " crop " << rect.toString(); /* YUYV8_2X8 is required on the ISP source path pad for YUV output. */ format.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8; - LOG(RkISP1, Debug) << "Configuring ISP output pad with " << format.toString(); + LOG(RkISP1, Debug) + << "Configuring ISP output pad with " << format.toString() + << " crop (img stabilizer) " << rect.toString(); + + ret = isp_->setSelection(2, V4L2_SEL_TGT_CROP, &rect); + if (ret < 0) + return ret; ret = isp_->setFormat(2, &format); if (ret < 0) return ret; - LOG(RkISP1, Debug) << "ISP output pad configured with " << format.toString(); + LOG(RkISP1, Debug) + << "ISP output pad configured with " << format.toString() + << " crop (img stabilizer) " << rect.toString(); for (const StreamConfiguration &cfg : *config) { if (cfg.stream() == &data->mainPathStream_) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index e98515c8..50c0747c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -117,9 +117,14 @@ int RkISP1Path::configure(const StreamConfiguration &config, if (ret < 0) return ret; + Rectangle rect(0, 0, ispFormat.size); + ret = resizer_->setSelection(0, V4L2_SEL_TGT_CROP, &rect); + if (ret < 0) + return ret; + LOG(RkISP1, Debug) << "Configured " << name_ << " resizer input pad with " - << ispFormat.toString(); + << ispFormat.toString() << " crop " << rect.toString(); ispFormat.size = config.size;