[v3,6/6] ipa: simple: Report exposure in metadata
diff mbox series

Message ID 20250113133405.12167-7-mzamazal@redhat.com
State Superseded
Headers show
Series
  • ipa: simple: Introduce metadata reporting
Related show

Commit Message

Milan Zamazal Jan. 13, 2025, 1:34 p.m. UTC
Report the exposure+gain in metadata.

The exposure value is especially dubious because it should be in
microseconds but it's handled using V4L2_CID_EXPOSURE control, which
doesn't specify the unit, see
https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/ipa/simple/algorithms/agc.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Jan. 27, 2025, 7:10 a.m. UTC | #1
Hi Milan,

Thank you for the patch.

On Mon, Jan 13, 2025 at 02:34:05PM +0100, Milan Zamazal wrote:
> Report the exposure+gain in metadata.
> 
> The exposure value is especially dubious because it should be in
> microseconds but it's handled using V4L2_CID_EXPOSURE control, which
> doesn't specify the unit, see
> https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html.

Please convert it to the right unit.

> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> ---
>  src/ipa/simple/algorithms/agc.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
> index 72aade14..ba7e7adc 100644
> --- a/src/ipa/simple/algorithms/agc.cpp
> +++ b/src/ipa/simple/algorithms/agc.cpp
> @@ -11,6 +11,8 @@
>  
>  #include <libcamera/base/log.h>
>  
> +#include "control_ids.h"
> +
>  namespace libcamera {
>  
>  LOG_DEFINE_CATEGORY(IPASoftExposure)
> @@ -99,8 +101,11 @@ void Agc::process(IPAContext &context,
>  		  [[maybe_unused]] const uint32_t frame,
>  		  [[maybe_unused]] IPAFrameContext &frameContext,
>  		  const SwIspStats *stats,
> -		  [[maybe_unused]] ControlList &metadata)
> +		  ControlList &metadata)
>  {
> +	metadata.set(controls::ExposureTime, frameContext.sensor.exposure);
> +	metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
> +
>  	/*
>  	 * Calculate Mean Sample Value (MSV) according to formula from:
>  	 * https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf
Milan Zamazal Jan. 27, 2025, 12:44 p.m. UTC | #2
Hi Laurent,

thank you for review.

Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:

> Hi Milan,
>
> Thank you for the patch.
>
> On Mon, Jan 13, 2025 at 02:34:05PM +0100, Milan Zamazal wrote:
>> Report the exposure+gain in metadata.
>> 
>> The exposure value is especially dubious because it should be in
>> microseconds but it's handled using V4L2_CID_EXPOSURE control, which
>> doesn't specify the unit, see
>> https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html.
>
> Please convert it to the right unit.

But what's the original unit?  It's unspecified in the link above:

  V4L2_CID_EXPOSURE (integer)
    Exposure (cameras). [Unit?]

Is there any better source of information?

>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
>> ---
>>  src/ipa/simple/algorithms/agc.cpp | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>> 
>> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
>> index 72aade14..ba7e7adc 100644
>> --- a/src/ipa/simple/algorithms/agc.cpp
>> +++ b/src/ipa/simple/algorithms/agc.cpp
>> @@ -11,6 +11,8 @@
>>  
>>  #include <libcamera/base/log.h>
>>  
>> +#include "control_ids.h"
>> +
>>  namespace libcamera {
>>  
>>  LOG_DEFINE_CATEGORY(IPASoftExposure)
>> @@ -99,8 +101,11 @@ void Agc::process(IPAContext &context,
>>  		  [[maybe_unused]] const uint32_t frame,
>>  		  [[maybe_unused]] IPAFrameContext &frameContext,
>>  		  const SwIspStats *stats,
>> -		  [[maybe_unused]] ControlList &metadata)
>> +		  ControlList &metadata)
>>  {
>> +	metadata.set(controls::ExposureTime, frameContext.sensor.exposure);
>> +	metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
>> +
>>  	/*
>>  	 * Calculate Mean Sample Value (MSV) according to formula from:
>>  	 * https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf
Laurent Pinchart Jan. 27, 2025, 4:35 p.m. UTC | #3
Hi Milan,

On Mon, Jan 27, 2025 at 01:44:05PM +0100, Milan Zamazal wrote:
> Laurent Pinchart writes:
> > On Mon, Jan 13, 2025 at 02:34:05PM +0100, Milan Zamazal wrote:
> >> Report the exposure+gain in metadata.
> >> 
> >> The exposure value is especially dubious because it should be in
> >> microseconds but it's handled using V4L2_CID_EXPOSURE control, which
> >> doesn't specify the unit, see
> >> https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html.
> >
> > Please convert it to the right unit.
> 
> But what's the original unit?  It's unspecified in the link above:
> 
>   V4L2_CID_EXPOSURE (integer)
>     Exposure (cameras). [Unit?]
> 
> Is there any better source of information?

The camera helpers in libipa provide functions to convert exposure time
between time units and V4L2 control units. You can look at how rkisp1
handles that for instance.

> >> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> >> ---
> >>  src/ipa/simple/algorithms/agc.cpp | 7 ++++++-
> >>  1 file changed, 6 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
> >> index 72aade14..ba7e7adc 100644
> >> --- a/src/ipa/simple/algorithms/agc.cpp
> >> +++ b/src/ipa/simple/algorithms/agc.cpp
> >> @@ -11,6 +11,8 @@
> >>  
> >>  #include <libcamera/base/log.h>
> >>  
> >> +#include "control_ids.h"
> >> +
> >>  namespace libcamera {
> >>  
> >>  LOG_DEFINE_CATEGORY(IPASoftExposure)
> >> @@ -99,8 +101,11 @@ void Agc::process(IPAContext &context,
> >>  		  [[maybe_unused]] const uint32_t frame,
> >>  		  [[maybe_unused]] IPAFrameContext &frameContext,
> >>  		  const SwIspStats *stats,
> >> -		  [[maybe_unused]] ControlList &metadata)
> >> +		  ControlList &metadata)
> >>  {
> >> +	metadata.set(controls::ExposureTime, frameContext.sensor.exposure);
> >> +	metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
> >> +
> >>  	/*
> >>  	 * Calculate Mean Sample Value (MSV) according to formula from:
> >>  	 * https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
index 72aade14..ba7e7adc 100644
--- a/src/ipa/simple/algorithms/agc.cpp
+++ b/src/ipa/simple/algorithms/agc.cpp
@@ -11,6 +11,8 @@ 
 
 #include <libcamera/base/log.h>
 
+#include "control_ids.h"
+
 namespace libcamera {
 
 LOG_DEFINE_CATEGORY(IPASoftExposure)
@@ -99,8 +101,11 @@  void Agc::process(IPAContext &context,
 		  [[maybe_unused]] const uint32_t frame,
 		  [[maybe_unused]] IPAFrameContext &frameContext,
 		  const SwIspStats *stats,
-		  [[maybe_unused]] ControlList &metadata)
+		  ControlList &metadata)
 {
+	metadata.set(controls::ExposureTime, frameContext.sensor.exposure);
+	metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
+
 	/*
 	 * Calculate Mean Sample Value (MSV) according to formula from:
 	 * https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf