/*=========================================================================== * FUNCTION : openLegacy * * DESCRIPTION: Function to open older hal version implementation * * PARAMETERS : * @camera_id : camera ID * @halVersion: Based on camera_module_t.common.module_api_version * @hw_device : ptr to struct storing camera hardware device info * * RETURN : 0 -- success * none-zero failure code *==========================================================================*/ int QCamera2Factory::openLegacy( int32_t cameraId, uint32_t halVersion, struct hw_device_t** hw_device) { int rc = NO_ERROR; ALOGI(":%s openLegacy halVersion: %d", __func__, halVersion); //Assumption: all cameras can support legacy API version if (cameraId < 0 || cameraId >= gQCamera2Factory->getNumberOfCameras()) return -ENODEV; switch(halVersion) { case CAMERA_DEVICE_API_VERSION_1_0: { QCamera2HardwareInterface *hw = new QCamera2HardwareInterface((uint32_t)cameraId); if (!hw) { ALOGE("%s: Allocation of hardware interface failed", __func__); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != NO_ERROR) { delete hw; } break; } default: ALOGE("%s: Device API version: %d for camera id %d invalid", __func__, halVersion, cameraId); return BAD_VALUE; } return rc; }
/*=========================================================================== * FUNCTION : cameraDeviceOpen * * DESCRIPTION: open a camera device with its ID * * PARAMETERS : * @camera_id : camera ID * @hw_device : ptr to struct storing camera hardware device info * * RETURN : int32_t type of status * NO_ERROR -- success * none-zero failure code *==========================================================================*/ int QCamera2Factory::cameraDeviceOpen(int camera_id, struct hw_device_t **hw_device) { int rc = NO_ERROR; if (camera_id < 0 || camera_id >= mNumOfCameras) return -ENODEV; if ( NULL == mHalDescriptors ) { LOGE("Hal descriptor table is not initialized!"); return NO_INIT; } LOGI("Open camera id %d API version %d", camera_id, mHalDescriptors[camera_id].device_version); if ( mHalDescriptors[camera_id].device_version == CAMERA_DEVICE_API_VERSION_3_0 ) { CAMSCOPE_INIT(CAMSCOPE_SECTION_HAL); QCamera3HardwareInterface *hw = new QCamera3HardwareInterface(mHalDescriptors[camera_id].cameraId, mCallbacks); if (!hw) { LOGE("Allocation of hardware interface failed"); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != 0) { delete hw; } } #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"); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != NO_ERROR) { delete hw; } } #endif else { LOGE("Device version for camera id %d invalid %d", camera_id, mHalDescriptors[camera_id].device_version); return BAD_VALUE; } return rc; }
/*=========================================================================== * FUNCTION : cameraDeviceOpen * * DESCRIPTION: open a camera device with its ID * * PARAMETERS : * @camera_id : camera ID * @hw_device : ptr to struct storing camera hardware device info * * RETURN : int32_t type of status * NO_ERROR -- success * none-zero failure code *==========================================================================*/ int QCamera2Factory::cameraDeviceOpen(int camera_id, struct hw_device_t **hw_device) { int rc = NO_ERROR; if (camera_id < 0 || camera_id >= mNumOfCameras) return BAD_VALUE; QCamera2HardwareInterface *hw = new QCamera2HardwareInterface(camera_id); if (!hw) { ALOGE("Allocation of hardware interface failed"); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != NO_ERROR) { delete hw; } return rc; }
/*=========================================================================== * FUNCTION : cameraDeviceOpen * * DESCRIPTION: open a camera device with its ID * * PARAMETERS : * @camera_id : camera ID * @hw_device : ptr to struct storing camera hardware device info * * RETURN : int32_t type of status * NO_ERROR -- success * none-zero failure code *==========================================================================*/ int QCamera2Factory::cameraDeviceOpen(int camera_id, struct hw_device_t **hw_device) { int rc = NO_ERROR; if (camera_id < 0 || camera_id >= mNumOfCameras) return -ENODEV; if ( NULL == mHalDescriptors ) { ALOGE("%s : Hal descriptor table is not initialized!", __func__); return NO_INIT; } if ( mHalDescriptors[camera_id].device_version == CAMERA_DEVICE_API_VERSION_3_0 ) { QCamera3HardwareInterface *hw = new QCamera3HardwareInterface(mHalDescriptors[camera_id].cameraId, mCallbacks); if (!hw) { ALOGE("Allocation of hardware interface failed"); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != 0) { delete hw; } } else if (mHalDescriptors[camera_id].device_version == CAMERA_DEVICE_API_VERSION_1_0) { QCamera2HardwareInterface *hw = new QCamera2HardwareInterface(camera_id); if (!hw) { ALOGE("Allocation of hardware interface failed"); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != NO_ERROR) { delete hw; } } else { ALOGE("%s: Device version for camera id %d invalid %d", __func__, camera_id, mHalDescriptors[camera_id].device_version); return BAD_VALUE; } return rc; }
/*=========================================================================== * FUNCTION : openLegacy * * DESCRIPTION: Function to open older hal version implementation * * PARAMETERS : * @camera_id : camera ID * @halVersion: Based on camera_module_t.common.module_api_version * @hw_device : ptr to struct storing camera hardware device info * * RETURN : 0 -- success * none-zero failure code *==========================================================================*/ int QCamera2Factory::openLegacy( int32_t cameraId, uint32_t halVersion, struct hw_device_t** hw_device) { int rc = NO_ERROR; LOGI("openLegacy halVersion: %d cameraId = %d", halVersion, cameraId); //Assumption: all cameras can support legacy API version if (cameraId < 0 || cameraId >= gQCamera2Factory->getNumberOfCameras()) return -ENODEV; switch(halVersion) { #ifdef QCAMERA_HAL1_SUPPORT case CAMERA_DEVICE_API_VERSION_1_0: { CAMSCOPE_INIT(CAMSCOPE_SECTION_HAL); QCamera2HardwareInterface *hw = new QCamera2HardwareInterface((uint32_t)cameraId); if (!hw) { LOGE("Allocation of hardware interface failed"); return NO_MEMORY; } rc = hw->openCamera(hw_device); if (rc != NO_ERROR) { delete hw; } break; } #endif default: LOGE("Device API version: %d for camera id %d invalid", halVersion, cameraId); return BAD_VALUE; } return rc; }