MBOOL Pass2NodeImpl:: dequePass2() { CAM_TRACE_CALL(); MBOOL ret = MFALSE; QParams dequeParams; Vector<Input>::const_iterator iterIn; Vector<Output>::const_iterator iterOut; // MY_LOGV("type(%d) cnt %d: deque", mPass2Type, muDeqFrameCnt); if( !mpPostProcPipe->deque(dequeParams, PASS2_TIMEOUT) ) { MY_LOGE("type(%d) pass2 cnt %d: deque fail", mPass2Type, muDeqFrameCnt); aee_system_exception( LOG_TAG, NULL, DB_OPT_DEFAULT, "\nCRDISPATCH_KEY:MtkCam/P1Node:ISP pass2 deque fail"); goto lbExit; } if( !handleP2Done(dequeParams) ) { MY_LOGE("handle p2 callback failed"); goto lbExit; } ret = MTRUE; lbExit: CAM_TRACE_FMT_END(); return ret; }
MBOOL StereoNodeImpl:: onReturnBuffer(MUINT32 const data, MUINTPTR const buf, MUINT32 const ext) { MBOOL ret = MTRUE; CAM_TRACE_CALL(); if ( data != STEREO_FEO ) { ICamBufHandler* pBufHdl = getBufferHandler(data); if( !pBufHdl ) { MY_LOGE("no buffer hdl for data %d, buf 0x%x", data, buf); return MFALSE; } ret = pBufHdl->enqueBuffer(data, (IImageBuffer*)buf); if( !ret ) { MY_LOGE("enque fail: data %d, buf 0x%x", data, buf); } MY_LOGD("data %d, buf 0x%x", data, buf); } else { Mutex::Autolock lock(mLock); IMEM_BUF_INFO feo = *(IMEM_BUF_INFO*)buf; mlFeBufQueue.push_back(feo); MY_LOGD("size(%d) data %d, buf(0x%x) ID(%d) VA(0x%x)", mlFeBufQueue.size(), data, buf, feo.memID, feo.virtAddr); } return MTRUE; }
MBOOL SyncNodeImpl:: onReturnBuffer(MUINT32 const data, MUINTPTR const buf, MUINT32 const ext) { CAM_TRACE_CALL(); MY_LOGD("data %d, buf 0x%x ext 0x%08X", data, buf, ext); switch(data) { case SYNC_DST_0: handleReturnBuffer(SYNC_SRC_0, buf); break; case SYNC_DST_1: handleReturnBuffer(SYNC_SRC_1, buf); break; default: MY_LOGE("not support data: %d", data); break; } return MTRUE; }
MBOOL Pass2NodeImpl:: enquePass2(MBOOL const doCallback) { //workaround for start/stop recording Mutex::Autolock lock(mRecordingLock); CAM_TRACE_CALL(); QParams enqueParams; vector<p2data> vP2data; MUINT32 trace_begin = muEnqFrameCnt; if( !getPass2Buffer(vP2data) ) { // no dst buffers return MTRUE; } if( vP2data.size() == 0 ) { MY_LOGE("no src/dst buf"); return MFALSE; } enqueParams.mvIn.reserve( vP2data.size() ); //enqueParams.mvOut.reserve(dstCount); MUINT32 index = 0; vector<p2data>::const_iterator pData = vP2data.begin(); while( pData != vP2data.end() ) { MUINT32 magicNum; MVOID* pPrivateData; MUINT32 privateDataSize; MCropRect p2InCrop; MSize srcSize; MINT64 timestamp; // input Input src; // src.mPortID = mapToPortID(pData->src.data); src.mPortID.group = index; src.mBuffer = pData->src.buf; // if( pData->doCrop ) { mpIspSyncCtrlHw->getPass2Info( src.mBuffer, pData->dstSize, magicNum, pPrivateData, privateDataSize, p2InCrop); } else { MBOOL isRrzo; mpIspSyncCtrlHw->queryImgBufInfo( src.mBuffer, magicNum, isRrzo, pPrivateData, privateDataSize); p2InCrop.p_integral = MPoint(0, 0); p2InCrop.p_fractional = MPoint(0, 0); p2InCrop.s = src.mBuffer->getImgSize(); } // if( !isPreviewPath() ) magicNum = SetCap(magicNum); // enqueParams.mvPrivaData.push_back(pPrivateData); enqueParams.mvMagicNo.push_back(magicNum); enqueParams.mvIn.push_back(src); // srcSize = src.mBuffer->getImgSize(); timestamp = src.mBuffer->getTimestamp(); // MY_LOGD("i %d data %d, buf 0x%x, va 0x%x, # 0x%X, type %d cnt %d", index, pData->src.data, src.mBuffer, src.mBuffer->getBufVA(0), magicNum, mPass2Type, muEnqFrameCnt); //output // MCrpRsInfo crop1; crop1.mGroupID = 1; crop1.mCropRect.s = srcSize; crop1.mResizeDst = srcSize; // MCrpRsInfo crop2; crop2.mGroupID = 2; crop2.mCropRect = p2InCrop; //crop2.mResizeDst = MSize(0,0); // output MUINT32 i = 0; for( vector<ImgRequest>::const_iterator pOutReq = pData->vDstReq.begin(); pOutReq != pData->vDstReq.end(); pOutReq++, i++ ) { const MUINT32 dstDataType = pData->vDstData[i]; Output dst; IImageBuffer* pDstBuf = const_cast<IImageBuffer*>(pOutReq->mBuffer); // MY_LOGD("data %d, buf 0x%x, va 0x%x, tans %d usg %d", dstDataType, pDstBuf, pDstBuf->getBufVA(0), pOutReq->mTransform, pOutReq->mUsage); // dst.mPortID = mapToPortID(dstDataType); dst.mPortID.group = index; dst.mPortID.capbility = (NSIoPipe::EPortCapbility)(pOutReq->mUsage); // dst.mBuffer = pDstBuf; dst.mTransform = pOutReq->mTransform; // dst.mBuffer->setTimestamp(timestamp); // enqueParams.mvOut.push_back(dst); // if(mapToPortID(dstDataType) == IMG2O) { crop1.mCropRect = p2InCrop; crop1.mResizeDst = dst.mBuffer->getImgSize(); MY_LOGD("IMG2O:B(%p),S(%dx%d),C(%d,%d,%dx%d)", dst.mBuffer, crop1.mResizeDst.w, crop1.mResizeDst.h, crop1.mCropRect.p_integral.x, crop1.mCropRect.p_integral.y, crop1.mCropRect.s.w, crop1.mCropRect.s.h); } } // enqueParams.mvCropRsInfo.push_back( crop1 ); enqueParams.mvCropRsInfo.push_back( crop2 ); // // next src/dst pair pData++; muEnqFrameCnt++; index++; } // configFeature(); // #if PASS2_CALLBACL_ENABLE if( doCallback ) { enqueParams.mpfnCallback = pass2CbFunc; enqueParams.mpCookie = this; } else #endif { enqueParams.mpfnCallback = NULL; enqueParams.mpCookie = NULL; } // if( !mpIspSyncCtrlHw->lockHw(IspSyncControlHw::HW_PASS2) ) { MY_LOGE("isp sync lock pass2 failed"); return MFALSE; } // CAM_TRACE_FMT_BEGIN("enqP2:%d", trace_begin); if( !mpPostProcPipe->enque(enqueParams) ) { CAM_TRACE_FMT_END(); MY_LOGE("enque pass2 failed"); AEE_ASSERT("ISP pass2 enque fail"); return MFALSE; } CAM_TRACE_FMT_END(); return MTRUE; }
MBOOL StereoNodeImpl:: handleP2Done(QParams& rParams) { CAM_TRACE_CALL(); CAM_TRACE_FMT_BEGIN("deqP2:%d", muDeqFrameCnt); MBOOL ret = MFALSE; MBOOL isZoom = (rParams.mvCropRsInfo[0].mCropRect.p_integral.x != 0) ? MTRUE : MFALSE; Vector<Input>::const_iterator iterIn; Vector<Output>::const_iterator iterOut; Vector<ModuleInfo>::const_iterator iterMInfo; // MY_LOGD("cnt %d in(%d) out(%d) moduleData(%d) isZoom(%d)", muDeqFrameCnt, rParams.mvIn.size(), rParams.mvOut.size(), rParams.mvModuleData.size(), isZoom); // if( !mpIspSyncCtrlHw->unlockHw(IspSyncControlHw::HW_PASS2) ) { MY_LOGE("isp sync unlock pass2 failed"); goto lbExit; } // for( iterIn = rParams.mvIn.begin(); iterIn != rParams.mvIn.end(); iterIn++ ) { PortID portId = iterIn->mPortID; portId.group = 0; MUINT32 nodeDataType = mapToNodeDataType( portId ); MY_LOGD("In PortID(0x%08X), nodeData(%d)",portId, nodeDataType); handleReturnBuffer( nodeDataType, (MUINTPTR)iterIn->mBuffer); } // for( iterOut = rParams.mvOut.begin(); iterOut != rParams.mvOut.end(); iterOut++ ) { PortID portId = iterOut->mPortID; portId.group = 0; MUINT32 nodeDataType = mapToNodeDataType( portId ); MY_LOGD("Out PortID(0x%08X), nodeData(%d), bufInfo(0x%x), va/pa(0x%x/0x%x), ID(%d)", portId, nodeDataType, iterOut->mBuffer, iterOut->mBuffer->getBufVA(0), iterOut->mBuffer->getBufPA(0), iterOut->mBuffer->getFD()); handlePostBuffer( nodeDataType, (MUINTPTR)iterOut->mBuffer, (MUINT32)isZoom ); } for( iterMInfo = rParams.mvModuleData.begin(); iterMInfo != rParams.mvModuleData.end(); iterMInfo++ ) { if ( iterMInfo->moduleTag == EFeatureModule_STA_FEO ) { StaData* pModuleData = reinterpret_cast<StaData*>(iterMInfo->moduleStruct); PortID portId = PortID((EPortType)pModuleData->port_type, pModuleData->port_idx, pModuleData->port_inout); portId.group = 0; MUINT32 nodeDataType = mapToNodeDataType( portId ); MY_LOGD("ModuleInfo PortID(0x%08X), nodeData(%d), bufInfo(0x%x), va/pa(0x%x/0x%x), ID(%d)", portId, nodeDataType, &(pModuleData->bufInfo), pModuleData->bufInfo.virtAddr, pModuleData->bufInfo.phyAddr, pModuleData->bufInfo.memID); handlePostBuffer( nodeDataType, (MUINTPTR)&pModuleData->bufInfo, (MUINT32)isZoom ); } } // { Mutex::Autolock lock(mLock); muDeqFrameCnt++; mCondDeque.broadcast(); } // ret = MTRUE; lbExit: CAM_TRACE_FMT_END(); return ret; }
MBOOL StereoNodeImpl:: enquePass2(MUINT32 const data, IImageBuffer* const buf, MUINT32 const ext) { CAM_TRACE_CALL(); // get output bufffers MUINT32 dstCount = 0, dstDataType[MAX_DST_PORT_NUM]; ImgRequest outRequest[MAX_DST_PORT_NUM]; IMEM_BUF_INFO feoRequest; vector<MUINT32> vDataDst = getDataConnected(); MSize const srcImgSize = buf->getImgSize(); MSize const dstImgSize = getAlgoImgSize(); // for(MUINT32 i = 0; i < vDataDst.size(); i++) { if ( STEREO_FEO != vDataDst[i] ) { ICamBufHandler* pBufHdl = getBufferHandler( vDataDst[i] ); if( pBufHdl && pBufHdl->dequeBuffer( vDataDst[i], &outRequest[dstCount]) ) { dstDataType[dstCount] = vDataDst[i]; dstCount++; } else { MY_LOGE("no dst buf (0x%x)", vDataDst[i]); } } else { Mutex::Autolock lock(mLock); if( mlFeBufQueue.size() == 0 ) { MY_LOGE("no feo buf"); } else { feoRequest = mlFeBufQueue.front(); mlFeBufQueue.pop_front(); // dstDataType[dstCount] = vDataDst[i]; dstCount++; } } } if( dstCount == 0 ) { MY_LOGW("no dst buffer, skip data(%d), buf(0x%x)", data, buf); handleReturnBuffer(data, (MUINTPTR)buf); return MTRUE; } QParams enqueParams; StaData feoData; MUINT32 magicNum = 0; MVOID* pPrivateData = NULL; MUINT32 privateDataSize = 0; MCropRect p2InCrop; MSize feSize = getFEImgSize(); MINT64 timestamp = 0; //input { IImageBuffer const* pSrcBuf = buf; Input src; // src.mPortID = mapToPortID(data); src.mBuffer = const_cast<IImageBuffer*>(pSrcBuf); // mpIspSyncCtrlHw->getPass2Info( src.mBuffer, srcImgSize, magicNum, pPrivateData, privateDataSize, p2InCrop); // enqueParams.mpPrivaData = pPrivateData; enqueParams.mFrameNo = magicNum; // timestamp = pSrcBuf->getTimestamp(); enqueParams.mvIn.push_back(src); } // MCrpRsInfo crop1; crop1.mGroupID = 1; crop1.mCropRect = p2InCrop; crop1.mResizeDst = dstImgSize; // MCrpRsInfo crop2; crop2.mGroupID = 2; crop2.mCropRect.s = dstImgSize; MY_LOGD("data %d, buf 0x%x,va/pa(0x%x/0x%x),size(%dx%d),crop(%d,%d,%d,%d) # 0x%X, cnt %d; crop1(%d,%d,%d,%d)(%dx%d), crop2(%d,%d,%d,%d)(%dx%d)", data, buf, buf->getBufVA(0), buf->getBufPA(0), buf->getImgSize().w, buf->getImgSize().h, p2InCrop.p_integral.x, p2InCrop.p_integral.y, p2InCrop.s.w, p2InCrop.s.h, magicNum, muEnqFrameCnt, crop1.mCropRect.p_integral.x, crop1.mCropRect.p_integral.y, crop1.mCropRect.s.w, crop1.mCropRect.s.h, crop1.mResizeDst.w, crop1.mResizeDst.h, crop2.mCropRect.p_integral.x, crop2.mCropRect.p_integral.y, crop2.mCropRect.s.w, crop2.mCropRect.s.h, crop2.mResizeDst.w, crop2.mResizeDst.h); // // output for( MUINT32 i = 0 ; i < dstCount ; i++ ) { if(dstDataType[i] != STEREO_FEO) { IImageBuffer const* pDstBuf = outRequest[i].mBuffer; MY_LOGD("data %d, buf 0x%x, va/pa(0x%x/0x%x), size(%dx%d), tans %d", dstDataType[i], pDstBuf, pDstBuf->getBufVA(0), pDstBuf->getBufPA(0), pDstBuf->getImgSize().w, pDstBuf->getImgSize().h, outRequest[i].mTransform); Output dst; dst.mPortID = mapToPortID(dstDataType[i]); dst.mBuffer = const_cast<IImageBuffer*>(pDstBuf); dst.mTransform = outRequest[i].mTransform; dst.mBuffer->setTimestamp(timestamp); // enqueParams.mvOut.push_back(dst); } else { MINT32 idx = muEnqFrameCnt%BUF_COUNT; mpStaParam[idx]->bufInfo.size = feoRequest.size; mpStaParam[idx]->bufInfo.memID = feoRequest.memID; mpStaParam[idx]->bufInfo.virtAddr = feoRequest.virtAddr; mpStaParam[idx]->bufInfo.phyAddr = feoRequest.phyAddr; mpStaParam[idx]->bufInfo.bufSecu = 0; mpStaParam[idx]->bufInfo.bufCohe = 0; mpStaParam[idx]->bufInfo.useNoncache = 0; mpStaParam[idx]->w = feSize.w; mpStaParam[idx]->h = feSize.h; mpStaParam[idx]->stride = feSize.w; mpStaParam[idx]->port_idx = FEO.index; mpStaParam[idx]->port_type = FEO.type; mpStaParam[idx]->port_inout = FEO.inout; /* feoData.bufInfo.size = feoRequest.size; feoData.bufInfo.memID = feoRequest.memID; feoData.bufInfo.virtAddr = feoRequest.virtAddr; feoData.bufInfo.phyAddr = feoRequest.phyAddr; feoData.bufInfo.bufSecu = 0; feoData.bufInfo.bufCohe = 0; feoData.bufInfo.useNoncache = 0; feoData.w = FE_W; feoData.h = FE_H; feoData.stride = FE_W; feoData.port_idx = FEO.index; feoData.port_type = FEO.type; feoData.port_inout = FEO.inout; MY_LOGD("(0x%x)FEO:Size(%d),ID(%d),S(%dx%d,%d),VA(%p)PA(%p),Port(%d/%d/%d)", &feoData, feoData.bufInfo.size, feoData.bufInfo.memID, feoData.w, feoData.h, feoData.stride, feoData.bufInfo.virtAddr, feoData.bufInfo.phyAddr, feoData.port_idx, feoData.port_type, feoData.port_inout);*/ ModuleInfo feoInfo; feoInfo.moduleTag = (MINT32)(EFeatureModule_STA_FEO); feoInfo.moduleStruct = reinterpret_cast<MVOID*>(mpStaParam[idx]); enqueParams.mvModuleData.push_back(feoInfo); mpSrzParam[idx]->in_w = crop1.mResizeDst.w; mpSrzParam[idx]->in_h = crop1.mResizeDst.h; mpSrzParam[idx]->out_w = getFEImgSize().w; mpSrzParam[idx]->out_h = getFEImgSize().h; ModuleInfo srzInfo; srzInfo.moduleTag = (MINT32)(EFeatureModule_SRZ1); srzInfo.moduleStruct = reinterpret_cast<MVOID*>(mpSrzParam[idx]); enqueParams.mvModuleData.push_back(srzInfo); MY_LOGD("[0x%x]FEO:Size(%d),ID(%d),S(%dx%d,%d),VA(%p)PA(%p),Port(%d/%d/%d);[0x%x]SRZ:in(%dx%d),out(%dx%d)", mpStaParam[idx], mpStaParam[idx]->bufInfo.size, mpStaParam[idx]->bufInfo.memID, mpStaParam[idx]->w, mpStaParam[idx]->h, mpStaParam[idx]->stride, mpStaParam[idx]->bufInfo.virtAddr, mpStaParam[idx]->bufInfo.phyAddr, mpStaParam[idx]->port_idx, mpStaParam[idx]->port_type, mpStaParam[idx]->port_inout, mpSrzParam[idx], mpSrzParam[idx]->in_w, mpSrzParam[idx]->in_h, mpSrzParam[idx]->out_w, mpSrzParam[idx]->out_h); } } // enqueParams.mvCropRsInfo.push_back( crop1 ); enqueParams.mvCropRsInfo.push_back( crop2 ); // enqueParams.mpfnCallback = pass2CbFunc; enqueParams.mpCookie = this; // if( !mpIspSyncCtrlHw->lockHw(IspSyncControlHw::HW_PASS2) ) { MY_LOGE("isp sync lock pass2 failed"); return MFALSE; } // CAM_TRACE_FMT_BEGIN("enqP2:%d", muEnqFrameCnt); if( !mpPostProcPipe->enque(enqueParams) ) { CAM_TRACE_FMT_END(); MY_LOGE("enque pass2 failed"); AEE_ASSERT("ISP pass2 enque fail"); if( !mpIspSyncCtrlHw->unlockHw(IspSyncControlHw::HW_PASS2) ) { MY_LOGE("isp sync unlock pass2 failed"); } return MFALSE; } CAM_TRACE_FMT_END(); muEnqFrameCnt++; FUNC_END; return MTRUE; }