{"id":19732,"url":"https://patchwork.libcamera.org/api/1.1/patches/19732/?format=json","web_url":"https://patchwork.libcamera.org/patch/19732/","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":"<20240315001613.2033-14-laurent.pinchart@ideasonboard.com>","date":"2024-03-15T00:16:12","name":"[v2,13/14] libcamera: camera_sensor: Test for read-only HBLANK with READ_ONLY flag","commit_ref":"58bcddbdeb7e7b40ba8e7eecc2fad385d85f23ce","pull_url":null,"state":"accepted","archived":false,"hash":"d05e1bf7331258999b61942fcb585b8e860c608c","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19732/mbox/","series":[{"id":4226,"url":"https://patchwork.libcamera.org/api/1.1/series/4226/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4226","date":"2024-03-15T00:15:59","name":"libcamera: Prepare for new camera sensor class","version":2,"mbox":"https://patchwork.libcamera.org/series/4226/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19732/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19732/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 97BB4BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Mar 2024 00:16:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 13F0462CEC;\n\tFri, 15 Mar 2024 01:16:46 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F174D62CA1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Mar 2024 01:16:34 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 482CC667\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Mar 2024 01:16:11 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"as6QV7kD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710461771;\n\tbh=2Xxd8BDrlf9YxmGtjiJTQsmA6Xvarr2niKvcfZEP2x4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=as6QV7kDFjsdI/CKRZkMgd7Jt+L2TJDaxhRlqznrwGemLpHB5VVfZ3RJo7FqsiVA+\n\tR/LQLgYDJaoMd4IfPRYxA17GWGhftC606+V8GJHaQhWDNx/LxpP6prmr9FQYPzbcpS\n\tbV4QDMm5+s8iXP+5tUqrHM37iMvPWOFeq+WWXMLY=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v2 13/14] libcamera: camera_sensor: Test for read-only HBLANK\n\twith READ_ONLY flag","Date":"Fri, 15 Mar 2024 02:16:12 +0200","Message-ID":"<20240315001613.2033-14-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.43.2","In-Reply-To":"<20240315001613.2033-1-laurent.pinchart@ideasonboard.com>","References":"<20240315001613.2033-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The CameraSensor class tests if the sensor HBLANK control is read-only\nby comparing the minimum and maximum values, and documents this as being\na workaround for the lack of a read-only control flag in V4L2. This is\nincorrect, as the V4L2 API provides such a flag. Use it to replace the\nworkaround.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/sensor/camera_sensor.cpp | 27 +++++++-------------------\n 1 file changed, 7 insertions(+), 20 deletions(-)","diff":"diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp\nindex 86ad9a85371c..402025566544 100644\n--- a/src/libcamera/sensor/camera_sensor.cpp\n+++ b/src/libcamera/sensor/camera_sensor.cpp\n@@ -188,28 +188,15 @@ int CameraSensor::init()\n \t * Set HBLANK to the minimum to start with a well-defined line length,\n \t * allowing IPA modules that do not modify HBLANK to use the sensor\n \t * minimum line length in their calculations.\n-\t *\n-\t * At present, there is no way of knowing if a control is read-only.\n-\t * As a workaround, assume that if the minimum and maximum values of\n-\t * the V4L2_CID_HBLANK control are the same, it implies the control\n-\t * is read-only.\n-\t *\n-\t * \\todo The control API ought to have a flag to specify if a control\n-\t * is read-only which could be used below.\n \t */\n-\tif (ctrls.infoMap()->find(V4L2_CID_HBLANK) != ctrls.infoMap()->end()) {\n-\t\tconst ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK);\n-\t\tconst int32_t hblankMin = hblank.min().get<int32_t>();\n-\t\tconst int32_t hblankMax = hblank.max().get<int32_t>();\n+\tconst struct v4l2_query_ext_ctrl *hblankInfo = subdev_->controlInfo(V4L2_CID_HBLANK);\n+\tif (hblankInfo && !(hblankInfo->flags & V4L2_CTRL_FLAG_READ_ONLY)) {\n+\t\tControlList ctrl(subdev_->controls());\n \n-\t\tif (hblankMin != hblankMax) {\n-\t\t\tControlList ctrl(subdev_->controls());\n-\n-\t\t\tctrl.set(V4L2_CID_HBLANK, hblankMin);\n-\t\t\tret = subdev_->setControls(&ctrl);\n-\t\t\tif (ret)\n-\t\t\t\treturn ret;\n-\t\t}\n+\t\tctrl.set(V4L2_CID_HBLANK, static_cast<int32_t>(hblankInfo->minimum));\n+\t\tret = subdev_->setControls(&ctrl);\n+\t\tif (ret)\n+\t\t\treturn ret;\n \t}\n \n \treturn applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);\n","prefixes":["v2","13/14"]}