[libcamera-devel,RFC,v4,09/21] android, controls: Add and plumb MaxLatency control
diff mbox series

Message ID 20210716105631.158153-10-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Preliminary FULL plumbing
Related show

Commit Message

Paul Elder July 16, 2021, 10:56 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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---
Changes in v3:
- use v3 setMetadata
- add comment to explain 4
- remove todo

Changes in v2:
- use new setMetadata
- rebase on camera capabilities refactor
---
 src/android/camera_capabilities.cpp |  7 +++++--
 src/libcamera/control_ids.yaml      | 10 ++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi July 17, 2021, 10:25 a.m. UTC | #1
Hi Paul,

On Fri, Jul 16, 2021 at 07:56:19PM +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>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> ---
> Changes in v3:
> - use v3 setMetadata
> - add comment to explain 4
> - remove todo
>
> Changes in v2:
> - use new setMetadata
> - rebase on camera capabilities refactor
> ---
>  src/android/camera_capabilities.cpp |  7 +++++--
>  src/libcamera/control_ids.yaml      | 10 ++++++++++
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index 21e31cf2..c333b329 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -1127,8 +1127,11 @@ int CameraCapabilities::initializeStaticMetadata()
>  	}
>
>  	/* Sync static metadata. */
> -	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
> -	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, maxLatency);
> +	setMetadata<int32_t, int32_t>(
> +		staticMetadata_.get(), ANDROID_SYNC_MAX_LATENCY,

As I've read this, I thought if

        staticMetadata->setMetadata()

wouldn't be a nicer API

> +		controlsInfo, &controls::draft::MaxLatency,
> +		ControlRange::Def,

If ::Def serves to get which ControlValue to get from ControlInfo,
can't we pass the ControlValue in directly ?

Anyway, these comments are not on this patch

> +		ANDROID_SYNC_MAX_LATENCY_UNKNOWN);
>
>  	/* Flash static metadata. */
>  	char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE;
> 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.
> +

Do we have a sorting order for controls ? It seems we don't...
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

>    - TestPatternMode:
>        type: int32_t
>        draft: true
> --
> 2.27.0
>
Paul Elder July 19, 2021, 5:50 a.m. UTC | #2
Hi Jacopo,

On Sat, Jul 17, 2021 at 12:25:10PM +0200, Jacopo Mondi wrote:
> Hi Paul,
> 
> On Fri, Jul 16, 2021 at 07:56:19PM +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>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > ---
> > Changes in v3:
> > - use v3 setMetadata
> > - add comment to explain 4
> > - remove todo
> >
> > Changes in v2:
> > - use new setMetadata
> > - rebase on camera capabilities refactor
> > ---
> >  src/android/camera_capabilities.cpp |  7 +++++--
> >  src/libcamera/control_ids.yaml      | 10 ++++++++++
> >  2 files changed, 15 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> > index 21e31cf2..c333b329 100644
> > --- a/src/android/camera_capabilities.cpp
> > +++ b/src/android/camera_capabilities.cpp
> > @@ -1127,8 +1127,11 @@ int CameraCapabilities::initializeStaticMetadata()
> >  	}
> >
> >  	/* Sync static metadata. */
> > -	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
> > -	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, maxLatency);
> > +	setMetadata<int32_t, int32_t>(
> > +		staticMetadata_.get(), ANDROID_SYNC_MAX_LATENCY,
> 
> As I've read this, I thought if
> 
>         staticMetadata->setMetadata()
> 
> wouldn't be a nicer API

setMetadata() reconciles (?) libcamera controls into android controls.
staticMetadata (CameraMetadata) is a wrapper around the android
metadata, so it shouldn't be dealing with libcamera controls.

> 
> > +		controlsInfo, &controls::draft::MaxLatency,
> > +		ControlRange::Def,
> 
> If ::Def serves to get which ControlValue to get from ControlInfo,
> can't we pass the ControlValue in directly ?

Then we have to do find() and if (it != end()), and that's what I want
to avoid :D Don't you remember how much copy&pasting there was of
exactly that?

> 
> Anyway, these comments are not on this patch
> 
> > +		ANDROID_SYNC_MAX_LATENCY_UNKNOWN);
> >
> >  	/* Flash static metadata. */
> >  	char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE;
> > 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.
> > +
> 
> Do we have a sorting order for controls ? It seems we don't...

Apparently not.

> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>


Thanks,

Paul

> 
> >    - TestPatternMode:
> >        type: int32_t
> >        draft: true
> > --
> > 2.27.0
> >

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index 21e31cf2..c333b329 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -1127,8 +1127,11 @@  int CameraCapabilities::initializeStaticMetadata()
 	}
 
 	/* Sync static metadata. */
-	int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
-	staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, maxLatency);
+	setMetadata<int32_t, int32_t>(
+		staticMetadata_.get(), ANDROID_SYNC_MAX_LATENCY,
+		controlsInfo, &controls::draft::MaxLatency,
+		ControlRange::Def,
+		ANDROID_SYNC_MAX_LATENCY_UNKNOWN);
 
 	/* Flash static metadata. */
 	char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE;
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