summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-03-04 14:10:13 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-03-08 16:21:13 +0100
commitf484857994075d0e4d33f8897cb3b47c7cf3fd6a (patch)
treeee1655623c4b2fb84ddf2b14e625baa6065d1ec9
parent237e23bb19f49814584d99cc6c0a2e80dad46be8 (diff)
libcamera: camera_sensor: Cap resolution to max frame size
Since commit 96aecfe36508 ("libcamera: camera_sensor: Use active area size as resolution") the CameraSensor::resolution() method returned the sensor's active pixel area size. As the CameraSensor::resolution() method is widely used in the library code base to retrieve the maximum frame size the sensor can produce, in case it is smaller than the pixel area size the returned size cannot be used to configure the sensor correctly. Fix this by returning the maximum frame resolution the sensor can produce, or the pixel area size in case the sensor embeds and ISP that can upscale and the supported maximum frame size is thus larger that the pixel array size. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--include/libcamera/internal/camera_sensor.h2
-rw-r--r--src/libcamera/camera_sensor.cpp14
2 files changed, 14 insertions, 2 deletions
diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
index 71d012f7..3e98f71b 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -53,7 +53,7 @@ public:
const MediaEntity *entity() const { return entity_; }
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
const std::vector<Size> &sizes() const { return sizes_; }
- Size resolution() const { return activeArea_.size(); }
+ Size resolution() const;
V4L2SubdeviceFormat getFormat(const std::vector<unsigned int> &mbusCodes,
const Size &size) const;
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index a0498297..27f82071 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -551,10 +551,22 @@ int CameraSensor::initProperties()
*/
/**
- * \fn CameraSensor::resolution()
* \brief Retrieve the camera sensor resolution
+ *
+ * The camera sensor resolution is the active pixel area size, clamped to the
+ * maximum frame size the sensor can produce if it is smaller than the active
+ * pixel area.
+ *
+ * \todo Consider if it desirable to distinguish between the maximum resolution
+ * the sensor can produce (also including upscaled ones) and the actual pixel
+ * array size by splitting this method in two.
+ *
* \return The camera sensor resolution in pixels
*/
+Size CameraSensor::resolution() const
+{
+ return std::min(sizes_.back(), activeArea_.size());
+}
/**
* \brief Retrieve the best sensor format for a desired output