From patchwork Thu Jun 9 06:03:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 16186 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 0003DC3274 for ; Thu, 9 Jun 2022 06:03:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3257C65640; Thu, 9 Jun 2022 08:03:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654754597; bh=2HzTEAjgjllaAMAH5YbUX47ROk1ATiZreLc76dBGlyc=; 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=L7m2SZE4bdKbNMqt8q261vSOKo4rNkr1jnM0Xx5sPSENNKjRNKcZiBxODPFcD+LNi ByGPw81pAfyQldscw3uucOF+Ue1195ZTlnR74/ZEuLAqoYow7I5tG5DWKdZfaMn8eF yDb1pb5yBoE9WZHSWnhfBVlChxKuzZsTltRRBIYZX2ZEWKvYMeZtVkBvzdLNEKkk62 6gYzXg7Io8JnHSsuTXDjOz/oJUxV1E8t/0FzqvqGopEFnCFCXQ07akFqlmNdQsf0km 2Ev6gCF+I8t4Nvq87FbV3QQiVcAyKs2miaRiH9fHB7hEhgpPMO9WElkL0MNcS76U9F UxAs3+ErzxPZA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A1E265635 for ; Thu, 9 Jun 2022 08:03:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pLVLcvc2"; dkim-atps=neutral Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:ae94:9dc3:50ea:aee6]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5FB1C9B1; Thu, 9 Jun 2022 08:03:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1654754593; bh=2HzTEAjgjllaAMAH5YbUX47ROk1ATiZreLc76dBGlyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLVLcvc2/Pv4lR0iH3+pMO/0WRcaVlJAC98LKMdFd9oOyxDrSEHjKpnYLPjc5EjBw TbJTUPz6eIIfH2yl8cogmJLC3VJ+RDX3p+St9gMitkAbf9AlT7vLVMkUNkwPbh9A/+ AFL9An/4u9nKAIKaFzQH2KfV8O+25DYQaJVrbisQ= To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jun 2022 08:03:05 +0200 Message-Id: <20220609060306.57953-4-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220609060306.57953-1-jeanmichel.hautbois@ideasonboard.com> References: <20220609060306.57953-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/4] libcamera: lens: Add a helper to get the fixed range lens values 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: Jean-Michel Hautbois via libcamera-devel From: Jean-Michel Hautbois Reply-To: Jean-Michel Hautbois Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When the focus algorithm runs, it can be asked to go to a specific position, through the controls::LensPosition control. Those controls need specific values to be known, in particular the minimum and maximum value the driver can set to the lens to make it move to a given position. Add a new helper on the camera lens side to get this range or a default nulled structure if it is not available. This particular value needs to be taken into account by the caller and it shall use the minimum and maximum reported by the driver. Signed-off-by: Jean-Michel Hautbois --- include/libcamera/internal/camera_lens.h | 1 + .../internal/camera_lens_properties.h | 2 ++ src/libcamera/camera_lens.cpp | 19 +++++++++++++++++++ src/libcamera/camera_lens_properties.cpp | 9 ++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h index 523a1481..f6daff01 100644 --- a/include/libcamera/internal/camera_lens.h +++ b/include/libcamera/internal/camera_lens.h @@ -29,6 +29,7 @@ public: int init(); int setFocusPosition(int32_t position); + const Size &getLensRange(); const std::string &model() const { return model_; } diff --git a/include/libcamera/internal/camera_lens_properties.h b/include/libcamera/internal/camera_lens_properties.h index 73982550..7424b375 100644 --- a/include/libcamera/internal/camera_lens_properties.h +++ b/include/libcamera/internal/camera_lens_properties.h @@ -17,6 +17,8 @@ namespace libcamera { struct CameraLensProperties { static const CameraLensProperties *get(const std::string &lens); + + Size lensFocusRange; }; } /* namespace libcamera */ diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp index d4d44bc7..abec5a27 100644 --- a/src/libcamera/camera_lens.cpp +++ b/src/libcamera/camera_lens.cpp @@ -79,6 +79,25 @@ int CameraLens::init() return 0; } +/** + * \brief Retrieve the lens position range + * \return The minimum and maximum positions for the given lens or a default + * nulled Size reference + * + * If a lens has no static properties associated, a special value is returned, + * where the minimum and maximum are set to 0. The caller may then chose the + * ones returned by the V4L2_CID_FOCUS_ABSOLUTE call. + */ +const Size &CameraLens::getLensRange() +{ + static const Size defaultLensFocusRange = { 0, 0 }; + if (!staticProps_ || staticProps_->lensFocusRange.isNull()) + return defaultLensFocusRange; + + return staticProps_->lensFocusRange; +} + + /** * \brief This function sets the focal point of the lens to a specific position. * \param[in] position The focal point of the lens diff --git a/src/libcamera/camera_lens_properties.cpp b/src/libcamera/camera_lens_properties.cpp index dee73b43..225546ae 100644 --- a/src/libcamera/camera_lens_properties.cpp +++ b/src/libcamera/camera_lens_properties.cpp @@ -32,6 +32,9 @@ LOG_DEFINE_CATEGORY(CameraLensProperties) /** * \struct CameraLensProperties * \brief Database of camera lens properties + * + * \var CameraLensProperties::lensFocusRange + * \brief The limits for the sensor position, stored as a min and a max. */ /** @@ -42,7 +45,11 @@ LOG_DEFINE_CATEGORY(CameraLensProperties) */ const CameraLensProperties *CameraLensProperties::get(const std::string &lens) { - static const std::map lensProps = {}; + static const std::map lensProps = { + { "dw9714", { + .lensFocusRange = { 150, 800 }, + } }, + }; const auto it = lensProps.find(lens); if (it == lensProps.end()) {