| Message ID | 20201228164003.53051-4-jacopo@jmondi.org |
|---|---|
| State | Accepted |
| Commit | 0a0264da8d6d845b743fdf7ad1092aa26eccc547 |
| Delegated to: | Jacopo Mondi |
| Headers | show |
| Series |
|
| Related | show |
Hi Jacopo, On Mon, Dec 28, 2020 at 05:40:01PM +0100, Jacopo Mondi wrote: > Inspect the list of media bus codes supported by the camera sensor > in order to deduce the color filter arrangement and register the > ColorFilterArrangement draft property. > > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > src/libcamera/camera_sensor.cpp | 36 +++++++++++++++++++++++++++++---- > 1 file changed, 32 insertions(+), 4 deletions(-) > > diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp > index 1628ba9c892b..e786821d4ba2 100644 > --- a/src/libcamera/camera_sensor.cpp > +++ b/src/libcamera/camera_sensor.cpp > @@ -17,6 +17,7 @@ > > #include <libcamera/property_ids.h> > > +#include "libcamera/internal/bayer_format.h" > #include "libcamera/internal/formats.h" > #include "libcamera/internal/sysfs.h" > #include "libcamera/internal/utils.h" > @@ -178,10 +179,6 @@ int CameraSensor::init() > if (ret < 0) > return ret; > > - ret = initProperties(); > - if (ret) > - return ret; > - > /* Enumerate, sort and cache media bus codes and sizes. */ > formats_ = subdev_->formats(pad_); > if (formats_.empty()) { > @@ -210,6 +207,10 @@ int CameraSensor::init() > */ > resolution_ = sizes_.back(); > > + ret = initProperties(); > + if (ret) > + return ret; > + > return 0; > } > > @@ -307,6 +308,33 @@ int CameraSensor::initProperties() > properties_.set(properties::PixelArrayActiveAreas, { crop }); > } > > + /* 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; > + > + int32_t cfa; > + switch (bayerFormat.order) { > + case BayerFormat::BGGR: > + cfa = properties::draft::BGGR; > + break; > + case BayerFormat::GBRG: > + cfa = properties::draft::GBRG; > + break; > + case BayerFormat::GRBG: > + cfa = properties::draft::GRBG; > + break; > + case BayerFormat::RGGB: > + cfa = properties::draft::RGGB; > + break; > + } > + > + properties_.set(properties::draft::ColorFilterArrangement, cfa); > + break; > + } > + > return 0; > } > > -- > 2.29.2 > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 1628ba9c892b..e786821d4ba2 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -17,6 +17,7 @@ #include <libcamera/property_ids.h> +#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/formats.h" #include "libcamera/internal/sysfs.h" #include "libcamera/internal/utils.h" @@ -178,10 +179,6 @@ int CameraSensor::init() if (ret < 0) return ret; - ret = initProperties(); - if (ret) - return ret; - /* Enumerate, sort and cache media bus codes and sizes. */ formats_ = subdev_->formats(pad_); if (formats_.empty()) { @@ -210,6 +207,10 @@ int CameraSensor::init() */ resolution_ = sizes_.back(); + ret = initProperties(); + if (ret) + return ret; + return 0; } @@ -307,6 +308,33 @@ int CameraSensor::initProperties() properties_.set(properties::PixelArrayActiveAreas, { crop }); } + /* 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; + + int32_t cfa; + switch (bayerFormat.order) { + case BayerFormat::BGGR: + cfa = properties::draft::BGGR; + break; + case BayerFormat::GBRG: + cfa = properties::draft::GBRG; + break; + case BayerFormat::GRBG: + cfa = properties::draft::GRBG; + break; + case BayerFormat::RGGB: + cfa = properties::draft::RGGB; + break; + } + + properties_.set(properties::draft::ColorFilterArrangement, cfa); + break; + } + return 0; }