[libcamera-devel,v2,1/5] libcamera: camera_manager: Refactor device enumeration into separate function

Message ID 20200513172950.72685-2-email@uajain.com
State Superseded
Delegated to: Umang Jain
Headers show
Series
  • Introduce UVC hotplug support
Related show

Commit Message

Umang Jain May 13, 2020, 5:29 p.m. UTC
This commit introduces no functional changes.
Split device enumeration code into a separate function,
so that the function can be re-used for upcoming hotplug
functionality in subsequent commits.

Also, fixup correct tag for \todo.

Signed-off-by: Umang Jain <email@uajain.com>
---
 src/libcamera/camera_manager.cpp | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Kieran Bingham May 18, 2020, 3:35 p.m. UTC | #1
Hi Umang,

On 13/05/2020 18:29, Umang Jain wrote:
> This commit introduces no functional changes.
> Split device enumeration code into a separate function,
> so that the function can be re-used for upcoming hotplug
> functionality in subsequent commits.
> 
> Also, fixup correct tag for \todo.

With three fixups I 'might' have moved this to it's own patch - but it's
really minimal and not a problem I don't think.

> 
> Signed-off-by: Umang Jain <email@uajain.com>
> ---
>  src/libcamera/camera_manager.cpp | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> index fddf734..1579ad4 100644
> --- a/src/libcamera/camera_manager.cpp
> +++ b/src/libcamera/camera_manager.cpp
> @@ -53,6 +53,7 @@ protected:
>  
>  private:
>  	int init();
> +	void enumerateDevices();
>  	void cleanup();
>  
>  	CameraManager *cm_;
> @@ -121,11 +122,20 @@ int CameraManager::Private::init()
>  		return -ENODEV;
>  
>  	/*
> -	 * TODO: Try to read handlers and order from configuration
> +	 * \todo Try to read handlers and order from configuration
>  	 * file and only fallback on all handlers if there is no
>  	 * configuration file.
>  	 */
> -	std::vector<PipelineHandlerFactory *> &factories = PipelineHandlerFactory::factories();

The \todo comment above hugs this line. Shouldn't it move to
CameraManager::Private::enumerateDevices() with the factories variable?


> +
> +	enumerateDevices();
> +
> +	return 0;
> +}
> +
> +void CameraManager::Private::enumerateDevices()
> +{
> +	std::vector<PipelineHandlerFactory *> &factories =
> +		PipelineHandlerFactory::factories();
>  
>  	for (PipelineHandlerFactory *factory : factories) {
>  		/*
> @@ -144,14 +154,12 @@ int CameraManager::Private::init()
>  		}
>  	}
>  
> -	/* TODO: register hot-plug callback here */
> -
> -	return 0;
> +	/* \todo register hot-plug callback here */
>  }
>  
>  void CameraManager::Private::cleanup()
>  {
> -	/* TODO: unregister hot-plug callback here */
> +	/* \todo unregister hot-plug callback here */
>  
>  	/*
>  	 * Release all references to cameras and pipeline handlers to ensure
>

Patch

diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index fddf734..1579ad4 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -53,6 +53,7 @@  protected:
 
 private:
 	int init();
+	void enumerateDevices();
 	void cleanup();
 
 	CameraManager *cm_;
@@ -121,11 +122,20 @@  int CameraManager::Private::init()
 		return -ENODEV;
 
 	/*
-	 * TODO: Try to read handlers and order from configuration
+	 * \todo Try to read handlers and order from configuration
 	 * file and only fallback on all handlers if there is no
 	 * configuration file.
 	 */
-	std::vector<PipelineHandlerFactory *> &factories = PipelineHandlerFactory::factories();
+
+	enumerateDevices();
+
+	return 0;
+}
+
+void CameraManager::Private::enumerateDevices()
+{
+	std::vector<PipelineHandlerFactory *> &factories =
+		PipelineHandlerFactory::factories();
 
 	for (PipelineHandlerFactory *factory : factories) {
 		/*
@@ -144,14 +154,12 @@  int CameraManager::Private::init()
 		}
 	}
 
-	/* TODO: register hot-plug callback here */
-
-	return 0;
+	/* \todo register hot-plug callback here */
 }
 
 void CameraManager::Private::cleanup()
 {
-	/* TODO: unregister hot-plug callback here */
+	/* \todo unregister hot-plug callback here */
 
 	/*
 	 * Release all references to cameras and pipeline handlers to ensure