1 /*
2  * Copyright (C) 2015 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 CAMERA_HAL_H_
18 #define CAMERA_HAL_H_
19 
20 #include <hardware/hardware.h>
21 #include <hardware/camera_common.h>
22 #include <utils/Vector.h>
23 #include <utils/Mutex.h>
24 #include "HotplugThread.h"
25 #include "Camera.h"
26 
27 namespace usb_camera_hal {
28 
29 class HotplugThread;
30 
31 /**
32  * CameraHAL contains all module state that isn't specific to an individual camera device
33  */
34 class CameraHAL {
35     public:
36         CameraHAL();
37         ~CameraHAL();
38 
39         // Camera Module Interface (see <hardware/camera_common.h>)
40         int getNumberOfCameras();
41         int getCameraInfo(int camera_id, struct camera_info *info);
42         int setCallbacks(const camera_module_callbacks_t *callbacks);
43         void getVendorTagOps(vendor_tag_ops_t* ops);
44 
45         // Hardware Module Interface (see <hardware/hardware.h>)
46         int open(const hw_module_t* mod, const char* name, hw_device_t** dev);
47 
48     private:
49         // Callback handle
50         const camera_module_callbacks_t *mCallbacks;
51         android::Vector<Camera*> mCameras;
52         // Lock to protect the module method calls.
53         android::Mutex mModuleLock;
54         // Hot plug thread managing camera hot plug.
55         HotplugThread *mHotplugThread;
56 
57 };
58 } // namespace usb_camera_hal
59 
60 #endif // CAMERA_HAL_H_
61