From patchwork Thu Jun 30 13:39:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16480 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 A3605C3274 for ; Thu, 30 Jun 2022 13:39:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A75F656B7; Thu, 30 Jun 2022 15:39:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656596399; bh=ppR811V+Kq0f8c46mGFUwZj89Mn6DI0vaywGAE1speA=; 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=T0l+oC+Cr683r1bwG3ftUIZFu3tghf6KOUxJaGWICt8aDeZ+A8UmRKT2gd0Zq7fMA 3o1GtWVeuI5RcEyAPWzthj1jKERA+1VH5nhV4byZcHfzEdxzkNFwuO7c+tBAZWS+6m Wik+L4w/qKIYsxo1g5jl7UzsuGxWDslLy1OXw288Rf7fwNRHRfY2UlqPwDknsh0wb3 IEj5q6THzVlVcpRocm65F6Ubxc5NIAxfol9JAb3WG2X4Eft4DnhIdUThXFXt4lBXZG MoABI+J9pLii5m7K2F9SbmybEQfVfDejQmC7Vs8fMghAL2wR3Wqiqj+CSBhJNSrcw/ sJo8BB6pWlPTA== Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 17879656A7 for ; Thu, 30 Jun 2022 15:39:53 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 7D859240005; Thu, 30 Jun 2022 13:39:50 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Jun 2022 15:39:01 +0200 Message-Id: <20220630133902.321099-23-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630133902.321099-1-jacopo@jmondi.org> References: <20220630133902.321099-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 22/23] libcamera: camera_lens: Expose libcamera control limits 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: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The CameraLens class exposes the list of V4L2 controls through the CameraLens::controls() function. Modify the implementation to expose the newly introduced LensFocusAbsolute control limits. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/libcamera/internal/camera_lens.h | 5 +++- src/libcamera/camera_lens.cpp | 33 ++++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h index 277417daffed..ea98379ecc62 100644 --- a/include/libcamera/internal/camera_lens.h +++ b/include/libcamera/internal/camera_lens.h @@ -30,7 +30,7 @@ public: const std::string &model() const { return model_; } - const ControlInfoMap &controls() const; + const ControlInfoMap &controls() const { return controls_; } protected: std::string logPrefix() const override; @@ -39,11 +39,14 @@ private: LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraLens) int validateLensDriver(); + void updateControls(); const MediaEntity *entity_; std::unique_ptr subdev_; std::string model_; + + ControlInfoMap controls_; }; } /* namespace libcamera */ diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp index b3d48199ec3b..08c2c42a9cfa 100644 --- a/src/libcamera/camera_lens.cpp +++ b/src/libcamera/camera_lens.cpp @@ -9,6 +9,7 @@ #include +#include "libcamera/internal/control_ids.h" #include "libcamera/internal/v4l2_subdevice.h" /** @@ -73,6 +74,9 @@ int CameraLens::init() return ret; model_ = subdev_->model(); + + updateControls(); + return 0; } @@ -124,6 +128,13 @@ int CameraLens::validateLensDriver() return ret; } +/** + * \fn CameraLens::controls() + * \brief Retrieve the CameraLens controls limits + * + * \return The ControlInfoMap with the CameraLens controls limits + */ + /** * \fn CameraLens::model() * \brief Retrieve the lens model name @@ -139,15 +150,21 @@ std::string CameraLens::logPrefix() const return "'" + entity_->name() + "'"; } -/** - * \fn CameraLens::controls() - * \brief Retrieve the V4L2 controls of the lens' subdev - * - * \return A map of the V4L2 controls supported by the lens' driver - */ -const ControlInfoMap &CameraLens::controls() const +void CameraLens::updateControls() { - return subdev_->controls(); + ControlInfoMap::Map controls; + + /* The lens driver has been validate, the control is there. */ + const ControlInfoMap &lensControls = subdev_->controls(); + const ControlInfo &focusAbsolute = lensControls.at(V4L2_CID_FOCUS_ABSOLUTE); + + controls[&controls::internal::draft::LensFocusAbsolute] = + ControlInfo(focusAbsolute.min().get(), + focusAbsolute.max().get(), + focusAbsolute.def().get()); + + controls_ = ControlInfoMap(std::move(controls), + controls::internal::controls); } } /* namespace libcamera */