From 8aaa41ee9b4103ae2826d85e4505075a080e3591 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 6 Nov 2020 14:47:26 +0100 Subject: libcamera: camera_sensor: Initialize PixelArray properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize pixel array properties 'PixelArraySize' and 'PixelArrayActiveAreas' by inspecting the V4L2 CROP_BOUNDS and CROP_DEFAULT selection targets. The properties are registered only if the sensor subdevice support the above mentioned selection targets. Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- src/libcamera/camera_sensor.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/libcamera/camera_sensor.cpp') diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 7e6995c4..1628ba9c 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -288,6 +288,25 @@ int CameraSensor::initProperties() propertyValue = 0; properties_.set(properties::Rotation, propertyValue); + Rectangle bounds; + ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_BOUNDS, &bounds); + if (!ret) + properties_.set(properties::PixelArraySize, bounds.size()); + + Rectangle crop; + ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &crop); + if (!ret) { + /* + * V4L2_SEL_TGT_CROP_DEFAULT and V4L2_SEL_TGT_CROP_BOUNDS are + * defined relatively to the sensor full pixel array size, + * while properties::PixelArrayActiveAreas is defined relatively + * to properties::PixelArraySize. Adjust it. + */ + crop.x -= bounds.x; + crop.y -= bounds.y; + properties_.set(properties::PixelArrayActiveAreas, { crop }); + } + return 0; } -- cgit v1.2.1