[libcamera-devel,RFC,08/14] android: Plumb AwbMode control
diff mbox series

Message ID 20210618103351.1642060-9-paul.elder@ideasonboard.com
State Superseded
Delegated to: Paul Elder
Headers show
Series
  • Preliminary FULL plumbing
Related show

Commit Message

Paul Elder June 18, 2021, 10:33 a.m. UTC
Plumb the AwbMode control into the HAL for
CONTROL_AWB_AVAILABLE_MODES for static metadata.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=44
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
TODO: plumb result metadata
---
 src/android/camera_device.cpp | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

Comments

Laurent Pinchart June 28, 2021, 1:42 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, Jun 18, 2021 at 07:33:45PM +0900, Paul Elder wrote:
> Plumb the AwbMode control into the HAL for
> CONTROL_AWB_AVAILABLE_MODES for static metadata.
> 
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=44
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> TODO: plumb result metadata

Same comment as for 07/14.

> ---
>  src/android/camera_device.cpp | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 3add5bc6..a8b6fa38 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -985,15 +985,25 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  	staticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
>  				  availableStabilizationModes);
>  
> -	/*
> -	 * \todo Inspect the Camera capabilities to report the available
> -	 * AWB modes. Default to AUTO as CTS tests require it.
> -	 */
> -	std::vector<uint8_t> availableAwbModes = {
> -		ANDROID_CONTROL_AWB_MODE_AUTO,
> -	};
> +	std::vector<uint8_t> awbAvailableModes;
> +	awbAvailableModes.reserve(2);
> +	const auto &awbModesInfo = controlsInfo.find(&controls::AwbMode);
> +	if (awbModesInfo != controlsInfo.end()) {
> +		for (const auto &value : awbModesInfo->second.values())
> +			awbAvailableModes.push_back(value.get<int32_t>());
> +	} else {
> +		awbAvailableModes.push_back(ANDROID_CONTROL_AWB_MODE_AUTO);
> +	}
> +
> +	if (std::find(awbAvailableModes.begin(),
> +		      awbAvailableModes.end(),
> +		      ANDROID_CONTROL_AWB_MODE_OFF) == awbAvailableModes.end()) {
> +		fullSupport = false;
> +		/* \todo Double check if this is the correct capability */
> +		capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING] = false;

It's not explicitly mentioned in the documentation, but the manual
post-processing capability requires supporting
android.colorCorrection.gains, which is only taken into account when AWB
is OFF, so this makes sense.

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

> +	}
>  	staticMetadata_->addEntry(ANDROID_CONTROL_AWB_AVAILABLE_MODES,
> -				  availableAwbModes);
> +				  awbAvailableModes);
>  
>  	std::vector<int32_t> availableMaxRegions = {
>  		0, 0, 0,

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 3add5bc6..a8b6fa38 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -985,15 +985,25 @@  const camera_metadata_t *CameraDevice::getStaticMetadata()
 	staticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
 				  availableStabilizationModes);
 
-	/*
-	 * \todo Inspect the Camera capabilities to report the available
-	 * AWB modes. Default to AUTO as CTS tests require it.
-	 */
-	std::vector<uint8_t> availableAwbModes = {
-		ANDROID_CONTROL_AWB_MODE_AUTO,
-	};
+	std::vector<uint8_t> awbAvailableModes;
+	awbAvailableModes.reserve(2);
+	const auto &awbModesInfo = controlsInfo.find(&controls::AwbMode);
+	if (awbModesInfo != controlsInfo.end()) {
+		for (const auto &value : awbModesInfo->second.values())
+			awbAvailableModes.push_back(value.get<int32_t>());
+	} else {
+		awbAvailableModes.push_back(ANDROID_CONTROL_AWB_MODE_AUTO);
+	}
+
+	if (std::find(awbAvailableModes.begin(),
+		      awbAvailableModes.end(),
+		      ANDROID_CONTROL_AWB_MODE_OFF) == awbAvailableModes.end()) {
+		fullSupport = false;
+		/* \todo Double check if this is the correct capability */
+		capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING] = false;
+	}
 	staticMetadata_->addEntry(ANDROID_CONTROL_AWB_AVAILABLE_MODES,
-				  availableAwbModes);
+				  awbAvailableModes);
 
 	std::vector<int32_t> availableMaxRegions = {
 		0, 0, 0,