| Message ID | 20251112090941.2626202-1-barnabas.pocze@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
On 2025-11-12 14:39, Barnabás Pőcze wrote: > The enumerated controls/properties use `int32_t` as their backing type. > In multiple cases, when parsing such an enum value from a source, an > integer type is used. Replace the integer type with the proper enum > type where it is trivially doable. > > This change also brings `CameraSensorLegacy::initProperties()` in line > with `CameraSensorRaw::initProperties()`, by defaulting the color > filter arrangement to `MONO`. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <uajain@igalia.com> > --- > changes in v2: > * don't use `auto` > > v1: https://patchwork.libcamera.org/patch/24954/ > --- > src/ipa/libipa/agc_mean_luminance.cpp | 2 +- > src/ipa/rpi/common/ipa_base.cpp | 4 +++- > src/libcamera/sensor/camera_sensor_legacy.cpp | 5 +++-- > src/libcamera/sensor/camera_sensor_raw.cpp | 5 ++--- > 4 files changed, 9 insertions(+), 7 deletions(-) > > diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp > index 64f36bd75d..4df1201892 100644 > --- a/src/ipa/libipa/agc_mean_luminance.cpp > +++ b/src/ipa/libipa/agc_mean_luminance.cpp > @@ -297,7 +297,7 @@ int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData) > * possible before touching gain. > */ > if (availableExposureModes.empty()) { > - int32_t exposureModeId = controls::ExposureNormal; > + controls::AeExposureModeEnum exposureModeId = controls::ExposureNormal; > std::vector<std::pair<utils::Duration, double>> stages = { }; > > std::shared_ptr<ExposureModeHelper> helper = > diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp > index 8dfe35cc32..865035e578 100644 > --- a/src/ipa/rpi/common/ipa_base.cpp > +++ b/src/ipa/rpi/common/ipa_base.cpp > @@ -1584,7 +1584,9 @@ void IpaBase::reportMetadata(unsigned int ipaContext) > > const AfStatus *afStatus = rpiMetadata.getLocked<AfStatus>("af.status"); > if (afStatus) { > - int32_t s, p; > + controls::AfStateEnum s; > + controls::AfPauseStateEnum p; > + > switch (afStatus->state) { > case AfState::Scanning: > s = controls::AfStateScanning; > diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp > index f9e685a9ac..8f45ec9e15 100644 > --- a/src/libcamera/sensor/camera_sensor_legacy.cpp > +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp > @@ -571,7 +571,7 @@ int CameraSensorLegacy::initProperties() > const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION); > if (orientation != controls.end()) { > int32_t v4l2Orientation = orientation->second.def().get<int32_t>(); > - int32_t propertyValue; > + properties::LocationEnum propertyValue; > > switch (v4l2Orientation) { > default: > @@ -624,7 +624,8 @@ int CameraSensorLegacy::initProperties() > > /* Color filter array pattern, register only for RAW sensors. */ > if (bayerFormat_) { > - int32_t cfa; > + properties::draft::ColorFilterArrangementEnum cfa = properties::draft::MONO; > + > switch (bayerFormat_->order) { > case BayerFormat::BGGR: > cfa = properties::draft::BGGR; > diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp > index 8ea4423698..1aabc0485b 100644 > --- a/src/libcamera/sensor/camera_sensor_raw.cpp > +++ b/src/libcamera/sensor/camera_sensor_raw.cpp > @@ -576,7 +576,7 @@ int CameraSensorRaw::initProperties() > const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION); > if (orientation != controls.end()) { > int32_t v4l2Orientation = orientation->second.def().get<int32_t>(); > - int32_t propertyValue; > + properties::LocationEnum propertyValue; > > switch (v4l2Orientation) { > default: > @@ -628,7 +628,7 @@ int CameraSensorRaw::initProperties() > properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); > > /* Color filter array pattern. */ > - uint32_t cfa; > + properties::draft::ColorFilterArrangementEnum cfa = properties::draft::MONO; > > switch (cfaPattern_) { > case BayerFormat::BGGR: > @@ -644,7 +644,6 @@ int CameraSensorRaw::initProperties() > cfa = properties::draft::RGGB; > break; > case BayerFormat::MONO: > - default: > cfa = properties::draft::MONO; > break; > } > -- > 2.51.2
diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 64f36bd75d..4df1201892 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -297,7 +297,7 @@ int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData) * possible before touching gain. */ if (availableExposureModes.empty()) { - int32_t exposureModeId = controls::ExposureNormal; + controls::AeExposureModeEnum exposureModeId = controls::ExposureNormal; std::vector<std::pair<utils::Duration, double>> stages = { }; std::shared_ptr<ExposureModeHelper> helper = diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 8dfe35cc32..865035e578 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -1584,7 +1584,9 @@ void IpaBase::reportMetadata(unsigned int ipaContext) const AfStatus *afStatus = rpiMetadata.getLocked<AfStatus>("af.status"); if (afStatus) { - int32_t s, p; + controls::AfStateEnum s; + controls::AfPauseStateEnum p; + switch (afStatus->state) { case AfState::Scanning: s = controls::AfStateScanning; diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index f9e685a9ac..8f45ec9e15 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -571,7 +571,7 @@ int CameraSensorLegacy::initProperties() const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION); if (orientation != controls.end()) { int32_t v4l2Orientation = orientation->second.def().get<int32_t>(); - int32_t propertyValue; + properties::LocationEnum propertyValue; switch (v4l2Orientation) { default: @@ -624,7 +624,8 @@ int CameraSensorLegacy::initProperties() /* Color filter array pattern, register only for RAW sensors. */ if (bayerFormat_) { - int32_t cfa; + properties::draft::ColorFilterArrangementEnum cfa = properties::draft::MONO; + switch (bayerFormat_->order) { case BayerFormat::BGGR: cfa = properties::draft::BGGR; diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index 8ea4423698..1aabc0485b 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -576,7 +576,7 @@ int CameraSensorRaw::initProperties() const auto &orientation = controls.find(V4L2_CID_CAMERA_ORIENTATION); if (orientation != controls.end()) { int32_t v4l2Orientation = orientation->second.def().get<int32_t>(); - int32_t propertyValue; + properties::LocationEnum propertyValue; switch (v4l2Orientation) { default: @@ -628,7 +628,7 @@ int CameraSensorRaw::initProperties() properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); /* Color filter array pattern. */ - uint32_t cfa; + properties::draft::ColorFilterArrangementEnum cfa = properties::draft::MONO; switch (cfaPattern_) { case BayerFormat::BGGR: @@ -644,7 +644,6 @@ int CameraSensorRaw::initProperties() cfa = properties::draft::RGGB; break; case BayerFormat::MONO: - default: cfa = properties::draft::MONO; break; }