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

Message ID 20201009122101.73858-11-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_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES
static metadata property inspecting the values retuned by the pipeline
handler through the properties::draft::AvailableLensShadingMapModes
libcamera property.

Reserve in static metadata pack enough space to support all the 2
available lens shading map modes Android defines.

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

Comments

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

On 09/10/2020 13:21, Jacopo Mondi wrote:
> Register the ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES
> static metadata property inspecting the values retuned by the pipeline
> handler through the properties::draft::AvailableLensShadingMapModes
> libcamera property.
> 
> Reserve in static metadata pack enough space to support all the 2
> available lens shading map modes Android defines.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/android/camera_device.cpp | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 172676f98059..d776b61c07e6 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -537,8 +537,8 @@ std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()
>  	 * \todo Keep this in sync with the actual number of entries.
>  	 * Currently: 51 entries, 687 bytes of static metadata
>  	 */
> -	uint32_t numEntries = 51;
> -	uint32_t byteSize = 693;
> +	uint32_t numEntries = 52;
> +	uint32_t byteSize = 694;

693+2=695 ... but possibly needs update from previous too.

With correct sizings:

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


>  
>  	/*
>  	 * Calculate space occupation in bytes for dynamically built metadata
> @@ -766,6 +766,18 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  	staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
>  				  &maxFaceCount, 1);
>  
> +	if (cameraProperties.contains(properties::draft::AvailableLensShadingMapModes)) {
> +		Span<const int32_t> pipelineLensShadingMapModes =
> +			cameraProperties.get<Span<const int32_t>>
> +			(properties::draft::AvailableLensShadingMapModes);
> +
> +		std::vector<uint8_t> lensMapModes;
> +		for (int32_t mode : pipelineLensShadingMapModes)
> +			lensMapModes.push_back(mode);
> +		staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
> +					  lensMapModes.data(), lensMapModes.size());
> +	}
> +
>  	/* Sync static metadata. */
>  	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
>  	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, &maxLatency, 1);
>

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 172676f98059..d776b61c07e6 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -537,8 +537,8 @@  std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()
 	 * \todo Keep this in sync with the actual number of entries.
 	 * Currently: 51 entries, 687 bytes of static metadata
 	 */
-	uint32_t numEntries = 51;
-	uint32_t byteSize = 693;
+	uint32_t numEntries = 52;
+	uint32_t byteSize = 694;
 
 	/*
 	 * Calculate space occupation in bytes for dynamically built metadata
@@ -766,6 +766,18 @@  const camera_metadata_t *CameraDevice::getStaticMetadata()
 	staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
 				  &maxFaceCount, 1);
 
+	if (cameraProperties.contains(properties::draft::AvailableLensShadingMapModes)) {
+		Span<const int32_t> pipelineLensShadingMapModes =
+			cameraProperties.get<Span<const int32_t>>
+			(properties::draft::AvailableLensShadingMapModes);
+
+		std::vector<uint8_t> lensMapModes;
+		for (int32_t mode : pipelineLensShadingMapModes)
+			lensMapModes.push_back(mode);
+		staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
+					  lensMapModes.data(), lensMapModes.size());
+	}
+
 	/* Sync static metadata. */
 	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
 	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, &maxLatency, 1);