From patchwork Thu Jan 19 10:45:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18152 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 454C4C3294 for ; Thu, 19 Jan 2023 10:46:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 758DD62601; Thu, 19 Jan 2023 11:46:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125161; bh=pCYDqWG1bzsiLjnS9Uk+VA5sJ5mMkrThp7UsBsHq4y4=; 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=r8Nb+2FULls9ikox7Xt0aG9XPZzhMOLK5TDBcoLP3ZCN4h87OVvW1PfMbbpGYhM+l fNyea9DlbNcRbnEseKuwRGnq9qHaxT42UKRMvoU98Tl0eDQ7Aq3iRJHKTw50z4Tept vPK1l+kWDEcTst0mkk8anQvKByKIGdVotqA1yQel25yCcbbYVn9a40pbG7Hz/x9drt MP31GGzUMeFvEUpIclI93bOFDsYEFjr4594CZjrB43EY9ZAoGeHSnvMV+uUSP0wodK Mj0ogimoN14XQGZHPdefJVHb7ZIQroX02ZASJWGbYJwR+MSqnSLq+SfEFgHhK88g7C ISUrDvX+ld41A== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1ABAC625E4 for ; Thu, 19 Jan 2023 11:45:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kT2iMPgk"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id q8so1143517wmo.5 for ; Thu, 19 Jan 2023 02:45:55 -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=gJvgKHIB0yXSef4zLViBaTt2sEAFd85mBvT5BPozY1Q=; b=kT2iMPgkULlfSgJT/y2xTAr0Xn6BP3vPXJp9j9od7CHhf7xo/WGXdmJnHyI+coOaxE mgHR5HEPlihGjWxwwH5A91zpnxvOccQnj7W0ikSTozLMsu7ksMmVqqh33hkiic22Lmvp nSHOXBkvK0kThwW+13DaMKhOWRsvmoK0KsujiCnMJ0CzAO3dltimQV/hLyS8zi/R9TVI 3+xJyKTIejnEPh9CRsDhfNMoIs0XEAuaIU4deR4nGYvRYq4qKC/dVitMRQ2O5ChZ6/i0 mJwXx30SMPNWXREhcLFVx6HXaOLjP6z4twAAw8Y+vRPkm49pp2H4lTcEtvRC8RdWIR7I YLQw== 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=gJvgKHIB0yXSef4zLViBaTt2sEAFd85mBvT5BPozY1Q=; b=kswHTM7195VbNS/KzelRRCoXnreDxg3QX8ZcwAH4uPnPWE5WfZ1G3ctekPsKGpybQ1 PpFHzHNhnN4E/AEDxLhwb8P42ucZwHD2Nk2o8qAD6sdvN5UIVlwesdn0V/yzYgrsj9xz lgvw7nQ3c/iuuz4LzGWuSgNOKn+YN0Hs7qZLL3ZUJj8eaE8mqhR8kBVrKBUqiB6SJ0ej pV1Lo8dU1F5ANzzEuuXC5PNSrwQ/QWlTciKFoYm70CyidtA/ngJD7h/buE3FP+Ip0O37 SY1CVKam0EC81nfagcO9AR3Dd6a3NoKVSD/EmNVEfJYTv7XmsBZyAjQWnDWYpMjqZNAQ 6vcQ== X-Gm-Message-State: AFqh2kpCFRaPuISD24TKxfm+jHFZSWKRBZrPXCKvLOiM8m0pAqT5KScl dUk5T1fyGHtQonhLB5WIIEfhEJLLf0CHh4PDfjM= X-Google-Smtp-Source: AMrXdXuUhmxcxg7d4Y2Gui9n8QfE1CtDdFI9Aun6cixMeXhPR7fsW4UL3veKc5hCsC9NK1B1dGPd4g== X-Received: by 2002:a05:600c:4256:b0:3da:1d51:ef9e with SMTP id r22-20020a05600c425600b003da1d51ef9emr9713938wmm.17.1674125154549; Thu, 19 Jan 2023 02:45:54 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:54 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:34 +0000 Message-Id: <20230119104544.9456-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 2 ++ 3 files changed, 24 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..249dedcd8c09 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1617,6 +1617,8 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA 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);