[libcamera-devel,v5,02/10] ipa: rkisp1: Add lens limits to the session config
diff mbox series

Message ID 20230324142908.64224-3-dse@thaumatec.com
State Superseded
Headers show
Series
  • ipa: rkisp1: Add autofocus algorithm
Related show

Commit Message

Daniel Semkowicz March 24, 2023, 2:29 p.m. UTC
Add information about focus lens position limits to the IPA session
configuration. These information can then be used by IPA algorithms
to know which focus positions are valid.

Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
---
 src/ipa/rkisp1/ipa_context.cpp | 12 ++++++++++++
 src/ipa/rkisp1/ipa_context.h   |  5 +++++
 src/ipa/rkisp1/rkisp1.cpp      | 13 ++++++++++++-
 3 files changed, 29 insertions(+), 1 deletion(-)

Comments

Jacopo Mondi March 24, 2023, 2:56 p.m. UTC | #1
Hi Daniel

On Fri, Mar 24, 2023 at 03:29:00PM +0100, Daniel Semkowicz via libcamera-devel wrote:
> Add information about focus lens position limits to the IPA session
> configuration. These information can then be used by IPA algorithms
> to know which focus positions are valid.
>
> Signed-off-by: Daniel Semkowicz <dse@thaumatec.com>
> ---
>  src/ipa/rkisp1/ipa_context.cpp | 12 ++++++++++++
>  src/ipa/rkisp1/ipa_context.h   |  5 +++++
>  src/ipa/rkisp1/rkisp1.cpp      | 13 ++++++++++++-
>  3 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp
> index 9bbf3684..401c098f 100644
> --- a/src/ipa/rkisp1/ipa_context.cpp
> +++ b/src/ipa/rkisp1/ipa_context.cpp
> @@ -89,6 +89,18 @@ namespace libcamera::ipa::rkisp1 {
>   * \brief Sensor output resolution
>   */
>
> +/**
> + * \var IPASessionConfiguration::lens
> + * \brief Lens-specific information
> + *
> + * \var IPASessionConfiguration::lens.minFocusPosition
> + * \brief Minimum position supported by the camera focus lens
> + *
> + * \var IPASessionConfiguration::lens.maxFocusPosition
> + * \brief Maximum position supported by the camera focus lens
> + *
> + */
> +
>  /**
>   * \var IPASessionConfiguration::raw
>   * \brief Indicates if the camera is configured to capture raw frames
> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
> index b9b20653..bfb6e1b7 100644
> --- a/src/ipa/rkisp1/ipa_context.h
> +++ b/src/ipa/rkisp1/ipa_context.h
> @@ -45,6 +45,11 @@ struct IPASessionConfiguration {
>  		Size size;
>  	} sensor;
>
> +	struct {
> +		int32_t minFocusPosition;
> +		int32_t maxFocusPosition;
> +	} lens;
> +
>  	struct {
>  		rkisp1_cif_isp_version revision;
>  	} hw;
> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
> index 248cf5e0..cd1fbae3 100644
> --- a/src/ipa/rkisp1/rkisp1.cpp
> +++ b/src/ipa/rkisp1/rkisp1.cpp
> @@ -267,9 +267,20 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,
>  			return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW;
>  		});
>
> -	if (!ipaConfig.lensControls.empty())
> +	if (!ipaConfig.lensControls.empty()) {
>  		lensControls_ = ipaConfig.lensControls;
>
> +		const ControlInfo focusAbsolute =

This could be a reference

> +			lensControls_->find(V4L2_CID_FOCUS_ABSOLUTE)->second;
> +
> +		LOG(IPARkISP1, Debug)
> +			<< "Focus lens: " << focusAbsolute.toString();
> +
> +		auto &lensConfig = context_.configuration.lens;
> +		lensConfig.minFocusPosition = focusAbsolute.min().get<int32_t>();
> +		lensConfig.maxFocusPosition = focusAbsolute.max().get<int32_t>();
> +	}
> +

The rest looks good and I can fix when applying
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

>  	for (auto const &a : algorithms()) {
>  		Algorithm *algo = static_cast<Algorithm *>(a.get());
>
> --
> 2.39.2
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp
index 9bbf3684..401c098f 100644
--- a/src/ipa/rkisp1/ipa_context.cpp
+++ b/src/ipa/rkisp1/ipa_context.cpp
@@ -89,6 +89,18 @@  namespace libcamera::ipa::rkisp1 {
  * \brief Sensor output resolution
  */
 
+/**
+ * \var IPASessionConfiguration::lens
+ * \brief Lens-specific information
+ *
+ * \var IPASessionConfiguration::lens.minFocusPosition
+ * \brief Minimum position supported by the camera focus lens
+ *
+ * \var IPASessionConfiguration::lens.maxFocusPosition
+ * \brief Maximum position supported by the camera focus lens
+ *
+ */
+
 /**
  * \var IPASessionConfiguration::raw
  * \brief Indicates if the camera is configured to capture raw frames
diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
index b9b20653..bfb6e1b7 100644
--- a/src/ipa/rkisp1/ipa_context.h
+++ b/src/ipa/rkisp1/ipa_context.h
@@ -45,6 +45,11 @@  struct IPASessionConfiguration {
 		Size size;
 	} sensor;
 
+	struct {
+		int32_t minFocusPosition;
+		int32_t maxFocusPosition;
+	} lens;
+
 	struct {
 		rkisp1_cif_isp_version revision;
 	} hw;
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 248cf5e0..cd1fbae3 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -267,9 +267,20 @@  int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,
 			return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW;
 		});
 
-	if (!ipaConfig.lensControls.empty())
+	if (!ipaConfig.lensControls.empty()) {
 		lensControls_ = ipaConfig.lensControls;
 
+		const ControlInfo focusAbsolute =
+			lensControls_->find(V4L2_CID_FOCUS_ABSOLUTE)->second;
+
+		LOG(IPARkISP1, Debug)
+			<< "Focus lens: " << focusAbsolute.toString();
+
+		auto &lensConfig = context_.configuration.lens;
+		lensConfig.minFocusPosition = focusAbsolute.min().get<int32_t>();
+		lensConfig.maxFocusPosition = focusAbsolute.max().get<int32_t>();
+	}
+
 	for (auto const &a : algorithms()) {
 		Algorithm *algo = static_cast<Algorithm *>(a.get());