[libcamera-devel,3/5] android: camera_device: Add debug to stream initialization

Message ID 20200902104730.43451-4-jacopo@jmondi.org
State Accepted
Headers show
Series
  • android: camera_device: List JPEG/RAW correct resolutions
Related show

Commit Message

Jacopo Mondi Sept. 2, 2020, 10:47 a.m. UTC
Add debug printouts to the CameraDevice::initializeStreamConfigurations()
function that helps to follow the process of building the stream
configurations map.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Sept. 2, 2020, 12:58 p.m. UTC | #1
Hi Jacopo,

On 02/09/2020 11:47, Jacopo Mondi wrote:
> Add debug printouts to the CameraDevice::initializeStreamConfigurations()
> function that helps to follow the process of building the stream
> configurations map.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

I don't think these hurt, and more visibility is helpful right now.

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

> ---
>  src/android/camera_device.cpp | 26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 8a8072123961..493d6cecde72 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -363,6 +363,9 @@ int CameraDevice::initializeStreamConfigurations()
>  		const std::vector<PixelFormat> &libcameraFormats =
>  			camera3Format.libcameraFormats;
>  
> +		LOG(HAL, Debug) << "Testing Android format: "
> +				<< camera3Format.name;
> +
>  		/*
>  		 * Fixed format mapping for JPEG.
>  		 *
> @@ -375,6 +378,10 @@ int CameraDevice::initializeStreamConfigurations()
>  		 */
>  		if (androidFormat == HAL_PIXEL_FORMAT_BLOB) {
>  			formatsMap_[androidFormat] = formats::MJPEG;
> +			LOG(HAL, Debug) << "Mapped Android format: "
> +					<< camera3Format.name << " to: "
> +					<< formats::MJPEG.toString()
> +					<< " (fixed mapping)";
>  			continue;
>  		}
>  
> @@ -385,6 +392,10 @@ int CameraDevice::initializeStreamConfigurations()
>  		PixelFormat mappedFormat;
>  		for (const PixelFormat &pixelFormat : libcameraFormats) {
>  
> +			LOG(HAL, Debug) << "Testing Android format: "
> +					<< camera3Format.name << " with: "
> +					<< pixelFormat.toString();
> +
>  			/*
>  			 * The stream configuration size can be adjusted,
>  			 * not the pixel format.
> @@ -420,14 +431,27 @@ int CameraDevice::initializeStreamConfigurations()
>  		 * stream configurations map, by testing the image resolutions.
>  		 */
>  		formatsMap_[androidFormat] = mappedFormat;
> +		LOG(HAL, Debug) << "Mapped Android format: "
> +				<< camera3Format.name << " to: "
> +				<< mappedFormat.toString();
>  
>  		for (const Size &res : cameraResolutions) {
>  			cfg.pixelFormat = mappedFormat;
>  			cfg.size = res;
>  
> +			std::stringstream ss;
> +			ss << "Testing (" << res.toString() << ")["
> +			   << mappedFormat.toString() << "]: ";
> +
>  			CameraConfiguration::Status status = cameraConfig->validate();
> -			if (status != CameraConfiguration::Valid)
> +			if (status != CameraConfiguration::Valid) {
> +				ss << " not supported";
> +				LOG(HAL, Debug) << ss.str();
>  				continue;
> +			}
> +
> +			ss << " supported";
> +			LOG(HAL, Debug) << ss.str();
>  
>  			streamConfigurations_.push_back({ res, androidFormat });
>  
>

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 8a8072123961..493d6cecde72 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -363,6 +363,9 @@  int CameraDevice::initializeStreamConfigurations()
 		const std::vector<PixelFormat> &libcameraFormats =
 			camera3Format.libcameraFormats;
 
+		LOG(HAL, Debug) << "Testing Android format: "
+				<< camera3Format.name;
+
 		/*
 		 * Fixed format mapping for JPEG.
 		 *
@@ -375,6 +378,10 @@  int CameraDevice::initializeStreamConfigurations()
 		 */
 		if (androidFormat == HAL_PIXEL_FORMAT_BLOB) {
 			formatsMap_[androidFormat] = formats::MJPEG;
+			LOG(HAL, Debug) << "Mapped Android format: "
+					<< camera3Format.name << " to: "
+					<< formats::MJPEG.toString()
+					<< " (fixed mapping)";
 			continue;
 		}
 
@@ -385,6 +392,10 @@  int CameraDevice::initializeStreamConfigurations()
 		PixelFormat mappedFormat;
 		for (const PixelFormat &pixelFormat : libcameraFormats) {
 
+			LOG(HAL, Debug) << "Testing Android format: "
+					<< camera3Format.name << " with: "
+					<< pixelFormat.toString();
+
 			/*
 			 * The stream configuration size can be adjusted,
 			 * not the pixel format.
@@ -420,14 +431,27 @@  int CameraDevice::initializeStreamConfigurations()
 		 * stream configurations map, by testing the image resolutions.
 		 */
 		formatsMap_[androidFormat] = mappedFormat;
+		LOG(HAL, Debug) << "Mapped Android format: "
+				<< camera3Format.name << " to: "
+				<< mappedFormat.toString();
 
 		for (const Size &res : cameraResolutions) {
 			cfg.pixelFormat = mappedFormat;
 			cfg.size = res;
 
+			std::stringstream ss;
+			ss << "Testing (" << res.toString() << ")["
+			   << mappedFormat.toString() << "]: ";
+
 			CameraConfiguration::Status status = cameraConfig->validate();
-			if (status != CameraConfiguration::Valid)
+			if (status != CameraConfiguration::Valid) {
+				ss << " not supported";
+				LOG(HAL, Debug) << ss.str();
 				continue;
+			}
+
+			ss << " supported";
+			LOG(HAL, Debug) << ss.str();
 
 			streamConfigurations_.push_back({ res, androidFormat });