diff options
author | davidevinavil <davidevinavil@gmail.com> | 2018-01-13 15:11:11 +0100 |
---|---|---|
committer | Davide Garberi <dade.garberi@gmail.com> | 2018-01-19 14:08:50 +0100 |
commit | cc4ccf34871da343111bf68d16ba4e4c67cac1dc (patch) | |
tree | 2b5b34eb29bf65eb11d7389492fc2e399107e3e9 /camera | |
parent | c78e9c34620ba1f689d8f2bc16757f6ace8f6ca7 (diff) |
msm8996-common: camera: Drop wrapper
Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
Diffstat (limited to 'camera')
-rw-r--r-- | camera/Android.mk | 34 | ||||
-rw-r--r-- | camera/Camera3Wrapper.cpp | 266 | ||||
-rw-r--r-- | camera/Camera3Wrapper.h | 19 | ||||
-rw-r--r-- | camera/CameraWrapper.cpp | 132 | ||||
-rw-r--r-- | camera/CameraWrapper.h | 35 |
5 files changed, 0 insertions, 486 deletions
diff --git a/camera/Android.mk b/camera/Android.mk deleted file mode 100644 index 4b3731e..0000000 --- a/camera/Android.mk +++ /dev/null @@ -1,34 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - CameraWrapper.cpp \ - Camera3Wrapper.cpp - -LOCAL_STATIC_LIBRARIES := \ - libbase \ - libarect - -LOCAL_SHARED_LIBRARIES := \ - libhardware \ - liblog \ - libcamera_client \ - libutils \ - libcutils \ - android.hidl.token@1.0-utils \ - android.hardware.graphics.bufferqueue@1.0 - -LOCAL_C_INCLUDES += \ - system/core/include \ - system/core/base/include \ - system/media/camera/include \ - frameworks/native/libs/nativebase/include - -LOCAL_32_BIT_ONLY := true -#LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_MODULE_RELATIVE_PATH := hw - -LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) -LOCAL_MODULE_TAGS := optional - -include $(BUILD_SHARED_LIBRARY) diff --git a/camera/Camera3Wrapper.cpp b/camera/Camera3Wrapper.cpp deleted file mode 100644 index df0ab6b..0000000 --- a/camera/Camera3Wrapper.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2012, The CyanogenMod Project - * Copyright (C) 2017, The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//#define LOG_NDEBUG 0 - -#define LOG_TAG "Camera3Wrapper" -#include <cutils/log.h> - -#include "CameraWrapper.h" -#include "Camera3Wrapper.h" - -typedef struct wrapper_camera3_device { - camera3_device_t base; - int id; - camera3_device_t *vendor; -} wrapper_camera3_device_t; - -#define VENDOR_CALL(device, func, ...) ({ \ - wrapper_camera3_device_t *__wrapper_dev = (wrapper_camera3_device_t*) device; \ - __wrapper_dev->vendor->ops->func(__wrapper_dev->vendor, ##__VA_ARGS__); \ -}) - -#define CAMERA_ID(device) (((wrapper_camera3_device_t *)(device))->id) - -static camera_module_t *gVendorModule = 0; - -static int check_vendor_module() -{ - int rv = 0; - ALOGV("%s", __FUNCTION__); - - if(gVendorModule) - return 0; - - rv = hw_get_module_by_class("camera", "vendor", (const hw_module_t **)&gVendorModule); - if (rv) - ALOGE("failed to open vendor camera module"); - return rv; -} - -/******************************************************************* - * implementation of camera_device_ops functions - *******************************************************************/ - -static int camera3_initialize(const camera3_device_t *device, const camera3_callback_ops_t *callback_ops) -{ - if (!device) - return -1; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - return VENDOR_CALL(device, initialize, callback_ops); -} - -static int camera3_configure_streams(const camera3_device *device, camera3_stream_configuration_t *stream_list) -{ - if (!device) - return -1; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - return VENDOR_CALL(device, configure_streams, stream_list); -} - -static int camera3_register_stream_buffers(const camera3_device *device, const camera3_stream_buffer_set_t *buffer_set) -{ - if (!device) - return -1; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - return VENDOR_CALL(device, register_stream_buffers, buffer_set); -} - -static const camera_metadata_t *camera3_construct_default_request_settings(const camera3_device_t *device, int type) -{ - if (!device) - return NULL; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - return VENDOR_CALL(device, construct_default_request_settings, type); -} - -static int camera3_process_capture_request(const camera3_device_t *device, camera3_capture_request_t *request) -{ - if (!device) - return -1; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - return VENDOR_CALL(device, process_capture_request, request); -} - -static void camera3_get_metadata_vendor_tag_ops(const camera3_device *device, vendor_tag_query_ops_t* ops) -{ - if (!device) - return; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - VENDOR_CALL(device, get_metadata_vendor_tag_ops, ops); -} - -static void camera3_dump(const camera3_device_t *device, int fd) -{ - if (!device) - return; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - VENDOR_CALL(device, dump, fd); -} - -static int camera3_flush(const camera3_device_t* device) -{ - if (!device) - return -1; - - ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, - (uintptr_t)(((wrapper_camera3_device_t*)device)->vendor)); - - return VENDOR_CALL(device, flush); -} - -static int camera3_device_close(hw_device_t *device) -{ - int ret = 0; - wrapper_camera3_device_t *wrapper_dev = NULL; - - ALOGV("%s", __FUNCTION__); - - android::Mutex::Autolock lock(gCameraWrapperLock); - - if (!device) { - ret = -EINVAL; - goto done; - } - - wrapper_dev = (wrapper_camera3_device_t*) device; - - wrapper_dev->vendor->common.close((hw_device_t*)wrapper_dev->vendor); - if (wrapper_dev->base.ops) - free(wrapper_dev->base.ops); - free(wrapper_dev); -done: - return ret; -} - -/******************************************************************* - * implementation of camera_module functions - *******************************************************************/ - -/* open device handle to one of the cameras - * - * assume camera service will keep singleton of each camera - * so this function will always only be called once per camera instance - */ - -int camera3_device_open(const hw_module_t *module, const char *name, - hw_device_t **device) -{ - int rv = 0; - int num_cameras = 0; - int cameraid; - wrapper_camera3_device_t *camera3_device = NULL; - camera3_device_ops_t *camera3_ops = NULL; - - android::Mutex::Autolock lock(gCameraWrapperLock); - - ALOGV("%s", __FUNCTION__); - - if (name != NULL) { - if (check_vendor_module()) - return -EINVAL; - - cameraid = atoi(name); - num_cameras = gVendorModule->get_number_of_cameras(); - - if (cameraid > num_cameras) { - ALOGE("camera service provided cameraid out of bounds, " - "cameraid = %d, num supported = %d", - cameraid, num_cameras); - rv = -EINVAL; - goto fail; - } - - camera3_device = (wrapper_camera3_device_t*)malloc(sizeof(*camera3_device)); - if (!camera3_device) { - ALOGE("camera3_device allocation fail"); - rv = -ENOMEM; - goto fail; - } - memset(camera3_device, 0, sizeof(*camera3_device)); - camera3_device->id = cameraid; - - rv = gVendorModule->common.methods->open((const hw_module_t*)gVendorModule, name, (hw_device_t**)&(camera3_device->vendor)); - if (rv) - { - ALOGE("vendor camera open fail"); - goto fail; - } - ALOGV("%s: got vendor camera device 0x%08X", __FUNCTION__, (uintptr_t)(camera3_device->vendor)); - - camera3_ops = (camera3_device_ops_t*)malloc(sizeof(*camera3_ops)); - if (!camera3_ops) { - ALOGE("camera3_ops allocation fail"); - rv = -ENOMEM; - goto fail; - } - - memset(camera3_ops, 0, sizeof(*camera3_ops)); - - camera3_device->base.common.tag = HARDWARE_DEVICE_TAG; - camera3_device->base.common.version = CAMERA_DEVICE_API_VERSION_3_2; - camera3_device->base.common.module = (hw_module_t *)(module); - camera3_device->base.common.close = camera3_device_close; - camera3_device->base.ops = camera3_ops; - - camera3_ops->initialize = camera3_initialize; - camera3_ops->configure_streams = camera3_configure_streams; - camera3_ops->register_stream_buffers = NULL; - camera3_ops->construct_default_request_settings = camera3_construct_default_request_settings; - camera3_ops->process_capture_request = camera3_process_capture_request; - camera3_ops->get_metadata_vendor_tag_ops = camera3_get_metadata_vendor_tag_ops; - camera3_ops->dump = camera3_dump; - camera3_ops->flush = camera3_flush; - - *device = &camera3_device->base.common; - } - - return rv; - -fail: - if (camera3_device) { - free(camera3_device); - camera3_device = NULL; - } - if (camera3_ops) { - free(camera3_ops); - camera3_ops = NULL; - } - *device = NULL; - return rv; -} diff --git a/camera/Camera3Wrapper.h b/camera/Camera3Wrapper.h deleted file mode 100644 index bf815ca..0000000 --- a/camera/Camera3Wrapper.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017, The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <hardware/camera3.h> - -int camera3_device_open(const hw_module_t *module, const char *name, hw_device_t **device); diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp deleted file mode 100644 index c49ddf0..0000000 --- a/camera/CameraWrapper.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2017, The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_NDEBUG 0 - -#define LOG_TAG "CameraWrapper" -#include <cutils/log.h> - -#include "CameraWrapper.h" -#include "Camera3Wrapper.h" - -static camera_module_t *gVendorModule = 0; -static char prop[PROPERTY_VALUE_MAX]; - -static int check_vendor_module() -{ - int rv = 0; - ALOGV("%s", __FUNCTION__); - - if(gVendorModule) - return 0; - - rv = hw_get_module_by_class("camera", "vendor", (const hw_module_t **)&gVendorModule); - if (rv) - ALOGE("failed to open vendor camera module"); - return rv; -} - -static struct hw_module_methods_t camera_module_methods = { - .open = camera_device_open -}; - -camera_module_t HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .module_api_version = CAMERA_MODULE_API_VERSION_2_4, - .hal_api_version = HARDWARE_HAL_API_VERSION, - .id = CAMERA_HARDWARE_MODULE_ID, - .name = "LineageOS Camera Wrapper", - .author = "The LineageOS Project", - .methods = &camera_module_methods, - .dso = NULL, - .reserved = {0}, - }, - .get_number_of_cameras = camera_get_number_of_cameras, - .get_camera_info = camera_get_camera_info, - .set_callbacks = camera_set_callbacks, - .get_vendor_tag_ops = camera_get_vendor_tag_ops, - .open_legacy = NULL, - .set_torch_mode = camera_set_torch_mode, - .init = NULL, - .reserved = {0}, -}; - -static int camera_device_open(const hw_module_t* module, const char* name, - hw_device_t** device) -{ - int rv = -EINVAL; - - property_get("persist.camera.HAL3.enabled", prop, "1"); - int isHAL3Enabled = atoi(prop); - - ALOGV("%s: property persist.camera.HAL3.enabled is set to %d", __FUNCTION__, isHAL3Enabled); - - if (name != NULL) { - if (check_vendor_module()) - return -EINVAL; - - if (isHAL3Enabled) { - ALOGV("%s: using HAL3", __FUNCTION__); - rv = camera3_device_open(module, name, device); - } else { - ALOGV("%s: Only HAL3 is supported", __FUNCTION__); - return -EINVAL; - } - } - - return rv; -} - -static int camera_get_number_of_cameras(void) -{ - ALOGV("%s", __FUNCTION__); - if (check_vendor_module()) - return 0; - return gVendorModule->get_number_of_cameras(); -} - -static int camera_get_camera_info(int camera_id, struct camera_info *info) -{ - ALOGV("%s", __FUNCTION__); - if (check_vendor_module()) - return 0; - return gVendorModule->get_camera_info(camera_id, info); -} - -static int camera_set_callbacks(const camera_module_callbacks_t *callbacks) -{ - ALOGV("%s", __FUNCTION__); - if (check_vendor_module()) - return 0; - return gVendorModule->set_callbacks(callbacks); -} - -static void camera_get_vendor_tag_ops(vendor_tag_ops_t* ops) -{ - ALOGV("%s", __FUNCTION__); - if (check_vendor_module()) - return; - return gVendorModule->get_vendor_tag_ops(ops); -} - -static int camera_set_torch_mode(const char* camera_id, bool on) -{ - ALOGV("%s", __FUNCTION__); - if (check_vendor_module()) - return -EINVAL; - return gVendorModule->set_torch_mode(camera_id, on); -} diff --git a/camera/CameraWrapper.h b/camera/CameraWrapper.h deleted file mode 100644 index ee86d29..0000000 --- a/camera/CameraWrapper.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2017, The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <utils/threads.h> -#include <utils/String8.h> -#include <cutils/properties.h> -#include <hardware/hardware.h> -#include <hardware/camera.h> -#include <camera/Camera.h> -#include <camera/CameraParameters.h> -#include <camera/CameraParametersExtra.h> - -static android::Mutex gCameraWrapperLock; - -static int camera_device_open(const hw_module_t* module, const char* name, - hw_device_t** device); -static int camera_device_close(hw_device_t* device); -static int camera_get_number_of_cameras(void); -static int camera_get_camera_info(int camera_id, struct camera_info *info); -static int camera_set_callbacks(const camera_module_callbacks_t *callbacks); -static void camera_get_vendor_tag_ops(vendor_tag_ops_t* ops); -static int camera_set_torch_mode(const char* camera_id, bool on); |