From patchwork Mon Jan 23 15:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18179 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 51AE3C3240 for ; Mon, 23 Jan 2023 15:49:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15FB9625F8; Mon, 23 Jan 2023 16:49:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674488994; bh=8oh+xFylsUCpNA5AeRcTyGVjoYq0AXKXMU73wp4krkY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=MkbHM/5HkHy5cYMX4C0RYT4TGNHYTJ3DwnAX9jICV1XbCgp3sbONSl41h2HDWnT4g n9QlOyVrkJy3Q7KC4lqePrAoYyFvixil8XMlB8AzQqulCss3pg22r/IoRHx7VQRTWY A5s3HDOZ0sky3vMU1V6jf+pO8xnJ5pL5m865+gfjSeKKoGjP2z+CnHzA/iSrPoU4Th iBFptiasuAHx64MWD+nAZ65nDjhgORY8B+oXMcJgEheP5Nhh/k1GzIDM1Kc7jUFopf ikJsL0CS6wZ3y/DffUmxTu3bWQ7HPrwSjCES9dDqUodh3XTdHX8MI0n3c2SeYbUVjQ jBvOQSzK2Mw2A== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BA07625DF for ; Mon, 23 Jan 2023 16:49:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ZQDhtdIc"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id fl11-20020a05600c0b8b00b003daf72fc844so10952956wmb.0 for ; Mon, 23 Jan 2023 07:49:50 -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=FhJw6of4WXMHBF4q06UQklcI9vOo0hl5yvU9EvL/D4E=; b=ZQDhtdIc866vEkbwkwlNzpOjhaKN7X29NrOraWgOTk8rZzyKGRRmkBERC2/+3ay1u8 NmryBB//kP+EWmybbEmUzSvNNzk7BCzjXwZfuRkOqs4s2wtlF5/oXHxywLHdM3oYISEp th9nahvIiYCN1ooNz0CtEah/sz0wiDGB4jEu+LfPIB36J/yOryH8kiE0R8aHGTBQjKyA lGr0JKYCPx8YM6xRbUvFnMjKP/bYNKy+MNajdyHS242mHCVyI36B7kmftzbYfvtyezvn AY/NW9XWOYy0Jn0Z8uqhfbD41J/tZsMcxq8b5wH3XmtmmW/tMp4WQZbKV48eMuYETDSP Txrg== 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=FhJw6of4WXMHBF4q06UQklcI9vOo0hl5yvU9EvL/D4E=; b=Lesuy3+Vr0F+S6wMM8sXKZvj9zGMchHZrswu6WA61NRE4uI6vjyANZgN6m7FxLgl1b OTKqAr4yzZALA8UgwOeVWoOz2Rdga0UJdy4kgU/vkB44Ef6Q4c145CjuCl5o3YXfvapb rz8ursWDyl94uGz7KO8F0OS6/FdePglMw+vGBKAxsAvPeMv1fYLBa7AP3zErU6qbAJmP Ytdib8gWeFKJAW+Ijg/fvnkr4rWQouZCGWLliHq1RYYlnstPq/LQZe5ruJ07zI+47M8G I/Gqmi+PQqd9fmfeqkm1MtJPuK8sMHBEpBSEiUnB7IIBMHxEw42gI+PBorhHKtvJgFF9 C87A== X-Gm-Message-State: AFqh2kra0uAXj1PYGjhtKJoVzjhwJhPeB42tFEQoR8PKkBdDqOryYOst TPXIgnGRu+cu8pPvii2WL4CnKpV7HqFIszG4OG0= X-Google-Smtp-Source: AMrXdXu5kgBaXm7+Uf7Kbk23I/OVchsYhhs6mdPZEAzE+CA55XbvJiYys9tveUDDF1fA8y3SgLfSHQ== X-Received: by 2002:a05:600c:3d19:b0:3db:1810:8c9e with SMTP id bh25-20020a05600c3d1900b003db18108c9emr20089281wmb.38.1674488989962; Mon, 23 Jan 2023 07:49:49 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n16-20020a05600c181000b003d1de805de5sm10339689wmp.16.2023.01.23.07.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 07:49:49 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Mon, 23 Jan 2023 15:49:24 +0000 Message-Id: <20230123154934.27803-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230123154934.27803-1-naush@raspberrypi.com> References: <20230123154934.27803-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 04/14] pipeline: ipa: raspberrypi: Validate lens controls 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 Cc: Nick Hollinghurst Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Pass the available lens controls to the IPA through the configure() function. Validate that the V4L2_CID_FOCUS_ABSOLUTE does exist. If it doesn't, log a warning message, and do not advertise focus related controls from the IPA. Signed-off-by: Naushir Patuck Reviewed-by: Nick Hollinghurst Reviewed-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 21 +++++++++++++++++++ .../pipeline/raspberrypi/raspberrypi.cpp | 3 +++ 3 files changed, 25 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 2a4821fbc0ef..bfacd1275bfb 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -38,6 +38,7 @@ struct IPAConfig { libcamera.SharedFD lsTableHandle; libcamera.ControlInfoMap sensorControls; libcamera.ControlInfoMap ispControls; + libcamera.ControlInfoMap lensControls; }; struct IPAConfigResult { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index aa18ed750370..bbf3c7dc4a69 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -131,6 +131,7 @@ private: void setMode(const IPACameraSensorInfo &sensorInfo); bool validateSensorControls(); bool validateIspControls(); + bool validateLensControls(); void queueRequest(const ControlList &controls); void returnEmbeddedBuffer(unsigned int bufferId); void prepareISP(const ISPConfig &data); @@ -155,6 +156,7 @@ private: ControlInfoMap sensorCtrls_; ControlInfoMap ispCtrls_; + ControlInfoMap lensCtrls_; bool lensPresent_; ControlList libcameraMetadata_; @@ -394,6 +396,15 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ip return -1; } + if (lensPresent_) { + lensCtrls_ = ipaConfig.lensControls; + if (!validateLensControls()) { + LOG(IPARPI, Warning) << "Lens validation failed, " + << "no lens control will be available."; + lensPresent_ = false; + } + } + maxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get(); /* Setup a metadata ControlList to output metadata. */ @@ -648,6 +659,16 @@ bool IPARPi::validateIspControls() return true; } +bool IPARPi::validateLensControls() +{ + if (lensCtrls_.find(V4L2_CID_FOCUS_ABSOLUTE) == lensCtrls_.end()) { + LOG(IPARPI, Error) << "Unable to find Lens control V4L2_CID_FOCUS_ABSOLUTE"; + return false; + } + + return true; +} + /* * Converting between enums (used in the libcamera API) and the names that * we use to identify different modes. Unfortunately, the conversion tables diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9dd36cbaea78..b0f4930c6f1b 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1615,8 +1615,11 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA std::map entityControls; ipa::RPi::IPAConfig ipaConfig; + /* \todo Move passing of ispControls and lensControls to ipa::init() */ ipaConfig.sensorControls = sensor_->controls(); ipaConfig.ispControls = isp_[Isp::Input].dev()->controls(); + if (sensor_->focusLens()) + ipaConfig.lensControls = sensor_->focusLens()->controls(); /* Always send the user transform to the IPA. */ ipaConfig.transform = static_cast(config->transform);