From b33a5c4153852274efc7e3cd076d057bb7affbed Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 6 Nov 2020 14:27:59 +0100 Subject: libcamera: camera_sensor: Adjust CameraSensorInfo::analogCrop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CameraSensorInfo::analogCrop top-left corner is defined relatively to the sensor active area. The analogCrop rectangle is constucted by retrieving the V4L2 selection target V4L2_SEL_TGT_CROP which is instead defined relatively to the whole sensor's pixel array size. Adjust the the analogCrop rectangle subtracting from its top-left corner the active area distance from the full pixel array. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- src/libcamera/camera_sensor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libcamera/camera_sensor.cpp') diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 935de528..c5fa8914 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -527,6 +527,16 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const return ret; } + /* + * CameraSensorInfo::analogCrop::x and CameraSensorInfo::analogCrop::y + * are defined relatively to the active pixel area, while V4L2's + * TGT_CROP target is defined in respect to the full pixel array. + * + * Compensate it by subtracting the active areas offset. + */ + info->analogCrop.x -= rect.x; + info->analogCrop.y -= rect.y; + /* The bit depth and image size depend on the currently applied format. */ V4L2SubdeviceFormat format{}; ret = subdev_->getFormat(pad_, &format); -- cgit v1.2.1