MBOOL ExtImgProcNodeImpl:: pushBuf(MUINT32 const data, IImageBuffer* const buf, MUINT32 const ext) { Mutex::Autolock lock(mLock); PostBufInfo postBufData = {data, buf, ext}; mlPostBufData.push_back(postBufData); MY_LOGD("size(%d), data(%d), buf(0x%x)", mlPostBufData.size(), postBufData.data, postBufData.buf); muPostFrameCnt++; if( isReadyToTransfrom() ) { triggerLoop(); } return MTRUE; }
MBOOL JpegCodec:: isSupportedFormat(EImageFormat const eFmt) { FUNCTION_LOG_START; MY_LOGD("Format:0x%x", eFmt); if (eFmt == eImgFmt_YUY2) { return MTRUE; } #if 0 else if (eFmt == eImgFmt_NV21) { return MTRUE; } #endif else { return MFALSE; } FUNCTION_LOG_END; }
MBOOL EngBufHandlerImpl:: unmapPort(EBufProvider bufType) { Mutex::Autolock _l(mLock); // MBOOL isFind= MFALSE; MUINT32 i; list<MAP_PORT_INFO>::iterator iterMapPort; // for(i=0; i<EPass2Out_DST_AMOUNT; i++) { for(iterMapPort = mlMapPort[i].begin(); iterMapPort != mlMapPort[i].end();) { if((*iterMapPort).bufType == bufType) { MY_LOGD("bufType(%d),nodeType(%d)", (*iterMapPort).bufType, (*iterMapPort).nodeType); iterMapPort = mlMapPort[i].erase(iterMapPort); isFind = MTRUE; break; } else { iterMapPort++; } } } // if(!isFind) { MY_LOGW("Can't fin bufType(%d)",bufType); } // return MTRUE; }
MBOOL MultiShotCc:: sendCommand(MINT32 cmd, MINT32 arg1, MINT32 arg2, MINT32 arg3) { FUNCTION_LOG_START; MBOOL ret = MTRUE; // switch (cmd) { case ECamShot_CMD_SET_CSHOT_SPEED: if(arg1 > 0) { mu4ShotSpeed = arg1; ret = MTRUE; } else { MY_LOGD("set invalid shot speed: %d", arg1); ret = MFALSE; } break; case ECamShot_CMD_SET_CAPBUF_MGR: { ICaptureBufMgrHandler* pCaptureBufMgr = reinterpret_cast<ICaptureBufMgrHandler*>(arg1); mpCaptureBufMgr = pCaptureBufMgr; } break; default: break; } // FUNCTION_LOG_END; // return ret; }
MBOOL MultiShotNcc:: onCreateImage() { AutoCPTLog cptlog(Event_MShot_onCreateImage); mpYuvImageCreateThread->postCommand(Command(Command::eID_WAKEUP)); MUINT32 u4ShotCount = 0; //MBOOL bCShotEndCB = false; // (3) loop, handle jpeg buffer while(u4ShotCount<mu4ShotCount) { CPTLogStr(Event_MShot_onCreateImage, CPTFlagSeparator, "wait jpeg done"); ::sem_wait(&semJpeg); CPTLogStr(Event_MShot_onCreateImage, CPTFlagSeparator, "handle callback"); if(mbIsLastShot || u4ShotCount==mu4ShotCount-1) // last frame { MY_LOGD("notify last shot will callback"); handleNotifyCallback(ECamShot_NOTIFY_MSG_CSHOT_END, 0, 0); handleNotifyCallback(ECamShot_NOTIFY_MSG_FOCUS_VALUE, mFocusVal.u4ValH, mFocusVal.u4ValL); handleDataCallback(ECamShot_DATA_MSG_JPEG, (mThumbImgBufInfoReady.u4BufVA), mu4ThumbnailSize, reinterpret_cast<MUINT8*>(mJpegImgBufInfoReady.u4BufVA), mu4JpegSize); break; } handleNotifyCallback(ECamShot_NOTIFY_MSG_FOCUS_VALUE, mFocusVal.u4ValH, mFocusVal.u4ValL); handleDataCallback(ECamShot_DATA_MSG_JPEG, (mThumbImgBufInfoReady.u4BufVA), mu4ThumbnailSize, reinterpret_cast<MUINT8*>(mJpegImgBufInfoReady.u4BufVA), mu4JpegSize); u4ShotCount++; } // (7) start end CPTLogStr(Event_MShot_start, CPTFlagSeparator, "post start end sem"); ::sem_post(&semStartEnd); return MTRUE; }
status_t ParamsManager:: setParameters(CameraParameters const& params) { IParamsManager::showParameters(params.flatten()); // status_t status = OK; bool bIsSceneChanged = false; Size oldPrvSize, tmpPrvSize, newPrvSize; Size oldPicSize, newPicSize; // // (1) Check to see if new parameters are valid or not. if ( OK != (status = checkParams(params)) ) { MY_LOGE("checkParams() return %d", status); return status; } // (2) Check to see if Scene Changes or not. MY_LOGD("%d: +", getOpenId()); RWLock::AutoWLock _lock(mRWLock); MY_LOGD("AutoWLock"); // char const*const pOldScene = mParameters.get(CameraParameters::KEY_SCENE_MODE); char const*const pNewScene = params.get(CameraParameters::KEY_SCENE_MODE); if ( 0 != ::strcmp(pOldScene, pNewScene) ) { // scene mode has changed MY_LOGD("Scene change: %s -> %s", pOldScene, pNewScene); bIsSceneChanged = true; } // // (3.1) Check to see if Preview Size Changes or not. Get old preview size mParameters.getPreviewSize(&oldPrvSize.width, &oldPrvSize.height); params.getPreviewSize(&tmpPrvSize.width, &tmpPrvSize.height); // (3.2) Get old&new picture size mParameters.getPictureSize(&oldPicSize.width, &oldPicSize.height); params.getPictureSize(&newPicSize.width, &newPicSize.height); // (4) Update Parameter mParameters = params; if ( bIsSceneChanged ) { if ( ! updateSceneAndParams() ) { status = BAD_VALUE; } } // (5) Update Parameter: preview size updatePreviewSize(); // (6) Update FOV according to picture size MY_LOGI("picSZ(%d,%d)->(%d,%d)",oldPicSize.width,oldPicSize.height,newPicSize.width,newPicSize.height); if(oldPicSize.width != newPicSize.width || oldPicSize.height != newPicSize.height) { updateFov(newPicSize); } // (3.2) Check to see if Preview Size Changes or not. Get new preview size mParameters.getPreviewSize(&newPrvSize.width, &newPrvSize.height); if ( oldPrvSize.width != newPrvSize.width || oldPrvSize.height != newPrvSize.height ) { MY_LOGD( "Preview Size change: %dx%d/%dx%d -> (%dx%d)", oldPrvSize.width, oldPrvSize.height, tmpPrvSize.width, tmpPrvSize.height, newPrvSize.width, newPrvSize.height ); } // MY_LOGD("-"); return status; }
MBOOL CamIOPipe:: dequeHWBuf(MUINT32 const u4TimeoutMs /*= 0xFFFFFFFF*/) { //FUNCTION_LOG_START; MY_LOGD("+ tid(%d) tout)=(%d)", gettid(), u4TimeoutMs); // NSImageio::NSIspio::QTimeStampBufInfo rQTimeOutBufInfo; NSImageio::NSIspio::PortID rPortID(NSImageio::NSIspio::EPortType_Memory, NSImageio::NSIspio::EPortIndex_IMGO, 1); //Jackie, wait deque directly // (1). wait interrupt done //mpCamIOPipe->irq(NSImageio::NSIspio::EPipePass_PASS1_TG1,NSImageio::NSIspio::EPIPEIRQ_PATH_DONE); // (2.1). dequeue buffer , Raw mpCamIOPipe->dequeOutBuf(rPortID, rQTimeOutBufInfo); if( rQTimeOutBufInfo.vBufInfo.size() == 0 ) { MY_LOGE("deque failed"); return MFALSE; } // (2.2). put buffer Raw in queue mrRawQTBufInfo.u4User = rQTimeOutBufInfo.u4User; mrRawQTBufInfo.u4Reserved = rQTimeOutBufInfo.u4Reserved; mrRawQTBufInfo.i4TimeStamp_sec = rQTimeOutBufInfo.vBufInfo.at(0).i4TimeStamp_sec; mrRawQTBufInfo.i4TimeStamp_us = rQTimeOutBufInfo.vBufInfo.at(0).i4TimeStamp_us; for (MUINT32 i = 0; i < rQTimeOutBufInfo.vBufInfo.size(); i++) { BufInfo rBufInfo; mapBufInfo(rBufInfo, rQTimeOutBufInfo.vBufInfo.at(i)); mrRawQTBufInfo.vBufInfo.push_back(rBufInfo); } if (mfgIsYUVPortON) { // (3.1). dequeue buffer , Raw rPortID.index = NSImageio::NSIspio::EPortIndex_IMG2O; mpCamIOPipe->dequeOutBuf(rPortID, rQTimeOutBufInfo); if( rQTimeOutBufInfo.vBufInfo.size() == 0 ) { MY_LOGE("deque failed"); return MFALSE; } // (3.2). put buffer yuv in queue mrYuvQTBufInfo.u4User = rQTimeOutBufInfo.u4User; mrYuvQTBufInfo.u4Reserved = rQTimeOutBufInfo.u4Reserved; mrYuvQTBufInfo.i4TimeStamp_sec = rQTimeOutBufInfo.vBufInfo.at(0).i4TimeStamp_sec; mrYuvQTBufInfo.i4TimeStamp_us = rQTimeOutBufInfo.vBufInfo.at(0).i4TimeStamp_us; for (MUINT32 i = 0; i < rQTimeOutBufInfo.vBufInfo.size(); i++) { BufInfo rBufInfo; mapBufInfo(rBufInfo, rQTimeOutBufInfo.vBufInfo.at(i)); mrYuvQTBufInfo.vBufInfo.push_back(rBufInfo); } } //FUNCTION_LOG_END; return MTRUE; }
MBOOL PostProcPipe:: dequeBuf(PortID const ePortID, QTimeStampBufInfo& rQBufInfo, MUINT32 const u4TimeoutMs /*= 0xFFFFFFFF*/) { FUNCTION_LOG_START; MY_LOGD("+ tid(%d) PortID:(type, index, inout, timeout)=(%d, %d, %d, %d)", gettid(), ePortID.type, ePortID.index, ePortID.inout, u4TimeoutMs); MBOOL ret = MTRUE; // NSImageio::NSIspio::QTimeStampBufInfo rQTimeOutBufInfo; NSImageio::NSIspio::PortID rPortID(NSImageio::NSIspio::EPortType_Memory, NSImageio::NSIspio::EPortIndex_IMGI, 0); // dequeue buffer if (EPortType_MemoryOut == ePortID.type) { rPortID.inout = 1; if (0 == ePortID.index && (mu4OutPortEnableFlag & 0x1)) //disp port { rPortID.type = NSImageio::NSIspio::EPortType_DISP_RDMA; rPortID.index = NSImageio::NSIspio::EPortIndex_DISPO; } else if(1 == ePortID.index && (mu4OutPortEnableFlag & 0x2)) //vdo port { rPortID.type = NSImageio::NSIspio::EPortType_VID_RDMA; rPortID.index = NSImageio::NSIspio::EPortIndex_VIDO; } else { MY_LOGE("The deque out port is not config"); return MFALSE; } } // if (EPortType_MemoryOut == ePortID.type) { ret = mpPostProcPipe->dequeOutBuf(rPortID, rQTimeOutBufInfo); } else { ret = mpPostProcPipe->dequeInBuf(rPortID, rQTimeOutBufInfo); } // (2.2). put buffer in queue rQBufInfo.u4User = rQTimeOutBufInfo.u4User; rQBufInfo.u4Reserved = rQTimeOutBufInfo.u4Reserved; rQBufInfo.i4TimeStamp_sec = rQTimeOutBufInfo.i4TimeStamp_sec; rQBufInfo.i4TimeStamp_us = rQTimeOutBufInfo.i4TimeStamp_us; for (MUINT32 i = 0; i < rQTimeOutBufInfo.vBufInfo.size(); i++) { BufInfo rBufInfo; mapBufInfo(rBufInfo, rQTimeOutBufInfo.vBufInfo.at(i)); rQBufInfo.vBufInfo.push_back(rBufInfo); } MY_LOGD("TimeStamp: (sec, us) = (%d, %d)", rQBufInfo.i4TimeStamp_sec, rQBufInfo.i4TimeStamp_us); for (MUINT32 i = 0; i < rQBufInfo.vBufInfo.size(); i++) { MY_LOGD("QBufInfo(VA, PA, Size, ID) = (%x, %x, %d, %d)", rQBufInfo.vBufInfo.at(i).u4BufVA, rQBufInfo.vBufInfo.at(i).u4BufPA, rQBufInfo.vBufInfo.at(i).u4BufSize, rQBufInfo.vBufInfo.at(i).i4MemID); } FUNCTION_LOG_END; return ret; }
//----------------------------------------------------------------------------- MBOOL ResourceLockImp:: GetResMgr( ECamAdapter Type, RES_MGR_DRV_MODE_STRUCT& Dst) { MBOOL Result = MTRUE; // if(mUser <= 0) { MY_LOGE("No user"); Result = MFALSE; goto EXIT; } // switch(Type) { case eMTK_NONE: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_NONE; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_NONE; break; } case eMTKCAM_IDLE: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_CAM_IDLE; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_NONE; break; } case eMTKPHOTO_PRV: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_CAM_PRV; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } case eMTKVIDEO_PRV: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_VIDEO_PRV; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } case eMTKVIDEO_REC: case eMTKVIDEO_REC_HS: { Dst.Dev = RES_MGR_DRV_DEV_CAM; if(Type == eMTKVIDEO_REC) { Dst.ScenSw = RES_MGR_DRV_SCEN_SW_VIDEO_REC; } else { Dst.ScenSw = RES_MGR_DRV_SCEN_SW_VIDEO_REC_HS; } Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } case eMTKVIDEO_VSS: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_VIDEO_VSS; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } case eMTKZSDNCC_PRV: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_ZSD; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_ZSD; break; } case eMTKZSDCC_PRV: { Dst.Dev = RES_MGR_DRV_DEV_CAM; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_ZSD; // zsd am i right? Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } case eMTK_ATV: { Dst.Dev = RES_MGR_DRV_DEV_ATV; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_CAM_PRV; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } case eMTK_VT: { Dst.Dev = RES_MGR_DRV_DEV_VT; Dst.ScenSw = RES_MGR_DRV_SCEN_SW_CAM_PRV; Dst.ScenHw = RES_MGR_DRV_SCEN_HW_VSS; break; } default: { break; } } // MY_LOGD("Type(%d),ScenSw(%d),ScenHw(%d),Dev(%d)", Type, Dst.ScenSw, Dst.ScenHw, Dst.Dev); // EXIT: return Result; }
MBOOL CamIOPipe:: querySensorInfo(MUINT32 const u4DeviceID, MUINT32 const u4Scenario, MUINT32 const u4BitDepth, EImageFormat &eFmt, MUINT32 &u4Width, MUINT32 &u4Height, MUINT32 & u4RawPixelID) { MY_LOGD("+ (id, scenario, bitdepth) = (%d, %d, %d)", u4DeviceID, u4Scenario, u4BitDepth); MINT32 cmd = 0; switch (u4Scenario) { case ACDK_SCENARIO_ID_CAMERA_PREVIEW: cmd = SENSOR_CMD_GET_SENSOR_PRV_RANGE; break; case ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG: cmd = SENSOR_CMD_GET_SENSOR_FULL_RANGE; break; case ACDK_SCENARIO_ID_VIDEO_PREVIEW: cmd = SENSOR_CMD_GET_SENSOR_VIDEO_RANGE; break; } // Sensor type halSensorType_e eSensorType; mpSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID), SENSOR_CMD_GET_SENSOR_TYPE, reinterpret_cast<int>(&eSensorType), 0, 0 ); //get sensor format info halSensorRawImageInfo_t rRawImgInfo; memset(&rRawImgInfo, 0, sizeof(rRawImgInfo)); mpSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID), SENSOR_CMD_GET_RAW_INFO, (MINT32)&rRawImgInfo, 1, 0 ); switch(eSensorType) { case SENSOR_TYPE_RAW: eFmt = mapRawFormat(u4BitDepth); u4RawPixelID = mapRawPixelID(rRawImgInfo.u1Order); break; case SENSOR_TYPE_YUV: case SENSOR_TYPE_YCBCR: eFmt = mapYUVFormat(rRawImgInfo.u1Order); break; break; case SENSOR_TYPE_RGB565: eFmt = eImgFmt_RGB565; break; case SENSOR_TYPE_RGB888: eFmt = eImgFmt_RGB888; break; case SENSOR_TYPE_JPEG: eFmt = eImgFmt_JPEG; default: eFmt = eImgFmt_UNKNOWN; break; } // resolution mpSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID), cmd, (int)&u4Width, (int)&u4Height, 0 ); MY_LOGD("- (eFmt, u4Width, u4Height, u4RawPixelID) = (0x%x, %d, %d, %d)", eFmt, u4Width, u4Height, u4RawPixelID); return MTRUE; }
MINT32 halASD::mHalAsdInit(void* AAAData,void* working_buffer,MUINT8 SensorType, MINT32 Asd_Buf_Width, MINT32 Asd_Buf_Height) { g_udCount++; MY_LOGD("[halASD] g_udCount++:%d \n", g_udCount); AAA_ASD_PARAM* rASDInfo=(AAA_ASD_PARAM*)AAAData; MINT32 Retcode = S_ASD_OK; MUINT32* AFtable=(MUINT32*)malloc((rASDInfo->i4AFTableIdxNum + 1)*sizeof(MUINT32)); //********************************************************************************// //********Binchang 20110810 Add ASD Debug Opition****************// char value[PROPERTY_VALUE_MAX] = {'\0'}; property_get("ASD.debug.dump", value, "0"); mHalASDDumpOPT = atoi(value); //********************************************************************************// //********************************************************************************// gMyAsdInitInfo.pInfo = &gMyAsdEnvInfo; gMyAsdInitInfo.pDeciderInfo = &gMyDeciderEnvInfo; gMyAsdInitInfo.pDeciderTuningInfo = &gMyDeciderTuningInfo; gMyAsdInitInfo.pInfo->ext_mem_start_addr=(MUINT32)working_buffer; // working buffer, size: ASD_WORKING_BUFFER_SIZE gMyAsdInitInfo.pInfo->image_width =Asd_Buf_Width; // source image width (160) gMyAsdInitInfo.pInfo->image_height=Asd_Buf_Height; // source image height gMyAsdInitInfo.pInfo->asd_tuning_data.num_of_ort=ASD_ORT; // num_of_ort, drfault = 4 //*********************************************************************************************************************************************// //Please fix me Bin if(SensorType) { MY_LOGD("[YUV Sensor] \n"); gMyAsdInitInfo.pDeciderInfo->DeciderInfoVer = ASD_DECIDER_INFO_SRC_YUV; // Smart Phone Info } else { MY_LOGD("[SP_RAW_Sensor] \n"); gMyAsdInitInfo.pDeciderInfo->DeciderInfoVer = ASD_DECIDER_INFO_SRC_SP_RAW; // Smart Phone Info } //*********************************************************************************************************************************************// /* if(SensorType==ISP_SENSOR_TYPE_YUV) { gMyAsdInitInfo.pDeciderInfo->DeciderInfoVer = ASD_DECIDER_INFO_SRC_YUV; // Smart Phone Info } else { gMyAsdInitInfo.pDeciderInfo->DeciderInfoVer = ASD_DECIDER_INFO_SRC_SP_RAW; // Smart Phone Info } */ //*********************************************************************************************************************************************// gMyAsdInitInfo.pDeciderInfo->RefAwbD65Rgain = rASDInfo->i4AWBRgain_D65_X128; // reference 3A info, get from sensor or AWB data gMyAsdInitInfo.pDeciderInfo->RefAwbD65Bgain = rASDInfo->i4AWBBgain_D65_X128; // reference 3A info, get from sensor or AWB data gMyAsdInitInfo.pDeciderInfo->RefAwbCwfRgain = rASDInfo->i4AWBRgain_CWF_X128; // reference 3A info, get from sensor or AWB data gMyAsdInitInfo.pDeciderInfo->RefAwbCwfBgain = rASDInfo->i4AWBBgain_CWF_X128; // reference 3A info, get from sensor or AWB data *AFtable=rASDInfo->i4AFTableMacroIdx; memcpy((AFtable+1),rASDInfo->pAFTable,(rASDInfo->i4AFTableIdxNum*sizeof(MUINT32))); MY_LOGD("[mHalAsdInit] i4AFTableMacroIdx %d i4AFTableIdxNum %d i4AFTableOffset %d\n",rASDInfo->i4AFTableMacroIdx,rASDInfo->i4AFTableIdxNum,rASDInfo->i4AFTableOffset); for(int i=1;i<rASDInfo->i4AFTableIdxNum+1;i++) { *(AFtable+i) = *(AFtable+i) + rASDInfo->i4AFTableOffset; MY_LOGD("[mHalAsdInit] After (Offset) AF table %d \n",*(AFtable+i)); } //BinChang 20121228 //gMyAsdInitInfo.pDeciderInfo->RefAfTbl = (void *)AFtable; // reference 3A info, get from lens or AF data if(rASDInfo->i4AFTableMacroIdx != 0) gMyAsdInitInfo.pDeciderInfo->RefAfTbl = (void *)AFtable; else gMyAsdInitInfo.pDeciderInfo->RefAfTbl = NULL; gMyAsdInitInfo.pDeciderTuningInfo = 0; // use default value if (m_pMTKAsdObj) { Retcode = E_ASD_ERR; MY_LOGD("[v] Err, Init has been called \n"); } /* Create MTKPano Interface */ if(m_pMTKAsdObj == NULL) { m_pMTKAsdObj = MTKAsd::createInstance(DRV_ASD_OBJ_SW); MY_LOGW_IF(m_pMTKAsdObj == NULL, "Err"); } m_pMTKAsdObj->AsdInit(&gMyAsdInitInfo, 0); if (AFtable) { free(AFtable); } return Retcode; }
status_t MetadataProvider:: constructStaticMetadata(sp<IMetadataConverter> pConverter, camera_metadata*& rpDstMetadata, IMetadata& mtkMetadata) { MY_LOGD("construct static metadata\n"); status_t status = OK; //-----(1)-----// //get static informtation from customization (with camera_metadata format) //calculate its entry count and data count if ( OK != (status = impConstructStaticMetadata(mtkMetadata)) ) { MY_LOGE("Unable evaluate the size for camera static info - status[%s(%d)]\n", ::strerror(-status), -status); return status; } MY_LOGD("Allocating %d entries from customization", mtkMetadata.count()); //-----(2.1)------// //get static informtation from sensor hal moduls (with IMetadata format) IMetadata sensorMetadata = IHalSensorList::get()->queryStaticInfo(mInfo.getDeviceId()); MY_LOGD("Allocating %d entries from sensor HAL", sensorMetadata.count()); //--- (2.1.1) --- // //merge. for (size_t i = 0; i < sensorMetadata.count(); i++) { IMetadata::Tag_t mTag = sensorMetadata.entryAt(i).tag(); mtkMetadata.update(mTag, sensorMetadata.entryAt(i)); } MY_LOGD("Allocating %d entries from customization + sensor HAL", mtkMetadata.count()); #if 0 //-----(2.2)------// //get static informtation from other hal moduls (with IMetadata format) IMetadata halmetadata = IHalSensorList::get()->queryStaticInfo(mInfo.getDeviceId()); //calculate its entry count and data count entryCount = 0; dataCount = 0; status = AndroidMetadata::getIMetadata_dataCount(halmetadata, entryCount, dataCount); if (status != OK) { MY_LOGE("get Imetadata count error - status[%s(%d)", ::strerror(-status), -status); return status; } MY_LOGD( "Allocating %d entries, %d extra bytes from HAL modules", entryCount, dataCount ); addOrSizeInfo.mEntryCount += entryCount; addOrSizeInfo.mDataCount += dataCount; #endif //overwrite updateData(mtkMetadata); // #if (PLATFORM_SDK_VERSION >= 21) pConverter->convert(mtkMetadata, rpDstMetadata); // ::sort_camera_metadata(rpDstMetadata); #endif return status; }
MBOOL Mhal_facebeauty:: onCmd_capture() { MBOOL ret = MFALSE; MINT32 g_BufWidth; MINT32 g_BufHeight; if((mShotParam.mi4PostviewWidth*3) == (mShotParam.mi4PostviewHeight*4)) { g_BufWidth = 320; g_BufHeight = 240; } else if((mShotParam.mi4PostviewWidth*9) == (mShotParam.mi4PostviewHeight*16)) { g_BufWidth = 320; g_BufHeight = 180; } else if((mShotParam.mi4PostviewWidth*3) == (mShotParam.mi4PostviewHeight*5)) { g_BufWidth = 320; g_BufHeight = 192; } else { g_BufWidth = 320; if(mShotParam.mi4PostviewWidth != 0) g_BufHeight = 320 * mShotParam.mi4PostviewHeight/mShotParam.mi4PostviewWidth; else g_BufHeight = 180; } MY_LOGD("[onCmd_capture] Postview %dx%d -> Buf %dx%d\n",mShotParam.mi4PostviewWidth, mShotParam.mi4PostviewHeight, g_BufWidth, g_BufHeight); for(int i=0;i<FBmetadata.number_of_faces;i++) { FBmetadata.faces[i].rect[0] = ((FBmetadata.faces[i].rect[0] + 1000) * g_BufWidth) / 2000; FBmetadata.faces[i].rect[1] = ((FBmetadata.faces[i].rect[1] + 1000) * g_BufHeight) / 2000; FBmetadata.faces[i].rect[2] = ((FBmetadata.faces[i].rect[2] + 1000) * g_BufWidth) / 2000; FBmetadata.faces[i].rect[3] = ((FBmetadata.faces[i].rect[3] + 1000) * g_BufHeight) / 2000; int face_size = FBmetadata.faces[i].rect[2] - FBmetadata.faces[i].rect[0]; if(face_size >= 30) { int zoom_size; zoom_size = face_size/15; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= g_BufWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= g_BufHeight-1)) { zoom_size = face_size/12; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= g_BufWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= g_BufHeight-1)) { zoom_size = face_size/10; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= g_BufWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= g_BufHeight-1)) { zoom_size = face_size/8; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= g_BufWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= g_BufHeight-1)) { zoom_size = face_size/7; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= g_BufWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= g_BufHeight-1)) { ; } else { zoom_size = face_size/8; } } else { zoom_size = face_size/10; } } else { zoom_size = face_size/12; } } else { zoom_size = face_size/15; } FBmetadata.faces[i].rect[0] -= zoom_size; FBmetadata.faces[i].rect[1] -= zoom_size; FBmetadata.faces[i].rect[2] += zoom_size; FBmetadata.faces[i].rect[3] += zoom_size; } } MY_LOGI("[onCmd_capture] After FBFaceInfo num %d left %d top %d right %d button %d pose %d \n",i,FBmetadata.faces[i].rect[0],FBmetadata.faces[i].rect[1],FBmetadata.faces[i].rect[2],FBmetadata.faces[i].rect[3],MTKPoseInfo[i].rip_dir); } sem_init(&semMemoryDone, 0, 0); sem_init(&semFBthread, 0, 0); pthread_create(&threadFB, NULL, FBCapture, NULL); sem_init(&semUtilitythread, 0, 0); pthread_create(&threadUtility, NULL, FBUtility, NULL); sem_wait(&semFBthread); ret = createFBJpegImg(mpSource,mu4W_yuv,mu4H_yuv,0); if ( ! ret ) { goto lbExit; } //------------------ Sava test ----------------// #ifdef BanchMark char szFileName[100]; MUINT32 FDInfo[100]={0}; MUINT32* htable=(MUINT32*)msFaceBeautyResultInfo.PCAHTable; int i=0; for(i=0;i<FBmetadata.number_of_faces;i++) { FDInfo[i*4] = FBmetadata.faces[i].rect[0]; FDInfo[i*4+1] = FBmetadata.faces[i].rect[1]; FDInfo[i*4+2] = FBmetadata.faces[i].rect[2]-FBmetadata.faces[i].rect[0]; FDInfo[i*4+3] = MTKPoseInfo[i].rip_dir; MY_LOGI("[FACEINFO] x %d y %d w %d",FBmetadata.faces[i].rect[0],FBmetadata.faces[i].rect[1],FBmetadata.faces[i].rect[2]); } ::sprintf(szFileName, "/sdcard/DCIM/Camera/%s_H_%d_%d.txt", "FDinfo", *htable,capturecount); saveBufToFile(szFileName, (MUINT8*)&FDInfo, 100 * 4); MY_LOGI("[FACEINFO] Save File done"); #endif //------------------ Sava test ----------------// // Force to handle done even if there is any error before. //to do handleCaptureDone(); ret = MTRUE; lbExit: releaseBufs(); pthread_join(threadFB, NULL); UtilityStatus = 0; sem_post(&semUtilitythread); pthread_join(threadUtility, NULL); CPTLog(Event_FcaeBeautyShot, CPTFlagEnd); CPTLog(Event_FBShot_Utility, CPTFlagEnd); #if (FB_PROFILE_CAPTURE) DbgTmr.print("FBProfiling:: Done"); #endif return ret; }
MBOOL Mhal_facebeauty:: requestBufs() { MBOOL fgRet = MFALSE; mu4W_yuv = mShotParam.mi4PictureWidth; mu4H_yuv = mShotParam.mi4PictureHeight; #ifdef Debug_Mode mu4W_yuv = 640; mu4H_yuv = 480; #endif if((mu4W_yuv*3) == (mu4H_yuv*4)) { mDSWidth = 640; mDSHeight = 480; } else if((mu4W_yuv*9) == (mu4H_yuv*16)) { mDSWidth = 640; mDSHeight = 360; } else if((mu4W_yuv*3) == (mu4H_yuv*5)) { mDSWidth = 640; mDSHeight = 384; } else { mDSWidth = 640; if(mu4W_yuv != 0) mDSHeight = 640 * mu4H_yuv/mu4W_yuv; else mDSHeight = 480; } CPTLog(Event_FBShot_requestBufs, CPTFlagStart); MY_LOGD("[requestBufs] mu4W_yuv %d mu4H_yuv %d",mu4W_yuv,mu4H_yuv); // (1) mu4SourceSize=mu4W_yuv*mu4H_yuv*2; if(mu4SourceSize< (mShotParam.mi4PostviewWidth * mShotParam.mi4PostviewHeight * 2) ) mu4SourceSize = (mShotParam.mi4PostviewWidth * mShotParam.mi4PostviewHeight * 2); mpSource.size = mu4SourceSize; if(!(allocMem(mpSource))) { mpSource.size = 0; MY_LOGE("[requestBufs] mpSource alloc fail"); goto lbExit; } UtilityStatus = 3; sem_post(&semUtilitythread); CPTLog(Event_FBShot_requestBufs, CPTFlagEnd); fgRet = MTRUE; lbExit: if ( ! fgRet ) { releaseBufs(); } return fgRet; }
MBOOL Mhal_facebeauty:: createFBJpegImg(IMEM_BUF_INFO Srcbufinfo, int u4SrcWidth, int u4SrcHeight, MUINT32 const Mode) { MY_LOGD("[createFBJpegImg] in"); MBOOL ret = MTRUE; CPTLog(Event_FBShot_createFBJpegImg, CPTFlagStart); MUINT32 u4Stride[3]; u4Stride[0] = mu4W_yuv; u4Stride[1] = mu4W_yuv >> 1; u4Stride[2] = mu4W_yuv >> 1; //mrHdrCroppedResult as rYuvImgBufInfo MUINT32 u4ResultSize = Srcbufinfo.size; NSCamHW::ImgInfo rYuvImgInfo(eImgFmt_I422, u4SrcWidth , u4SrcHeight); NSCamHW::BufInfo rYuvBufInfo(u4ResultSize, (MUINT32)Srcbufinfo.virtAddr, 0, Srcbufinfo.memID); NSCamHW::ImgBufInfo rYuvImgBufInfo(rYuvImgInfo, rYuvBufInfo, u4Stride); mPostviewWidth = mShotParam.mi4PostviewWidth; mPostviewHeight = mShotParam.mi4PostviewHeight; IMEM_BUF_INFO tmpPostView; tmpPostView.size = android::MtkCamUtils::FmtUtils::queryImgBufferSize(mShotParam.ms8PostviewDisplayFormat, mPostviewWidth, mPostviewHeight); if(!(allocMem(tmpPostView))) { tmpPostView.size = 0; MY_LOGE("[STEP1] tmpPostView alloc fail"); ret = MFALSE; return ret; } EImageFormat mPostviewFormat = static_cast<EImageFormat>(android::MtkCamUtils::FmtUtils::queryImageioFormat(mShotParam.ms8PostviewDisplayFormat)); mpPostviewImgBuf.size = android::MtkCamUtils::FmtUtils::queryImgBufferSize(mShotParam.ms8PostviewDisplayFormat, mPostviewWidth, mPostviewHeight); mpPostviewImgBuf.virtAddr = tmpPostView.virtAddr; //using original buffer for reduce memory mpPostviewImgBuf.memID = -1; ImgProcess(Srcbufinfo, u4SrcWidth, u4SrcHeight, eImgFmt_I422, mpPostviewImgBuf, mPostviewWidth, mPostviewHeight, mPostviewFormat); MUINT32 u4PosStride[3]; u4PosStride[0] = mPostviewWidth; u4PosStride[1] = mPostviewWidth >> 1; u4PosStride[2] = mPostviewWidth >> 1; NSCamHW::ImgInfo rPostViewImgInfo(mPostviewFormat, mPostviewWidth, mPostviewHeight); NSCamHW::BufInfo rPostViewBufInfo(mpPostviewImgBuf.size, (MUINT32)mpPostviewImgBuf.virtAddr, 0, mpPostviewImgBuf.memID); NSCamHW::ImgBufInfo rPostViewImgBufInfo(rPostViewImgInfo, rPostViewBufInfo, u4PosStride); if(!Mode) handlePostViewData((MUINT8*)mpPostviewImgBuf.virtAddr, mpPostviewImgBuf.size); ret = createJpegImgWithThumbnail(rYuvImgBufInfo, rPostViewImgBufInfo, Mode); if(!(deallocMem(tmpPostView))) { tmpPostView.size = 0; MY_LOGE("tmpPostView dealloc fail"); ret = MFALSE; return ret; } CPTLog(Event_FBShot_createFBJpegImg, CPTFlagEnd); MY_LOGD("[createFBJpegImg] out"); return ret; }
MBOOL HalSensor:: powerOn( char const* szCallerName, MUINT const uCountOfIndex, MUINT const*pArrayOfIndex ) { MBOOL ret = MFALSE; MUINT sensorDev = 0; MUINT pcEn = 1; // Mutex::Autolock _l(mMutex); #if 0 { #define DEV_IOC_MAGIC 'd' #define READ_DEV_DATA _IOR(DEV_IOC_MAGIC, 1, unsigned int) unsigned int devinfo_data = 3; unsigned int isp_bonding = 0; MBOOL ISP_Limit = MFALSE; MUINT16 CapWidth = sensorDrvInfo[0].SensorCapWidth; int fd = open("/dev/devmap", O_RDONLY, 0); if(fd < 0) { MY_LOGE("/dev/devmap kernel open fail, errno(%d):%s",errno,strerror(errno)); } else { if(ioctl(fd, READ_DEV_DATA, &devinfo_data) == 0) { isp_bonding = (devinfo_data >> 29) & 0x3; MY_LOGD("devinfo_data(0x%08X) Bound(%d) CapWidth(%d)", devinfo_data, isp_bonding, CapWidth); if(isp_bonding != 0x0) { switch(isp_bonding){ case 1: // 16M if(CapWidth > 4708) { ISP_Limit =MTRUE; } break; case 2: // 13M if(CapWidth > 4324) { ISP_Limit =MTRUE; } break; case 3: // 8M if(CapWidth > 3364) { ISP_Limit =MTRUE; } break; default: break; } } } else { MY_LOGE("Get devinfo_data fail"); } close(fd); }
halASD::halASD() { m_pMTKAsdObj = NULL; MY_LOGD("[halASD] Reset g_udCount:%d \n", g_udCount); g_udCount=0; }
RawDumpCmdQueThread::~RawDumpCmdQueThread() { MY_LOGD("this=%p, sizeof:%d", this, sizeof(RawDumpCmdQueThread)); }
MBOOL CamIOPipe:: configPipe(vector<PortInfo const*>const& vInPorts, vector<PortInfo const*>const& vOutPorts) { FUNCTION_LOG_START; MY_LOGD("+ tid(%d), %d in / %d out", gettid(), vInPorts.size(), vOutPorts.size()); MBOOL ret = MTRUE; // if (0 == vInPorts.size() || 0 == vOutPorts.size() || vOutPorts.size() > 2) { MY_LOGE("Port config error"); return MFALSE; } // if (EPortType_Sensor != vInPorts.at(0)->type) { MY_LOGE("The IN port type should be sensor type"); return MFALSE; } // for (MUINT32 i = 0; i < vOutPorts.size(); i++) { if (EPortType_MemoryOut != vOutPorts.at(i)->type) { MY_LOGE("The OUT port type should be EPortType_MemoryOut"); return MFALSE; } } // (1). callbacks mpCamIOPipe->setCallbacks(NULL, NULL, NULL); // (2). command queue config ret = ret && mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_CQ_CHANNEL, (MINT32)NSImageio::NSIspio::EPIPE_PASS1_CQ0, 0, 0 ) && mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_CQ_TRIGGER_MODE, (MINT32)NSImageio::NSIspio::EPIPE_PASS1_CQ0, (MINT32)NSImageio::NSIspio::EPIPECQ_TRIGGER_SINGLE_IMMEDIATE, (MINT32)NSImageio::NSIspio::EPIPECQ_TRIG_BY_START ) && mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_CONFIG_STAGE, (MINT32)NSImageio::NSIspio::eConfigSettingStage_Init, 0, 0 ); if (!ret) { MY_LOGE("Cammand queue config fail:%d", mpCamIOPipe->getLastErrorCode()); return ret; } // // (3). In sensor port vector<NSImageio::NSIspio::PortInfo const*> vCamIOInPorts; SensorPortInfo const* const pSensorPort = reinterpret_cast<SensorPortInfo const*> (vInPorts.at(0)); ::memcpy(&mrSensorPortInfo, const_cast<SensorPortInfo*>(pSensorPort),sizeof(SensorPortInfo)); MUINT32 u4SensorWidth = 0, u4SensorHeight = 0; MUINT32 u4RawPixelID = 0; EImageFormat eSensorFmt = eImgFmt_UNKNOWN; // (3.1) Sensor instance if (NULL == mpSensorHal) { mpSensorHal = SensorHal::createInstance(); if (NULL == mpSensorHal) { MY_LOGE("Null sensorHal object"); return MFALSE; } } // mpSensorHal->sendCommand(static_cast<halSensorDev_e>(pSensorPort->u4DeviceID), SENSOR_CMD_SET_SENSOR_DEV, 0, 0, 0 ); // //mpSensorHal->init(); ret = querySensorInfo( pSensorPort->u4DeviceID, pSensorPort->u4Scenario, pSensorPort->u4Bitdepth, eSensorFmt, u4SensorWidth, u4SensorHeight, u4RawPixelID); MY_LOGD("SensorPortInfo: (u4DeviceID, u4Scenario, bitdepth, fgBypassDelay, fgBypassScenaio, u4RawType) = (%d, %d, %d, %d, %d, %d)", pSensorPort->u4DeviceID, pSensorPort->u4Scenario, pSensorPort->u4Bitdepth, pSensorPort->fgBypassDelay, pSensorPort->fgBypassScenaio, pSensorPort->u4RawType); // MUINT32 u4SensorStride = u4SensorWidth; if (eImgFmt_BAYER8 == eSensorFmt || eImgFmt_BAYER10 == eSensorFmt || eImgFmt_BAYER12 == eSensorFmt) { u4SensorStride = NSImageio::NSIspio::queryRawStride(eSensorFmt, u4SensorWidth); } MY_LOGD("SensorPortInfo: (width, height, format, stride) = (%d, %d, 0x%x, %d, %d, %d)", u4SensorWidth, u4SensorHeight, eSensorFmt, u4SensorStride); // NSImageio::NSIspio::PortInfo tgi; tgi.eImgFmt = eSensorFmt; tgi.eRawPxlID = mapRawPixelID(u4RawPixelID); tgi.u4ImgWidth = u4SensorWidth; tgi.u4ImgHeight = u4SensorHeight; tgi.u4Stride[0] = u4SensorStride; tgi.u4Stride[1] = 0; tgi.u4Stride[2] = 0; tgi.type = NSImageio::NSIspio::EPortType_Sensor; mu4DeviceID = pSensorPort->u4DeviceID; tgi.index = ((mu4DeviceID == SENSOR_DEV_MAIN)||(mu4DeviceID == SENSOR_DEV_ATV)) ? (NSImageio::NSIspio::EPortIndex_TG1I) : (NSImageio::NSIspio::EPortIndex_TG2I); tgi.inout = NSImageio::NSIspio::EPortDirection_In; tgi.u4BufSize = (MUINT32)0; vCamIOInPorts.push_back(&tgi); // The raw type, 0: pure raw, 1: pre-process raw if(pSensorPort->u4RawType == 1) { ret = mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_IMGO_RAW_TYPE, (MINT32)NSImageio::NSIspio::eRawImageType_PreProc, 0, 0 ); } // // (4). Out Port vector<NSImageio::NSIspio::PortInfo const*> vCamIOOutPorts; NSImageio::NSIspio::PortInfo imgo; NSImageio::NSIspio::PortInfo img2o; for (MUINT32 i = 0; i < vOutPorts.size(); i++) { MemoryOutPortInfo const* const memOutPort= reinterpret_cast<MemoryOutPortInfo const*> (vOutPorts.at(i)); // if (0 == memOutPort->index) { MY_LOGD("MemoryOutPortInfo1: (fmt, width, height) = (0x%x, %d, %d)", tgi.eImgFmt, tgi.u4ImgWidth, tgi.u4ImgHeight); MY_LOGD("MemoryOutPortInfo1: stride = (%d, %d, %d)", memOutPort->u4Stride[0], memOutPort->u4Stride[1], memOutPort->u4Stride[2]); imgo.eImgFmt = tgi.eImgFmt; imgo.u4ImgWidth = tgi.u4ImgWidth; imgo.u4ImgHeight = tgi.u4ImgHeight; // no crop imgo.crop.y = 0; imgo.crop.h = imgo.u4ImgHeight; imgo.type = NSImageio::NSIspio::EPortType_Memory; imgo.index = NSImageio::NSIspio::EPortIndex_IMGO; imgo.inout = NSImageio::NSIspio::EPortDirection_Out; imgo.u4Stride[0] = memOutPort->u4Stride[0]; imgo.u4Stride[1] = memOutPort->u4Stride[1]; imgo.u4Stride[2] = memOutPort->u4Stride[2]; imgo.u4Offset = 0; vCamIOOutPorts.push_back(&imgo); } #warning [TODO] Should check the port config by scenario else if (1 == memOutPort->index) { MY_LOGD("MemoryOutPortInfo2: (fmt, width, height) = (0x%x, %d, %d)", memOutPort->eImgFmt, memOutPort->u4ImgWidth, memOutPort->u4ImgHeight); MY_LOGD("MemoryOutPortInfo2: stride = (%d, %d, %d)", memOutPort->u4Stride[0], memOutPort->u4Stride[1], memOutPort->u4Stride[2]); img2o.eImgFmt = memOutPort->eImgFmt; img2o.u4ImgWidth = memOutPort->u4ImgWidth; img2o.u4ImgHeight = memOutPort->u4ImgHeight; img2o.crop.y = 0; img2o.crop.h = img2o.u4ImgHeight; img2o.type = NSImageio::NSIspio::EPortType_Memory; img2o.index = NSImageio::NSIspio::EPortIndex_IMG2O; img2o.inout = NSImageio::NSIspio::EPortDirection_Out; img2o.u4Stride[0] = memOutPort->u4Stride[0]; img2o.u4Stride[1] = memOutPort->u4Stride[1]; img2o.u4Stride[2] = memOutPort->u4Stride[2]; vCamIOOutPorts.push_back(&img2o); mfgIsYUVPortON = MTRUE; } } ret = mpCamIOPipe->configPipe(vCamIOInPorts, vCamIOOutPorts); // ret = configSensor(pSensorPort->u4DeviceID, pSensorPort->u4Scenario, u4SensorWidth, u4SensorHeight, pSensorPort->fgBypassDelay, pSensorPort->fgBypassScenaio, MTRUE); FUNCTION_LOG_END; return ret; }
bool RawDumpCmdQueThread:: postCommand(IImageBuffer const * pImgBuffer) { FUNCTION_IN; // bool ret = true; CamProfile profile(__FUNCTION__, "RawDumpCmdQueThread::postCommand"); // { Mutex::Autolock _l(mCmdMtx); // add frame count for remember what frame it is. mFrameCnt++; // if (NULL == pImgBuffer) { MY_LOGD("- Requester stop to dump: tid(%d), frame_count(%d), Q size(%d)", FREE_MEMORY_THRESHOLD, ::gettid(), mFrameCnt, mCmdQ.size()); mpCamMsgCbInfo->mNotifyCb(MTK_CAMERA_MSG_EXT_NOTIFY, MTK_CAMERA_MSG_EXT_NOTIFY_RAW_DUMP_STOPPED, 0, mpCamMsgCbInfo->mCbCookie); return false; } MY_LOGD("+ tid(%d), frame_count (%d), buf_addr(%p), stride(%d), buf_size(%d), free(%d)", ::gettid(), mFrameCnt, pImgBuffer->getBufVA(0), pImgBuffer->getBufStridesInBytes(0), pImgBuffer->getBufSizeInBytes(0), getFreeMemorySize()); // if (!mCmdQ.empty()) { MY_LOGD("queue is not empty, (%d) is in the head of queue, Q size (%d)", ((*mCmdQ.begin())->getFrameCnt()), mCmdQ.size()); } // check if the memory threshold is enough if ( FREE_MEMORY_THRESHOLD > getFreeMemorySize()) { MY_LOGD("- Memory is under:%d: RAW DUMP IS STOPPED: tid(%d), frame_count(%d), Q size(%d)", FREE_MEMORY_THRESHOLD, ::gettid(), mFrameCnt, mCmdQ.size()); mpCamMsgCbInfo->mNotifyCb(MTK_CAMERA_MSG_EXT_NOTIFY, MTK_CAMERA_MSG_EXT_NOTIFY_RAW_DUMP_STOPPED, 0, mpCamMsgCbInfo->mCbCookie); return false; } // MUINT32 u4RealRawSize = pImgBuffer->getBufStridesInBytes(0) * pImgBuffer->getImgSize().h; MUINT8 *pbuf = (MUINT8*) malloc (u4RealRawSize); if (NULL == pbuf) { MY_LOGW("tid(%d) fail to allocate memory, frame_count (%d), buf_addr(%p), buf_size(%d)", ::gettid(), mFrameCnt, pImgBuffer->getBufVA(0), u4RealRawSize); return false; } // memcpy(pbuf,(MUINT8*)pImgBuffer->getBufVA(0), u4RealRawSize); // sp<RawDumpCmdCookie> cmdCookie(new RawDumpCmdCookie(mFrameCnt, new RawImageBufInfo(pImgBuffer->getImgSize().w, pImgBuffer->getImgSize().h, pImgBuffer->getBufStridesInBytes(0), (MUINTPTR)pbuf, u4RealRawSize, pImgBuffer->getTimestamp() ) , mspParamsMgr->getStr(MtkCameraParameters::KEY_RAW_PATH))); mCmdQ.push_back(cmdCookie); mCmdCond.broadcast(); MY_LOGD("- frame added: tid(%d), frame_count(%d), que size(%d)", ::gettid(), mFrameCnt, mCmdQ.size()); } // profile.print(); FUNCTION_OUT; // return ret; }
void FeaturePass2:: setParameters( sp<IParamsManager> spParamsMgr, MUINT32 openId) { Mutex::Autolock _l(mLock); // if(!mbFeature) { FEATURE_MASK_CLEAR(mFeatureMask); MY_LOGD("All features are disabled FeatureMask(0x%08X)",mFeatureMask); return; } // if(mSensorType == SENSOR_TYPE_UNKNOWN) { SensorStaticInfo sensorInfo; IHalSensorList* const pHalSensorList = IHalSensorList::get(); pHalSensorList->querySensorStaticInfo( pHalSensorList->querySensorDevIdx(openId), &sensorInfo); mSensorType = sensorInfo.sensorType; MY_LOGD("mSensorType(%d)",mSensorType); } // mFeaturePipeTuning.SmoothLevel = spParamsMgr->getInt(MtkCameraParameters::KEY_FB_SMOOTH_LEVEL); mFeaturePipeTuning.SkinColor = spParamsMgr->getInt(MtkCameraParameters::KEY_FB_SKIN_COLOR); mFeaturePipeTuning.EnlargeEyeLevel = spParamsMgr->getInt(MtkCameraParameters::KEY_FB_ENLARGE_EYE); mFeaturePipeTuning.SlimFaceLevel = spParamsMgr->getInt(MtkCameraParameters::KEY_FB_SLIM_FACE); mFeaturePipeTuning.Rotation = spParamsMgr->getInt(MtkCameraParameters::KEY_ROTATION); // if(::strcmp(spParamsMgr->getStr(MtkCameraParameters::KEY_FB_EXTREME_BEAUTY), MtkCameraParameters::TRUE) == 0) { mFeaturePipeTuning.ExtremeBeauty = MTRUE; } else { mFeaturePipeTuning.ExtremeBeauty = MFALSE; } // spParamsMgr->getFaceBeautyTouchPosition(mTouch); // FEATURE_MASK_CLEAR(mFeatureMask); // MINT32 vdoWidth, vdoHeight; spParamsMgr->getVideoSize( &vdoWidth, &vdoHeight); if(!mbPreview) { mVdoSizeBeforePreview.w = vdoWidth; mVdoSizeBeforePreview.h = vdoHeight; } MY_LOGD("bPreivew(%d),VdoSize before preview:%dx%d,Cur VdoSize:%dx%d", mbPreview, mVdoSizeBeforePreview.w, mVdoSizeBeforePreview.h, vdoWidth, vdoHeight); // if( ::strcmp(spParamsMgr->getStr(MtkCameraParameters::KEY_3DNR_MODE), "on") == 0 && mSensorType == SENSOR_TYPE_RAW) { if( ( spParamsMgr->getRecordingHint() && vdoWidth*vdoHeight <= IMG_1080P_SIZE ) || !(spParamsMgr->getRecordingHint())) { #if 1 //Vent@20140228: For 3DNR enable. char EnableOption[PROPERTY_VALUE_MAX] = {'\0'}; property_get("camera.3dnr.enable", EnableOption, "1"); if (EnableOption[0] == '1') { #ifdef MTK_CAM_NR3D_SUPPORT FEATURE_MASK_ENABLE_3DNR(mFeatureMask); #endif // MTK_CAM_NR3D_SUPPORT } #else // Original. #ifdef MTK_CAM_NR3D_SUPPORT FEATURE_MASK_ENABLE_3DNR(mFeatureMask); #endif // MTK_CAM_NR3D_SUPPORT #endif //Vent@20140228: End. } } #if 0 // this chip not support EIS2.0 MBOOL isVFB = (::strcmp(spParamsMgr->getStr(MtkCameraParameters::KEY_FACE_BEAUTY), MtkCameraParameters::TRUE) == 0) ? MTRUE : MFALSE; if( spParamsMgr->getVideoStabilization() && spParamsMgr->getRecordingHint() && (mVdoSizeBeforePreview.w*mVdoSizeBeforePreview.h) <= IMG_1080P_SIZE && !isVFB) { FEATURE_MASK_ENABLE_EIS(mFeatureMask); } #endif // mbRecordingHint = spParamsMgr->getRecordingHint(); // if(::strcmp(spParamsMgr->getStr(MtkCameraParameters::KEY_FACE_BEAUTY), MtkCameraParameters::TRUE) == 0) { FEATURE_MASK_ENABLE_VFB(mFeatureMask); // if(mbGDPreview) { FEATURE_MASK_ENABLE_GESTURE_SHOT(mFeatureMask); } } // if( !(CamManager::getInstance()->isMultiDevice()) && spParamsMgr->getVHdr() == SENSOR_VHDR_MODE_IVHDR) { FEATURE_MASK_ENABLE_VHDR(mFeatureMask); } MY_LOGD("FeatureMask(0x%08X)",mFeatureMask); }
MBOOL Mhal_facebeauty:: requestBufs() { MBOOL fgRet = MFALSE; mu4W_yuv = mShotParam.mi4PictureWidth; mu4H_yuv = mShotParam.mi4PictureHeight; #ifdef Debug_Mode mu4W_yuv = 640; mu4H_yuv = 480; #endif if((mu4W_yuv*3) == (mu4H_yuv*4)) { mDSWidth = 640; mDSHeight = 480; } else if((mu4W_yuv*9) == (mu4H_yuv*16)) { mDSWidth = 640; mDSHeight = 360; } else if((mu4W_yuv*3) == (mu4H_yuv*5)) { mDSWidth = 640; mDSHeight = 384; } else { mDSWidth = 640; mDSHeight = 480; } CPTLog(Event_FBShot_requestBufs, CPTFlagStart); MY_LOGD("[requestBufs] mu4W_yuv %d mu4H_yuv %d",mu4W_yuv,mu4H_yuv); // (1) mu4SourceSize=mu4W_yuv*mu4H_yuv*2; if(mu4SourceSize< (mShotParam.mi4PostviewWidth * mShotParam.mi4PostviewHeight * 2) ) mu4SourceSize = (mShotParam.mi4PostviewWidth * mShotParam.mi4PostviewHeight * 2); mpSource.size = mu4SourceSize; if(!(allocMem(mpSource))) { mpSource.size = 0; MY_LOGE("[requestBufs] mpSource alloc fail"); goto lbExit; } mpAmap.size = mu4SourceSize; if(!(allocMem(mpAmap))) { mpAmap.size = 0; MY_LOGE("[requestBufs] mpAmap alloc fail"); goto lbExit; } mpBlurImg.size = mu4SourceSize; if(!(allocMem(mpBlurImg))) { mpBlurImg.size = 0; MY_LOGE("[requestBufs] mpBlurImg alloc fail"); goto lbExit; } FBWorkingBufferSize = mpFb->getWorkingBuffSize(); MY_LOGD("[requestBufs] FBWorkingBufferSize %d",FBWorkingBufferSize); mpWorkingBuferr.size = FBWorkingBufferSize; if(!(allocMem(mpWorkingBuferr))) { mpWorkingBuferr.size = 0; MY_LOGE("[requestBufs] mpWorkingBuferr alloc fail"); goto lbExit; } CPTLog(Event_FBShot_requestBufs, CPTFlagEnd); fgRet = MTRUE; lbExit: if ( ! fgRet ) { releaseBufs(); } return fgRet; }
//----------------------------------------------------------------------------- MBOOL ResourceLockImp:: Init(void) { MBOOL Result = MTRUE; // Mutex::Autolock lock(mLock); // if(mUser == 0) { MY_LOGD("First user(%d)",mUser); } else { MY_LOGD("More user(%d)",mUser); android_atomic_inc(&mUser); goto EXIT; } // mpResMgr = ResMgrDrv::CreateInstance(); if(mpResMgr != NULL) { if(mpResMgr->Init()) { //MY_LOGD("mpResMgr->Init OK"); } else { MY_LOGE("mpResMgr->Init fail"); Result = MFALSE; goto EXIT; } } else { MY_LOGE("mpResMgr is NULL"); Result = MFALSE; goto EXIT; } // mpPipeMgr = PipeMgrDrv::CreateInstance(); if(mpPipeMgr != NULL) { if(mpPipeMgr->Init()) { //MY_LOGD("mpPipeMgr->Init OK"); } else { MY_LOGE("mpPipeMgr->Init fail"); Result = MFALSE; goto EXIT; } } else { MY_LOGE("mpPipeMgr is NULL"); Result = MFALSE; goto EXIT; } // android_atomic_inc(&mUser); // EXIT: return Result; }
bool Mhal_facebeauty:: onCreate(MtkCameraFaceMetadata* FaceInfo) { MBOOL ret = MFALSE; MINT32 ec = 0; MY_LOGD("[facebeauty init] FBFaceInfo adr 0x%x FBFaceInfo num %d \n",(MUINT32)FaceInfo->faces,FaceInfo->number_of_faces); FBmetadata.faces=(MtkCameraFace *)FBFaceInfo; FBmetadata.posInfo=(MtkFaceInfo *)MTKPoseInfo; FBmetadata.number_of_faces = FaceInfo->number_of_faces; for(int i=0;i<FaceInfo->number_of_faces;i++) { FBmetadata.faces[i].rect[0] = ((FaceInfo->faces[i].rect[0] + 1000) * FBFDWidth) / 2000; FBmetadata.faces[i].rect[1] = ((FaceInfo->faces[i].rect[1] + 1000) * FBFDHeight) / 2000; FBmetadata.faces[i].rect[2] = ((FaceInfo->faces[i].rect[2] + 1000) * FBFDWidth) / 2000; FBmetadata.faces[i].rect[3] = ((FaceInfo->faces[i].rect[3] + 1000) * FBFDHeight) / 2000; FBmetadata.posInfo[i].rop_dir = FaceInfo->posInfo[i].rop_dir; FBmetadata.posInfo[i].rip_dir = FaceInfo->posInfo[i].rip_dir; int face_size = FBmetadata.faces[i].rect[2] - FBmetadata.faces[i].rect[0]; if(face_size >= 30) { int zoom_size; zoom_size = face_size/15; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= FBFDWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= FBFDHeight-1)) { zoom_size = face_size/12; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= FBFDWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= FBFDHeight-1)) { zoom_size = face_size/10; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= FBFDWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= FBFDHeight-1)) { zoom_size = face_size/8; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= FBFDWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= FBFDHeight-1)) { zoom_size = face_size/7; if( (FBmetadata.faces[i].rect[0] - zoom_size >= 0) && (FBmetadata.faces[i].rect[1] - zoom_size >= 0) && (FBmetadata.faces[i].rect[2] + zoom_size <= FBFDWidth -1) && (FBmetadata.faces[i].rect[3] + zoom_size <= FBFDHeight-1)) { ; } else { zoom_size = face_size/8; } } else { zoom_size = face_size/10; } } else { zoom_size = face_size/12; } } else { zoom_size = face_size/15; } FBmetadata.faces[i].rect[0] -= zoom_size; FBmetadata.faces[i].rect[1] -= zoom_size; FBmetadata.faces[i].rect[2] += zoom_size; FBmetadata.faces[i].rect[3] += zoom_size; } } MY_LOGI("[facebeauty init] After FBFaceInfo num %d left %d top %d right %d button %d pose %d \n",i,FBmetadata.faces[i].rect[0],FBmetadata.faces[i].rect[1],FBmetadata.faces[i].rect[2],FBmetadata.faces[i].rect[3],MTKPoseInfo[i].rip_dir); } mpIMemDrv = IMemDrv::createInstance(); if (mpIMemDrv == NULL) { MY_LOGE("g_pIMemDrv is NULL \n"); return 0; } mpFb = halFACEBEAUTIFYBase::createInstance(HAL_FACEBEAUTY_OBJ_SW); if ( ! mpFb ) { MY_LOGE("[init] NULL mpFb \n"); goto lbExit; } mpFbObj = this; mpFb->CANCEL = MFALSE; ret = MTRUE; lbExit: if ( ! ret ) { onDestroy(); } MY_LOGD("[init] rc(%d) \n", ret); return ret; }
MBOOL PostProcPipe:: configPipe(vector<PortInfo const*>const& vInPorts, vector<PortInfo const*>const& vOutPorts) { FUNCTION_LOG_START; MY_LOGD("+ %d in / %d out", vInPorts.size(), vOutPorts.size()); MBOOL ret; // if (0 == vInPorts.size() || 0 == vOutPorts.size() || vOutPorts.size() > 2) { MY_LOGE("Port config error"); return false; } // if (EPortType_MemoryIn != vInPorts.at(0)->type) { MY_LOGE("The IN port type should be EPortType_MemoryIn type"); return false; } // for (MUINT32 i = 0; i < vOutPorts.size(); i++) { if (EPortType_MemoryOut != vOutPorts.at(i)->type) { MY_LOGE("The OUT port type should be EPortType_MemoryOut"); return false; } } // (1). callbacks #warning [TODO] callbacks mpPostProcPipe->setCallbacks(NULL, NULL, NULL); // (2). set CQ first before pipe config ret = mpPostProcPipe->sendCommand((MINT32)NSImageio::NSIspio::EPIPECmd_SET_CQ_CHANNEL, (MINT32)NSImageio::NSIspio::EPIPE_PASS2_CQ1, 0, 0 ); //kk tset ret = mpPostProcPipe->sendCommand((MINT32)NSImageio::NSIspio::EPIPECmd_SET_CONFIG_STAGE, (MINT32)NSImageio::NSIspio::eConfigSettingStage_Init, 0, 0 ); ret = mpPostProcPipe->sendCommand((MINT32)NSImageio::NSIspio::EPIPECmd_SET_CONFIG_STAGE, (MINT32)(MINT32)NSImageio::NSIspio::eConfigSettingStage_UpdateTrigger, 0, 0 ); // // (3). In MemoryIn Port vector<NSImageio::NSIspio::PortInfo const*> vPostProcInPorts; MemoryInPortInfo const* const pMemoryInPort = reinterpret_cast<MemoryInPortInfo const*> (vInPorts.at(0)); MY_LOGD("MemoryInPortInfo: (fmt, width, height) = (0x%x, %d, %d)", pMemoryInPort->eImgFmt, pMemoryInPort->u4ImgWidth, pMemoryInPort->u4ImgHeight); MY_LOGD("MemoryInPortInfo: stride = (%d, %d, %d)", pMemoryInPort->u4Stride[0], pMemoryInPort->u4Stride[1], pMemoryInPort->u4Stride[2]); MY_LOGD("MemoryInPortInfo: crop:(x, y, w, h) = (%d, %d, %d, %d)", pMemoryInPort->rCrop.x, pMemoryInPort->rCrop.y, pMemoryInPort->rCrop.w, pMemoryInPort->rCrop.h); // NSImageio::NSIspio::PortInfo imgi; imgi.eImgFmt = pMemoryInPort->eImgFmt; imgi.u4ImgWidth = pMemoryInPort->u4ImgWidth; imgi.u4ImgHeight = pMemoryInPort->u4ImgHeight; imgi.u4Stride[0] = pMemoryInPort->u4Stride[0]; imgi.u4Stride[1] = pMemoryInPort->u4Stride[1]; ; imgi.u4Stride[2] = pMemoryInPort->u4Stride[2]; ; imgi.crop.x = pMemoryInPort->rCrop.x; imgi.crop.y = pMemoryInPort->rCrop.y; imgi.crop.w = pMemoryInPort->rCrop.w; imgi.crop.h = pMemoryInPort->rCrop.h; imgi.type = NSImageio::NSIspio::EPortType_Memory; imgi.index = NSImageio::NSIspio::EPortIndex_IMGI; imgi.inout = NSImageio::NSIspio::EPortDirection_In; imgi.pipePass = NSImageio::NSIspio::EPipePass_PASS2; vPostProcInPorts.push_back(&imgi); // // (4). Out Port vector<NSImageio::NSIspio::PortInfo const*> vPostProcOutPorts; NSImageio::NSIspio::PortInfo dispo; NSImageio::NSIspio::PortInfo vido; for (MUINT32 i = 0; i < vOutPorts.size(); i++) { MemoryOutPortInfo const* const memOutPort= reinterpret_cast<MemoryOutPortInfo const*> (vOutPorts.at(i)); // if (0 == memOutPort->index) { MY_LOGD("MemoryOutPortInfo1: (fmt, width, height) = (0x%x, %d, %d)", memOutPort->eImgFmt, memOutPort->u4ImgWidth, memOutPort->u4ImgHeight); MY_LOGD("MemoryOutPortInfo1: stride = (%d, %d, %d)", memOutPort->u4Stride[0], memOutPort->u4Stride[1], memOutPort->u4Stride[2]); dispo.eImgFmt = memOutPort->eImgFmt; dispo.u4ImgWidth = memOutPort->u4ImgWidth; dispo.u4ImgHeight = memOutPort->u4ImgHeight; dispo.eImgRot = NSImageio::NSIspio::eImgRot_0; //dispo NOT support rotation dispo.eImgFlip = NSImageio::NSIspio::eImgFlip_OFF; //dispo NOT support flip dispo.type = NSImageio::NSIspio::EPortType_DISP_RDMA; dispo.index = NSImageio::NSIspio::EPortIndex_DISPO; dispo.inout = NSImageio::NSIspio::EPortDirection_Out; dispo.u4Stride[0] = memOutPort->u4Stride[0]; dispo.u4Stride[1] = memOutPort->u4Stride[1]; dispo.u4Stride[2] = memOutPort->u4Stride[2]; vPostProcOutPorts.push_back(&dispo); mu4OutPortEnableFlag |= 0x1; } #warning [TODO] Should check the port config by scenario else if (1 == memOutPort->index) { MY_LOGD("MemoryOutPortInfo2: (fmt, width, height) = (0x%x, %d, %d)", memOutPort->eImgFmt, memOutPort->u4ImgWidth, memOutPort->u4ImgHeight); MY_LOGD("MemoryOutPortInfo2: stride = (%d, %d, %d)", memOutPort->u4Stride[0], memOutPort->u4Stride[1], memOutPort->u4Stride[2]); MY_LOGD("MemoryOutPortInfo2: (flip, rotation) = (%d, %d)", memOutPort->u4Rotation, memOutPort->u4Flip); vido.eImgFmt = memOutPort->eImgFmt; vido.u4ImgWidth = memOutPort->u4ImgWidth; vido.u4ImgHeight = memOutPort->u4ImgHeight; vido.eImgRot = static_cast<NSImageio::NSIspio::EImageRotation>(memOutPort->u4Rotation/90); vido.eImgFlip = static_cast<NSImageio::NSIspio::EImageFlip>(memOutPort->u4Flip); vido.type = NSImageio::NSIspio::EPortType_VID_RDMA; vido.index = NSImageio::NSIspio::EPortIndex_VIDO; vido.inout = NSImageio::NSIspio::EPortDirection_Out; vido.u4Stride[0] = memOutPort->u4Stride[0]; vido.u4Stride[1] = memOutPort->u4Stride[1]; vido.u4Stride[2] = memOutPort->u4Stride[2]; vPostProcOutPorts.push_back(&vido); mu4OutPortEnableFlag |= 0x2; } } mpPostProcPipe->configPipe(vPostProcInPorts, vPostProcOutPorts); FUNCTION_LOG_END; return MTRUE; }
MBOOL Mhal_facebeauty:: createFullFrame(IMEM_BUF_INFO Srcbufinfo) { MBOOL ret = MTRUE; MINT32 err = 0; CPTLog(Event_FBShot_createFullFrame, CPTFlagStart); MY_LOGD("[createFullFrame] + \n"); NSCamShot::ISingleShot *pSingleShot = NSCamShot::ISingleShot::createInstance(eShotMode_FaceBeautyShot, "FaceBeautyshot"); // pSingleShot->init(); EImageFormat ePostViewFmt = static_cast<EImageFormat>(android::MtkCamUtils::FmtUtils::queryImageioFormat(mShotParam.ms8PostviewDisplayFormat)); ImgBufInfo rSrcImgInfo; rSrcImgInfo.u4ImgWidth = mu4W_yuv; rSrcImgInfo.u4ImgHeight = mu4H_yuv; rSrcImgInfo.eImgFmt = eImgFmt_YV16; rSrcImgInfo.u4Stride[0] = rSrcImgInfo.u4ImgWidth; rSrcImgInfo.u4Stride[1] = rSrcImgInfo.u4ImgWidth >> 1; rSrcImgInfo.u4Stride[2] = rSrcImgInfo.u4ImgWidth >> 1; rSrcImgInfo.u4BufSize = Srcbufinfo.size; rSrcImgInfo.u4BufVA = Srcbufinfo.virtAddr; rSrcImgInfo.u4BufPA = Srcbufinfo.phyAddr; rSrcImgInfo.i4MemID = Srcbufinfo.memID; pSingleShot->registerImgBufInfo(ECamShot_BUF_TYPE_YUV, rSrcImgInfo); ImgBufInfo rPostImgInfo; rPostImgInfo.u4ImgWidth = mShotParam.mi4PostviewWidth; rPostImgInfo.u4ImgHeight = mShotParam.mi4PostviewHeight; rPostImgInfo.eImgFmt = ePostViewFmt; rPostImgInfo.u4Stride[0] = rPostImgInfo.u4ImgWidth; rPostImgInfo.u4Stride[1] = rPostImgInfo.u4ImgWidth >> 1; rPostImgInfo.u4Stride[2] = rPostImgInfo.u4ImgWidth >> 1; // using blurimg buffer for reduce buffer size rPostImgInfo.u4BufSize = mpBlurImg.size; rPostImgInfo.u4BufVA = mpBlurImg.virtAddr; rPostImgInfo.u4BufPA = mpBlurImg.phyAddr; rPostImgInfo.i4MemID = mpBlurImg.memID; pSingleShot->registerImgBufInfo(ECamShot_BUF_TYPE_POSTVIEW, rPostImgInfo); // pSingleShot->enableDataMsg(ECamShot_DATA_MSG_YUV //| ECamShot_DATA_MSG_JPEG ); pSingleShot->enableNotifyMsg(NSCamShot::ECamShot_NOTIFY_MSG_EOF); // shot param NSCamShot::ShotParam rShotParam(eImgFmt_YV16, //yuv format mShotParam.mi4PictureWidth, //picutre width mShotParam.mi4PictureHeight, //picture height 0, //picture rotation in jpg 0, //picture flip ePostViewFmt, mShotParam.mi4PostviewWidth, //postview width mShotParam.mi4PostviewHeight, //postview height 0, //postview rotation 0, //postview flip mShotParam.mu4ZoomRatio //zoom ); // jpeg param NSCamShot::JpegParam rJpegParam(mJpegParam.mu4JpegQuality, //Quality MTRUE //isSOI ); // sensor param NSCamShot::SensorParam rSensorParam(static_cast<MUINT32>(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())), //Device ID #warning [FIXME] workaround for Alta phone capture mode can not work ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG, //Scenaio //ACDK_SCENARIO_ID_CAMERA_PREVIEW, //Scenaio 10, //bit depth MFALSE, //bypass delay MFALSE //bypass scenario ); // pSingleShot->setCallbacks(fgCamShotNotifyCb, fgCamShotDataCb, this); // pSingleShot->setShotParam(rShotParam); // pSingleShot->setJpegParam(rJpegParam); // pSingleShot->startOne(rSensorParam); // pSingleShot->uninit(); // pSingleShot->destroyInstance(); if(mShotParam.ms8ShotFileName.string()!=NULL) { ret = createFBJpegImg(Srcbufinfo,mu4W_yuv,mu4H_yuv,1); if ( ! ret ) { goto lbExit; } } #ifdef Debug_Mode loadFileToBuf("/data/FBSOURCE.yuv",(uint8_t*)Srcbufinfo.virtAddr,Srcbufinfo.size); saveBufToFile("/sdcard/img.yuv", (uint8_t*)Srcbufinfo.virtAddr, Srcbufinfo.size); #endif CPTLog(Event_FBShot_createFullFrame, CPTFlagEnd); MY_LOGD("[createFullFrame] - \n"); lbExit: return ret; }
MBOOL CamIOPipe:: configPipe(vector<PortInfo const*>const& vInPorts, vector<PortInfo const*>const& vOutPorts) { //FUNCTION_LOG_START; MY_LOGD("+ tid(%d), %d in / %d out", gettid(), vInPorts.size(), vOutPorts.size()); MBOOL ret = MTRUE; // if (0 == vInPorts.size() || 0 == vOutPorts.size() || vOutPorts.size() > 2) { MY_LOGE("Port config error"); return MFALSE; } // if (EPortType_Sensor != vInPorts.at(0)->type) { MY_LOGE("The IN port type should be sensor type"); return MFALSE; } // for (MUINT32 i = 0; i < vOutPorts.size(); i++) { if (EPortType_MemoryOut != vOutPorts.at(i)->type) { MY_LOGE("The OUT port type should be EPortType_MemoryOut"); return MFALSE; } } // (1). callbacks mpCamIOPipe->setCallbacks(NULL, NULL, NULL); // (2). command queue config ret = ret && mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_CQ_CHANNEL, (MINT32)NSImageio::NSIspio::EPIPE_PASS1_CQ0, 0, 0 ) && mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_CQ_TRIGGER_MODE, (MINT32)NSImageio::NSIspio::EPIPE_PASS1_CQ0, (MINT32)NSImageio::NSIspio::EPIPECQ_TRIGGER_SINGLE_IMMEDIATE, (MINT32)NSImageio::NSIspio::EPIPECQ_TRIG_BY_START ) && mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_CONFIG_STAGE, (MINT32)NSImageio::NSIspio::eConfigSettingStage_Init, 0, 0 ); if (!ret) { MY_LOGE("Cammand queue config fail:%d", mpCamIOPipe->getLastErrorCode()); return ret; } // // (3). In sensor port vector<NSImageio::NSIspio::PortInfo const*> vCamIOInPorts; SensorPortInfo const* const pSensorPort = reinterpret_cast<SensorPortInfo const*> (vInPorts.at(0)); ::memcpy(&mrSensorPortInfo, const_cast<SensorPortInfo*>(pSensorPort),sizeof(SensorPortInfo)); MUINT32 u4SensorWidth = 0, u4SensorHeight = 0; MUINT32 u4RawPixelID = 0; EImageFormat eSensorFmt = eImgFmt_UNKNOWN; // (3.1) Sensor instance if (NULL == mpSensorHal) { mpSensorHal = SensorHal::createInstance(); if (NULL == mpSensorHal) { MY_LOGE("Null sensorHal object"); return MFALSE; } } // mpSensorHal->sendCommand(static_cast<halSensorDev_e>(pSensorPort->u4DeviceID), SENSOR_CMD_SET_SENSOR_DEV, 0, 0, 0 ); // //mpSensorHal->init(); ret = querySensorInfo( pSensorPort->u4DeviceID, pSensorPort->u4Scenario, pSensorPort->u4Bitdepth, eSensorFmt, u4SensorWidth, u4SensorHeight, u4RawPixelID); MY_LOGD("Sensor: (devID,scen)(%d,%d) (w,h,fmt,bits,pixID)(%d,%d,0x%x,%d,%d) (bpDelay,bpScen,rawType)(%d,%d,%d)", pSensorPort->u4DeviceID, pSensorPort->u4Scenario, u4SensorWidth, u4SensorHeight, eSensorFmt, pSensorPort->u4Bitdepth, u4RawPixelID, pSensorPort->fgBypassDelay, pSensorPort->fgBypassScenaio, pSensorPort->u4RawType); // MUINT32 u4SensorStride = u4SensorWidth; if (eImgFmt_BAYER8 == eSensorFmt || eImgFmt_BAYER10 == eSensorFmt || eImgFmt_BAYER12 == eSensorFmt) { u4SensorStride = NSImageio::NSIspio::queryRawStride(eSensorFmt, u4SensorWidth); } //MY_LOGD("SensorPortInfo: (width, height, format, stride) = (%d, %d, 0x%x, %d, %d, %d)", // u4SensorWidth, u4SensorHeight, eSensorFmt, u4SensorStride); // NSImageio::NSIspio::PortInfo tgi; tgi.eImgFmt = eSensorFmt; tgi.eRawPxlID = mapRawPixelID(u4RawPixelID); tgi.u4ImgWidth = u4SensorWidth; tgi.u4ImgHeight = u4SensorHeight; tgi.u4Stride[0] = u4SensorStride; tgi.u4Stride[1] = 0; tgi.u4Stride[2] = 0; tgi.type = NSImageio::NSIspio::EPortType_Sensor; mu4DeviceID = pSensorPort->u4DeviceID; tgi.index = ((mu4DeviceID == SENSOR_DEV_MAIN)||(mu4DeviceID == SENSOR_DEV_ATV)) ? (NSImageio::NSIspio::EPortIndex_TG1I) : (NSImageio::NSIspio::EPortIndex_TG2I); tgi.inout = NSImageio::NSIspio::EPortDirection_In; tgi.u4BufSize = (MUINT32)0; vCamIOInPorts.push_back(&tgi); // The raw type, 0: pure raw, 1: pre-process raw if(pSensorPort->u4RawType == 1) { ret = mpCamIOPipe->sendCommand(NSImageio::NSIspio::EPIPECmd_SET_IMGO_RAW_TYPE, (MINT32)NSImageio::NSIspio::eRawImageType_PreProc, 0, 0 ); } // // (4). Out Port vector<NSImageio::NSIspio::PortInfo const*> vCamIOOutPorts; NSImageio::NSIspio::PortInfo imgo; NSImageio::NSIspio::PortInfo img2o; for (MUINT32 i = 0; i < vOutPorts.size(); i++) { MemoryOutPortInfo const* const memOutPort= reinterpret_cast<MemoryOutPortInfo const*> (vOutPorts.at(i)); // if (0 == memOutPort->index) { MY_LOGD("Out 0: (fmt,w,h)(0x%x,%d,%d) stride(%d,%d,%d)", tgi.eImgFmt, tgi.u4ImgWidth, tgi.u4ImgHeight, memOutPort->u4Stride[0], memOutPort->u4Stride[1], memOutPort->u4Stride[2]); imgo.eImgFmt = tgi.eImgFmt; imgo.u4ImgWidth = tgi.u4ImgWidth; imgo.u4ImgHeight = tgi.u4ImgHeight; // no crop imgo.crop.y = 0; imgo.crop.h = imgo.u4ImgHeight; imgo.type = NSImageio::NSIspio::EPortType_Memory; imgo.index = NSImageio::NSIspio::EPortIndex_IMGO; imgo.inout = NSImageio::NSIspio::EPortDirection_Out; imgo.u4Stride[0] = memOutPort->u4Stride[0]; imgo.u4Stride[1] = memOutPort->u4Stride[1]; imgo.u4Stride[2] = memOutPort->u4Stride[2]; imgo.u4Offset = 0; vCamIOOutPorts.push_back(&imgo); } #warning [TODO] Should check the port config by scenario else if (1 == memOutPort->index) { MY_LOGD("Out 1: (fmt,w,h)(0x%x,%d,%d) stride(%d,%d,%d)", memOutPort->eImgFmt, memOutPort->u4ImgWidth, memOutPort->u4ImgHeight, memOutPort->u4Stride[0], memOutPort->u4Stride[1], memOutPort->u4Stride[2]); img2o.eImgFmt = memOutPort->eImgFmt; img2o.u4ImgWidth = memOutPort->u4ImgWidth; img2o.u4ImgHeight = memOutPort->u4ImgHeight; img2o.crop.y = 0; img2o.crop.h = img2o.u4ImgHeight; img2o.type = NSImageio::NSIspio::EPortType_Memory; img2o.index = NSImageio::NSIspio::EPortIndex_IMG2O; img2o.inout = NSImageio::NSIspio::EPortDirection_Out; img2o.u4Stride[0] = memOutPort->u4Stride[0]; img2o.u4Stride[1] = memOutPort->u4Stride[1]; img2o.u4Stride[2] = memOutPort->u4Stride[2]; vCamIOOutPorts.push_back(&img2o); mfgIsYUVPortON = MTRUE; } } ret = mpCamIOPipe->configPipe(vCamIOInPorts, vCamIOOutPorts); // ret = configSensor(pSensorPort->u4DeviceID, pSensorPort->u4Scenario, u4SensorWidth, u4SensorHeight, pSensorPort->fgBypassDelay, pSensorPort->fgBypassScenaio, MTRUE); // The raw type, 0: pure raw, 1: pre-process raw 2: sensor test pattern if(pSensorPort->u4RawType == 2) { MINT32 u32Enable = 1; mpSensorHal->sendCommand(static_cast<halSensorDev_e>(pSensorPort->u4DeviceID), SENSOR_CMD_SET_TEST_PATTERN_OUTPUT, (MINT32)&u32Enable, 0, 0); MY_LOGD("Sensor Test Pattern"); } // query skip frame to wait for stable mu4SkipFrame = 0; if (mrSensorPortInfo.fgBypassDelay == MFALSE) { MUINT32 u4Mode = SENSOR_CAPTURE_DELAY; switch (pSensorPort->u4Scenario) { case ACDK_SCENARIO_ID_CAMERA_PREVIEW: u4Mode = SENSOR_PREVIEW_DELAY; break; case ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG: u4Mode = SENSOR_CAPTURE_DELAY; break; case ACDK_SCENARIO_ID_VIDEO_PREVIEW: u4Mode = SENSOR_VIDEO_DELAY; break; } // mpSensorHal->sendCommand(static_cast<halSensorDev_e>(mrSensorPortInfo.u4DeviceID), static_cast<int>(SENSOR_CMD_GET_UNSTABLE_DELAY_FRAME_CNT), reinterpret_cast<int>(&mu4SkipFrame), reinterpret_cast<int>(&u4Mode)); } handleNotifyCallback( ECamPipe_NOTIFY_MSG_DROPFRAME, mu4SkipFrame, 0 ); //FUNCTION_LOG_END; return ret; }
MBOOL Mhal_facebeauty:: createJpegImgWithThumbnail(NSCamHW::ImgBufInfo const &rYuvImgBufInfo, NSCamHW::ImgBufInfo const &rPostViewBufInfo, MUINT32 const Mode) { MBOOL ret = MTRUE; MUINT32 stride[3]; MY_LOGD("[createJpegImgWithThumbnail] in"); //rJpegImgBufInfo IMEM_BUF_INFO jpegBuf; jpegBuf.size = mu4W_yuv * mu4H_yuv; mpIMemDrv->allocVirtBuf(&jpegBuf); NSCamHW::ImgInfo rJpegImgInfo(eImgFmt_JPEG, mu4W_yuv, mu4H_yuv); NSCamHW::BufInfo rJpegBufInfo(jpegBuf.size, jpegBuf.virtAddr, jpegBuf.phyAddr, jpegBuf.memID); NSCamHW::ImgBufInfo rJpegImgBufInfo(rJpegImgInfo, rJpegBufInfo, stride); //rThumbImgBufInfo IMEM_BUF_INFO thumbBuf; thumbBuf.size = mJpegParam.mi4JpegThumbWidth * mJpegParam.mi4JpegThumbHeight; mpIMemDrv->allocVirtBuf(&thumbBuf); NSCamHW::ImgInfo rThumbImgInfo(eImgFmt_JPEG, mJpegParam.mi4JpegThumbWidth, mJpegParam.mi4JpegThumbHeight); NSCamHW::BufInfo rThumbBufInfo(thumbBuf.size, thumbBuf.virtAddr, thumbBuf.phyAddr, thumbBuf.memID); NSCamHW::ImgBufInfo rThumbImgBufInfo(rThumbImgInfo, rThumbBufInfo, stride); MUINT32 u4JpegSize = 0; MUINT32 u4ThumbSize = 0; NSCamShot::JpegParam yuvJpegParam(mJpegParam.mu4JpegQuality, MFALSE); ret = ret && createJpegImg(rYuvImgBufInfo, yuvJpegParam, mShotParam.mi4Rotation, 0 , rJpegImgBufInfo, u4JpegSize); // (3.1) create thumbnail // If postview is enable, use postview buffer, // else use yuv buffer to do thumbnail if (0 != mJpegParam.mi4JpegThumbWidth && 0 != mJpegParam.mi4JpegThumbHeight) { NSCamShot::JpegParam rParam(mJpegParam.mu4JpegThumbQuality, MFALSE); ret = ret && createJpegImg(rPostViewBufInfo, rParam, mShotParam.mi4Rotation, 0, rThumbImgBufInfo, u4ThumbSize); } #ifdef Debug_Mode // Save Img for debug. { char szFileName[100]; saveBufToFile("/sdcard/Result.jpg", (uint8_t*)jpegBuf.virtAddr, u4JpegSize); MY_LOGD("[createJpegImgWithThumbnail] Save %s done.", szFileName); saveBufToFile("/sdcard/ThumbImg.jpg", (uint8_t*)thumbBuf.virtAddr, u4ThumbSize); MY_LOGD("[createJpegImgWithThumbnail] Save %s done.", szFileName); } #endif // Debug_Mode // Jpeg callback, it contains thumbnail in ext1, ext2. handleJpegData((MUINT8*)rJpegImgBufInfo.u4BufVA, u4JpegSize, (MUINT8*)rThumbImgBufInfo.u4BufVA, u4ThumbSize, Mode); mpIMemDrv->freeVirtBuf(&jpegBuf); mpIMemDrv->freeVirtBuf(&thumbBuf); MY_LOGD("[createJpegImgWithThumbnail] out"); return ret; }
status_t ParamsManager:: dump(int fd, Vector<String8>const& args) { // if ( args.empty() ) { mParameters.dump(fd, Vector<String16>()); return OK; } // MY_LOGD("args(%d)=%s", args.size(), (*args.begin()).string()); // // // Parse command: "s1=s2" if ( args.size() == 1 ) { String8 s8OutputTemp; String8 const& s8Arg1 = args[0]; // find pattern in s8Arg1: "s1=s2" ssize_t const AssignIndex = s8Arg1.find("="); // (1) No assignment. Just show the old value. if ( -1 == AssignIndex ) { String8 const key(s8Arg1.string()); char const *value_old = mParameters.get(key); // s8OutputTemp = String8::format("\t%s: ", key.string()); if ( value_old ) { s8OutputTemp += value_old; } s8OutputTemp += "\n"; ::write(fd, s8OutputTemp.string(), s8OutputTemp.size()); } // (2) Assignment. Show both old/new values and then set the new value. else { String8 const key(s8Arg1.string(), AssignIndex); char const *value_old = mParameters.get(key); char const *value_new = s8Arg1.string() + AssignIndex + 1; // // show old key-value s8OutputTemp = String8::format("\t[old] %s: ", key.string()); if ( value_old ) { s8OutputTemp += value_old; } s8OutputTemp += "\n"; ::write(fd, s8OutputTemp.string(), s8OutputTemp.size()); // // show new key-value s8OutputTemp = String8::format("\t[new] %s: ", key.string()); if ( value_new ) { s8OutputTemp += value_new; } s8OutputTemp += "\n"; ::write(fd, s8OutputTemp.string(), s8OutputTemp.size()); // // set new key-value mParameters.set(key, value_new); } return OK; } // return OK; }
//----------------------------------------------------------------------------- MBOOL CapBufNodeImp:: threadLoopUpdate() { FUNC_START; handleNotify( PASS1_SOF, 0, 0 ); // MUINT32 imgoAddr = 0; // if(isDataConnected(PASS1_FULLRAW)) { if(mpCapBufMgr != NULL) { IImageBuffer* pImageBuffer = NULL; if(mpCapBufMgr->dequeBuf(pImageBuffer)) { if(pImageBuffer != NULL) { imgoAddr = (MUINT32)pImageBuffer; // { Mutex::Autolock _l(mLock); mlpDequeFullBuf.push_back(pImageBuffer); } } else { MY_LOGE("Deque NULL buffer"); } } else { MY_LOGE("Deque fail"); } } else if(mpImageBuffer != NULL) { imgoAddr = (MUINT32)mpImageBuffer; // { Mutex::Autolock _l(mLock); mlpDequeFullBuf.push_back(mpImageBuffer); } } else { MY_LOGE("mpCapBufMgr is NULL"); } } else { MY_LOGE("Please connect PASS1_FULLRAW"); usleep(10*1000); } // if(imgoAddr) { MUINT32 magicNum; MBOOL isRrzo; MVOID* pPrivateData; MUINT32 privateDataSize; // mpIspSyncCtrl->queryImgBufInfo( (IImageBuffer*)imgoAddr, magicNum, isRrzo, pPrivateData, privateDataSize); // MY_LOGD("imgoAddr(0x%08X),MN(0x%08X)", imgoAddr, magicNum); // handleNotify(PASS1_EOF, -1, magicNum); handlePostBuffer(PASS1_FULLRAW, imgoAddr, 0); } else { MY_LOGE("imgoAddr is 0"); } FUNC_END; return MTRUE; }