diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-02-08 01:33:11 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-03-03 22:52:00 +0200 |
commit | 96aecfe36508f3c2a2b1be621b3fbe4f72ef1fe6 (patch) | |
tree | a90780ffb82acac62df50f9ba72afaab37547158 /src | |
parent | 87194982ebd282a23b894d002df49cd86c37bfcb (diff) |
libcamera: camera_sensor: Use active area size as resolution
When a sensor can upscale the image, the native sensor resolution isn't
equal to the largest size reported by the sensor. Use the active area
size instead, and default it to the largest enumerated size if the crop
rectangle targets are not supported.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/camera_sensor.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 8a1b9bd2..8db6e897 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -234,12 +234,6 @@ int CameraSensor::init() sizes_.erase(last, sizes_.end()); /* - * The sizes_ vector is sorted in ascending order, the resolution is - * thus the last element of the vector. - */ - resolution_ = sizes_.back(); - - /* * VIMC is a bit special, as it does not yet support all the mandatory * requirements regular sensors have to respect. * @@ -324,14 +318,20 @@ int CameraSensor::validateSensorDriver() Rectangle rect; int ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &rect); if (ret) { - rect = Rectangle(resolution()); + /* + * Default the pixel array size to the largest size supported + * by the sensor. The sizes_ vector is sorted in ascending + * order, the largest size is thus the last element. + */ + pixelArraySize_ = sizes_.back(); + LOG(CameraSensor, Warning) << "The PixelArraySize property has been defaulted to " - << rect.toString(); + << pixelArraySize_.toString(); err = -EINVAL; + } else { + pixelArraySize_ = rect.size(); } - pixelArraySize_.width = rect.width; - pixelArraySize_.height = rect.height; ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &activeArea_); if (ret) { @@ -397,7 +397,8 @@ int CameraSensor::validateSensorDriver() */ void CameraSensor::initVimcDefaultProperties() { - pixelArraySize_ = resolution(); + /* Use the largest supported size. */ + pixelArraySize_ = sizes_.back(); activeArea_ = Rectangle(pixelArraySize_); } |