From 68478ce3e332bcb008c55f793adb11b88f63ad03 Mon Sep 17 00:00:00 2001 From: Shukla Mradul Date: Sat, 21 May 2016 14:32:30 +0530 Subject: msm8996-common: QCamera2:HAL : HAL1 Removal during Compile time Issue: Compile time HAL1 Removal as for IOT projects we are going to use only HAL3 so removing HAL1 Camera files from compile time. fix: Modified the Android.mk file to remove HAL1 during compilation.In case if HAL1 is not getting compiled muxer object is also not created in QCamera2Factory. CRs-Fixed: 1021955 Change-Id: I17af448d7c423c73c5f3c29e95fb42cc69ca5944 Signed-off-by: Davide Garberi --- camera/QCamera2/QCamera2Factory.cpp | 67 ++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 16 deletions(-) (limited to 'camera/QCamera2/QCamera2Factory.cpp') diff --git a/camera/QCamera2/QCamera2Factory.cpp b/camera/QCamera2/QCamera2Factory.cpp index fa266f9..e54f7b1 100644 --- a/camera/QCamera2/QCamera2Factory.cpp +++ b/camera/QCamera2/QCamera2Factory.cpp @@ -32,16 +32,19 @@ // System dependencies #include #include +#include // Camera dependencies +#ifdef QCAMERA_HAL1_SUPPORT #include "camera.h" -#include "camera3.h" #include "HAL/QCamera2HWI.h" +#include "QCameraMuxer.h" +#endif + +#include "hardware/camera3.h" #include "HAL3/QCamera3HWI.h" #include "util/QCameraFlash.h" #include "QCamera2Factory.h" -#include "QCameraMuxer.h" - extern "C" { #include "mm_camera_dbg.h" } @@ -51,8 +54,11 @@ using namespace android; namespace qcamera { QCamera2Factory *gQCamera2Factory = NULL; -QCameraMuxer *gQCameraMuxer = NULL; pthread_mutex_t gCamLock = PTHREAD_MUTEX_INITIALIZER; +#ifdef QCAMERA_HAL1_SUPPORT +QCameraMuxer *gQCameraMuxer = NULL; +#endif + //Total number of cameras opened simultaneously. //This variable updation is protected by gCamLock. uint8_t gNumCameraSessions = 0; @@ -78,24 +84,35 @@ QCamera2Factory::QCamera2Factory() char prop[PROPERTY_VALUE_MAX]; property_get("persist.camera.HAL3.enabled", prop, "1"); int isHAL3Enabled = atoi(prop); +#ifndef QCAMERA_HAL1_SUPPORT + isHAL3Enabled = 1; +#endif // Signifies whether system has to enable dual camera mode snprintf(propDefault, PROPERTY_VALUE_MAX, "%d", isDualCamAvailable(isHAL3Enabled)); property_get("persist.camera.dual.camera", prop, propDefault); bDualCamera = atoi(prop); LOGH("dualCamera:%d ", bDualCamera); +#ifndef QCAMERA_HAL1_SUPPORT + bDualCamera = 0; +#endif if(bDualCamera) { LOGI("Enabling QCamera Muxer"); +#ifdef QCAMERA_HAL1_SUPPORT if (!gQCameraMuxer) { QCameraMuxer::getCameraMuxer(&gQCameraMuxer, mNumOfCameras); if (!gQCameraMuxer) { LOGE("Error !! Failed to get QCameraMuxer"); } } +#endif } - if (!gQCameraMuxer && (mNumOfCameras > 0) && - (mNumOfCameras <= MM_CAMERA_MAX_NUM_SENSORS)) { +#ifdef QCAMERA_HAL1_SUPPORT + if (!gQCameraMuxer && (mNumOfCameras > 0) &&(mNumOfCameras <= MM_CAMERA_MAX_NUM_SENSORS)) { +#else + if ((mNumOfCameras > 0) &&(mNumOfCameras <= MM_CAMERA_MAX_NUM_SENSORS)) { +#endif mHalDescriptors = new hal_desc[mNumOfCameras]; if ( NULL != mHalDescriptors) { uint32_t cameraId = 0; @@ -133,10 +150,12 @@ QCamera2Factory::~QCamera2Factory() if ( NULL != mHalDescriptors ) { delete [] mHalDescriptors; } +#ifdef QCAMERA_HAL1_SUPPORT if (gQCameraMuxer) { delete gQCameraMuxer; gQCameraMuxer = NULL; } +#endif } /*=========================================================================== @@ -159,10 +178,11 @@ int QCamera2Factory::get_number_of_cameras() return 0; } } - +#ifdef QCAMERA_HAL1_SUPPORT if(gQCameraMuxer) numCameras = gQCameraMuxer->get_number_of_cameras(); else +#endif numCameras = gQCamera2Factory->getNumberOfCameras(); LOGH("num of cameras: %d", numCameras); @@ -185,10 +205,11 @@ int QCamera2Factory::get_number_of_cameras() int QCamera2Factory::get_camera_info(int camera_id, struct camera_info *info) { int rc = NO_ERROR; - +#ifdef QCAMERA_HAL1_SUPPORT if(gQCameraMuxer) rc = gQCameraMuxer->get_camera_info(camera_id, info); else +#endif rc = gQCamera2Factory->getCameraInfo(camera_id, info); return rc; @@ -208,9 +229,11 @@ int QCamera2Factory::get_camera_info(int camera_id, struct camera_info *info) int QCamera2Factory::set_callbacks(const camera_module_callbacks_t *callbacks) { int rc = NO_ERROR; +#ifdef QCAMERA_HAL1_SUPPORT if(gQCameraMuxer) rc = gQCameraMuxer->set_callbacks(callbacks); else +#endif rc = gQCamera2Factory->setCallbacks(callbacks); return rc; @@ -242,9 +265,11 @@ int QCamera2Factory::open_legacy(const struct hw_module_t* module, LOGE("Invalid camera id"); return BAD_VALUE; } +#ifdef QCAMERA_HAL1_SUPPORT if(gQCameraMuxer) rc = gQCameraMuxer->open_legacy(module, id, halVersion, device); else +#endif rc = gQCamera2Factory->openLegacy(atoi(id), halVersion, device); return rc; @@ -323,7 +348,6 @@ int QCamera2Factory::getCameraInfo(int camera_id, struct camera_info *info) CAMERA_DEVICE_API_VERSION_1_0) { info->device_version = CAMERA_DEVICE_API_VERSION_1_0; } - return rc; } @@ -392,7 +416,9 @@ int QCamera2Factory::cameraDeviceOpen(int camera_id, if (rc != 0) { delete hw; } - } else if (mHalDescriptors[camera_id].device_version == CAMERA_DEVICE_API_VERSION_1_0) { + } +#ifdef QCAMERA_HAL1_SUPPORT + else if (mHalDescriptors[camera_id].device_version == CAMERA_DEVICE_API_VERSION_1_0) { QCamera2HardwareInterface *hw = new QCamera2HardwareInterface((uint32_t)camera_id); if (!hw) { LOGE("Allocation of hardware interface failed"); @@ -402,7 +428,9 @@ int QCamera2Factory::cameraDeviceOpen(int camera_id, if (rc != NO_ERROR) { delete hw; } - } else { + } +#endif + else { LOGE("Device version for camera id %d invalid %d", camera_id, mHalDescriptors[camera_id].device_version); @@ -439,12 +467,12 @@ int QCamera2Factory::camera_device_open( LOGE("Invalid camera id"); return BAD_VALUE; } - +#ifdef QCAMERA_HAL1_SUPPORT if(gQCameraMuxer) rc = gQCameraMuxer->camera_device_open(module, id, hw_device); else +#endif rc = gQCamera2Factory->cameraDeviceOpen(atoi(id), hw_device); - return rc; } @@ -477,6 +505,7 @@ int QCamera2Factory::openLegacy( switch(halVersion) { +#ifdef QCAMERA_HAL1_SUPPORT case CAMERA_DEVICE_API_VERSION_1_0: { QCamera2HardwareInterface *hw = @@ -491,6 +520,7 @@ int QCamera2Factory::openLegacy( } break; } +#endif default: LOGE("Device API version: %d for camera id %d invalid", halVersion, cameraId); @@ -577,24 +607,29 @@ int QCamera2Factory::setTorchMode(const char* camera_id, bool on) *==========================================================================*/ bool QCamera2Factory::isDualCamAvailable(int hal3Enabled) { - bool rc = FALSE; + bool rc = false; int i = 0; camera_info info; cam_sync_type_t cam_type = CAM_TYPE_MAIN; for (i = 0; i < mNumOfCameras; i++) { if (!hal3Enabled) { +#ifdef QCAMERA_HAL1_SUPPORT QCamera2HardwareInterface::getCapabilities(i, &info, &cam_type); +#endif } if(cam_type == CAM_TYPE_AUX) { LOGH("Have Dual Camera HW Avaiable."); - rc = TRUE; + rc = true; break; } } - +#ifdef QCAMERA_HAL1_SUPPORT return rc; +#else + return false; +#endif } }; // namespace qcamera -- cgit v1.2.3