Message ID | 20210131181722.5410-2-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Delegated to: | Laurent Pinchart |
Headers | show |
Series |
|
Related | show |
Hi Laurent, On Sun, Jan 31, 2021 at 08:17:20PM +0200, Laurent Pinchart wrote: > The Bayer pattern is retrieved based on the media bus formats supported > by the sensor, when registering camera sensor properties. To prepare for > its usage elsewhere in the CameraSensor class, store it in a private > member variable. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Looks good, thank you Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Thanks j > --- > include/libcamera/internal/camera_sensor.h | 2 ++ > src/libcamera/camera_sensor.cpp | 22 +++++++++++++--------- > 2 files changed, 15 insertions(+), 9 deletions(-) > > diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h > index bf83d53134bf..a662807ab504 100644 > --- a/include/libcamera/internal/camera_sensor.h > +++ b/include/libcamera/internal/camera_sensor.h > @@ -20,6 +20,7 @@ > > namespace libcamera { > > +class BayerFormat; > class MediaEntity; > > struct CameraSensorInfo { > @@ -89,6 +90,7 @@ private: > > Size pixelArraySize_; > Rectangle activeArea_; > + const BayerFormat *bayerFormat_; > > ControlList properties_; > }; > diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp > index 2d15043431aa..35312857ff90 100644 > --- a/src/libcamera/camera_sensor.cpp > +++ b/src/libcamera/camera_sensor.cpp > @@ -133,7 +133,8 @@ LOG_DEFINE_CATEGORY(CameraSensor) > * Once constructed the instance must be initialized with init(). > */ > CameraSensor::CameraSensor(const MediaEntity *entity) > - : entity_(entity), pad_(UINT_MAX), properties_(properties::properties) > + : entity_(entity), pad_(UINT_MAX), bayerFormat_(nullptr), > + properties_(properties::properties) > { > } > > @@ -223,6 +224,15 @@ int CameraSensor::init() > return initProperties(); > } > > + /* Get the color filter array pattern (only for RAW sensors). */ > + for (unsigned int mbusCode : mbusCodes_) { > + const BayerFormat &bayerFormat = BayerFormat::fromMbusCode(mbusCode); > + if (bayerFormat.isValid()) { > + bayerFormat_ = &bayerFormat; > + break; > + } > + } > + > ret = validateSensorDriver(); > if (ret) > return ret; > @@ -405,14 +415,9 @@ int CameraSensor::initProperties() > properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); > > /* Color filter array pattern, register only for RAW sensors. */ > - for (const auto &format : formats_) { > - unsigned int mbusCode = format.first; > - BayerFormat bayerFormat = BayerFormat::fromMbusCode(mbusCode); > - if (!bayerFormat.isValid()) > - continue; > - > + if (bayerFormat_) { > int32_t cfa; > - switch (bayerFormat.order) { > + switch (bayerFormat_->order) { > case BayerFormat::BGGR: > cfa = properties::draft::BGGR; > break; > @@ -428,7 +433,6 @@ int CameraSensor::initProperties() > } > > properties_.set(properties::draft::ColorFilterArrangement, cfa); > - break; > } > > return 0; > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
Hi Laurent, On Sun, Jan 31, 2021 at 08:17:20PM +0200, Laurent Pinchart wrote: > The Bayer pattern is retrieved based on the media bus formats supported > by the sensor, when registering camera sensor properties. To prepare for > its usage elsewhere in the CameraSensor class, store it in a private > member variable. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > include/libcamera/internal/camera_sensor.h | 2 ++ > src/libcamera/camera_sensor.cpp | 22 +++++++++++++--------- > 2 files changed, 15 insertions(+), 9 deletions(-) > > diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h > index bf83d53134bf..a662807ab504 100644 > --- a/include/libcamera/internal/camera_sensor.h > +++ b/include/libcamera/internal/camera_sensor.h > @@ -20,6 +20,7 @@ > > namespace libcamera { > > +class BayerFormat; > class MediaEntity; > > struct CameraSensorInfo { > @@ -89,6 +90,7 @@ private: > > Size pixelArraySize_; > Rectangle activeArea_; > + const BayerFormat *bayerFormat_; > > ControlList properties_; > }; > diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp > index 2d15043431aa..35312857ff90 100644 > --- a/src/libcamera/camera_sensor.cpp > +++ b/src/libcamera/camera_sensor.cpp > @@ -133,7 +133,8 @@ LOG_DEFINE_CATEGORY(CameraSensor) > * Once constructed the instance must be initialized with init(). > */ > CameraSensor::CameraSensor(const MediaEntity *entity) > - : entity_(entity), pad_(UINT_MAX), properties_(properties::properties) > + : entity_(entity), pad_(UINT_MAX), bayerFormat_(nullptr), > + properties_(properties::properties) > { > } > > @@ -223,6 +224,15 @@ int CameraSensor::init() > return initProperties(); > } > > + /* Get the color filter array pattern (only for RAW sensors). */ > + for (unsigned int mbusCode : mbusCodes_) { > + const BayerFormat &bayerFormat = BayerFormat::fromMbusCode(mbusCode); > + if (bayerFormat.isValid()) { > + bayerFormat_ = &bayerFormat; > + break; > + } > + } > + > ret = validateSensorDriver(); > if (ret) > return ret; > @@ -405,14 +415,9 @@ int CameraSensor::initProperties() > properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); > > /* Color filter array pattern, register only for RAW sensors. */ > - for (const auto &format : formats_) { > - unsigned int mbusCode = format.first; > - BayerFormat bayerFormat = BayerFormat::fromMbusCode(mbusCode); > - if (!bayerFormat.isValid()) > - continue; > - > + if (bayerFormat_) { > int32_t cfa; > - switch (bayerFormat.order) { > + switch (bayerFormat_->order) { > case BayerFormat::BGGR: > cfa = properties::draft::BGGR; > break; > @@ -428,7 +433,6 @@ int CameraSensor::initProperties() > } > > properties_.set(properties::draft::ColorFilterArrangement, cfa); > - break; > } > > return 0; > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index bf83d53134bf..a662807ab504 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -20,6 +20,7 @@ namespace libcamera { +class BayerFormat; class MediaEntity; struct CameraSensorInfo { @@ -89,6 +90,7 @@ private: Size pixelArraySize_; Rectangle activeArea_; + const BayerFormat *bayerFormat_; ControlList properties_; }; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 2d15043431aa..35312857ff90 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -133,7 +133,8 @@ LOG_DEFINE_CATEGORY(CameraSensor) * Once constructed the instance must be initialized with init(). */ CameraSensor::CameraSensor(const MediaEntity *entity) - : entity_(entity), pad_(UINT_MAX), properties_(properties::properties) + : entity_(entity), pad_(UINT_MAX), bayerFormat_(nullptr), + properties_(properties::properties) { } @@ -223,6 +224,15 @@ int CameraSensor::init() return initProperties(); } + /* Get the color filter array pattern (only for RAW sensors). */ + for (unsigned int mbusCode : mbusCodes_) { + const BayerFormat &bayerFormat = BayerFormat::fromMbusCode(mbusCode); + if (bayerFormat.isValid()) { + bayerFormat_ = &bayerFormat; + break; + } + } + ret = validateSensorDriver(); if (ret) return ret; @@ -405,14 +415,9 @@ int CameraSensor::initProperties() properties_.set(properties::PixelArrayActiveAreas, { activeArea_ }); /* Color filter array pattern, register only for RAW sensors. */ - for (const auto &format : formats_) { - unsigned int mbusCode = format.first; - BayerFormat bayerFormat = BayerFormat::fromMbusCode(mbusCode); - if (!bayerFormat.isValid()) - continue; - + if (bayerFormat_) { int32_t cfa; - switch (bayerFormat.order) { + switch (bayerFormat_->order) { case BayerFormat::BGGR: cfa = properties::draft::BGGR; break; @@ -428,7 +433,6 @@ int CameraSensor::initProperties() } properties_.set(properties::draft::ColorFilterArrangement, cfa); - break; } return 0;
The Bayer pattern is retrieved based on the media bus formats supported by the sensor, when registering camera sensor properties. To prepare for its usage elsewhere in the CameraSensor class, store it in a private member variable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- include/libcamera/internal/camera_sensor.h | 2 ++ src/libcamera/camera_sensor.cpp | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-)