1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_CAMERA_DEVICE_H_ 18 #define HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_CAMERA_DEVICE_H_ 19 20 #include <android/hardware/camera/device/3.5/ICameraDevice.h> 21 #include <android/hardware/camera/device/3.5/ICameraDeviceCallback.h> 22 23 #include "camera_device.h" 24 25 namespace android { 26 namespace hardware { 27 namespace camera { 28 namespace device { 29 namespace V3_5 { 30 namespace implementation { 31 32 using ::android::hardware::camera::common::V1_0::CameraResourceCost; 33 using ::android::hardware::camera::common::V1_0::Status; 34 using ::android::hardware::camera::common::V1_0::TorchMode; 35 using ::android::hardware::camera::device::V3_5::ICameraDevice; 36 using ::android::hardware::camera::device::V3_5::ICameraDeviceCallback; 37 38 using ::android::google_camera_hal::CameraDevice; 39 40 // HidlCameraDevice implements the HIDL camera device interface, ICameraDevice, 41 // using Google Camera HAL to provide information about the associated camera 42 // device. 43 class HidlCameraDevice : public ICameraDevice { 44 public: 45 static const std::string kDeviceVersion; 46 47 // Create a HidlCameraDevice. 48 // google_camera_device is a google camera device that HidlCameraDevice 49 // is going to manage. Creating a HidlCameraDevice will fail if 50 // google_camera_device is nullptr. 51 static std::unique_ptr<HidlCameraDevice> Create( 52 std::unique_ptr<CameraDevice> google_camera_device); 53 virtual ~HidlCameraDevice() = default; 54 55 // Override functions in ICameraDevice 56 Return<void> getResourceCost( 57 ICameraDevice::getResourceCost_cb _hidl_cb) override; 58 59 Return<void> getCameraCharacteristics( 60 ICameraDevice::getCameraCharacteristics_cb _hidl_cb) override; 61 62 Return<Status> setTorchMode(TorchMode mode) override; 63 64 Return<void> open(const sp<V3_2::ICameraDeviceCallback>& callback, 65 ICameraDevice::open_cb _hidl_cb) override; 66 67 Return<void> dumpState(const ::android::hardware::hidl_handle& handle) override; 68 69 Return<void> getPhysicalCameraCharacteristics( 70 const hidl_string& physicalCameraId, 71 ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) override; 72 73 Return<void> isStreamCombinationSupported( 74 const V3_4::StreamConfiguration& streams, 75 ICameraDevice::isStreamCombinationSupported_cb _hidl_cb) override; 76 // End of override functions in ICameraDevice 77 78 protected: 79 HidlCameraDevice() = default; 80 81 private: 82 status_t Initialize(std::unique_ptr<CameraDevice> google_camera_device); 83 84 std::unique_ptr<CameraDevice> google_camera_device_; 85 uint32_t camera_id_ = 0; 86 }; 87 88 } // namespace implementation 89 } // namespace V3_5 90 } // namespace device 91 } // namespace camera 92 } // namespace hardware 93 } // namespace android 94 95 #endif // HARDWARE_GOOGLE_CAMERA_HAL_HIDL_SERVICE_HIDL_CAMERA_DEVICE_H_ 96