[libcamera-devel,RFC,02/14] android, controls: Add and plumb MaxLatency control
diff mbox series

Message ID 20210618103351.1642060-3-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
Add a MaxLatency control, and plumb it into the HAL accordingly.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=50
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/android/camera_device.cpp  |  8 ++++++++
 src/libcamera/control_ids.yaml | 10 ++++++++++
 2 files changed, 18 insertions(+)

Comments

Laurent Pinchart June 27, 2021, 11:24 p.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Fri, Jun 18, 2021 at 07:33:39PM +0900, Paul Elder wrote:
> Add a MaxLatency control, and plumb it into the HAL accordingly.
> 
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=50
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  src/android/camera_device.cpp  |  8 ++++++++
>  src/libcamera/control_ids.yaml | 10 ++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 25dd2569..86f47e00 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1187,6 +1187,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  
>  	/* Sync static metadata. */
>  	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
> +	const auto &maxLatencyInfo = controlsInfo.find(&controls::draft::MaxLatency);
> +	if (maxLatencyInfo != controlsInfo.end())
> +		maxLatency = maxLatencyInfo->second.def().get<int32_t>();
> +	if (maxLatency < 0 && 4 < maxLatency)

maxLatency will have a hard time being smaller than zero and larger than
four at the same time.

Where does 4 come from btw ? A comment to explain the logic could be
useful.

> +		capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE] = false;
> +	/* \todo Double check if this is the case */

I think this is correct, the documentation explicitly states

PER_FRAME_CONTROL (v3.2) = 0 [...] All FULL capability devices will
have this as their maxLatency.

With this fixed,

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

> +	if (maxLatency != 0)
> +		fullSupport = false;
>  	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, maxLatency);
>  
>  	/* Flash static metadata. */
> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> index d92f29f5..9d4638ae 100644
> --- a/src/libcamera/control_ids.yaml
> +++ b/src/libcamera/control_ids.yaml
> @@ -622,6 +622,16 @@ controls:
>          detection, additional format conversions etc) count as an additional
>          pipeline stage.
>  
> +  - MaxLatency:
> +      type: int32_t
> +      draft: true
> +      description: |
> +        The maximum number of frames that can occur after a request (different
> +        than the previous) has been submitted, and before the result's state
> +        becomes synchronized. A value of -1 indicates unknown latency, and 0
> +        indicates per-frame control. Currently identical to
> +        ANDROID_SYNC_MAX_LATENCY.
> +
>    - TestPatternMode:
>        type: int32_t
>        draft: true

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 25dd2569..86f47e00 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1187,6 +1187,14 @@  const camera_metadata_t *CameraDevice::getStaticMetadata()
 
 	/* Sync static metadata. */
 	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
+	const auto &maxLatencyInfo = controlsInfo.find(&controls::draft::MaxLatency);
+	if (maxLatencyInfo != controlsInfo.end())
+		maxLatency = maxLatencyInfo->second.def().get<int32_t>();
+	if (maxLatency < 0 && 4 < maxLatency)
+		capabilities[ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE] = false;
+	/* \todo Double check if this is the case */
+	if (maxLatency != 0)
+		fullSupport = false;
 	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, maxLatency);
 
 	/* Flash static metadata. */
diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
index d92f29f5..9d4638ae 100644
--- a/src/libcamera/control_ids.yaml
+++ b/src/libcamera/control_ids.yaml
@@ -622,6 +622,16 @@  controls:
         detection, additional format conversions etc) count as an additional
         pipeline stage.
 
+  - MaxLatency:
+      type: int32_t
+      draft: true
+      description: |
+        The maximum number of frames that can occur after a request (different
+        than the previous) has been submitted, and before the result's state
+        becomes synchronized. A value of -1 indicates unknown latency, and 0
+        indicates per-frame control. Currently identical to
+        ANDROID_SYNC_MAX_LATENCY.
+
   - TestPatternMode:
       type: int32_t
       draft: true