Message ID | 20200206185247.202233-7-jacopo@jmondi.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, Thank you for the patch. On Thu, Feb 06, 2020 at 07:52:46PM +0100, Jacopo Mondi wrote: > Implement sensor specific pixel array properties initialization for the > OV5670 sensor driver by overriding CameraSensor::initProperties() > method. > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> > --- > src/libcamera/sensor/ov5670.cpp | 41 +++++++++++++++++++++++++++++++++ > src/libcamera/sensor/ov5670.h | 3 +++ > 2 files changed, 44 insertions(+) > > diff --git a/src/libcamera/sensor/ov5670.cpp b/src/libcamera/sensor/ov5670.cpp > index de6011875a2d..a49fcebb2d9d 100644 > --- a/src/libcamera/sensor/ov5670.cpp > +++ b/src/libcamera/sensor/ov5670.cpp > @@ -6,6 +6,12 @@ > */ > > #include "ov5670.h" > + > +#include <array> > + > +#include <libcamera/controls.h> > +#include <libcamera/property_ids.h> > + > #include "camera_sensor.h" > > /** > @@ -38,6 +44,41 @@ OV5670CameraSensor::OV5670CameraSensor(const MediaEntity *entity) > { > } > > +/** > + * \brief Initialize Camera properties with ov5670 specific values > + * \param[in] controlMap The map of control information provided by the sensor > + * \return 0 on success, a negative error code otherwise > + */ > +int OV5670CameraSensor::initProperties(const ControlInfoMap &controlMap) > +{ > + /* Pixel Array Properties. */ > + std::array<float, 2> pixelArraySize = { 2.9f, 1.18f }; That's a very weird aspect ratio... According to the product brief, the image area is 2.9457mm x 2.214mm. > + properties_.set(properties::PixelArraySize, > + Span<float>{ pixelArraySize }); > + > + std::array<int32_t, 2> pixelArrayBounds = { 2592, 1944 }; > + properties_.set(properties::PixelArrayBounds, > + Span<int32_t>{ pixelArrayBounds }); > + > + std::array<int32_t, 2> pixelArrays = { 2592, 1944 }; > + properties_.set(properties::PixelArrays, > + Span<int32_t>{ pixelArrays }); > + > + std::array<int32_t, 4> activeAreaSize = { 16, 6, 2560, 1920 }; > + properties_.set(properties::ActiveAreaSize, > + Span<int32_t>{ activeAreaSize }); > + > + int32_t bayerFilter = properties::BayerFilterGRBG; > + properties_.set(properties::BayerFilterArrangement, bayerFilter); These 4 properties should really be retrieved from the kernel :-S > + > + std::array<int32_t, 2> isoSensitivities = { 50, 800 }; > + properties_.set(properties::ISOSensitivityRange, > + Span<int32_t>{ isoSensitivities }); > + > + return CameraSensor::initProperties(controlMap); > +} > + > REGISTER_CAMERA_SENSOR(OV5670); > > }; /* namespace libcamera */ > + > diff --git a/src/libcamera/sensor/ov5670.h b/src/libcamera/sensor/ov5670.h > index 4acf02a8b06b..a66bdb6ae276 100644 > --- a/src/libcamera/sensor/ov5670.h > +++ b/src/libcamera/sensor/ov5670.h > @@ -11,12 +11,15 @@ > > namespace libcamera { > > +class ControlInfoMap; > + > class OV5670CameraSensor final : public CameraSensor > { > public: > static const char *entityName(); > > OV5670CameraSensor(const MediaEntity *entity); > + int initProperties(const ControlInfoMap &controlMap); > }; > > }; /* namespace libcamera */
diff --git a/src/libcamera/sensor/ov5670.cpp b/src/libcamera/sensor/ov5670.cpp index de6011875a2d..a49fcebb2d9d 100644 --- a/src/libcamera/sensor/ov5670.cpp +++ b/src/libcamera/sensor/ov5670.cpp @@ -6,6 +6,12 @@ */ #include "ov5670.h" + +#include <array> + +#include <libcamera/controls.h> +#include <libcamera/property_ids.h> + #include "camera_sensor.h" /** @@ -38,6 +44,41 @@ OV5670CameraSensor::OV5670CameraSensor(const MediaEntity *entity) { } +/** + * \brief Initialize Camera properties with ov5670 specific values + * \param[in] controlMap The map of control information provided by the sensor + * \return 0 on success, a negative error code otherwise + */ +int OV5670CameraSensor::initProperties(const ControlInfoMap &controlMap) +{ + /* Pixel Array Properties. */ + std::array<float, 2> pixelArraySize = { 2.9f, 1.18f }; + properties_.set(properties::PixelArraySize, + Span<float>{ pixelArraySize }); + + std::array<int32_t, 2> pixelArrayBounds = { 2592, 1944 }; + properties_.set(properties::PixelArrayBounds, + Span<int32_t>{ pixelArrayBounds }); + + std::array<int32_t, 2> pixelArrays = { 2592, 1944 }; + properties_.set(properties::PixelArrays, + Span<int32_t>{ pixelArrays }); + + std::array<int32_t, 4> activeAreaSize = { 16, 6, 2560, 1920 }; + properties_.set(properties::ActiveAreaSize, + Span<int32_t>{ activeAreaSize }); + + int32_t bayerFilter = properties::BayerFilterGRBG; + properties_.set(properties::BayerFilterArrangement, bayerFilter); + + std::array<int32_t, 2> isoSensitivities = { 50, 800 }; + properties_.set(properties::ISOSensitivityRange, + Span<int32_t>{ isoSensitivities }); + + return CameraSensor::initProperties(controlMap); +} + REGISTER_CAMERA_SENSOR(OV5670); }; /* namespace libcamera */ + diff --git a/src/libcamera/sensor/ov5670.h b/src/libcamera/sensor/ov5670.h index 4acf02a8b06b..a66bdb6ae276 100644 --- a/src/libcamera/sensor/ov5670.h +++ b/src/libcamera/sensor/ov5670.h @@ -11,12 +11,15 @@ namespace libcamera { +class ControlInfoMap; + class OV5670CameraSensor final : public CameraSensor { public: static const char *entityName(); OV5670CameraSensor(const MediaEntity *entity); + int initProperties(const ControlInfoMap &controlMap); }; }; /* namespace libcamera */
Implement sensor specific pixel array properties initialization for the OV5670 sensor driver by overriding CameraSensor::initProperties() method. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/sensor/ov5670.cpp | 41 +++++++++++++++++++++++++++++++++ src/libcamera/sensor/ov5670.h | 3 +++ 2 files changed, 44 insertions(+)