android: hal_manager: Do not hardcode properties

The CameraHalManager::getCameraInfo() method hardcodes the camera facing
side and orientation (which corresponds, confusingly, to libcamera's
location and rotation properties).

Instead of hard-coding the values based on the camera id, inspect the
libcamera properties that report the camera location and rotation in a
new initialize() method, and use them to report the android camera info
and to populate the static metadata buffer.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2020-05-25 16:08:22 +02:00
parent 0ffb3a20ed
commit 64f4f667ed
3 changed files with 68 additions and 30 deletions

View file

@ -65,8 +65,11 @@ int CameraHalManager::init()
unsigned int index = 0;
for (auto &cam : cameraManager_->cameras()) {
CameraDevice *camera = new CameraDevice(index, cam);
cameras_.emplace_back(camera);
ret = camera->initialize();
if (ret)
continue;
cameras_.emplace_back(camera);
++index;
}
@ -107,9 +110,8 @@ int CameraHalManager::getCameraInfo(unsigned int id, struct camera_info *info)
CameraDevice *camera = cameras_[id].get();
/* \todo Get these info dynamically inspecting the camera module. */
info->facing = id ? CAMERA_FACING_FRONT : CAMERA_FACING_BACK;
info->orientation = 0;
info->facing = camera->facing();
info->orientation = camera->orientation();
info->device_version = CAMERA_DEVICE_API_VERSION_3_3;
info->resource_cost = 0;
info->static_camera_characteristics = camera->getStaticMetadata();