[libcamera-devel] [PATCH 08/10] libcamera: ipu3: Implement camera start/stop

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Mar 2 23:59:35 CET 2019


Hi Jacopo,

Thank you for the patch.

On Thu, Feb 28, 2019 at 09:04:08PM +0100, Jacopo Mondi wrote:
> Start and stop all video devices in the pipeline.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 57 ++++++++++++++++++++++++----
>  1 file changed, 49 insertions(+), 8 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 8ce661e27f62..b9bc992879f5 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -146,6 +146,8 @@ private:
>  	void registerCameras();
>  
>  	int releaseBuffers(V4L2Device *dev);
> +	int startDevice(V4L2Device *dev);
> +	int stopDevice(V4L2Device *dev);
>  
>  	ImguDevice imgu0_;
>  	ImguDevice imgu1_;
> @@ -410,14 +412,27 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)
>  int PipelineHandlerIPU3::start(const Camera *camera)
>  {
>  	IPU3CameraData *data = cameraData(camera);
> -	V4L2Device *cio2 = data->cio2.output;
>  	int ret;
>  
> -	ret = cio2->streamOn();
> -	if (ret) {
> -		LOG(IPU3, Info) << "Failed to start camera " << camera->name();
> +	ret = startDevice(data->imgu->output);
> +	if (ret)
> +		return ret;
> +
> +	ret = startDevice(data->imgu->viewfinder);
> +	if (ret)
> +		return ret;
> +
> +	ret = startDevice(data->imgu->stat);
> +	if (ret)
> +		return ret;
> +
> +	ret = startDevice(data->imgu->input);
> +	if (ret)
> +		return ret;
> +
> +	ret = startDevice(data->cio2.output);
> +	if (ret)
>  		return ret;
> -	}

Don't you need to clean up and stop the nodes that have been started ?
calling stop() might be all you need.

>  
>  	return 0;
>  }
> @@ -425,10 +440,12 @@ int PipelineHandlerIPU3::start(const Camera *camera)
>  void PipelineHandlerIPU3::stop(const Camera *camera)
>  {
>  	IPU3CameraData *data = cameraData(camera);
> -	V4L2Device *cio2 = data->cio2.output;
>  
> -	if (cio2->streamOff())
> -		LOG(IPU3, Info) << "Failed to stop camera " << camera->name();
> +	stopDevice(data->imgu->output);
> +	stopDevice(data->imgu->viewfinder);
> +	stopDevice(data->imgu->stat);
> +	stopDevice(data->imgu->input);
> +	stopDevice(data->cio2.output);

How about accummulating errors and printing one message at the end with
the number of nodes that failed to stop (if any) ?

>  }
>  
>  int PipelineHandlerIPU3::queueRequest(const Camera *camera, Request *request)
> @@ -934,6 +951,30 @@ int PipelineHandlerIPU3::releaseBuffers(V4L2Device *dev)
>  	return 0;
>  }
>  
> +int PipelineHandlerIPU3::startDevice(V4L2Device *dev)
> +{
> +	int ret = dev->streamOn();
> +	if (ret) {
> +		LOG(IPU3, Info)
> +			<< "Failed to start video device:" << dev->deviceNode();
> +		return ret;

The error message is already printed by the V4L2Device class, lets drop
these two methods.

> +	}
> +
> +	return 0;
> +}
> +
> +int PipelineHandlerIPU3::stopDevice(V4L2Device *dev)
> +{
> +	int ret = dev->streamOff();
> +	if (ret) {
> +		LOG(IPU3, Info)
> +			<< "Failed to stop video device:" << dev->deviceNode();
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3);
>  
>  } /* namespace libcamera */

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list