[libcamera-devel] [PATCH v3 06/13] libcamera: camera_sensor: Collect pixel array properties

Jacopo Mondi jacopo at jmondi.org
Fri Apr 24 23:52:57 CEST 2020


Collect the sensor pixel array properties by retrieving the subdevice
native size and active pixel array size.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 src/libcamera/camera_sensor.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 8d7abc7147a7..a54751fecf5a 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -169,6 +169,29 @@ int CameraSensor::initProperties()
 		propertyValue = rotationControl->second.def().get<int32_t>();
 	properties_.set(properties::Rotation, propertyValue);
 
+	/*
+	 * Sensor pixel array properties. Conditionally register them if the
+	 * sub-device provides support for the selection API.
+	 */
+	Size size{};
+	int ret = subdev_->getNativeSize(0, &size);
+	if (ret && ret != -ENOTTY)
+		return ret;
+	if (!ret)
+		properties_.set(properties::PixelArray, { static_cast<int>(size.width),
+							  static_cast<int>(size.height) });
+
+	/*
+	 * \todo The sub-device API only support a single active area rectangle
+	 */
+	Rectangle rect{};
+	ret = subdev_->getActiveArea(0, &rect);
+	if (ret && ret != -ENOTTY)
+		return ret;
+	if (!ret)
+		properties_.set(properties::ActiveAreas, { rect.x, rect.y,
+							   static_cast<int>(rect.width),
+							   static_cast<int>(rect.height) });
 	return 0;
 }
 
-- 
2.26.1



More information about the libcamera-devel mailing list