{"id":19608,"url":"https://patchwork.libcamera.org/api/1.1/patches/19608/?format=json","web_url":"https://patchwork.libcamera.org/patch/19608/","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":"<20240301212121.9072-18-laurent.pinchart@ideasonboard.com>","date":"2024-03-01T21:21:06","name":"[PATCH/RFC,17/32] libcamera: camera_sensor: Test for read-only HBLANK with READ_ONLY flag","commit_ref":null,"pull_url":null,"state":"rfc","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/19608/mbox/","series":[{"id":4197,"url":"https://patchwork.libcamera.org/api/1.1/series/4197/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4197","date":"2024-03-01T21:20:49","name":"libcamera: Support the upstream Unicam driver","version":1,"mbox":"https://patchwork.libcamera.org/series/4197/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19608/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19608/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 3C30CC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  1 Mar 2024 21:21:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F061E628AC;\n\tFri,  1 Mar 2024 22:21:46 +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 84608628AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Mar 2024 22:21:44 +0100 (CET)","from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C83031B4;\n\tFri,  1 Mar 2024 22:21:29 +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=\"Zpxlt9pV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709328090;\n\tbh=W1hY9Zc0vUQdCjUpqtgVDU/eAOOlhxehhQVpLFl/zeY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Zpxlt9pVSCF4b2DgE+LSVI2QlBiUVt+wdFsx042BxuBnylK4mqtsA9H9tEEyD8ldr\n\tSzWJs2Aazk+baHoaRW28IiGe6rBIJzq+gn1Jm2Zp1yhcausAnIfgKkEyK7sTUlhw4f\n\tiEc8/yjBR5y2a4uUgKEYNwrswDp+lS8L0ssqQJ9U=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH/RFC 17/32] libcamera: camera_sensor: Test for read-only\n\tHBLANK with READ_ONLY flag","Date":"Fri,  1 Mar 2024 23:21:06 +0200","Message-ID":"<20240301212121.9072-18-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20240301212121.9072-1-laurent.pinchart@ideasonboard.com>","References":"<20240301212121.9072-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>","Cc":"Sakari Ailus <sakari.ailus@iki.fi>","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>\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":["PATCH/RFC","17/32"]}