From patchwork Fri Mar 15 00:16:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19732 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 97BB4BD808 for ; Fri, 15 Mar 2024 00:16:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 13F0462CEC; Fri, 15 Mar 2024 01:16:46 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="as6QV7kD"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F174D62CA1 for ; Fri, 15 Mar 2024 01:16:34 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 482CC667 for ; Fri, 15 Mar 2024 01:16:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710461771; bh=2Xxd8BDrlf9YxmGtjiJTQsmA6Xvarr2niKvcfZEP2x4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=as6QV7kDFjsdI/CKRZkMgd7Jt+L2TJDaxhRlqznrwGemLpHB5VVfZ3RJo7FqsiVA+ R/LQLgYDJaoMd4IfPRYxA17GWGhftC606+V8GJHaQhWDNx/LxpP6prmr9FQYPzbcpS bV4QDMm5+s8iXP+5tUqrHM37iMvPWOFeq+WWXMLY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 13/14] libcamera: camera_sensor: Test for read-only HBLANK with 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 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The CameraSensor class tests if the sensor HBLANK control is read-only by comparing the minimum and maximum values, and documents this as being a workaround for the lack of a read-only control flag in V4L2. This is incorrect, as the V4L2 API provides such a flag. Use it to replace the workaround. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/sensor/camera_sensor.cpp | 27 +++++++------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/libcamera/sensor/camera_sensor.cpp b/src/libcamera/sensor/camera_sensor.cpp index 86ad9a85371c..402025566544 100644 --- a/src/libcamera/sensor/camera_sensor.cpp +++ b/src/libcamera/sensor/camera_sensor.cpp @@ -188,28 +188,15 @@ int CameraSensor::init() * Set HBLANK to the minimum to start with a well-defined line length, * allowing IPA modules that do not modify HBLANK to use the sensor * minimum line length in their calculations. - * - * At present, there is no way of knowing if a control is read-only. - * As a workaround, assume that if the minimum and maximum values of - * the V4L2_CID_HBLANK control are the same, it implies the control - * is read-only. - * - * \todo The control API ought to have a flag to specify if a control - * is read-only which could be used below. */ - if (ctrls.infoMap()->find(V4L2_CID_HBLANK) != ctrls.infoMap()->end()) { - const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); - const int32_t hblankMin = hblank.min().get(); - const int32_t hblankMax = hblank.max().get(); + const struct v4l2_query_ext_ctrl *hblankInfo = subdev_->controlInfo(V4L2_CID_HBLANK); + if (hblankInfo && !(hblankInfo->flags & V4L2_CTRL_FLAG_READ_ONLY)) { + ControlList ctrl(subdev_->controls()); - if (hblankMin != hblankMax) { - ControlList ctrl(subdev_->controls()); - - ctrl.set(V4L2_CID_HBLANK, hblankMin); - ret = subdev_->setControls(&ctrl); - if (ret) - return ret; - } + ctrl.set(V4L2_CID_HBLANK, static_cast(hblankInfo->minimum)); + ret = subdev_->setControls(&ctrl); + if (ret) + return ret; } return applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);