[libcamera-devel] [PATCH 1/4] libcamera: camera_sensor: Adjust CameraSensorInfo::analogCrop

Jacopo Mondi jacopo at jmondi.org
Fri Nov 6 16:49:44 CET 2020


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.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>

---
This patch depends on the upstreaming of
"media: i2c: imx219: Selection compliance fixes" in mainline Linux
---
 src/libcamera/camera_sensor.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 935de528c496..2af0b0a8db52 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -526,6 +526,15 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
 			<< "the camera sensor does not report the crop rectangle";
 		return ret;
 	}
+	/*
+	 * CameraSensorInfo::analogCrop::x and CameraSensorInfo::analogCrop::y
+	 * are defined in respect to the active pixel area, while V4L2's
+	 * TGT_CROP target is defined in respect to the native pixel array.
+	 *
+	 * Compensate it 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{};
-- 
2.29.1



More information about the libcamera-devel mailing list