@@ -13,6 +13,8 @@
#include <limits.h>
#include <math.h>
+#include <libcamera/property_ids.h>
+
#include "formats.h"
#include "utils.h"
#include "v4l2_subdevice.h"
@@ -89,6 +91,36 @@ int CameraSensor::init()
if (ret < 0)
return ret;
+ /* Retrieve and store the camera sensor properties. */
+ const ControlInfoMap &controls = subdev_->controls();
+ int32_t controlValue = V4L2_LOCATION_EXTERNAL;
+
+ const auto &locationControl = controls.find(V4L2_CID_CAMERA_SENSOR_LOCATION);
+ if (locationControl != controls.end())
+ controlValue = locationControl->second.defaultValue().get<int32_t>();
+
+ switch (controlValue) {
+ case V4L2_LOCATION_EXTERNAL:
+ location_ = CAMERA_LOCATION_EXTERNAL;
+ break;
+ case V4L2_LOCATION_FRONT:
+ location_ = CAMERA_LOCATION_FRONT;
+ break;
+ case V4L2_LOCATION_BACK:
+ location_ = CAMERA_LOCATION_BACK;
+ break;
+ default:
+ LOG(CameraSensor, Error)
+ << "Unsupported camera location: " << controlValue;
+ return -EINVAL;
+ }
+
+ controlValue = 0;
+ const auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION);
+ if (rotationControl != controls.end())
+ controlValue = rotationControl->second.defaultValue().get<int32_t>();
+ rotation_ = controlValue;
+
/* Enumerate and cache media bus codes and sizes. */
const ImageFormats formats = subdev_->formats(0);
if (formats.isEmpty()) {
@@ -56,6 +56,9 @@ private:
std::vector<unsigned int> mbusCodes_;
std::vector<Size> sizes_;
+
+ unsigned int location_;
+ unsigned int rotation_;
};
} /* namespace libcamera */
Store the camera sensor location and rotation by parsing the associated V4L2 controls. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/camera_sensor.cpp | 32 +++++++++++++++++++++++++++ src/libcamera/include/camera_sensor.h | 3 +++ 2 files changed, 35 insertions(+)