diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-01-31 19:26:08 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-02-05 01:24:35 +0200 |
commit | f19cbd517bd88a20a8b137ac465a3a4288cbc01a (patch) | |
tree | 7630cf062be17b3b508d644535d79570614c4a6d | |
parent | 47d243c44a82c001baddd496bf754cc761dce837 (diff) |
libcamera: camera_sensor: Store Bayer pattern in class member
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: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
-rw-r--r-- | include/libcamera/internal/camera_sensor.h | 2 | ||||
-rw-r--r-- | 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 3e07fcae..c8f81882 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 { @@ -92,6 +93,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 9d60b39f..563e531e 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -163,7 +163,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) { } @@ -253,6 +254,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; @@ -436,14 +446,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; @@ -459,7 +464,6 @@ int CameraSensor::initProperties() } properties_.set(properties::draft::ColorFilterArrangement, cfa); - break; } return 0; |