Mhal_facebeauty:: Mhal_facebeauty(char const*const pszShotName, uint32_t const u4ShotMode, int32_t const i4OpenId) : ImpShot(pszShotName, u4ShotMode, i4OpenId) { MY_LOGD("[Mhal_facebeauty] Mhal_facebeauty +"); halSensorDev_e meSensorDev; if (i4OpenId == 0) { meSensorDev = SENSOR_DEV_MAIN; } else if (i4OpenId == 1) { meSensorDev == SENSOR_DEV_SUB; } else { meSensorDev == SENSOR_DEV_NONE; } SensorHal* sensor = SensorHal::createInstance(); if(sensor) sensor->sendCommand(meSensorDev, SENSOR_CMD_GET_SENSOR_TYPE, (int)&meSensorType); else MY_LOGE("[Mhal_facebeauty] Can not get sensor object \n"); MY_LOGD("[Mhal_facebeauty] Mhal_facebeauty meSensorType %d \n",meSensorType); sensor->destroyInstance(); MY_LOGD("[Mhal_facebeauty] Mhal_facebeauty -"); }
bool Feature:: setupSensorInfo_FromExModule() { if ( DevMetaInfo::queryDeviceId(mi4OpenId) == eDevId_AtvSensor ) { ms8SensorName = DLSYM_MODULE_NAME_COMMON_SENSOR_ATV; mu4SensorType = NSSensorType::eSensorType_YUV; MY_LOGW("ATV sensor...return true"); return true; } #if '1'!=MTKCAM_HAVE_SENSOR_HAL //++++++++++++++++++++++++++++++++++++++++++ // #warning "[FIXME] setupSensorInfo()" ms8SensorName = "No_Sensor_Hal"; mu4SensorType = NSSensorType::eSensorType_RAW; return true; // #else //MTKCAM_HAVE_SENSOR_HAL //.......................................... // using namespace NSFeature; SensorInfoBase* pSensorInfo = NULL; bool ret = false; halSensorDev_s halSensorDev = (halSensorDev_s)DevMetaInfo::queryHalSensorDev(mi4OpenId); SensorHal* pSensorHal = SensorHal::createInstance(); if ( ! pSensorHal ) { MY_LOGE("SensorHal::createInstance()"); goto lbExit; } // if ( 0 != pSensorHal->sendCommand(halSensorDev, SENSOR_CMD_GET_SENSOR_FEATURE_INFO, (int)&pSensorInfo) || ! pSensorInfo ) { MY_LOGE("SensorHal::sendCommand(%x, SENSOR_CMD_GET_SENSOR_FEATURE_INFO), pSensorInfo(%p)", halSensorDev, pSensorInfo); goto lbExit; } // MY_LOGD("type:%d <%#x/%s/%s>", pSensorInfo->GetType(), pSensorInfo->GetID(), pSensorInfo->getDrvName(), pSensorInfo->getDrvMacroName()); ms8SensorName = pSensorInfo->getDrvMacroName(); switch (pSensorInfo->GetType()) { case SensorInfoBase::EType_RAW: mu4SensorType = NSSensorType::eSensorType_RAW; break; case SensorInfoBase::EType_YUV: mu4SensorType = NSSensorType::eSensorType_YUV; break; } // ret = true; lbExit: if ( pSensorHal ) { pSensorHal->destroyInstance(); pSensorHal = NULL; } return ret; // #endif //MTKCAM_HAVE_SENSOR_HAL //------------------------------------------ }
/****************************************************************************** * test capture *******************************************************************************/ static MUINT32 u4Capture_Cmd(int argc, char** argv) { // init sensor first SensorHal *pSensorHal = SensorHal:: createInstance(); if (NULL == pSensorHal) { MY_LOGE("pSensorHal is NULL"); return 0; } // search sensor pSensorHal->searchSensor(); // // (1). init main sensor // printf("init main sensor\n"); pSensorHal->sendCommand(SENSOR_DEV_MAIN, SENSOR_CMD_SET_SENSOR_DEV, 0, 0, 0); // printf("pSensorHal->init\n"); pSensorHal->init(); //insert HDR printf("insert HDR\n"); //sp<HdrShot> pShot = NULL; HdrShot *pShot = NULL; pShot = new HdrShot("HdrShot", 0, 0); pShot->mTestMode = 1; //test only //for ImpShit interface printf("pShot->onCmd_capture\n"); pShot->sendCommand(eCmd_capture, 0, 0); printf("delete pShot\n"); delete pShot; // printf("pSensorHal->destroyInstance\n"); pSensorHal->destroyInstance(); return 0; }
bool ParamsManagerImp:: updateDefaultParams2_ByQuery() { bool ret = false; MY_LOGD("+"); // mParameters.set(MtkCameraParameters::KEY_SENSOR_TYPE, 0xFF); // default values of sensor type are 1s for YUV type #if '1'==MTKCAM_HAVE_SENSOR_HAL halSensorDev_s halSensorDev = (halSensorDev_s)DevMetaInfo::queryHalSensorDev(mi4OpenId); SensorHal* pSensorHal = SensorHal::createInstance(); if ( ! pSensorHal ) { MY_LOGE("SensorHal::createInstance()"); } else { int iFOV_horizontal = 0, iFOV_vertical = 0; if ( 0 != pSensorHal->sendCommand(halSensorDev, SENSOR_CMD_GET_SENSOR_VIEWANGLE, (int)&iFOV_horizontal, (int)&iFOV_vertical) ) { MY_LOGE("SensorHal::sendCommand(%x, SENSOR_CMD_GET_SENSOR_VIEWANGLE)", halSensorDev); } else { MY_LOGD("view-angles:%d %d", iFOV_horizontal, iFOV_vertical); mParameters.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, iFOV_horizontal); mParameters.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, iFOV_vertical); } unsigned char uiSensorType; uiSensorType = 0xFF; halSensorType_e eSensorType; if (0 != pSensorHal->sendCommand(SENSOR_DEV_MAIN, SENSOR_CMD_GET_SENSOR_TYPE, reinterpret_cast<int>(&eSensorType), 0, 0)) { MY_LOGE("SensorHal::sendCommand(%x, SENSOR_CMD_GET_SENSOR_TYPE)", SENSOR_DEV_MAIN); } else { if (SENSOR_TYPE_RAW == eSensorType) { uiSensorType &= 0xFE; } else { uiSensorType |= 0x01; } } if (0 != pSensorHal->sendCommand(SENSOR_DEV_SUB, SENSOR_CMD_GET_SENSOR_TYPE, reinterpret_cast<int>(&eSensorType), 0, 0)) { MY_LOGE("SensorHal::sendCommand(%x, SENSOR_CMD_GET_SENSOR_TYPE)", SENSOR_DEV_SUB); } else { if (SENSOR_TYPE_RAW == eSensorType) { uiSensorType &= 0xFD; } else { uiSensorType |= 0x02; } } mParameters.set(MtkCameraParameters::KEY_SENSOR_TYPE, uiSensorType); MY_LOGD("KEY_SENSOR_TYPE = 0x%X", uiSensorType); pSensorHal->destroyInstance(); pSensorHal = NULL; } #endif //MTKCAM_HAVE_SENSOR_HAL // #if '1'==MTKCAM_HAVE_3A_HAL // // (1) Query from CORE using namespace NS3A; FeatureParam_T r3ASupportedParam; memset(&r3ASupportedParam, 0, sizeof(r3ASupportedParam)); Hal3ABase* p3AHal = Hal3ABase::createInstance(DevMetaInfo::queryHalSensorDev(getOpenId())); if ( ! p3AHal ) { MY_LOGE("Fail to create 3AHal"); return ret; } if ( ! p3AHal->getSupportedParams(r3ASupportedParam) ) { MY_LOGE("getSupportedParams fail"); goto lbExit; } // // AE/AWB Lock #undef TRUE #undef FALSE mParameters.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED, r3ASupportedParam.bExposureLockSupported ? CameraParameters::TRUE : CameraParameters::FALSE); mParameters.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED, r3ASupportedParam.bAutoWhiteBalanceLockSupported ? CameraParameters::TRUE : CameraParameters::FALSE); // // AE/AF areas mParameters.set(CameraParameters::KEY_MAX_NUM_FOCUS_AREAS, r3ASupportedParam.u4MaxFocusAreaNum); mParameters.set(CameraParameters::KEY_MAX_NUM_METERING_AREAS, r3ASupportedParam.u4MaxMeterAreaNum); mParameters.set(MtkCameraParameters::KEY_FOCUS_ENG_MAX_STEP, r3ASupportedParam.i4MaxLensPos); mParameters.set(MtkCameraParameters::KEY_FOCUS_ENG_MIN_STEP, r3ASupportedParam.i4MinLensPos); // // Focus Full Scan Step Range mParameters.set(MtkCameraParameters::KEY_ENG_FOCUS_FULLSCAN_FRAME_INTERVAL_MAX, MtkCameraParameters::KEY_ENG_FOCUS_FULLSCAN_FRAME_INTERVAL_MAX_DEFAULT); mParameters.set(MtkCameraParameters::KEY_ENG_FOCUS_FULLSCAN_FRAME_INTERVAL_MIN, MtkCameraParameters::KEY_ENG_FOCUS_FULLSCAN_FRAME_INTERVAL_MIN_DEFAULT); mParameters.set(MtkCameraParameters::KEY_ENG_FOCUS_FULLSCAN_FRAME_INTERVAL, MtkCameraParameters::KEY_ENG_FOCUS_FULLSCAN_FRAME_INTERVAL_MIN_DEFAULT); // Shading table initial value mParameters.set(MtkCameraParameters::KEY_ENG_SHADING_TABLE, MtkCameraParameters::KEY_ENG_SHADING_TABLE_AUTO); mParameters.set(MtkCameraParameters::KEY_ENG_SAVE_SHADING_TABLE, 0); // if (FlashMgr::getInstance()) { int st, ed; FlashMgr::getInstance()->egGetDutyRange(&st, &ed); MY_LOGD("duty range = %d ~ %d", st, ed); mParameters.set(MtkCameraParameters::KEY_ENG_FLASH_DUTY_MIN, st); mParameters.set(MtkCameraParameters::KEY_ENG_FLASH_DUTY_MAX, ed); mParameters.set(MtkCameraParameters::KEY_ENG_FLASH_DUTY_VALUE, MtkCameraParameters::KEY_ENG_FLASH_DUTY_DEFAULT_VALUE); FlashMgr::getInstance()->egGetStepRange(&st, &ed); MY_LOGD("step range = %d ~ %d", st, ed); mParameters.set(MtkCameraParameters::KEY_ENG_FLASH_STEP_MIN, st); mParameters.set(MtkCameraParameters::KEY_ENG_FLASH_STEP_MAX, ed); FlashMgr::getInstance()->egSetMfDutyStep(MtkCameraParameters::KEY_ENG_FLASH_DUTY_DEFAULT_VALUE, mParameters.getInt(MtkCameraParameters::KEY_ENG_FLASH_STEP_MAX)); // Default values for flash } // ret = true; // lbExit: // if ( p3AHal ) { p3AHal->destroyInstance(); p3AHal = NULL; } #endif //MTKCAM_HAVE_3A_HAL // MY_LOGD("- ret(%d)", ret); return ret; }
sp<ICamAdapter> createMtkZsdCamAdapter( String8 const& rName, int32_t const i4OpenId, sp<IParamsManager> pParamsMgr ) { // int32_t zsdMode = 0; SensorHal* pSensorHal = NULL; halSensorDev_e eSensorDev; halSensorType_e eSensorType; uint32_t u4TgInW = 0; uint32_t u4TgInH = 0; uint32_t scenario = ACDK_SCENARIO_ID_CAMERA_ZSD; uint32_t fps = 0; String8 const s8AppMode = PARAMSMANAGER_MAP_INST(eMapAppMode)->stringFor(pParamsMgr->getHalAppMode()); int err = 0; // 1) query sensor info MY_LOGD("SensorHal::createInstance(), i4OpenId:%d", i4OpenId); pSensorHal = SensorHal::createInstance(); if ( ! pSensorHal ) { MY_LOGE("pSensorHal == NULL"); goto lbExit; } // eSensorDev = (halSensorDev_e)DevMetaInfo::queryHalSensorDev(i4OpenId); // raw or yuv pSensorHal->sendCommand(eSensorDev, SENSOR_CMD_GET_SENSOR_TYPE, (int32_t)&eSensorType); // sensor full size pSensorHal->sendCommand(eSensorDev, SENSOR_CMD_GET_SENSOR_FULL_RANGE, (int32_t)&u4TgInW, (int32_t)&u4TgInH); // sensor full size fps pSensorHal->sendCommand(eSensorDev, SENSOR_CMD_GET_DEFAULT_FRAME_RATE_BY_SCENARIO, (int32_t)&scenario, (int32_t)&fps); // pSensorHal->destroyInstance(); pSensorHal = NULL; // 2) CC or NCC // 5M case: if (u4TgInW < SENSOR_8M_WIDTH_MIN) { zsdMode = ZSD_MODE_CC; } // 13M case: else if (u4TgInW > SENSOR_8M_WIDTH_MAX) { zsdMode = ZSD_MODE_NCC; } // 8M case: else { if (fps > 240) zsdMode = ZSD_MODE_NCC; else zsdMode = ZSD_MODE_CC; } MY_LOGD("Sensor full size (%dx%d) fps(%d) ZSD mode (%s)", u4TgInW, u4TgInH, fps,(zsdMode == ZSD_MODE_NCC)?"ZSDNCC":"ZSDCC"); // lbExit: // 3) Get property for debug char value[PROPERTY_VALUE_MAX] = {'\0'}; property_get("camera.zsdmode", value, "0"); int pty = atoi(value); if ( pty > 0 ) { zsdMode = pty; MY_LOGD("Set zsd mode by property(%d)(%s)", zsdMode, (zsdMode == ZSD_MODE_NCC)?"ZSDNCC":"ZSDCC"); } if ( ZSD_MODE_NCC == zsdMode ) { return createMtkZsdNccCamAdapter(s8AppMode, i4OpenId, pParamsMgr); } else { return createMtkZsdCcCamAdapter(s8AppMode, i4OpenId, pParamsMgr); } }
bool ParamsManager:: updateHalAppMode() { bool ret = false; String8 s8HalAppMode; // RWLock::AutoWLock _lock(mRWLock); // int32_t const i4CamMode = mParameters.getInt(MtkCameraParameters::KEY_CAMERA_MODE); MY_LOGD("+ KEY_CAMERA_MODE:%d", i4CamMode); // // // If Client App Mode != <Default> App, then. // if ( ms8ClientAppMode != MtkCameraParameters::APP_MODE_NAME_DEFAULT ) { s8HalAppMode = ms8ClientAppMode; goto lbExit; } // // If Client App Mode == <Default> App, then: // if ( i4CamMode == MtkCameraParameters::CAMERA_MODE_NORMAL ) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_DEFAULT; goto lbExit; } // if ( i4CamMode == MtkCameraParameters::CAMERA_MODE_MTK_PRV ) { char const* pszZsdMode = mParameters.get(MtkCameraParameters::KEY_ZSD_MODE); if ( ! pszZsdMode || 0 != ::strcmp(pszZsdMode, MtkCameraParameters::ON) ) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_PHOTO; } else { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_ZSD; } // zsd: only for test { #if defined (MTK_ZSD_SUPPORT) #warning "[FIXME] MTK_ZSD_SUPPORT" MY_LOGD("MTK_ZSD_SUPPORT=yes This MACRO is for test ONLY"); SensorHal* pSensorHal = NULL; halSensorType_e eSensorType; halSensorDev_e eSensorDev = (halSensorDev_e)DevMetaInfo::queryHalSensorDev(getOpenId()); pSensorHal = SensorHal::createInstance(); if (pSensorHal == NULL) { MY_LOGE("pSensorHal == NULL"); goto lbExit; } pSensorHal->sendCommand(eSensorDev, SENSOR_CMD_GET_SENSOR_TYPE, (int32_t)&eSensorType); MY_LOGD("get sensor type, %d", eSensorType); if (eSensorType == SENSOR_TYPE_RAW) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_ZSD; } pSensorHal->destroyInstance(); pSensorHal = NULL; #endif int32_t i4ZsdMode = 0; char value[PROPERTY_VALUE_MAX] = {'\0'}; property_get("camera.zsdmode", value, "0"); i4ZsdMode = atoi(value); MY_LOGD("zsd mode %d", i4ZsdMode); if ( 1 == i4ZsdMode || 2 == i4ZsdMode ) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_ZSD; } else if ( 3 == i4ZsdMode ) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_PHOTO; } } goto lbExit; } if ( i4CamMode == MtkCameraParameters::CAMERA_MODE_MTK_VT ) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_VT; goto lbExit; } // if ( i4CamMode == MtkCameraParameters::CAMERA_MODE_MTK_VDO ) { s8HalAppMode = MtkCameraParameters::APP_MODE_NAME_MTK_VIDEO; goto lbExit; } // // MY_LOGE("- NOT IMPLEMENT YET !"); return false; // lbExit: // (3) update Hal's App Mode. // (.1) update Hal's property. MtkCamUtils::Property::set(String8(PROPERTY_KEY_HAL_APPMODE), s8HalAppMode); // // (.2) set Hal's App Mode. mi4HalAppMode = PARAMSMANAGER_MAP_INST(eMapAppMode)->valueFor(s8HalAppMode); // MY_LOGD("- property:%s=%s[%d]", PROPERTY_KEY_HAL_APPMODE, s8HalAppMode.string(), mi4HalAppMode); return true; }
bool ImpShot:: makeExifHeader(MUINT32 const u4CamMode, MUINT8* const puThumbBuf, MUINT32 const u4ThumbSize, MUINT8* puExifBuf, MUINT32 &u4FinalExifSize, MUINT32 u4ImgIndex, MUINT32 u4GroupId, MUINT32 u4FocusValH, MUINT32 u4FocusValL) { // MY_LOGD("[ImpShot]+ (u4CamMode, puThumbBuf, u4ThumbSize, puExifBuf) = (%d, %p, %d, %p)", u4CamMode, puThumbBuf, u4ThumbSize, puExifBuf); if (u4ThumbSize > 63 * 1024) { MY_LOGW("The thumbnail size is large than 63K, the exif header will be broken"); } bool ret = true; uint32_t u4App1HeaderSize = 0; uint32_t u4AppnHeaderSize = 0; uint32_t exifHeaderSize = 0; CamExif rCamExif; CamExifParam rExifParam; CamDbgParam rDbgParam; // ExifParam (for Gps) if (! mJpegParam.ms8GpsLatitude.isEmpty() && !mJpegParam.ms8GpsLongitude.isEmpty()) { rExifParam.u4GpsIsOn = 1; ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLatitude), mJpegParam.ms8GpsLatitude.string(), mJpegParam.ms8GpsLatitude.length()); ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLongitude), mJpegParam.ms8GpsLongitude.string(), mJpegParam.ms8GpsLongitude.length()); ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSTimeStamp), mJpegParam.ms8GpsTimestamp.string(), mJpegParam.ms8GpsTimestamp.length()); ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSProcessingMethod), mJpegParam.ms8GpsMethod.string(), mJpegParam.ms8GpsMethod.length()); rExifParam.u4GPSAltitude = ::atoi(mJpegParam.ms8GpsAltitude.string()); } // the bitstream already rotated. rotation should be 0 //Add for JPEG-Sensor MBOOL outputJPEGFile, bFixedOrientation; SensorHal* pSensorHal = SensorHal::createInstance(); MUINT32 u4DeviceID = 0; if (NULL != pSensorHal) { u4DeviceID = static_cast<MUINT32>(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())); MY_LOGW("[shot][makeExifHeader] u4DeviceID=%d\n", u4DeviceID); pSensorHal->init(); //get sensor format info pSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID), SENSOR_CMD_GET_YUV_SENSOR_CAPTURE_OUTPUT_JPEG, (MBOOL)&outputJPEGFile, 0, 0 ); pSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID), SENSOR_CMD_GET_YUV_SENSOR_FIXED_JPEG_ORIENTATION, (MBOOL)&bFixedOrientation, 0, 0 ); } else { outputJPEGFile = 0; bFixedOrientation = 0; } if (outputJPEGFile && bFixedOrientation) { rExifParam.u4Orientation = mShotParam.mi4Rotation; MY_LOGW("[shot][makeExifHeader] u4Orientation=%d, bFixedOrientation=%d, outputJPEGFile=%d\n", mShotParam.mi4Rotation, bFixedOrientation, outputJPEGFile); } else { rExifParam.u4Orientation = 0; MY_LOGW("[shot][makeExifHeader] nonJpegSensor, u4Orientation=0\n"); } rExifParam.u4ZoomRatio = mShotParam.mu4ZoomRatio; // camera_info rCameraInfo = MtkCamUtils::DevMetaInfo::queryCameraInfo(getOpenId()); rExifParam.u4Facing = rCameraInfo.facing; // rExifParam.u4ImgIndex = u4ImgIndex; rExifParam.u4GroupId = u4GroupId; // rExifParam.u4FocusH = u4FocusValH; rExifParam.u4FocusL = u4FocusValL; // //! CamDbgParam (for camMode, shotMode) rDbgParam.u4CamMode = u4CamMode; rDbgParam.u4ShotMode = getShotMode(); // rCamExif.init(rExifParam, rDbgParam); // Hal3ABase* p3AHal = Hal3ABase::createInstance(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())); p3AHal->set3AEXIFInfo(&rCamExif); // the bitstream already rotated. it need to swap the width/height if ((!outputJPEGFile) && (90 == mShotParam.mi4Rotation || 270 == mShotParam.mi4Rotation)) { rCamExif.makeExifApp1(mShotParam.mi4PictureHeight, mShotParam.mi4PictureWidth, u4ThumbSize, puExifBuf, &u4App1HeaderSize); } else { rCamExif.makeExifApp1(mShotParam.mi4PictureWidth, mShotParam.mi4PictureHeight, u4ThumbSize, puExifBuf, &u4App1HeaderSize); } // copy thumbnail image after APP1 MUINT8 *pdest = puExifBuf + u4App1HeaderSize; ::memcpy(pdest, puThumbBuf, u4ThumbSize) ; // // 3A Debug Info p3AHal->setDebugInfo(&rCamExif); // // Sensor Debug Info pSensorHal->setDebugInfo(&rCamExif); pdest = puExifBuf + u4App1HeaderSize + u4ThumbSize; // rCamExif.appendDebugExif(pdest, &u4AppnHeaderSize); rCamExif.uninit(); u4FinalExifSize = u4App1HeaderSize + u4ThumbSize + u4AppnHeaderSize; p3AHal->destroyInstance(); pSensorHal->destroyInstance(); MY_LOGD("- (app1Size, appnSize, exifSize) = (%d, %d, %d)", u4App1HeaderSize, u4AppnHeaderSize, u4FinalExifSize); return ret; }
bool AsdClient:: init() { bool ret = true; //Get Sensor Type //MINT32 i4SensorDevId = DevMetaInfo::queryHalSensorDev(mpParamsMgr->getOpenId()); SensorHal* pSensorHal = SensorHal::createInstance(); if ( !pSensorHal ) { return NULL; } pSensorHal->sendCommand(static_cast<halSensorDev_e>(SENSOR_DEV_MAIN), SENSOR_CMD_GET_SENSOR_TYPE, reinterpret_cast<int>(&eSensorType), 0, 0 ); if ( pSensorHal ) { pSensorHal->destroyInstance(); pSensorHal = NULL; } if(eSensorType == SENSOR_TYPE_YUV) MY_LOGD("ASD: YUV Sensor"); else if(eSensorType == SENSOR_TYPE_RAW) MY_LOGD("ASD: RAW Sensor"); else MY_LOGD("ASD: Unknown Sensor"); //Create Working Buffer mpWorkingBuf = (MUINT8*)malloc(MHAL_ASD_WORKING_BUF_SIZE); if(mpWorkingBuf == NULL) { MY_LOGW("memory is not enough"); return false; } //Create FD Buffer mpFaceInfo = new MtkCameraFaceMetadata; if ( NULL != mpFaceInfo ) { MtkCameraFace *faces = new MtkCameraFace[AsdClient::mDetectedFaceNum]; MtkFaceInfo *posInfo = new MtkFaceInfo[AsdClient::mDetectedFaceNum]; if ( NULL != faces && NULL != posInfo) { mpFaceInfo->faces = faces; mpFaceInfo->posInfo = posInfo; mpFaceInfo->number_of_faces = 0; } } mSceneCur = mhal_ASD_DECIDER_UI_AUTO; mScenePre = mhal_ASD_DECIDER_UI_SCENE_NUM; // return ret; }
MBOOL HdrHal::init(void *pInitInData) { HDR_LOGD("- E. mUsers: %d.", mUsers); HDR_PIPE_INIT_INFO* prHdrPipeInitInfo = (HDR_PIPE_INIT_INFO*)pInitInData; HDR_LOGV("ImgW/H: (%d, %d). FinalGainDiff[0/1]: (%d, %d). OutputFrameNum: %d. TargetTone: %d.", prHdrPipeInitInfo->u4ImgW, prHdrPipeInitInfo->u4ImgH, prHdrPipeInitInfo->u4FinalGainDiff0, prHdrPipeInitInfo->u4FinalGainDiff1, prHdrPipeInitInfo->u4OutputFrameNum, prHdrPipeInitInfo->u4TargetTone); HDR_LOGV("pSourceImgBufAddr[0/1/2]: (%p, %p, %p).", prHdrPipeInitInfo->pSourceImgBufAddr[0], prHdrPipeInitInfo->pSourceImgBufAddr[1], prHdrPipeInitInfo->pSourceImgBufAddr[2]); MBOOL ret = MFALSE; MINT32 err = 0; // 0: No error. other value: error. Mutex::Autolock lock(mLock); if (mUsers > 0) { HDR_LOGD("%d has created.", mUsers); android_atomic_inc(&mUsers); HDR_LOGD("- X. ret: %d.", MTRUE); return MTRUE; } // Create HdrDrv instance. m_pHdrDrv = MTKHdr::createInstance(); if (!m_pHdrDrv) { HDR_LOGD("MTKHdr::createInstance() fail."); goto create_fail_exit; } // Allocate working buffer needed by Drv (HdrDrv and MavDrv). // Init HdrDrv object. // Fill init data. HDR_SET_ENV_INFO_STRUCT rHdrInitInfo; rHdrInitInfo.image_num = prHdrPipeInitInfo->u4OutputFrameNum; GS_u4OutputFrameNum = prHdrPipeInitInfo->u4OutputFrameNum; // Record u4OutputFrameNum for HDR Pipe to use. rHdrInitInfo.ev_gain1 = (MUINT16)prHdrPipeInitInfo->u4FinalGainDiff0; rHdrInitInfo.ev_gain2 = 1024; // Fix at 1024. rHdrInitInfo.ev_gain3 = (MUINT16)prHdrPipeInitInfo->u4FinalGainDiff1; rHdrInitInfo.target_tone = prHdrPipeInitInfo->u4TargetTone; rHdrInitInfo.image_width = prHdrPipeInitInfo->u4ImgW; rHdrInitInfo.image_height = prHdrPipeInitInfo->u4ImgH; if(CustomHdrUseIspGamma()) { HDR_LOGD("Use ISP Gamma"); rHdrInitInfo.pIsp_gamma = prHdrPipeInitInfo->pIsp_gamma; } else { HDR_LOGD("Use Fixed Gamma"); rHdrInitInfo.pIsp_gamma = NULL; } rHdrInitInfo.hdr_tuning_data.BRatio = CustomHdrBRatioGet(); for (MUINT32 i = 0; i < 11; i++) { rHdrInitInfo.hdr_tuning_data.Gain[i] = CustomHdrGainArrayGet(i); } rHdrInitInfo.hdr_tuning_data.BottomFRatio = CustomHdrBottomFRatioGet(); rHdrInitInfo.hdr_tuning_data.TopFRatio = CustomHdrTopFRatioGet(); rHdrInitInfo.hdr_tuning_data.BottomFBound = CustomHdrBottomFBoundGet(); rHdrInitInfo.hdr_tuning_data.TopFBound = CustomHdrTopFBoundGet(); rHdrInitInfo.hdr_tuning_data.ThHigh = CustomHdrThHighGet(); rHdrInitInfo.hdr_tuning_data.ThLow = CustomHdrThLowGet(); rHdrInitInfo.hdr_tuning_data.TargetLevelSub = CustomHdrTargetLevelSubGet(); rHdrInitInfo.hdr_tuning_data.CoreNumber = CustomHdrCoreNumberGet(); rHdrInitInfo.hdr_tuning_data.HdrSpeed = HDR_PROCESS_NORMAL; //Never use HDR_PROCESS_FAST #if 0 //(#) get sensor type { HDR_INFO_SRC_ENUM meSensorType = HDR_INFO_SRC_RAW; halSensorDev_e meSensorDev; SensorHal* mpSensor; //temp mark to avoid build error //mpSensor = SensorHal::createInstance(); if (!mpSensor) { HDR_LOGD("[%s] NULL m_pSensorHal!\n", __FUNCTION__); return MFALSE; } mpSensor->sendCommand(SENSOR_DEV_NONE, SENSOR_CMD_GET_SENSOR_DEV, (MINTPTR)&meSensorDev, 0, 0); if (meSensorDev == SENSOR_DEV_NONE) { HDR_LOGD("[%s] m_SensorDev is incorrect %d\n", __FUNCTION__, SENSOR_DEV_NONE); return MFALSE; } mpSensor->sendCommand(meSensorDev, SENSOR_CMD_GET_SENSOR_TYPE, (MINTPTR)&meSensorType); if(meSensorType == SENSOR_TYPE_YUV) { rHdrInitInfo.HdrSrcInfo = HDR_INFO_SRC_YUV; } else { rHdrInitInfo.HdrSrcInfo = HDR_INFO_SRC_RAW; } mpSensor->destroyInstance(); } HDR_LOGD("rHdrInitInfo:: ImgW/H: (%d, %d). FinalGainDiff[0/1]: (%d, %d). OutputFrameNum: %d. TargetTone: %d. RawSensor: %d." , rHdrInitInfo.image_width , rHdrInitInfo.image_height , rHdrInitInfo.ev_gain1 , rHdrInitInfo.ev_gain3 , rHdrInitInfo.image_num , rHdrInitInfo.target_tone , rHdrInitInfo.HdrSrcInfo); #else rHdrInitInfo.HdrSrcInfo = (prHdrPipeInitInfo->u4SensorType == SENSOR_TYPE_YUV) ? HDR_INFO_SRC_YUV : HDR_INFO_SRC_RAW; HDR_LOGD("rHdrInitInfo:: ImgW/H: (%d, %d). FinalGainDiff[0/1]: (%d, %d). OutputFrameNum: %d. TargetTone: %d." , rHdrInitInfo.image_width , rHdrInitInfo.image_height , rHdrInitInfo.ev_gain1 , rHdrInitInfo.ev_gain3 , rHdrInitInfo.image_num , rHdrInitInfo.target_tone); #endif //HDR_LOGV("rHdrInitInfo:: pSourceImgBufAddr[0/1/2]: (0x%08X, 0x%08X, 0x%08X).", rHdrInitInfo.image_addr[0], rHdrInitInfo.image_addr[1], rHdrInitInfo.image_addr[2]); HDR_LOGV("rHdrInitInfo:: BRatio: %d. BottomFRatio: %f. TopFRatio: %f. BottomFBound: %d. TopFBound: %d.", rHdrInitInfo.hdr_tuning_data.BRatio, rHdrInitInfo.hdr_tuning_data.BottomFRatio, rHdrInitInfo.hdr_tuning_data.TopFRatio, rHdrInitInfo.hdr_tuning_data.BottomFBound, rHdrInitInfo.hdr_tuning_data.TopFBound ); HDR_LOGV("rHdrInitInfo:: ThHigh: %d. ThLow: %d. TargetLevelSub: %d.", rHdrInitInfo.hdr_tuning_data.ThHigh, rHdrInitInfo.hdr_tuning_data.ThLow, rHdrInitInfo.hdr_tuning_data.TargetLevelSub ); for (MUINT32 i = 0; i < 11; i++) HDR_LOGV("rHdrInitInfo:: u4Gain[%d]: %d.", i, rHdrInitInfo.hdr_tuning_data.Gain[i]); // Call HdrDrv init. err = m_pHdrDrv->HdrInit(&rHdrInitInfo, 0); if (err) // if ret != 0 means error happened. { HDR_LOGD("m_pHdrDrv->HdrInit() fail, err=%d", err); goto create_fail_exit; } if(1) { // set HDR default pthread attribute to avoid RT throttling pthread_attr_t attr = {0, NULL, 1024 * 1024, 4096, SCHED_OTHER, ANDROID_PRIORITY_FOREGROUND+1}; m_pHdrDrv->HdrFeatureCtrl(HDR_FEATURE_SET_PTHREAD_ATTR, &attr, NULL); } #if EARLY_MAV_INIT // Create MavDrv instance. m_pMavDrv = MTKMav::createInstance(DRV_MAV_OBJ_SWHDR); if (!m_pMavDrv) { HDR_LOGD("MTKMav::createInstance() fail."); goto create_fail_exit; } // Init MavDrv object. // Fill init data. MavInitInfo rMavInitInfo; rMavInitInfo.WorkingBuffAddr = (MUINT32)global_buffer_rectify; // FIXME: Allocate working buffer for MAV. rMavInitInfo.pTuningInfo = NULL; // Call MavDrv init. err = m_pMavDrv->MavInit(&rMavInitInfo, 0); if (err) // if ret != 0 means error happened. { HDR_LOGD("m_pMavDrv->MavInit() fail. err: %d.", err); goto create_fail_exit; } #endif // EARLY_MAV_INIT android_atomic_inc(&mUsers); ret = MTRUE; HDR_LOGD("- X. ret: %d.", ret); return ret; create_fail_exit: // HdrDrv Init failed, destroy HdrDrv instance. if (m_pHdrDrv) { m_pHdrDrv->destroyInstance(); m_pHdrDrv = NULL; } #if EARLY_MAV_INIT // MavDrv Init failed, destroy MavDrv instance. if (m_pMavDrv) { m_pMavDrv->MavReset(); m_pMavDrv->destroyInstance(); m_pMavDrv = NULL; } #endif // EARLY_MAV_INIT HDR_LOGD("- X. ret: %d.", ret); return ret; // 0: No error. other value: error. }