2 * Copyright (C) 2017, The LineageOS Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #define LOG_PARAMETERS
20 #define LOG_TAG "CameraWrapper"
21 #include <cutils/log.h>
23 #include "CameraWrapper.h"
24 #include "Camera2Wrapper.h"
26 static camera_module_t
*gVendorModule
= 0;
28 static int check_vendor_module()
31 ALOGV("%s", __FUNCTION__
);
36 rv
= hw_get_module_by_class("camera", "vendor", (const hw_module_t
**)&gVendorModule
);
38 ALOGE("failed to open vendor camera module");
42 static struct hw_module_methods_t camera_module_methods
= {
43 .open
= camera_device_open
46 camera_module_t HAL_MODULE_INFO_SYM
= {
48 .tag
= HARDWARE_MODULE_TAG
,
49 .module_api_version
= CAMERA_MODULE_API_VERSION_2_4
,
50 .hal_api_version
= HARDWARE_HAL_API_VERSION
,
51 .id
= CAMERA_HARDWARE_MODULE_ID
,
52 .name
= "universal7580 Camera Wrapper",
53 .author
= "The LineageOS Project",
54 .methods
= &camera_module_methods
,
58 .get_number_of_cameras
= camera_get_number_of_cameras
,
59 .get_camera_info
= camera_get_camera_info
,
60 .set_callbacks
= camera_set_callbacks
,
61 .get_vendor_tag_ops
= camera_get_vendor_tag_ops
,
62 .open_legacy
= camera_open_legacy
,
63 .set_torch_mode
= NULL
,
68 static int camera_device_open(const hw_module_t
* module
, const char* name
,
74 if (check_vendor_module())
76 rv
= camera2_device_open(module
, name
, device
);
82 static int camera_get_number_of_cameras(void)
84 ALOGV("%s", __FUNCTION__
);
85 if (check_vendor_module())
87 return gVendorModule
->get_number_of_cameras();
90 static int camera_get_camera_info(int camera_id
, struct camera_info
*info
)
92 ALOGV("%s", __FUNCTION__
);
93 if (check_vendor_module())
95 return gVendorModule
->get_camera_info(camera_id
, info
);
98 static int camera_set_callbacks(const camera_module_callbacks_t
*callbacks
)
100 ALOGV("%s", __FUNCTION__
);
101 if (check_vendor_module())
103 return gVendorModule
->set_callbacks(callbacks
);
106 static void camera_get_vendor_tag_ops(vendor_tag_ops_t
* ops
)
108 ALOGV("%s", __FUNCTION__
);
109 if (check_vendor_module())
111 return gVendorModule
->get_vendor_tag_ops(ops
);
114 static int camera_open_legacy(const struct hw_module_t
* module
, const char* id
, uint32_t halVersion
, struct hw_device_t
** device
)
116 ALOGV("%s", __FUNCTION__
);
117 if (check_vendor_module())
119 return camera2_device_open(module
, id
, device
);