From patchwork Thu Jun 9 06:03:04 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: 16185 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 9D72DC3273 for ; Thu, 9 Jun 2022 06:03:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CB89665633; Thu, 9 Jun 2022 08:03:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654754596; bh=bcIxAAPp7QmJAWe6+zbVDqLDqlh/ZUg0ciwkrLulElo=; 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=jc0F4bHFzjtvuIOy3xZK8w90Lqjf1oYkCMbanIS5kqHML+8tOuFzwNlQ35EP47u9o T6e/AKVWTW4812M3mDgy3QOygg2UBlOf0C5l12Q9+PpBFOeYtTJmL+j2UYje3EefPb yleMNuh1n/L7N2V2kBS5BvYUlSz3nbwnRZla925/zZWMNx7TbRZJqxwyjMcbl8fB63 /4qRkVP7+xBkO5MijAffRNIOWC/ffcaWUmUOZSmyll2srW0f3rBlPmvDuYEuyaRwPK tBE01WPbCg2BOmHhNjQZKGntdX4k8NFWjLjYX+nlezndhl27nAmiiQ8MBxS6AItNY6 FWi1yt4NfTORA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8979465634 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="uex5CD1V"; 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 39A2580A; 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=bcIxAAPp7QmJAWe6+zbVDqLDqlh/ZUg0ciwkrLulElo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uex5CD1VLy3hAB+O9EiBO+FU/lf4PVBqT5QgSJBxUR5C41wfYchQty3JjKlHV+9hE 2Ts+RWjytGrt1kGg2ZpvMlZxoKSQ4hZazUHQz4nyrkELHj0o0E4eiNTOpqPP6Re9e6 eJLqzQmJlNaYAvkNy9tpcqHl/Oai+Epf1ccqV+d0= To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jun 2022 08:03:04 +0200 Message-Id: <20220609060306.57953-3-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 2/4] libcamera: lens: Grab the static properties at init time 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 CameraLens is created in the pipeline handler, it will offer various functions to access the lens properties. Add a call to get the static properties at init time. Signed-off-by: Jean-Michel Hautbois --- include/libcamera/internal/camera_lens.h | 4 ++++ src/libcamera/camera_lens.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h index 277417da..523a1481 100644 --- a/include/libcamera/internal/camera_lens.h +++ b/include/libcamera/internal/camera_lens.h @@ -19,6 +19,8 @@ namespace libcamera { class MediaEntity; class V4L2Subdevice; +struct CameraLensProperties; + class CameraLens : protected Loggable { public: @@ -44,6 +46,8 @@ private: std::unique_ptr subdev_; std::string model_; + + const CameraLensProperties *staticProps_; }; } /* namespace libcamera */ diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp index b3d48199..d4d44bc7 100644 --- a/src/libcamera/camera_lens.cpp +++ b/src/libcamera/camera_lens.cpp @@ -9,6 +9,7 @@ #include +#include "libcamera/internal/camera_lens_properties.h" #include "libcamera/internal/v4l2_subdevice.h" /** @@ -36,7 +37,7 @@ LOG_DEFINE_CATEGORY(CameraLens) * Once constructed the instance must be initialized with init(). */ CameraLens::CameraLens(const MediaEntity *entity) - : entity_(entity) + : entity_(entity), staticProps_(nullptr) { } @@ -73,6 +74,8 @@ int CameraLens::init() return ret; model_ = subdev_->model(); + staticProps_ = CameraLensProperties::get(model_); + return 0; } 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()) { From patchwork Thu Jun 9 06:03:06 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: 16187 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 4E291C3275 for ; Thu, 9 Jun 2022 06:03:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 888AC65642; 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=P/Bcl69wUsnsnNBY8yMyCSIbSTSZgX/mA31kq/ZiSGk=; 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=JfubH64gX4gFGnqFWbd5Rmp9zfWkwe+rfFKopBKTnbh5yDuYT3DapZeuA3ZYvhb14 Kcath3Pk4IXXf41UDvwXShcnAnpj/hVsMF7a/q5tvhw4HV48FylK+yee0TlK0F79vU iYj8r9t8vos5PZMYsY3uJK+hNLO+ZHeKonvQsl3Wh/E5pDYEkyfEJEVItijXjDW4Mc 6/BcOgRNZFnnOh9GleXzqoG14yj7e7xKUApPwSN3I//JTFftWYW8NBC/d9z4s35Hs5 k1M8HThh0T8fao9uDM/iraKxJK2HJ+MhRDc1/ZXIBu+OW5NIAxri6Y1CD5eoxboXqv a6uePfF6wcPUA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C570D65636 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="etD7DTjD"; 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 859566CF; 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=P/Bcl69wUsnsnNBY8yMyCSIbSTSZgX/mA31kq/ZiSGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=etD7DTjDqNoMPIz2kMpTXbQpiw+0d1S9xwXavvaUMl5PWp6sYW1GzUCyKaUZvfou1 fVFvP6bJf6qfhqkwlqOvPif2aygy8Ynb54ddSj7QQr5irEbzfMv6EFHhR30gBCxOhT 1swepI/lPFtgS1aPiHmbyo0qXe3WJhhSUoe7KAG0= To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jun 2022 08:03:06 +0200 Message-Id: <20220609060306.57953-5-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 4/4] libcamera: lens: Add the hyperfocale property support 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" A tuned lens may have measured its hyperfocale, which can then be used by the controls::LensPosition control. Add support for it in the camera lens properties database. Signed-off-by: Jean-Michel Hautbois --- include/libcamera/internal/camera_lens_properties.h | 1 + src/libcamera/camera_lens_properties.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/libcamera/internal/camera_lens_properties.h b/include/libcamera/internal/camera_lens_properties.h index 7424b375..13fa025c 100644 --- a/include/libcamera/internal/camera_lens_properties.h +++ b/include/libcamera/internal/camera_lens_properties.h @@ -19,6 +19,7 @@ struct CameraLensProperties { static const CameraLensProperties *get(const std::string &lens); Size lensFocusRange; + float hyperfocal; }; } /* namespace libcamera */ diff --git a/src/libcamera/camera_lens_properties.cpp b/src/libcamera/camera_lens_properties.cpp index 225546ae..7cab2704 100644 --- a/src/libcamera/camera_lens_properties.cpp +++ b/src/libcamera/camera_lens_properties.cpp @@ -35,6 +35,9 @@ LOG_DEFINE_CATEGORY(CameraLensProperties) * * \var CameraLensProperties::lensFocusRange * \brief The limits for the sensor position, stored as a min and a max. + * + * \var CameraLensProperties::hyperfocal + * \brief The hyperfocal distance measured, expressed in millimeters */ /** @@ -48,6 +51,7 @@ const CameraLensProperties *CameraLensProperties::get(const std::string &lens) static const std::map lensProps = { { "dw9714", { .lensFocusRange = { 150, 800 }, + .hyperfocal = 500, } }, };