[{"id":26664,"web_url":"https://patchwork.libcamera.org/comment/26664/","msgid":"<20230319135726.GI10144@pendragon.ideasonboard.com>","date":"2023-03-19T13:57:26","subject":"Re: [libcamera-devel] [PATCH 01/11] pipeline: ipu3: Check if sensor\n\tsupports test pattern control","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Dan,\n\nThank you for the patch.\n\nOn Sat, Mar 18, 2023 at 11:40:04PM +0000, Daniel Scally via libcamera-devel wrote:\n> The IPU3 pipeline calls CameraSensor::setTestPatternMode() in ::start().\n> That control is not a libcamera mandatory control and so might not be\n> present for a sensor. Check for its presence before trying to set the\n> control to avoid uneccessary failures.\n> \n> Fixes: acf8d028e (\"libcamera: pipeline: ipu3: Apply a requested test pattern mode\")\n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n> I'll patch this control into the ov7251 driver upstream as the sensor does have\n> a test pattern mode, but still - it's not mandatory!\n> \n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++----\n>  1 file changed, 8 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 355cb0cb..d0d55651 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -722,10 +722,14 @@ int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlLis\n>  \tint ret;\n>  \n>  \t/* Disable test pattern mode on the sensor, if any. */\n> -\tret = cio2->sensor()->setTestPatternMode(\n> -\t\tcontrols::draft::TestPatternModeEnum::TestPatternModeOff);\n> -\tif (ret)\n> -\t\treturn ret;\n> +\tconst ControlInfoMap &sensorControls = cio2->sensor()->controls();\n> +\n> +\tif (sensorControls.find(&controls::draft::TestPatternMode) != sensorControls.end()) {\n> +\t\tret = cio2->sensor()->setTestPatternMode(\n> +\t\t\tcontrols::draft::TestPatternModeEnum::TestPatternModeOff);\n\nCameraSensor::setTestPatternMode() starts with\n\n\tif (testPatternMode_ == mode)\n\t\treturn 0;\n\nwhich was meant to make the function a no-op if the sensor doesn't\nsupport test patterns. It seems the CameraSensor class may be missing\ninitialization of the testPatternMode_ member, which may explain why you\nget an error. Initializing it in the constructor would be a better fix.\n\n> +\t\tif (ret)\n> +\t\t\treturn ret;\n> +\t}\n>  \n>  \t/* Allocate buffers for internal pipeline usage. */\n>  \tret = allocateBuffers(camera);","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 8C534C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 19 Mar 2023 13:57:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0D034626DA;\n\tSun, 19 Mar 2023 14:57:26 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF1FC626CA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 19 Mar 2023 14:57:24 +0100 (CET)","from pendragon.ideasonboard.com (85-76-162-78-nat.elisa-mobile.fi\n\t[85.76.162.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 989831858;\n\tSun, 19 Mar 2023 14:57:23 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679234246;\n\tbh=v5bxj98yNEIiAwxzBGaqDHBtjHOe+HyIrsyTN5a6PB0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Pr7o/0IIu/u2sSbfg7RD2mANe5t2tPm4Ar59uH6czVt72TCc84SQyLqSmPnx0rJGd\n\tNdRFX9fOxJRO6KLkNMTpYSq6Wnxrc3qNeeq5YCpYKJPCBTdH6Dd4cFU9KaCh56q/Ir\n\tp6P2Honys63JsevAgpvB9t6Jc5Fu62dJpA84/duqOkWO6x4BKkxuXAJRTpflvoH/pv\n\teYVc5HhJ9GPh9+SMtpYjERoBwT49Vo4iBaKPQIejaS8KKcJuDDMo0R0uRF7gEUhZlh\n\tcEFJnurQFooQ/XOJmg76cF8Dg2/FcfcY/Fw45d3tmlE1Dm/Tvmg1Xt2lf7qTFGrADn\n\tri3dlXyauxQIA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1679234244;\n\tbh=v5bxj98yNEIiAwxzBGaqDHBtjHOe+HyIrsyTN5a6PB0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=UErS9DyMC8NVoPbhoI66M/Y2nUdIWpNCCuUAjNXEtBHEFyptgvOxXGQOKCjMSQv/6\n\tOq53OHmq9C4+qcjKdfcgtetaqB9rFxksEa43EWUEIlUAYUzNoh7Xcyy6r2pJjxzSaz\n\tErmGbWUQ2bfyZRLhrjZkxp5l5l0ct96PGG0MvMh8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"UErS9DyM\"; dkim-atps=neutral","Date":"Sun, 19 Mar 2023 15:57:26 +0200","To":"Daniel Scally <dan.scally@ideasonboard.com>","Message-ID":"<20230319135726.GI10144@pendragon.ideasonboard.com>","References":"<20230318234014.29506-1-dan.scally@ideasonboard.com>\n\t<20230318234014.29506-2-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230318234014.29506-2-dan.scally@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 01/11] pipeline: ipu3: Check if sensor\n\tsupports test pattern control","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]