[libcamera-devel,v5,5/6] libcamera: ipu3: Set pipe_mode based on stream configuration

Message ID 20190620153144.5394-6-jacopo@jmondi.org
State Superseded
Headers show
Series
  • Add support for V4L2 controls
Related show

Commit Message

Jacopo Mondi June 20, 2019, 3:31 p.m. UTC
Set the ImgU pipe_mode control based on the active stream configuration.
Use 'Video' pipe mode unless the viewfinder stream is not active.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Laurent Pinchart June 22, 2019, 8:30 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Thu, Jun 20, 2019 at 05:31:43PM +0200, Jacopo Mondi wrote:
> Set the ImgU pipe_mode control based on the active stream configuration.
> Use 'Video' pipe mode unless the viewfinder stream is not active.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 1c0a9825b4cd..54a6735dfc87 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -22,6 +22,7 @@
>  #include "media_device.h"
>  #include "pipeline_handler.h"
>  #include "utils.h"
> +#include "v4l2_controls.h"
>  #include "v4l2_subdevice.h"
>  #include "v4l2_videodevice.h"
>  
> @@ -194,6 +195,12 @@ private:
>  class PipelineHandlerIPU3 : public PipelineHandler
>  {
>  public:
> +	static constexpr unsigned int V4L2_CID_IPU3_PIPE_MODE = 0x009819c1;
> +	enum IPU3PipeModes {
> +		IPU3PipeModeVideo = 0,
> +		IPU3PipeModeStillCapture = 1,
> +	};
> +
>  	PipelineHandlerIPU3(CameraManager *manager);
>  
>  	CameraConfiguration *generateConfiguration(Camera *camera,
> @@ -559,6 +566,17 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
>  	if (ret)
>  		return ret;
>  
> +	/* Apply the "pipe_mode" control to the ImgU subdevice. */
> +	V4L2Controls ctrls;
> +	ctrls.add(V4L2_CID_IPU3_PIPE_MODE, vfStream->active_ ?
> +		       			   IPU3PipeModeVideo :
> +					   IPU3PipeModeStillCapture);
> +	ret = imgu->imgu_->setControls(&ctrls);
> +	if (ret) {
> +		LOG(IPU3, Error) << "Unable to set pipe_mode control";
> +		return ret;
> +	}
> +
>  	return 0;
>  }
>
Kieran Bingham June 24, 2019, 8:40 a.m. UTC | #2
Hi Jacopo,

On 20/06/2019 16:31, Jacopo Mondi wrote:
> Set the ImgU pipe_mode control based on the active stream configuration.
> Use 'Video' pipe mode unless the viewfinder stream is not active.
> 

Thanks for adding in the "enum IPU3PipeModes".

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 1c0a9825b4cd..54a6735dfc87 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -22,6 +22,7 @@
>  #include "media_device.h"
>  #include "pipeline_handler.h"
>  #include "utils.h"
> +#include "v4l2_controls.h"
>  #include "v4l2_subdevice.h"
>  #include "v4l2_videodevice.h"
>  
> @@ -194,6 +195,12 @@ private:
>  class PipelineHandlerIPU3 : public PipelineHandler
>  {
>  public:
> +	static constexpr unsigned int V4L2_CID_IPU3_PIPE_MODE = 0x009819c1;
> +	enum IPU3PipeModes {
> +		IPU3PipeModeVideo = 0,
> +		IPU3PipeModeStillCapture = 1,
> +	};
> +
>  	PipelineHandlerIPU3(CameraManager *manager);
>  
>  	CameraConfiguration *generateConfiguration(Camera *camera,
> @@ -559,6 +566,17 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
>  	if (ret)
>  		return ret;
>  
> +	/* Apply the "pipe_mode" control to the ImgU subdevice. */
> +	V4L2Controls ctrls;
> +	ctrls.add(V4L2_CID_IPU3_PIPE_MODE, vfStream->active_ ?
> +		       			   IPU3PipeModeVideo :
> +					   IPU3PipeModeStillCapture);
> +	ret = imgu->imgu_->setControls(&ctrls);
> +	if (ret) {
> +		LOG(IPU3, Error) << "Unable to set pipe_mode control";
> +		return ret;
> +	}
> +
>  	return 0;
>  }
>  
>

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 1c0a9825b4cd..54a6735dfc87 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -22,6 +22,7 @@ 
 #include "media_device.h"
 #include "pipeline_handler.h"
 #include "utils.h"
+#include "v4l2_controls.h"
 #include "v4l2_subdevice.h"
 #include "v4l2_videodevice.h"
 
@@ -194,6 +195,12 @@  private:
 class PipelineHandlerIPU3 : public PipelineHandler
 {
 public:
+	static constexpr unsigned int V4L2_CID_IPU3_PIPE_MODE = 0x009819c1;
+	enum IPU3PipeModes {
+		IPU3PipeModeVideo = 0,
+		IPU3PipeModeStillCapture = 1,
+	};
+
 	PipelineHandlerIPU3(CameraManager *manager);
 
 	CameraConfiguration *generateConfiguration(Camera *camera,
@@ -559,6 +566,17 @@  int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
 	if (ret)
 		return ret;
 
+	/* Apply the "pipe_mode" control to the ImgU subdevice. */
+	V4L2Controls ctrls;
+	ctrls.add(V4L2_CID_IPU3_PIPE_MODE, vfStream->active_ ?
+		       			   IPU3PipeModeVideo :
+					   IPU3PipeModeStillCapture);
+	ret = imgu->imgu_->setControls(&ctrls);
+	if (ret) {
+		LOG(IPU3, Error) << "Unable to set pipe_mode control";
+		return ret;
+	}
+
 	return 0;
 }