[libcamera-devel,09/10] android: camera_device: Handle COLOR_CORRECTION_ABERRATION_MODE
diff mbox series

Message ID 20201009122101.73858-10-jacopo@jmondi.org
State Accepted
Headers show
Series
  • android: Introduce draft controls
Related show

Commit Message

Jacopo Mondi Oct. 9, 2020, 12:21 p.m. UTC
Register the ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES
static metadata property inspecting the values retuned by the pipeline
handler through the properties::draft::AvailableNoiseReductionModes
libcamera property.

Reserve in the static metadata pack enough space to support all the 3
available color correction aberration modes Android defines.

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

Comments

Kieran Bingham Oct. 9, 2020, 12:50 p.m. UTC | #1
Hi Jacopo,

On 09/10/2020 13:21, Jacopo Mondi wrote:
> Register the ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES
> static metadata property inspecting the values retuned by the pipeline
> handler through the properties::draft::AvailableNoiseReductionModes

Noise reduction? or Color Correction...

> libcamera property.
> 
> Reserve in the static metadata pack enough space to support all the 3
> available color correction aberration modes Android defines.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/android/camera_device.cpp | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 39d8218a67e5..172676f98059 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -538,7 +538,7 @@ std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()
>  	 * Currently: 51 entries, 687 bytes of static metadata
>  	 */
>  	uint32_t numEntries = 51;
> -	uint32_t byteSize = 691;
> +	uint32_t byteSize = 693;

3 available color correction ...

691 (which will now be 692 from the previous patch?)

692 + 3 = 695 perhaps?

Maybe I need to try again to automate this part :-(

With those minors fixed up

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

>  
>  	/*
>  	 * Calculate space occupation in bytes for dynamically built metadata
> @@ -580,12 +580,18 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  	const ControlList &cameraProperties = camera_->properties();
>  
>  	/* Color correction static metadata. */
> -	std::vector<uint8_t> aberrationModes = {
> -		ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF,
> -	};
> -	staticMetadata_->addEntry(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
> -				  aberrationModes.data(),
> -				  aberrationModes.size());
> +	if (cameraProperties.contains(properties::draft::AvailableColorCorrectionAberrationModes)) {
> +		Span<const int32_t> pipelineAberrationModes =
> +			cameraProperties.get<Span<const int32_t>>
> +			(properties::draft::AvailableColorCorrectionAberrationModes);
> +
> +		std::vector<uint8_t> aberrationModes;
> +		for (int32_t mode : pipelineAberrationModes)
> +			aberrationModes.push_back(mode);
> +		staticMetadata_->addEntry(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
> +					  aberrationModes.data(),
> +					  aberrationModes.size());
> +	}
>  
>  	/* Control static metadata. */
>  	std::vector<uint8_t> aeAvailableAntiBandingModes = {
>

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 39d8218a67e5..172676f98059 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -538,7 +538,7 @@  std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()
 	 * Currently: 51 entries, 687 bytes of static metadata
 	 */
 	uint32_t numEntries = 51;
-	uint32_t byteSize = 691;
+	uint32_t byteSize = 693;
 
 	/*
 	 * Calculate space occupation in bytes for dynamically built metadata
@@ -580,12 +580,18 @@  const camera_metadata_t *CameraDevice::getStaticMetadata()
 	const ControlList &cameraProperties = camera_->properties();
 
 	/* Color correction static metadata. */
-	std::vector<uint8_t> aberrationModes = {
-		ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF,
-	};
-	staticMetadata_->addEntry(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
-				  aberrationModes.data(),
-				  aberrationModes.size());
+	if (cameraProperties.contains(properties::draft::AvailableColorCorrectionAberrationModes)) {
+		Span<const int32_t> pipelineAberrationModes =
+			cameraProperties.get<Span<const int32_t>>
+			(properties::draft::AvailableColorCorrectionAberrationModes);
+
+		std::vector<uint8_t> aberrationModes;
+		for (int32_t mode : pipelineAberrationModes)
+			aberrationModes.push_back(mode);
+		staticMetadata_->addEntry(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
+					  aberrationModes.data(),
+					  aberrationModes.size());
+	}
 
 	/* Control static metadata. */
 	std::vector<uint8_t> aeAvailableAntiBandingModes = {