mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-26 18:15:06 +03:00
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>
This commit is contained in:
parent
47d243c44a
commit
f19cbd517b
2 changed files with 15 additions and 9 deletions
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
|
class BayerFormat;
|
||||||
class MediaEntity;
|
class MediaEntity;
|
||||||
|
|
||||||
struct CameraSensorInfo {
|
struct CameraSensorInfo {
|
||||||
|
@ -92,6 +93,7 @@ private:
|
||||||
|
|
||||||
Size pixelArraySize_;
|
Size pixelArraySize_;
|
||||||
Rectangle activeArea_;
|
Rectangle activeArea_;
|
||||||
|
const BayerFormat *bayerFormat_;
|
||||||
|
|
||||||
ControlList properties_;
|
ControlList properties_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -163,7 +163,8 @@ LOG_DEFINE_CATEGORY(CameraSensor)
|
||||||
* Once constructed the instance must be initialized with init().
|
* Once constructed the instance must be initialized with init().
|
||||||
*/
|
*/
|
||||||
CameraSensor::CameraSensor(const MediaEntity *entity)
|
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();
|
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();
|
ret = validateSensorDriver();
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -436,14 +446,9 @@ int CameraSensor::initProperties()
|
||||||
properties_.set(properties::PixelArrayActiveAreas, { activeArea_ });
|
properties_.set(properties::PixelArrayActiveAreas, { activeArea_ });
|
||||||
|
|
||||||
/* Color filter array pattern, register only for RAW sensors. */
|
/* Color filter array pattern, register only for RAW sensors. */
|
||||||
for (const auto &format : formats_) {
|
if (bayerFormat_) {
|
||||||
unsigned int mbusCode = format.first;
|
|
||||||
BayerFormat bayerFormat = BayerFormat::fromMbusCode(mbusCode);
|
|
||||||
if (!bayerFormat.isValid())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int32_t cfa;
|
int32_t cfa;
|
||||||
switch (bayerFormat.order) {
|
switch (bayerFormat_->order) {
|
||||||
case BayerFormat::BGGR:
|
case BayerFormat::BGGR:
|
||||||
cfa = properties::draft::BGGR;
|
cfa = properties::draft::BGGR;
|
||||||
break;
|
break;
|
||||||
|
@ -459,7 +464,6 @@ int CameraSensor::initProperties()
|
||||||
}
|
}
|
||||||
|
|
||||||
properties_.set(properties::draft::ColorFilterArrangement, cfa);
|
properties_.set(properties::draft::ColorFilterArrangement, cfa);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue