[{"id":14227,"web_url":"https://patchwork.libcamera.org/comment/14227/","msgid":"<X9PkrP8j1KGlH2Qx@pendragon.ideasonboard.com>","date":"2020-12-11T21:29:16","subject":"Re: [libcamera-devel] [PATCH] src: pipeline: raspberrypi: Allow\n\tScalerCrop to work when passed in Camera::start","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Tue, Dec 08, 2020 at 08:51:17PM +0000, David Plowman wrote:\n> The ScalerCrop control is handled by the pipeline handler, not the\n> IPA, so must be handled explicitly in the Camera::start method. The\n> ScalerCrop code used when processing requests has been factored out to\n> make it easy to reuse.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 45 ++++++++++++-------\n>  1 file changed, 28 insertions(+), 17 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 2ec1f6e7..593fd7ac 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -156,6 +156,7 @@ public:\n>  \tvoid handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream);\n>  \tvoid handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream);\n>  \tvoid handleState();\n> +\tvoid applyScalerCrop(const ControlList &controls);\n>  \n>  \tCameraSensor *sensor_;\n>  \t/* Array of Unicam and ISP device streams and associated buffers/streams. */\n> @@ -751,6 +752,10 @@ int PipelineHandlerRPi::start(Camera *camera, [[maybe_unused]] ControlList *cont\n>  \t\treturn ret;\n>  \t}\n>  \n> +\t/* Check if a ScalerCrop control was specified. */\n> +\tif (controls)\n> +\t\tdata->applyScalerCrop(*controls);\n> +\n>  \t/* Start the IPA. */\n>  \tIPAOperationData ipaData = {};\n>  \tIPAOperationData result = {};\n> @@ -1610,24 +1615,10 @@ void RPiCameraData::checkRequestCompleted()\n>  \t}\n>  }\n>  \n> -void RPiCameraData::tryRunPipeline()\n> +void RPiCameraData::applyScalerCrop(const ControlList &controls)\n>  {\n> -\tFrameBuffer *bayerBuffer, *embeddedBuffer;\n> -\tIPAOperationData op;\n> -\n> -\t/* If any of our request or buffer queues are empty, we cannot proceed. */\n> -\tif (state_ != State::Idle || requestQueue_.empty() ||\n> -\t    bayerQueue_.empty() || embeddedQueue_.empty())\n> -\t\treturn;\n> -\n> -\tif (!findMatchingBuffers(bayerBuffer, embeddedBuffer))\n> -\t\treturn;\n> -\n> -\t/* Take the first request from the queue and action the IPA. */\n> -\tRequest *request = requestQueue_.front();\n> -\n> -\tif (request->controls().contains(controls::ScalerCrop)) {\n> -\t\tRectangle nativeCrop = request->controls().get<Rectangle>(controls::ScalerCrop);\n> +\tif (controls.contains(controls::ScalerCrop)) {\n> +\t\tRectangle nativeCrop = controls.get<Rectangle>(controls::ScalerCrop);\n>  \n>  \t\tif (!nativeCrop.width || !nativeCrop.height)\n>  \t\t\tnativeCrop = { 0, 0, 1, 1 };\n> @@ -1654,6 +1645,26 @@ void RPiCameraData::tryRunPipeline()\n>  \t\t\tupdateScalerCrop_ = true;\n>  \t\t}\n>  \t}\n> +}\n> +\n> +void RPiCameraData::tryRunPipeline()\n> +{\n> +\tFrameBuffer *bayerBuffer, *embeddedBuffer;\n> +\tIPAOperationData op;\n> +\n> +\t/* If any of our request or buffer queues are empty, we cannot proceed. */\n> +\tif (state_ != State::Idle || requestQueue_.empty() ||\n> +\t    bayerQueue_.empty() || embeddedQueue_.empty())\n> +\t\treturn;\n> +\n> +\tif (!findMatchingBuffers(bayerBuffer, embeddedBuffer))\n> +\t\treturn;\n> +\n> +\t/* Take the first request from the queue and action the IPA. */\n> +\tRequest *request = requestQueue_.front();\n> +\n> +\t/* See if a new ScalerCrop value needs to be applied. */\n> +\tapplyScalerCrop(request->controls());\n>  \n>  \t/*\n>  \t * Process all the user controls by the IPA. Once this is complete, we","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 02E18BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Dec 2020 21:29:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 83F5D67FB0;\n\tFri, 11 Dec 2020 22:29:23 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 09915608A7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Dec 2020 22:29:22 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77E7F99;\n\tFri, 11 Dec 2020 22:29:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"v7VlBys9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1607722161;\n\tbh=OoI64ZcTqUOOHuIQmWb1tywGEb5ufnAZL0Q7BYTerCE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=v7VlBys93Kq+HhVfcje5k6OK4CNyEraVTFkvVsCfoeyW1bSjnG+7u+67b25qCCBM5\n\taRPEJGjnKAr/mFofIR4BpbVy70RjMBUpR5vVd8GkAFvd+xiOiOmzIdO5AXcgW5fHfE\n\tRbOTbXSLmyeZPVx1ymJIuolSS3kJ6v70ymhVtKbM=","Date":"Fri, 11 Dec 2020 23:29:16 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<X9PkrP8j1KGlH2Qx@pendragon.ideasonboard.com>","References":"<20201208205117.22204-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201208205117.22204-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH] src: pipeline: raspberrypi: Allow\n\tScalerCrop to work when passed in Camera::start","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]