[libcamera-devel,v3,13/22] libcamera: pipeline_handler: Fatal if registering camera without media devices

Message ID 20200704133140.1738660-14-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Clean up formats in v4l2-compat and pipeline handlers
Related show

Commit Message

Paul Elder July 4, 2020, 1:31 p.m. UTC
Pipeline handlers must acquire media devices via
PipelineHander::acquireMediaDevice so that the media devices can be
registered with the pipeline handler, so that they can be automatically
added to the devnum map for the v4l2 compatibility layer to use. Die
fatally if any camera trying to be registered has not acquired any media
devices via acquireMediaDevice.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
No change in v3
---
 src/libcamera/pipeline_handler.cpp | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Laurent Pinchart July 4, 2020, 9:21 p.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Sat, Jul 04, 2020 at 10:31:31PM +0900, Paul Elder wrote:
> Pipeline handlers must acquire media devices via
> PipelineHander::acquireMediaDevice so that the media devices can be
> registered with the pipeline handler, so that they can be automatically
> added to the devnum map for the v4l2 compatibility layer to use. Die
> fatally if any camera trying to be registered has not acquired any media
> devices via acquireMediaDevice.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> No change in v3
> ---
>  src/libcamera/pipeline_handler.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> index de5ca09..8a6c9c2 100644
> --- a/src/libcamera/pipeline_handler.cpp
> +++ b/src/libcamera/pipeline_handler.cpp
> @@ -496,6 +496,10 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera,
>  	cameraData_[camera.get()] = std::move(data);
>  	cameras_.push_back(camera);
>  
> +	if (!mediaDevices_.size())

	if (mediaDevices_.empty())

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

> +		LOG(Pipeline, Fatal)
> +			<< "Registering camera with no media devices!";
> +
>  	/*
>  	 * Walk the entity list and map the devnums of all capture video nodes
>  	 * to the camera.

Patch

diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index de5ca09..8a6c9c2 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -496,6 +496,10 @@  void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera,
 	cameraData_[camera.get()] = std::move(data);
 	cameras_.push_back(camera);
 
+	if (!mediaDevices_.size())
+		LOG(Pipeline, Fatal)
+			<< "Registering camera with no media devices!";
+
 	/*
 	 * Walk the entity list and map the devnums of all capture video nodes
 	 * to the camera.