android: Override camera as "Internal" provided found in HAL config

Currently, all UVC cameras are reported with CameraLocationExternal [1]
by libcamera-core since there is no universal information or standard,
to know the location of these cameras. However, in the libcamera HAL
layer, we can make an informed decision whether it's external or
internal, simply by checking its presence in the HAL configuration
file.

The CameraHalManager will now assign the numerical id of the camera
accordingly when initializing the CameraDevice, based on the camera
facing value set in the HAL config file.

[1] 76809320bb ("libcamera: pipeline: uvcvideo: Treat all UVC cameras
                   as external")

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
Umang Jain 2021-07-30 16:31:53 +05:30
parent f65fad5a4d
commit 79abef2064
2 changed files with 29 additions and 1 deletions

View file

@ -330,7 +330,18 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData)
facing_ = CAMERA_FACING_BACK;
break;
case properties::CameraLocationExternal:
facing_ = CAMERA_FACING_EXTERNAL;
/*
* If the camera is reported as external, but the
* CameraHalManager has overriden it, use what is
* reported in the configuration file. This typically
* happens for UVC cameras reported as 'External' by
* libcamera but installed in fixed position on the
* device.
*/
if (cameraConfigData && cameraConfigData->facing != -1)
facing_ = cameraConfigData->facing;
else
facing_ = CAMERA_FACING_EXTERNAL;
break;
}