summaryrefslogtreecommitdiff
path: root/src/android/camera_hal_manager.h
AgeCommit message (Collapse)Author
2021-07-06android: Disable copy and move for CameraHalManagerLaurent Pinchart
The CameraHalManager should be instantiated once only, and never copied or moved. Disable copying and moving. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-05-26android: CameraHalManager: Create a static object dynamicallyHirokazu Honda
Originally CameraHalManager is created in the libcamera start up and destroyed in the libcamera termination. However, CameraHalManager destructor can access other static objects that has been destroyed. Avoid this issue by destroying CameraHalManager when tear_down() is called in ChromeOS or leaking it in other platforms. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-05-25android: camera_device: Get properties from configurationJacopo Mondi
Open the HAL configuration file in the Camera HAL manager and get the camera properties for each created CameraDevice and initialize it with them. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
2021-03-25android: CameraHalManager: Hold CameraManager with std::unique_ptrHirokazu Honda
CameraManager is owned by CameraHalManager. The ownership of the object is not shared with other classes. So CameraHalManager should manage CameraManager with std::unique_ptr. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-25android: CameraHalManager: Hold CameraDevice with std::unique_ptrHirokazu Honda
CameraDevice is owned by CameraHalManager. The ownership of the object is not shared with other classes. So CameraHalManager should manage CameraDevice with std::unique_ptr. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-23android: Return -EUSERS when failed to open a Camera that's in usePaul Elder
The correct return value for the HAL for hal_dev_open() when trying to open a camera that's already opened is EUSERS. Make hal_dev_open() return -EUSERS, and plumb the logic for this through CameraHalManager::open(). This allows the following CTS tests to pass: - android.hardware.camera2.cts.CameraManagerTest#testCameraManagerOpenAllCameras - android.hardware.camera2.cts.MultiViewTest#testDualCameraPreview Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-23android: camera_hal_manager: Support camera hotplugUmang Jain
Extend the support for camera hotplug from libcamera's CameraManager to CameraHalManager. Use camera module callbacks to let the framework know about the hotplug events and change the status of cameras being hotplugged or unplugged via camera_device_status_change(). Introduce a map cameraIdsMap_ which book-keeps all cameras seen in the past by the CameraHalManager. If the camera is seen for the first time, a new id is assigned to it. If the camera has been seen before by the manager, its old id is reused. IDs for internal cameras start with '0' and for external cameras, they start with '1000'. Accesses to cameraIdsMap_ and cameras_ are protected by a mutex. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-23android: camera_device: Make CameraDevice a shared objectUmang Jain
CameraDevice needs to be wrapper into the std::shared_ptr instead of std::unique_ptr to enable refcounting. The refcounting will help us to support hotplug and hot-unplug CameraHalManager operations in the subsequent commit. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-23android: camera_hal_manager: Set camera module callbacksUmang Jain
camera_module_callbacks are invoked to inform the framework about the events occurring module-wide. Allow to set these callbacks in camera_hal_manager as this will be used to integration camera hotplug support via camera_module_callbacks::camera_device_status_change in subsequent commit. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-06android: camera_hal_manager: Remove unused getStaticMetadata() methodUmang Jain
The CameraHalManager::getStaticMethod() method isn't used, remove it. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-02-13android: Remove internal threadLaurent Pinchart
Now that libcamera creates threads internally and doesn't rely on an application-provided event loop, remove the thread from the Android Camera HAL layer. The CameraProxy class becomes meaningless, remove it and communicate directly from the CameraHalManager to the CameraDevice. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19android: camera_hal_manager: Remove unused close() methodLaurent Pinchart
The CameraHalManager::close() method isn't used, remove it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19android: camera_hal_manager: Stop thread when destroyingLaurent Pinchart
The CameraHalManager starts a thread that is never stopped. This leads to the thread being destroyed while running, which causes a crash. Fix this by stopping the thread and waiting for it to finish in the destructor of the CameraHalManager. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-12hal: Fix comparison of integers of different signsLaurent Pinchart
The CameraHalManager::getCameraInfo() validates the camera id it receives from the camera service, and in doing so compares it with an unsigned integer, generating a compiler error: src/android/camera_hal_manager.cpp:121:9: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare] if (id >= numCameras() || id < 0) { ~~ ^ ~~~~~~~~~~~~ Fix this by turning the id into an unsigned int, as camera ids can't be negative. If a negative id is received from the camera service it will be converted to a large unsigned integer that will fail the comparison with numCameras(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-12android: hal: Add Camera3 HALJacopo Mondi
Add libcamera Android Camera HALv3 implementation. The initial camera HAL implementation supports the LIMITED hardware level and uses statically defined metadata and camera characteristics. Add a build option named 'android' and adjust the build system to selectively compile the Android camera HAL and link it against the required Android libraries. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>