1 /*
2  * Copyright 2016 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 // Modified from hardware/libhardware/modules/camera/CameraHAL.h
18 
19 #ifndef V4L2_CAMERA_HAL_V4L2_CAMERA_HAL_H_
20 #define V4L2_CAMERA_HAL_V4L2_CAMERA_HAL_H_
21 
22 #include <vector>
23 
24 #include <hardware/camera_common.h>
25 #include <hardware/hardware.h>
26 
27 #include "camera.h"
28 #include "common.h"
29 
30 namespace v4l2_camera_hal {
31 /*
32  * V4L2CameraHAL contains all module state that isn't specific to an
33  * individual camera device. This class is based off of the sample
34  * default CameraHAL from /hardware/libhardware/modules/camera.
35  */
36 class V4L2CameraHAL {
37  public:
38   V4L2CameraHAL();
39   ~V4L2CameraHAL();
40 
41   // Camera Module Interface (see <hardware/camera_common.h>).
42   int getNumberOfCameras();
43   int getCameraInfo(int camera_id, camera_info_t* info);
44   int setCallbacks(const camera_module_callbacks_t* callbacks);
45   void getVendorTagOps(vendor_tag_ops_t* ops);
46   int openLegacy(const hw_module_t* module,
47                  const char* id,
48                  uint32_t halVersion,
49                  hw_device_t** device);
50   int setTorchMode(const char* camera_id, bool enabled);
51 
52   // Hardware Module Interface (see <hardware/hardware.h>).
53   int openDevice(const hw_module_t* mod, const char* name, hw_device_t** dev);
54 
55  private:
56   // Vector of cameras.
57   std::vector<std::unique_ptr<default_camera_hal::Camera>> mCameras;
58   // Callback handle.
59   const camera_module_callbacks_t* mCallbacks;
60 
61   DISALLOW_COPY_AND_ASSIGN(V4L2CameraHAL);
62 };
63 
64 }  // namespace v4l2_camera_hal
65 
66 extern camera_module_t HAL_MODULE_INFO_SYM;
67 
68 #endif  // V4L2_CAMERA_HAL_V4L2_CAMERA_HAL_H_
69