[libcamera-devel,v2,06/13] ipa: raspberry: Initialize ControlInfo with values list
diff mbox series

Message ID 20201020180534.36855-7-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: Introduce draft controls
Related show

Commit Message

Jacopo Mondi Oct. 20, 2020, 6:05 p.m. UTC
Initialize the ControlInfoMap of controls supported by the Raspberry
pipeline handler and IPA using the list of the enumerated values instead
of specifying them manually.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 include/libcamera/ipa/raspberrypi.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Kieran Bingham Oct. 21, 2020, 1 p.m. UTC | #1
Hi Jacopo,

On 20/10/2020 19:05, Jacopo Mondi wrote:
> Initialize the ControlInfoMap of controls supported by the Raspberry
> pipeline handler and IPA using the list of the enumerated values instead
> of specifying them manually.
> 

Nice!

Aside from the post-fix naming, which is probably just a matter of taste
and can be determined in the previous patch...

This really is powerful. Suddenly the ControlInfo actually becomes much
more strongly typed.

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

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  include/libcamera/ipa/raspberrypi.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
> index b23baf2f1330..414d757a06c6 100644
> --- a/include/libcamera/ipa/raspberrypi.h
> +++ b/include/libcamera/ipa/raspberrypi.h
> @@ -50,13 +50,13 @@ static const ControlInfoMap Controls = {
>  	{ &controls::AeEnable, ControlInfo(false, true) },
>  	{ &controls::ExposureTime, ControlInfo(0, 999999) },
>  	{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
> -	{ &controls::AeMeteringMode, ControlInfo(0, static_cast<int32_t>(controls::MeteringModeMax)) },
> -	{ &controls::AeConstraintMode, ControlInfo(0, static_cast<int32_t>(controls::ConstraintModeMax)) },
> -	{ &controls::AeExposureMode, ControlInfo(0, static_cast<int32_t>(controls::ExposureModeMax)) },
> +	{ &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeList) },
> +	{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeList) },
> +	{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeList) },
>  	{ &controls::ExposureValue, ControlInfo(0.0f, 16.0f) },
>  	{ &controls::AwbEnable, ControlInfo(false, true) },
>  	{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },
> -	{ &controls::AwbMode, ControlInfo(0, static_cast<int32_t>(controls::AwbModeMax)) },
> +	{ &controls::AwbMode, ControlInfo(controls::AwbModeList) },
>  	{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
>  	{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },
>  	{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },
>
Jacopo Mondi Oct. 21, 2020, 1:43 p.m. UTC | #2
On Wed, Oct 21, 2020 at 02:00:28PM +0100, Kieran Bingham wrote:
> Hi Jacopo,
>
> On 20/10/2020 19:05, Jacopo Mondi wrote:
> > Initialize the ControlInfoMap of controls supported by the Raspberry
> > pipeline handler and IPA using the list of the enumerated values instead
> > of specifying them manually.
> >
>
> Nice!
>
> Aside from the post-fix naming, which is probably just a matter of taste
> and can be determined in the previous patch...
>
> This really is powerful. Suddenly the ControlInfo actually becomes much
> more strongly typed.

It could be probably be even made shorter with a macro of some kind:

To replace this:
        { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeList) },

with:
#define CONTROL_INFO_ALL_VALUES(_ctrl)      \
        { &controls::##_ctrl, ControlInfo(controls::##_ctrl##List) },

But for now I think it's ok!

>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  include/libcamera/ipa/raspberrypi.h | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
> > index b23baf2f1330..414d757a06c6 100644
> > --- a/include/libcamera/ipa/raspberrypi.h
> > +++ b/include/libcamera/ipa/raspberrypi.h
> > @@ -50,13 +50,13 @@ static const ControlInfoMap Controls = {
> >  	{ &controls::AeEnable, ControlInfo(false, true) },
> >  	{ &controls::ExposureTime, ControlInfo(0, 999999) },
> >  	{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
> > -	{ &controls::AeMeteringMode, ControlInfo(0, static_cast<int32_t>(controls::MeteringModeMax)) },
> > -	{ &controls::AeConstraintMode, ControlInfo(0, static_cast<int32_t>(controls::ConstraintModeMax)) },
> > -	{ &controls::AeExposureMode, ControlInfo(0, static_cast<int32_t>(controls::ExposureModeMax)) },
> > +	{ &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeList) },
> > +	{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeList) },
> > +	{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeList) },
> >  	{ &controls::ExposureValue, ControlInfo(0.0f, 16.0f) },
> >  	{ &controls::AwbEnable, ControlInfo(false, true) },
> >  	{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },
> > -	{ &controls::AwbMode, ControlInfo(0, static_cast<int32_t>(controls::AwbModeMax)) },
> > +	{ &controls::AwbMode, ControlInfo(controls::AwbModeList) },
> >  	{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
> >  	{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },
> >  	{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },
> >
>
> --
> Regards
> --
> Kieran

Patch
diff mbox series

diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
index b23baf2f1330..414d757a06c6 100644
--- a/include/libcamera/ipa/raspberrypi.h
+++ b/include/libcamera/ipa/raspberrypi.h
@@ -50,13 +50,13 @@  static const ControlInfoMap Controls = {
 	{ &controls::AeEnable, ControlInfo(false, true) },
 	{ &controls::ExposureTime, ControlInfo(0, 999999) },
 	{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
-	{ &controls::AeMeteringMode, ControlInfo(0, static_cast<int32_t>(controls::MeteringModeMax)) },
-	{ &controls::AeConstraintMode, ControlInfo(0, static_cast<int32_t>(controls::ConstraintModeMax)) },
-	{ &controls::AeExposureMode, ControlInfo(0, static_cast<int32_t>(controls::ExposureModeMax)) },
+	{ &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeList) },
+	{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeList) },
+	{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeList) },
 	{ &controls::ExposureValue, ControlInfo(0.0f, 16.0f) },
 	{ &controls::AwbEnable, ControlInfo(false, true) },
 	{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },
-	{ &controls::AwbMode, ControlInfo(0, static_cast<int32_t>(controls::AwbModeMax)) },
+	{ &controls::AwbMode, ControlInfo(controls::AwbModeList) },
 	{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
 	{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },
 	{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },