[libcamera-devel,1/2] android: camera_hal_manager: Set camera module callbacks

Message ID 20200805151437.157155-2-email@uajain.com
State Accepted
Headers show
Series
  • android: Camera hotplug support
Related show

Commit Message

Umang Jain Aug. 5, 2020, 3:14 p.m. UTC
camera_module_callbacks are invoked to inform the framework about
the events occuring module-wide. Allow to set these callbacks in
camera_hal_manager as this will be used to integration camera hotplug
support via camera_module_callbacks::camera_device_status_change in
subsequent commit.

Signed-off-by: Umang Jain <email@uajain.com>
---
 src/android/camera3_hal.cpp        | 2 +-
 src/android/camera_hal_manager.cpp | 7 +++++++
 src/android/camera_hal_manager.h   | 3 +++
 3 files changed, 11 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 5, 2020, 4:58 p.m. UTC | #1
Hi Umang,

Thank you for the patch.

On Wed, Aug 05, 2020 at 03:14:43PM +0000, Umang Jain wrote:
> camera_module_callbacks are invoked to inform the framework about
> the events occuring module-wide. Allow to set these callbacks in
> camera_hal_manager as this will be used to integration camera hotplug
> support via camera_module_callbacks::camera_device_status_change in
> subsequent commit.
> 
> Signed-off-by: Umang Jain <email@uajain.com>
> ---
>  src/android/camera3_hal.cpp        | 2 +-
>  src/android/camera_hal_manager.cpp | 7 +++++++
>  src/android/camera_hal_manager.h   | 3 +++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp
> index 716e36c..47c1aa9 100644
> --- a/src/android/camera3_hal.cpp
> +++ b/src/android/camera3_hal.cpp
> @@ -34,7 +34,7 @@ static int hal_get_camera_info(int id, struct camera_info *info)
>  
>  static int hal_set_callbacks(const camera_module_callbacks_t *callbacks)
>  {
> -	return 0;
> +	return cameraManager.setCallbacks(callbacks);
>  }
>  
>  static int hal_open_legacy(const struct hw_module_t *module, const char *id,
> diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
> index 02b6418..3ddcab5 100644
> --- a/src/android/camera_hal_manager.cpp
> +++ b/src/android/camera_hal_manager.cpp
> @@ -120,3 +120,10 @@ int CameraHalManager::getCameraInfo(unsigned int id, struct camera_info *info)
>  
>  	return 0;
>  }
> +
> +int CameraHalManager::setCallbacks(const camera_module_callbacks_t *callbacks)
> +{
> +	callbacks_ = callbacks;
> +
> +	return 0;

As this can't fail, I'd make it a void function.

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

> +}
> diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
> index 0619037..4345b1e 100644
> --- a/src/android/camera_hal_manager.h
> +++ b/src/android/camera_hal_manager.h
> @@ -10,6 +10,7 @@
>  #include <stddef.h>
>  #include <vector>
>  
> +#include <hardware/camera_common.h>
>  #include <hardware/hardware.h>
>  #include <system/camera_metadata.h>
>  
> @@ -29,10 +30,12 @@ public:
>  
>  	unsigned int numCameras() const;
>  	int getCameraInfo(unsigned int id, struct camera_info *info);
> +	int setCallbacks(const camera_module_callbacks_t *callbacks);
>  
>  private:
>  	libcamera::CameraManager *cameraManager_;
>  
> +	const camera_module_callbacks_t *callbacks_;
>  	std::vector<std::unique_ptr<CameraDevice>> cameras_;
>  };
>
Niklas Söderlund Aug. 5, 2020, 9:25 p.m. UTC | #2
Hi Umang,

Thanks for your work.

On 2020-08-05 15:14:43 +0000, Umang Jain wrote:
> camera_module_callbacks are invoked to inform the framework about
> the events occuring module-wide. Allow to set these callbacks in
> camera_hal_manager as this will be used to integration camera hotplug
> support via camera_module_callbacks::camera_device_status_change in
> subsequent commit.
> 
> Signed-off-by: Umang Jain <email@uajain.com>

With the comment pointed out by Laurent fixed,

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/android/camera3_hal.cpp        | 2 +-
>  src/android/camera_hal_manager.cpp | 7 +++++++
>  src/android/camera_hal_manager.h   | 3 +++
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp
> index 716e36c..47c1aa9 100644
> --- a/src/android/camera3_hal.cpp
> +++ b/src/android/camera3_hal.cpp
> @@ -34,7 +34,7 @@ static int hal_get_camera_info(int id, struct camera_info *info)
>  
>  static int hal_set_callbacks(const camera_module_callbacks_t *callbacks)
>  {
> -	return 0;
> +	return cameraManager.setCallbacks(callbacks);
>  }
>  
>  static int hal_open_legacy(const struct hw_module_t *module, const char *id,
> diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
> index 02b6418..3ddcab5 100644
> --- a/src/android/camera_hal_manager.cpp
> +++ b/src/android/camera_hal_manager.cpp
> @@ -120,3 +120,10 @@ int CameraHalManager::getCameraInfo(unsigned int id, struct camera_info *info)
>  
>  	return 0;
>  }
> +
> +int CameraHalManager::setCallbacks(const camera_module_callbacks_t *callbacks)
> +{
> +	callbacks_ = callbacks;
> +
> +	return 0;
> +}
> diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
> index 0619037..4345b1e 100644
> --- a/src/android/camera_hal_manager.h
> +++ b/src/android/camera_hal_manager.h
> @@ -10,6 +10,7 @@
>  #include <stddef.h>
>  #include <vector>
>  
> +#include <hardware/camera_common.h>
>  #include <hardware/hardware.h>
>  #include <system/camera_metadata.h>
>  
> @@ -29,10 +30,12 @@ public:
>  
>  	unsigned int numCameras() const;
>  	int getCameraInfo(unsigned int id, struct camera_info *info);
> +	int setCallbacks(const camera_module_callbacks_t *callbacks);
>  
>  private:
>  	libcamera::CameraManager *cameraManager_;
>  
> +	const camera_module_callbacks_t *callbacks_;
>  	std::vector<std::unique_ptr<CameraDevice>> cameras_;
>  };
>  
> -- 
> 2.26.2
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp
index 716e36c..47c1aa9 100644
--- a/src/android/camera3_hal.cpp
+++ b/src/android/camera3_hal.cpp
@@ -34,7 +34,7 @@  static int hal_get_camera_info(int id, struct camera_info *info)
 
 static int hal_set_callbacks(const camera_module_callbacks_t *callbacks)
 {
-	return 0;
+	return cameraManager.setCallbacks(callbacks);
 }
 
 static int hal_open_legacy(const struct hw_module_t *module, const char *id,
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
index 02b6418..3ddcab5 100644
--- a/src/android/camera_hal_manager.cpp
+++ b/src/android/camera_hal_manager.cpp
@@ -120,3 +120,10 @@  int CameraHalManager::getCameraInfo(unsigned int id, struct camera_info *info)
 
 	return 0;
 }
+
+int CameraHalManager::setCallbacks(const camera_module_callbacks_t *callbacks)
+{
+	callbacks_ = callbacks;
+
+	return 0;
+}
diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
index 0619037..4345b1e 100644
--- a/src/android/camera_hal_manager.h
+++ b/src/android/camera_hal_manager.h
@@ -10,6 +10,7 @@ 
 #include <stddef.h>
 #include <vector>
 
+#include <hardware/camera_common.h>
 #include <hardware/hardware.h>
 #include <system/camera_metadata.h>
 
@@ -29,10 +30,12 @@  public:
 
 	unsigned int numCameras() const;
 	int getCameraInfo(unsigned int id, struct camera_info *info);
+	int setCallbacks(const camera_module_callbacks_t *callbacks);
 
 private:
 	libcamera::CameraManager *cameraManager_;
 
+	const camera_module_callbacks_t *callbacks_;
 	std::vector<std::unique_ptr<CameraDevice>> cameras_;
 };