[libcamera-devel,v7,5/5] ipu3: ipa: Allow IPA to apply controls to the lens device
diff mbox series

Message ID 20211202140317.3118364-6-hanlinchen@chromium.org
State Accepted
Headers show
Series
  • Introduce Lens class and apply auto focus on ipu3
Related show

Commit Message

Hanlin Chen Dec. 2, 2021, 2:03 p.m. UTC
Allow IPA to apply controls to the lens device.

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Umang Jain Dec. 2, 2021, 5:26 p.m. UTC | #1
Hi,

On 12/2/21 7:33 PM, Han-Lin Chen wrote:
> Allow IPA to apply controls to the lens device.
>
> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   src/libcamera/pipeline/ipu3/ipu3.cpp | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index c65afdb2..d26c8a2e 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -24,6 +24,7 @@
>   #include <libcamera/stream.h>
>   
>   #include "libcamera/internal/camera.h"
> +#include "libcamera/internal/camera_lens.h"
>   #include "libcamera/internal/camera_sensor.h"
>   #include "libcamera/internal/delayed_controls.h"
>   #include "libcamera/internal/device_enumerator.h"
> @@ -1238,8 +1239,16 @@ void IPU3CameraData::queueFrameAction(unsigned int id,
>   {
>   	switch (action.op) {
>   	case ipa::ipu3::ActionSetSensorControls: {
> -		const ControlList &controls = action.sensorControls;
> -		delayedCtrls_->push(controls);
> +		const ControlList &sensorControls = action.sensorControls;
> +		delayedCtrls_->push(sensorControls);
> +
> +		const ControlList lensControls = action.lensControls;
> +		const ControlValue &focusValue =
> +			lensControls.get(V4L2_CID_FOCUS_ABSOLUTE);
> +
> +		CameraLens *lens = cio2_.sensor()->lens();
> +		if (lens && !focusValue.isNone())
> +			lens->setFocusPostion(focusValue.get<int32_t>());
>   		break;
>   	}
>   	case ipa::ipu3::ActionParamFilled: {
Laurent Pinchart Dec. 3, 2021, 12:56 a.m. UTC | #2
Hi Han-lin,

Thank you for the patch.

On Thu, Dec 02, 2021 at 10:03:17PM +0800, Han-Lin Chen wrote:
> Allow IPA to apply controls to the lens device.
> 
> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index c65afdb2..d26c8a2e 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -24,6 +24,7 @@
>  #include <libcamera/stream.h>
>  
>  #include "libcamera/internal/camera.h"
> +#include "libcamera/internal/camera_lens.h"
>  #include "libcamera/internal/camera_sensor.h"
>  #include "libcamera/internal/delayed_controls.h"
>  #include "libcamera/internal/device_enumerator.h"
> @@ -1238,8 +1239,16 @@ void IPU3CameraData::queueFrameAction(unsigned int id,
>  {
>  	switch (action.op) {
>  	case ipa::ipu3::ActionSetSensorControls: {
> -		const ControlList &controls = action.sensorControls;
> -		delayedCtrls_->push(controls);
> +		const ControlList &sensorControls = action.sensorControls;
> +		delayedCtrls_->push(sensorControls);
> +
> +		const ControlList lensControls = action.lensControls;
> +		const ControlValue &focusValue =
> +			lensControls.get(V4L2_CID_FOCUS_ABSOLUTE);
> +
> +		CameraLens *lens = cio2_.sensor()->lens();
> +		if (lens && !focusValue.isNone())
> +			lens->setFocusPostion(focusValue.get<int32_t>());
>  		break;
>  	}
>  	case ipa::ipu3::ActionParamFilled: {

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index c65afdb2..d26c8a2e 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -24,6 +24,7 @@ 
 #include <libcamera/stream.h>
 
 #include "libcamera/internal/camera.h"
+#include "libcamera/internal/camera_lens.h"
 #include "libcamera/internal/camera_sensor.h"
 #include "libcamera/internal/delayed_controls.h"
 #include "libcamera/internal/device_enumerator.h"
@@ -1238,8 +1239,16 @@  void IPU3CameraData::queueFrameAction(unsigned int id,
 {
 	switch (action.op) {
 	case ipa::ipu3::ActionSetSensorControls: {
-		const ControlList &controls = action.sensorControls;
-		delayedCtrls_->push(controls);
+		const ControlList &sensorControls = action.sensorControls;
+		delayedCtrls_->push(sensorControls);
+
+		const ControlList lensControls = action.lensControls;
+		const ControlValue &focusValue =
+			lensControls.get(V4L2_CID_FOCUS_ABSOLUTE);
+
+		CameraLens *lens = cio2_.sensor()->lens();
+		if (lens && !focusValue.isNone())
+			lens->setFocusPostion(focusValue.get<int32_t>());
 		break;
 	}
 	case ipa::ipu3::ActionParamFilled: {