From patchwork Fri Dec 2 12:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17937 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 EEDD7BE08B for ; Fri, 2 Dec 2022 12:40:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED9D663346; Fri, 2 Dec 2022 13:40:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669984810; bh=nvrOEvJVHz7j09luDy4xiun/bWXhoqUsyv867Z9Io5c=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ShR0/4ZOF9x7J4Qg17lwTtEp8aUBKKpEAR7GiQrLVZfC2oAg+OwmA64IiLPbGwZg4 yfYKKQMSqxLFVUVIGd2GyMqlHuZJWw6lIJEZf/DBYP20Yplo80DTfHVqhrYe4215l6 RkBvgnh7Mow7bx98MhTRydRNG3bcTLAsmgvoHPBPoSvZK60foAjIZCc0iFQFYn9Uix 5M8ruYQ+O6pK+ljJrp6UguVGIkeihjTOPJpRpJEOn1FGlSPfR+NQ+96lhSo2b92OId 0FxWPKVLlxcZsGxZt0czHQchRr6C2W3t+kgEGizRFiv7xRwuRGIaJ76wIuBpofOZnB djZ/LRZsUJXiw== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91FE96333E for ; Fri, 2 Dec 2022 13:40:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Y39Qfske"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id f18so7610423wrj.5 for ; Fri, 02 Dec 2022 04:40:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jdJada7Pm/o1Cp/fS3FBp6tTdVC42aBz9VmgOPqqXrw=; b=Y39Qfskej9W8PjV+t29zoAXyBl4BMAQqvzQYEAhsmaDERvQF/lQTl7kvZTgs/WozZq zThxF90fLlSYhJQ4yVaUKJqVZZTq9Gqe8SUx0hgj7f305/goedenZj0qgv/sRyunZDk7 Z4/KNhdyHbZvBmhesgVpW3telcOD8Ih8nYH0aoS/t2E3xd+ZRA7dqPQ/c6mVHtaX3hPF f1gBkZmJDrf2pww2ZP0J69E+mHjs1MuQUIftFjZ6FsymVj/0slQuBxSkj7433k48dxU0 dPTEqQFYoKo0+otMKCslTzbyyl1WslBtHd+kEu7i9Za/s5wUdCdwgimwF98kokt++gce GSLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jdJada7Pm/o1Cp/fS3FBp6tTdVC42aBz9VmgOPqqXrw=; b=JFarWwxEnuxQUf5YLdnQVhypftaX/A1HjWyYviZ5il2rs8WBFJBNRleylE5DTu2Vpc JYv8EFY7dP9OuBa8UawHdMfYVBHDEVnMAuOPXpbrMfy8W1dZdIweyNZQ9rSNyGGAXtQQ wBYasiQYDWveXv1VcT1JmEvZNAM2JvtaZByLSf4jy7VZdjBjwMlgf7gRkLo35lYZcx5H t70mxYBloj4TBQvGTuZBSVPybHlvoe68VD5NigkU4YrabuueNl0JdIsGwwhuqukIoZf4 /nm28VUmVNJUum1Z1+WSzkFqH0sPy7wwfRi2jTR+TKYEyIe2zkM+M+1Z2vUeeRDH1N5E K29w== X-Gm-Message-State: ANoB5pnO+xTAtmQClIYpIieHBYDaymKnBP2AKzmiDrmkSf+f+q6uMP/b jB1LtsYOl7yLnWHIWbiZvTZN6R/iafWaIj3F X-Google-Smtp-Source: AA0mqf6FNbUHTBOPH7SjrYFhEv8aHv4fdYPiXZsmS4wOB92KMZdQrTaw3Q78daqxI7qedKjTp4jfQw== X-Received: by 2002:adf:d206:0:b0:242:285f:c6f4 with SMTP id j6-20020adfd206000000b00242285fc6f4mr9425535wrh.452.1669984807927; Fri, 02 Dec 2022 04:40:07 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id y15-20020a5d4acf000000b00241e5b917d0sm8276484wrs.36.2022.12.02.04.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 04:40:07 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Dec 2022 12:40:05 +0000 Message-Id: <20221202124005.3643-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202124005.3643-1-naush@raspberrypi.com> References: <20221202124005.3643-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] libcamera:camera_sensor, ipa: raspberrypi: Test readOnly() for HBLANK control 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use ControlInfo::readOnly() to test if the camera sensor accepts V4L2_CID_HBLANK control changes. This replaces the current workaround where we test if the V4L2_CID_HBLANK min and max values are the same to determine if a control is read-only. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 12 +----------- src/libcamera/camera_sensor.cpp | 14 ++------------ 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bead436def3c..57f01496fc44 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1239,17 +1239,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) ctrls.set(V4L2_CID_EXPOSURE, exposureLines); ctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode); - /* - * 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. This seems to be the case for all the cameras our IPA - * works with. - * - * \todo The control API ought to have a flag to specify if a control - * is read-only which could be used below. - */ - if (mode_.minLineLength != mode_.maxLineLength) + if (!sensorCtrls_.at(V4L2_CID_HBLANK).readOnly()) ctrls.set(V4L2_CID_HBLANK, static_cast(hblank)); } diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ae3127d6b693..3785b6441b90 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -185,20 +185,10 @@ 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. */ const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); - const int32_t hblankMin = hblank.min().get(); - const int32_t hblankMax = hblank.max().get(); - - if (hblankMin != hblankMax) { + if (!hblank.readOnly()) { + const int32_t hblankMin = hblank.min().get(); ControlList ctrl(subdev_->controls()); ctrl.set(V4L2_CID_HBLANK, hblankMin);