MVOID StereoNodeImpl:: onDumpBuffer(const char* usr, MUINT32 const data, MUINTPTR const buf, MUINT32 const ext) { #define DUMP_PREFIX "/sdcard/cameradump_" char dumppath[256]; sprintf( dumppath, "%s%s/", DUMP_PREFIX, usr ); #define DUMP_IImageBuffer( type, pbuf, fileExt, cnt) \ do{ \ IImageBuffer* buffer = (IImageBuffer*)pbuf; \ char filename[256]; \ sprintf(filename, "%s%s_%d_%dx%d_%d.%s", \ dumppath, \ #type, \ getSensorIdx(), \ buffer->getImgSize().w,buffer->getImgSize().h, \ cnt, \ fileExt \ ); \ buffer->saveToFile(filename); \ }while(0) if(!makePath(dumppath,0660)) { MY_LOGE("makePath [%s] fail",dumppath); return; } switch( data ) { case STEREO_SRC: DUMP_IImageBuffer( STEREO_SRC, buf, "raw", muPostFrameCnt ); break; case STEREO_IMG: { if ( !mDebugDumpGB ) { IImageBuffer* buffer = (IImageBuffer*)buf; buffer->unlockBuf("DUMP"); buffer->lockBuf("DUMP", eBUFFER_USAGE_SW_READ_RARELY); DUMP_IImageBuffer( STEREO_IMG, buf, "yuv", muDeqFrameCnt ); buffer->unlockBuf("DUMP"); buffer->lockBuf("DUMP", eBUFFER_USAGE_HW_RENDER|eBUFFER_USAGE_HW_TEXTURE|eBUFFER_USAGE_SW_WRITE_RARELY); } else { DUMP_IImageBuffer( STEREO_IMG, buf, "yuv", muDeqFrameCnt ); } } break; case STEREO_RGB: DUMP_IImageBuffer( STEREO_RGB, buf, "rgb", muDeqFrameCnt ); break; default: MY_LOGE("not handle this yet: data %d", data); break; } #undef DUMP_IImageBuffer }
IImageBuffer* IImageBufferAllocator:: alloc_ion( char const* szCallerName, ImgParam const& rImgParam, ExtraParam const& rExtraParam ) { IImageBuffer* pImgBuf = NULL; // #if defined(MTK_ION_SUPPORT) // IIonImageBufferHeap::AllocImgParam_t imgParam = rImgParam; IIonImageBufferHeap::AllocExtraParam extraParam; extraParam.nocache = rExtraParam.nocache; if ( eImgFmt_JPEG == rImgParam.imgFormat ) { if ( 0 == imgParam.bufSize ) { CAM_LOGE("Err imgParam: bufSize should not be 0 for JPEG memory"); return NULL; } imgParam.imgFormat = eImgFmt_BLOB; } // sp<IImageBufferHeap> pHeap = IIonImageBufferHeap::create(szCallerName, imgParam, extraParam); if ( pHeap == 0 ) { CAM_LOGE("NULL Heap"); return NULL; } // if ( eImgFmt_JPEG == rImgParam.imgFormat ) { pImgBuf = pHeap->createImageBuffer_FromBlobHeap(0, rImgParam.imgFormat, rImgParam.jpgSize, rImgParam.bufStridesInBytes); } else { pImgBuf = pHeap->createImageBuffer(); } if ( pImgBuf == 0 ) { CAM_LOGE("createImageBuffer fail"); return NULL; } // pImgBuf->incStrong(pImgBuf); #else CAM_LOGW("does not support ION!"); #endif // return pImgBuf; }
static MBOOL handleJpegCallback(CamShotDataInfo const msg) { MY_LOGD("handleJpegCallback"); char fileName[256] = {'\0'}; sprintf(fileName, "/data/jpeg%02d.jpg", u4CapCnt); saveBufToFile(fileName, (MUINT8*)msg.pBuffer->getBufVA(0), msg.pBuffer->getBitstreamSize()); IImageBuffer* pThumbImg = reinterpret_cast<IImageBuffer*>(msg.ext1); memset(fileName, '\0', 256); sprintf(fileName, "/data/thumb%02d.jpg", u4CapCnt); saveBufToFile(fileName, (MUINT8*)pThumbImg->getBufVA(0), pThumbImg->getBitstreamSize()); return 0; }
IImageBuffer* IImageBufferAllocator:: alloc_gb( char const* szCallerName, ImgParam const& rImgParam, ExtraParam const& rExtraParam ) { IImageBuffer* pImgBuf = NULL; // IGrallocImageBufferHeap::AllocImgParam_t imgParam = rImgParam; IGrallocImageBufferHeap::AllocExtraParam extraParam(rExtraParam.usage, rExtraParam.nocache); if ( eImgFmt_JPEG == rImgParam.imgFormat ) { if ( 0 == imgParam.bufSize ) { CAM_LOGE("Err imgParam: bufSize should not be 0 for JPEG memory"); return NULL; } imgParam.imgFormat = eImgFmt_BLOB; } // sp<IImageBufferHeap> pHeap = IGrallocImageBufferHeap::create(szCallerName, imgParam, extraParam); if ( pHeap == 0 ) { CAM_LOGE("NULL Heap"); return NULL; } // if ( eImgFmt_JPEG == rImgParam.imgFormat ) { pImgBuf = pHeap->createImageBuffer_FromBlobHeap(0, rImgParam.imgFormat, rImgParam.jpgSize, rImgParam.bufStridesInBytes); } else { pImgBuf = pHeap->createImageBuffer(); } if ( pImgBuf == 0 ) { CAM_LOGE("createImageBuffer fail"); return NULL; } // pImgBuf->incStrong(pImgBuf); // return pImgBuf; }
MBOOL JpegCodec:: encode( IImageBuffer const *pSrcBufInfo, IImageBuffer const *pDstBufInfo, MRect const rROI, MUINT32 const u4Transform, MUINT32 const u4Quality, MUINT32 const u4IsSOI, MUINT32 const eCodecType, MUINT32 const u4TimeoutMs//, // MUINT32 &u4EncSize ) { MBOOL ret = MTRUE; if (checkIfNeedImgTransform(pSrcBufInfo, pDstBufInfo, rROI, u4Transform)) { // IImageBuffer *pImageBuff; int format = pSrcBufInfo->getImgFormat(); MUINT32 u4AlignedWidth = pDstBufInfo->getImgSize().w; MUINT32 u4AlignedHeight = pDstBufInfo->getImgSize().h; if( !isSupportedFormat((NSCam::EImageFormat)format) ) { MY_LOGW("use yuy2 for jpeg encode"); // default format format = eImgFmt_YUY2; } { // Jpeg code width/height should be aligned MUINT32 w_align, h_align; getAlignment(format, &w_align, &h_align); u4AlignedWidth = (~(w_align-1)) & ((w_align-1) + u4AlignedWidth); u4AlignedHeight = (~(h_align-1)) & ((h_align-1) + u4AlignedHeight); MY_LOGW("[encode] Ori (width, height) = (%d, %d), Aligned (width, height) = (%d, %d)", pSrcBufInfo->getImgSize().w, pSrcBufInfo->getImgSize().h, u4AlignedWidth, u4AlignedHeight); } if( !allocYuvMem(&pImageBuff, MSize(u4AlignedWidth, u4AlignedHeight), format) ) { return MFALSE; } // IImageTransform *pImgTransform = IImageTransform::createInstance(); ret = pImageBuff->lockBuf(LOG_TAG, eBUFFER_USAGE_HW_CAMERA_WRITE|eBUFFER_USAGE_SW_MASK); ret = pImageBuff->syncCache(eCACHECTRL_INVALID); ret = ret && pImgTransform->execute(pSrcBufInfo, pImageBuff, NULL, rROI, u4Transform, u4TimeoutMs); //10s timeout if (ret && mu4DumpFlag) { char fileName[256] = {0}; sprintf(fileName, "/%s/trans_%dx%d.yuv", MEDIA_PATH, u4AlignedWidth, u4AlignedHeight); pImageBuff->saveToFile(fileName); } pImgTransform->destroyInstance(); // (2). Encode ret = ret && encode(pImageBuff, pDstBufInfo, u4Quality, u4IsSOI, eCodecType, u4TimeoutMs); ret = ret && pImageBuff->unlockBuf(LOG_TAG); freeYuvMem(&pImageBuff); // } else { ret = encode(pSrcBufInfo, pDstBufInfo, u4Quality, u4IsSOI, eCodecType, u4TimeoutMs/*, u4EncSize*/); } return ret; }
int case2() { int ret=0; MBOOL isV3 = MFALSE; //temp disable tuning path cuz tuning function not ready NSCam::NSIoPipe::NSPostProc::IFeatureStream* pMFBMixStream; pMFBMixStream= NSCam::NSIoPipe::NSPostProc::IFeatureStream::createInstance(LOG_TAG, NSCam::NSIoPipe::NSPostProc::EFeatureStreamTag_MFB_Mix,0xFFFF, isV3); pMFBMixStream->init(); IMemDrv* mpImemDrv=NULL; mpImemDrv=IMemDrv::createInstance(); mpImemDrv->init(); IspDrv* mpIspDrv=NULL; mpIspDrv=IspDrv::createInstance(); mpIspDrv->init(LOG_TAG); // //data QParams enqueParams; enqueParams.mvPrivaData.push_back(NULL); enqueParams.mvMagicNo.push_back(0); //input image IMEM_BUF_INFO imgiBuf; MINT32 bufBoundaryInBytes[3] = {0, 0, 0}; IImageBuffer* srcBuffer; MUINT32 bufStridesInBytes[3] = {10560, 0, 0}; imgiBuf.size=sizeof(g_imgi_5280x960_yuy2); mpImemDrv->allocVirtBuf(&imgiBuf); memcpy( (MUINT8*)(imgiBuf.virtAddr), (MUINT8*)(g_imgi_5280x960_yuy2), imgiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 portBufInfo = PortBufInfo_v1( imgiBuf.memID,imgiBuf.virtAddr,0,imgiBuf.bufSecu, imgiBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_YUY2),MSize(5280, 960), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,true); srcBuffer = pHeap->createImageBuffer(); srcBuffer->incStrong(srcBuffer); srcBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input src; src.mPortID=IMGI; src.mBuffer=srcBuffer; enqueParams.mvIn.push_back(src); IMEM_BUF_INFO vipiBuf; IImageBuffer* vipi_srcBuffer; vipiBuf.size=sizeof(g_vipi_5280x960_yuy2); mpImemDrv->allocVirtBuf(&vipiBuf); memcpy( (MUINT8*)(vipiBuf.virtAddr), (MUINT8*)(g_vipi_5280x960_yuy2), vipiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 vipi_portBufInfo = PortBufInfo_v1( vipiBuf.memID,vipiBuf.virtAddr,0,vipiBuf.bufSecu, vipiBuf.bufCohe); IImageBufferAllocator::ImgParam vipi_imgParam = IImageBufferAllocator::ImgParam((eImgFmt_YUY2),MSize(5280, 960), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> vipi_pHeap = ImageBufferHeap::create( LOG_TAG, vipi_imgParam,vipi_portBufInfo,true); vipi_srcBuffer = vipi_pHeap->createImageBuffer(); vipi_srcBuffer->incStrong(vipi_srcBuffer); vipi_srcBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input vipi_src; vipi_src.mPortID=VIPI; vipi_src.mBuffer=vipi_srcBuffer; enqueParams.mvIn.push_back(vipi_src); //alpha maps IMEM_BUF_INFO vip3iBuf; IImageBuffer* vip3i_alpha1Buffer; MUINT32 vip3i_alphabufStridesInBytes[3] = {5280, 0, 0}; vip3iBuf.size=sizeof(g_vip3i_5280x960_b8); mpImemDrv->allocVirtBuf(&vip3iBuf); memcpy( (MUINT8*)(vip3iBuf.virtAddr), (MUINT8*)(g_vip3i_5280x960_b8), vip3iBuf.size); //imem buffer 2 image heap PortBufInfo_v1 vip3i_alpha1_portBufInfo = PortBufInfo_v1( vip3iBuf.memID,vip3iBuf.virtAddr,0,vip3iBuf.bufSecu, vip3iBuf.bufCohe); IImageBufferAllocator::ImgParam vip3i_alpha1_imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER8),MSize(5280, 960), vip3i_alphabufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> vip3i_alpha1_pHeap = ImageBufferHeap::create( LOG_TAG, vip3i_alpha1_imgParam,vip3i_alpha1_portBufInfo,true); vip3i_alpha1Buffer = vip3i_alpha1_pHeap->createImageBuffer(); vip3i_alpha1Buffer->incStrong(vip3i_alpha1Buffer); vip3i_alpha1Buffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input vip3i_alpha1; vip3i_alpha1.mPortID=VIP3I; vip3i_alpha1.mBuffer=vip3i_alpha1Buffer; enqueParams.mvIn.push_back(vip3i_alpha1); IMEM_BUF_INFO ufdiBuf; IImageBuffer* ufdi_alpha1Buffer; ufdiBuf.size=sizeof(g_ufdi_5280x960_b8); mpImemDrv->allocVirtBuf(&ufdiBuf); memcpy( (MUINT8*)(ufdiBuf.virtAddr), (MUINT8*)(g_ufdi_5280x960_b8), ufdiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 ufdi_alpha1_portBufInfo = PortBufInfo_v1( ufdiBuf.memID,ufdiBuf.virtAddr,0,ufdiBuf.bufSecu, ufdiBuf.bufCohe); IImageBufferAllocator::ImgParam ufdi_alpha1_imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER8),MSize(5280, 960), vip3i_alphabufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> ufdi_alpha1_pHeap = ImageBufferHeap::create( LOG_TAG, ufdi_alpha1_imgParam,ufdi_alpha1_portBufInfo,true); ufdi_alpha1Buffer = ufdi_alpha1_pHeap->createImageBuffer(); ufdi_alpha1Buffer->incStrong(ufdi_alpha1Buffer); ufdi_alpha1Buffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input ufdi_alpha1; ufdi_alpha1.mPortID=UFDI; ufdi_alpha1.mBuffer=ufdi_alpha1Buffer; enqueParams.mvIn.push_back(ufdi_alpha1); //crop information MCrpRsInfo crop; crop.mGroupID=1; MCrpRsInfo crop2; crop2.mGroupID=2; MCrpRsInfo crop3; crop3.mGroupID=3; //output buffer for(int i=0;i<5;i++) { //clear enqueParams.mvOut.clear(); enqueParams.mvCropRsInfo.clear(); //crop crop.mCropRect.p_fractional.x=0; crop.mCropRect.p_fractional.y=0; crop.mCropRect.p_integral.x=0; crop.mCropRect.p_integral.y=0; crop.mCropRect.s.w=5280; crop.mCropRect.s.h=960; crop.mResizeDst.w=5280; crop.mResizeDst.h=960; int wdma_out_w=0,wdma_out_h=0; int wrot_out_w=0,wrot_out_h=0; //different crop/same dst size if(i%2==0) { crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=5280; crop2.mCropRect.s.h=960; crop2.mResizeDst.w=1280; crop2.mResizeDst.h=720; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=280; crop3.mCropRect.p_integral.y=160; crop3.mCropRect.s.w=5000; crop3.mCropRect.s.h=800; crop3.mResizeDst.w=1920; crop3.mResizeDst.h=1080; wdma_out_w=1280; wdma_out_h=720; wrot_out_w=1920; wrot_out_h=1080; } else { crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=5000; crop2.mCropRect.s.h=800; crop2.mResizeDst.w=1280; crop2.mResizeDst.h=720; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=280; crop3.mCropRect.p_integral.y=160; crop3.mCropRect.s.w=5000; crop3.mCropRect.s.h=800; crop3.mResizeDst.w=960; crop3.mResizeDst.h=640; wdma_out_w=1280; wdma_out_h=720; wrot_out_w=960; wrot_out_h=640; } enqueParams.mvCropRsInfo.push_back(crop); enqueParams.mvCropRsInfo.push_back(crop2); enqueParams.mvCropRsInfo.push_back(crop3); //full size img3o IMEM_BUF_INFO img3oBuf; img3oBuf.size=5280*960*2; mpImemDrv->allocVirtBuf(&img3oBuf); memset((MUINT8*)img3oBuf.virtAddr, 0xffffffff, img3oBuf.size); MUINT32 bufStridesInBytes_1[3] = {5280,2640,2640}; PortBufInfo_v1 portBufInfo_1 = PortBufInfo_v1( img3oBuf.memID,img3oBuf.virtAddr,0,img3oBuf.bufSecu, img3oBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_1 = IImageBufferAllocator::ImgParam((eImgFmt_YV12), MSize(5280,960), bufStridesInBytes_1, bufBoundaryInBytes, 3); sp<ImageBufferHeap> pHeap_1 = ImageBufferHeap::create( LOG_TAG, imgParam_1,portBufInfo_1,true); IImageBuffer* outBuffer = pHeap_1->createImageBuffer(); outBuffer->incStrong(outBuffer); outBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst; dst.mPortID=IMG3O; dst.mBuffer=outBuffer; dst.mPortID.group=0; enqueParams.mvOut.push_back(dst); // IMEM_BUF_INFO wdmaoBuf; IMEM_BUF_INFO wrotoBuf; wdmaoBuf.size=wdma_out_w*wdma_out_h*2; mpImemDrv->allocVirtBuf(&wdmaoBuf); memset((MUINT8*)wdmaoBuf.virtAddr, 0xffffffff, wdmaoBuf.size); MUINT32 bufStridesInBytes_3[3] = {wdma_out_w, wdma_out_w/2, wdma_out_w/2}; PortBufInfo_v1 portBufInfo_3 = PortBufInfo_v1( wdmaoBuf.memID,wdmaoBuf.virtAddr,0,wdmaoBuf.bufSecu, wdmaoBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_3 = IImageBufferAllocator::ImgParam((eImgFmt_YV12), MSize(wdma_out_w, wdma_out_h), bufStridesInBytes_3, bufBoundaryInBytes, 3); sp<ImageBufferHeap> pHeap_3 = ImageBufferHeap::create( LOG_TAG, imgParam_3,portBufInfo_3,true); IImageBuffer* outBuffer2 = pHeap_3->createImageBuffer(); outBuffer2->incStrong(outBuffer2); outBuffer2->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst2; dst2.mPortID=WDMAO; dst2.mBuffer=outBuffer2; dst2.mPortID.group=0; enqueParams.mvOut.push_back(dst2); // wrotoBuf.size=wrot_out_w*wrot_out_h*2; mpImemDrv->allocVirtBuf(&wrotoBuf); memset((MUINT8*)wrotoBuf.virtAddr, 0xffffffff, wrotoBuf.size); MUINT32 bufStridesInBytes_4[3] = {wrot_out_w*2,0,0}; PortBufInfo_v1 portBufInfo_4 = PortBufInfo_v1( wrotoBuf.memID,wrotoBuf.virtAddr,0,wrotoBuf.bufSecu, wrotoBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_4 = IImageBufferAllocator::ImgParam((eImgFmt_YUY2), MSize(wrot_out_w, wrot_out_h), bufStridesInBytes_4, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap_4 = ImageBufferHeap::create( LOG_TAG, imgParam_4,portBufInfo_4,true); IImageBuffer* outBuffer3 = pHeap_4->createImageBuffer(); outBuffer3->incStrong(outBuffer3); outBuffer3->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst3; dst3.mPortID=WROTO; dst3.mBuffer=outBuffer3; dst3.mPortID.group=0; enqueParams.mvOut.push_back(dst3); //buffer operation mpImemDrv->cacheFlushAll(); printf("(%d) : enque\n",i); ret=pMFBMixStream->enque(enqueParams); if(!ret) { printf("(%d) : ERR enque fail\n",i); } else { printf("(%d) : enque done\n",i); } QParams dequeParams; ret=pMFBMixStream->deque(dequeParams); if(!ret) { printf("(%d) : ERR deque fail\n",i); } else { printf("(%d) : deque done\n",i); } printf("(%d) : (CAM_CTL_TILE 0x%x) \n",i,ISP_READ_REG_NOPROTECT(mpIspDrv,CAM_CTL_TILE)); //dump image char filename[256]; sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case2_%d_img3o_%dx%d.yuv",i, 5280,960); saveBufToFile(filename, reinterpret_cast<MUINT8*>(dequeParams.mvOut[0].mBuffer->getBufVA(0)), 5280 *960 * 2); sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case2_%d_wdmao_%dx%d.yuv",i, wdma_out_w,wdma_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(dequeParams.mvOut[1].mBuffer->getBufVA(0)), wdma_out_w *wdma_out_h * 2); sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case2_%d_wroto_%dx%d.yuv",i, wrot_out_w,wrot_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(dequeParams.mvOut[2].mBuffer->getBufVA(0)), wrot_out_w *wrot_out_h * 2); printf("(%d) : --- p2a done ---\n", i); //unmap and free buffer outBuffer->unlockBuf(LOG_TAG); outBuffer2->unlockBuf(LOG_TAG); outBuffer3->unlockBuf(LOG_TAG); mpImemDrv->freeVirtBuf(&img3oBuf); mpImemDrv->freeVirtBuf(&wdmaoBuf); mpImemDrv->freeVirtBuf(&wrotoBuf); } // pMFBMixStream->uninit(); pMFBMixStream->destroyInstance(LOG_TAG); mpImemDrv->uninit(); mpImemDrv->destroyInstance(); mpIspDrv->uninit(LOG_TAG); mpIspDrv->destroyInstance(); return ret; }
int case1() { int ret=0; MBOOL isV3 = MFALSE; //temp disable tuning path cuz tuning function not ready NSCam::NSIoPipe::NSPostProc::IFeatureStream* pP2AStream; pP2AStream= NSCam::NSIoPipe::NSPostProc::IFeatureStream::createInstance(LOG_TAG, NSCam::NSIoPipe::NSPostProc::EFeatureStreamTag_vFB_Stream,0xFFFF, isV3); pP2AStream->init(); NSCam::NSIoPipe::NSPostProc::IFeatureStream* pP2BStream; pP2BStream= NSCam::NSIoPipe::NSPostProc::IFeatureStream::createInstance(LOG_TAG, NSCam::NSIoPipe::NSPostProc::EFeatureStreamTag_vFB_FB,0xFFFF, isV3); pP2BStream->init(); IMemDrv* mpImemDrv=NULL; mpImemDrv=IMemDrv::createInstance(); mpImemDrv->init(); IspDrv* mpIspDrv=NULL; mpIspDrv=IspDrv::createInstance(); mpIspDrv->init(LOG_TAG); // //p2a data QParams p2aenqueParams; p2aenqueParams.mvPrivaData.push_back(NULL); p2aenqueParams.mvMagicNo.push_back(0); //input image IMEM_BUF_INFO imgiBuf; MINT32 bufBoundaryInBytes[3] = {0, 0, 0}; IImageBuffer* srcBuffer; MUINT32 bufStridesInBytes[3] = {3200, 0, 0}; imgiBuf.size=sizeof(g_imgi_array_2560x1440_b10); mpImemDrv->allocVirtBuf(&imgiBuf); memcpy( (MUINT8*)(imgiBuf.virtAddr), (MUINT8*)(g_imgi_array_2560x1440_b10), imgiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 portBufInfo = PortBufInfo_v1( imgiBuf.memID,imgiBuf.virtAddr,0,imgiBuf.bufSecu, imgiBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER10),MSize(2560, 1440), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,true); srcBuffer = pHeap->createImageBuffer(); srcBuffer->incStrong(srcBuffer); srcBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input src; src.mPortID=IMGI; src.mBuffer=srcBuffer; p2aenqueParams.mvIn.push_back(src); //crop information MCrpRsInfo crop; crop.mGroupID=1; MCrpRsInfo crop2; crop2.mGroupID=2; MCrpRsInfo crop3; crop3.mGroupID=3; //p2b data QParams p2benqueParams; p2benqueParams.mvPrivaData.push_back(NULL); p2benqueParams.mvMagicNo.push_back(0); //input image IMEM_BUF_INFO p2b_imgiBuf; IImageBuffer* p2b_srcBuffer; MUINT32 p2b_bufStridesInBytes[3] = {640, 0, 0}; p2b_imgiBuf.size=sizeof(g_imgi_320x240_yuyv); mpImemDrv->allocVirtBuf(&p2b_imgiBuf); memcpy( (MUINT8*)(p2b_imgiBuf.virtAddr), (MUINT8*)(g_imgi_320x240_yuyv), p2b_imgiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 p2b_portBufInfo = PortBufInfo_v1( p2b_imgiBuf.memID,p2b_imgiBuf.virtAddr,0,p2b_imgiBuf.bufSecu, p2b_imgiBuf.bufCohe); IImageBufferAllocator::ImgParam p2b_imgParam = IImageBufferAllocator::ImgParam((eImgFmt_YUY2),MSize(320, 240), p2b_bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> p2b_pHeap = ImageBufferHeap::create( LOG_TAG, p2b_imgParam,p2b_portBufInfo,true); p2b_srcBuffer = p2b_pHeap->createImageBuffer(); p2b_srcBuffer->incStrong(p2b_srcBuffer); p2b_srcBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input p2b_src; p2b_src.mPortID=IMGI; p2b_src.mBuffer=p2b_srcBuffer; p2benqueParams.mvIn.push_back(p2b_src); //alpha maps IMEM_BUF_INFO p2b_ufdiBuf; IImageBuffer* p2b_alpha1Buffer; MUINT32 p2b_alphabufStridesInBytes[3] = {320, 0, 0}; p2b_ufdiBuf.size=sizeof(g_alpha1_320x240_b8); mpImemDrv->allocVirtBuf(&p2b_ufdiBuf); memcpy( (MUINT8*)(p2b_ufdiBuf.virtAddr), (MUINT8*)(g_alpha1_320x240_b8), p2b_ufdiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 p2b_alpha1_portBufInfo = PortBufInfo_v1( p2b_ufdiBuf.memID,p2b_ufdiBuf.virtAddr,0,p2b_ufdiBuf.bufSecu, p2b_ufdiBuf.bufCohe); IImageBufferAllocator::ImgParam p2b_alpha1_imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER8),MSize(320, 240), p2b_alphabufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> p2b_alpha1_pHeap = ImageBufferHeap::create( LOG_TAG, p2b_alpha1_imgParam,p2b_alpha1_portBufInfo,true); p2b_alpha1Buffer = p2b_alpha1_pHeap->createImageBuffer(); p2b_alpha1Buffer->incStrong(p2b_alpha1Buffer); p2b_alpha1Buffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input p2b_alpha1; p2b_alpha1.mPortID=UFDI; p2b_alpha1.mBuffer=p2b_alpha1Buffer; p2benqueParams.mvIn.push_back(p2b_alpha1); // //alpha maps IMEM_BUF_INFO p2b_lceiBuf; IImageBuffer* p2b_alpha2Buffer; p2b_lceiBuf.size=sizeof(g_alpha2_320x240_b8); mpImemDrv->allocVirtBuf(&p2b_lceiBuf); memcpy( (MUINT8*)(p2b_lceiBuf.virtAddr), (MUINT8*)(g_alpha2_320x240_b8), p2b_lceiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 p2b_alpha2_portBufInfo = PortBufInfo_v1( p2b_lceiBuf.memID,p2b_lceiBuf.virtAddr,0,p2b_lceiBuf.bufSecu, p2b_lceiBuf.bufCohe); IImageBufferAllocator::ImgParam p2b_alpha2_imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER8),MSize(320, 240), p2b_alphabufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> p2b_alpha2_pHeap = ImageBufferHeap::create( LOG_TAG, p2b_alpha2_imgParam,p2b_alpha2_portBufInfo,true); p2b_alpha2Buffer = p2b_alpha2_pHeap->createImageBuffer(); p2b_alpha2Buffer->incStrong(p2b_alpha2Buffer); p2b_alpha2Buffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input p2b_alpha2; p2b_alpha2.mPortID=LCEI; p2b_alpha2.mBuffer=p2b_alpha2Buffer; p2benqueParams.mvIn.push_back(p2b_alpha2); //crop information MCrpRsInfo p2b_crop; p2b_crop.mGroupID=1; MCrpRsInfo p2b_crop2; p2b_crop2.mGroupID=2; MCrpRsInfo p2b_crop3; p2b_crop3.mGroupID=3; //output buffer for(int i=0;i<5;i++) { //clear p2aenqueParams.mvOut.clear(); p2aenqueParams.mvCropRsInfo.clear(); //////////////////////////////////////////////////////// //p2a //////////////////////////////////////////////////////// //crop crop.mCropRect.p_fractional.x=0; crop.mCropRect.p_fractional.y=0; crop.mCropRect.p_integral.x=0; crop.mCropRect.p_integral.y=0; crop.mCropRect.s.w=2560; crop.mCropRect.s.h=1440; crop.mResizeDst.w=1920; crop.mResizeDst.h=1080; int wdma_out_w=0,wdma_out_h=0; int wrot_out_w=0,wrot_out_h=0; //different crop/same dst size if(i%2==0) { crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=1800; crop2.mCropRect.s.h=800; crop2.mResizeDst.w=1280; crop2.mResizeDst.h=720; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=120; crop3.mCropRect.p_integral.y=280; crop3.mCropRect.s.w=1800; crop3.mCropRect.s.h=800; crop3.mResizeDst.w=1920; crop3.mResizeDst.h=1080; } else { crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=120; crop2.mCropRect.p_integral.y=280; crop2.mCropRect.s.w=1800; crop2.mCropRect.s.h=800; crop2.mResizeDst.w=1280; crop2.mResizeDst.h=720; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=0; crop3.mCropRect.p_integral.y=0; crop3.mCropRect.s.w=1800; crop3.mCropRect.s.h=800; crop3.mResizeDst.w=1920; crop3.mResizeDst.h=1080; } wdma_out_w=1280; wdma_out_h=720; wrot_out_w=1920; wrot_out_h=1080; p2aenqueParams.mvCropRsInfo.push_back(crop); p2aenqueParams.mvCropRsInfo.push_back(crop2); p2aenqueParams.mvCropRsInfo.push_back(crop3); //full size img3o IMEM_BUF_INFO img3oBuf; img3oBuf.size=1920*1080*2; mpImemDrv->allocVirtBuf(&img3oBuf); memset((MUINT8*)img3oBuf.virtAddr, 0xffffffff, img3oBuf.size); MUINT32 bufStridesInBytes_1[3] = {1920,960,960}; PortBufInfo_v1 portBufInfo_1 = PortBufInfo_v1( img3oBuf.memID,img3oBuf.virtAddr,0,img3oBuf.bufSecu, img3oBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_1 = IImageBufferAllocator::ImgParam((eImgFmt_YV12), MSize(1920,1080), bufStridesInBytes_1, bufBoundaryInBytes, 3); sp<ImageBufferHeap> pHeap_1 = ImageBufferHeap::create( LOG_TAG, imgParam_1,portBufInfo_1,true); IImageBuffer* outBuffer = pHeap_1->createImageBuffer(); outBuffer->incStrong(outBuffer); outBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst; dst.mPortID=IMG3O; dst.mBuffer=outBuffer; dst.mPortID.group=0; p2aenqueParams.mvOut.push_back(dst); // IMEM_BUF_INFO wdmaoBuf; IMEM_BUF_INFO wrotoBuf; wdmaoBuf.size=wdma_out_w*wdma_out_h*2; mpImemDrv->allocVirtBuf(&wdmaoBuf); memset((MUINT8*)wdmaoBuf.virtAddr, 0xffffffff, wdmaoBuf.size); MUINT32 bufStridesInBytes_3[3] = {wdma_out_w, wdma_out_w/2, wdma_out_w/2}; PortBufInfo_v1 portBufInfo_3 = PortBufInfo_v1( wdmaoBuf.memID,wdmaoBuf.virtAddr,0,wdmaoBuf.bufSecu, wdmaoBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_3 = IImageBufferAllocator::ImgParam((eImgFmt_YV12), MSize(wdma_out_w, wdma_out_h), bufStridesInBytes_3, bufBoundaryInBytes, 3); sp<ImageBufferHeap> pHeap_3 = ImageBufferHeap::create( LOG_TAG, imgParam_3,portBufInfo_3,true); IImageBuffer* outBuffer2 = pHeap_3->createImageBuffer(); outBuffer2->incStrong(outBuffer2); outBuffer2->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst2; dst2.mPortID=WDMAO; dst2.mBuffer=outBuffer2; dst2.mPortID.group=0; p2aenqueParams.mvOut.push_back(dst2); // wrotoBuf.size=wrot_out_w*wrot_out_h*2; mpImemDrv->allocVirtBuf(&wrotoBuf); memset((MUINT8*)wrotoBuf.virtAddr, 0xffffffff, wrotoBuf.size); MUINT32 bufStridesInBytes_4[3] = {wrot_out_w*2,0,0}; PortBufInfo_v1 portBufInfo_4 = PortBufInfo_v1( wrotoBuf.memID,wrotoBuf.virtAddr,0,wrotoBuf.bufSecu, wrotoBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_4 = IImageBufferAllocator::ImgParam((eImgFmt_YUY2), MSize(wrot_out_w, wrot_out_h), bufStridesInBytes_4, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap_4 = ImageBufferHeap::create( LOG_TAG, imgParam_4,portBufInfo_4,true); IImageBuffer* outBuffer3 = pHeap_4->createImageBuffer(); outBuffer3->incStrong(outBuffer3); outBuffer3->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst3; dst3.mPortID=WROTO; dst3.mBuffer=outBuffer3; dst3.mPortID.group=0; p2aenqueParams.mvOut.push_back(dst3); //buffer operation mpImemDrv->cacheFlushAll(); printf("(%d) : p2a enque\n",i); ret=pP2AStream->enque(p2aenqueParams); if(!ret) { printf("(%d) : p2a ERR enque fail\n",i); } else { printf("(%d) : p2a enque done\n",i); } QParams p2adequeParams; ret=pP2AStream->deque(p2adequeParams); if(!ret) { printf("(%d) : p2a ERR deque fail\n",i); } else { printf("(%d) : p2a deque done\n",i); } printf("(%d) : (CAM_CTL_TILE 0x%x) \n",i,ISP_READ_REG_NOPROTECT(mpIspDrv,CAM_CTL_TILE)); //dump image char filename[256]; sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case1_p2a_%d_img3o_%dx%d.yuv",i, 1920,1080); saveBufToFile(filename, reinterpret_cast<MUINT8*>(p2adequeParams.mvOut[0].mBuffer->getBufVA(0)), 1920 *1080 * 2); sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case1_p2a_%d_wdmao_%dx%d.yuv",i, wdma_out_w,wdma_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(p2adequeParams.mvOut[1].mBuffer->getBufVA(0)), wdma_out_w *wdma_out_h * 2); sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case1_p2a_%d_wroto_%dx%d.yuv",i, wrot_out_w,wrot_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(p2adequeParams.mvOut[2].mBuffer->getBufVA(0)), wrot_out_w *wrot_out_h * 2); printf("(%d) : --- p2a done ---\n", i); //////////////////////////////////////////////////////// //p2b //vipi: 1920x1080 //imgi: 320x240, ufdi: 320x240, lcei: 320x240 //////////////////////////////////////////////////////// //clear p2benqueParams.mvOut.clear(); p2benqueParams.mvCropRsInfo.clear(); //img3o from p2a as vipi for p2b Input vipisrc; vipisrc.mPortID=VIPI; vipisrc.mBuffer=p2adequeParams.mvOut[0].mBuffer; vipisrc.mPortID.group=0; p2benqueParams.mvIn.push_back(vipisrc); //crop p2b_crop.mCropRect.p_fractional.x=0; p2b_crop.mCropRect.p_fractional.y=0; p2b_crop.mCropRect.p_integral.x=0; p2b_crop.mCropRect.p_integral.y=0; p2b_crop.mCropRect.s.w=320; p2b_crop.mCropRect.s.h=240; p2b_crop.mResizeDst.w=1920; p2b_crop.mResizeDst.h=1080; wdma_out_w=0; wdma_out_h=0; wrot_out_w=0; wrot_out_h=0; if(i%2==0) { //different crop/same dst size p2b_crop2.mCropRect.p_fractional.x=0; p2b_crop2.mCropRect.p_fractional.y=0; p2b_crop2.mCropRect.p_integral.x=0; p2b_crop2.mCropRect.p_integral.y=0; p2b_crop2.mCropRect.s.w=1800; p2b_crop2.mCropRect.s.h=800; p2b_crop2.mResizeDst.w=1280; p2b_crop2.mResizeDst.h=720; p2b_crop3.mCropRect.p_fractional.x=0; p2b_crop3.mCropRect.p_fractional.y=0; p2b_crop3.mCropRect.p_integral.x=120; p2b_crop3.mCropRect.p_integral.y=280; p2b_crop3.mCropRect.s.w=1800; p2b_crop3.mCropRect.s.h=800; p2b_crop3.mResizeDst.w=1920; p2b_crop3.mResizeDst.h=1080; wdma_out_w=1280; wdma_out_h=720; wrot_out_w=1920; wrot_out_h=1080; } else { //different crop/same dst size p2b_crop2.mCropRect.p_fractional.x=0; p2b_crop2.mCropRect.p_fractional.y=0; p2b_crop2.mCropRect.p_integral.x=120; p2b_crop2.mCropRect.p_integral.y=280; p2b_crop2.mCropRect.s.w=1800; p2b_crop2.mCropRect.s.h=800; p2b_crop2.mResizeDst.w=1280; p2b_crop2.mResizeDst.h=720; p2b_crop3.mCropRect.p_fractional.x=0; p2b_crop3.mCropRect.p_fractional.y=0; p2b_crop3.mCropRect.p_integral.x=0; p2b_crop3.mCropRect.p_integral.y=0; p2b_crop3.mCropRect.s.w=1800; p2b_crop3.mCropRect.s.h=800; p2b_crop3.mResizeDst.w=960; p2b_crop3.mResizeDst.h=640; wdma_out_w=1280; wdma_out_h=720; wrot_out_w=960; wrot_out_h=640; } p2benqueParams.mvCropRsInfo.push_back(p2b_crop); p2benqueParams.mvCropRsInfo.push_back(p2b_crop2); p2benqueParams.mvCropRsInfo.push_back(p2b_crop3); //output IMEM_BUF_INFO p2b_wdmaoBuf; IMEM_BUF_INFO p2b_wrotoBuf; p2b_wdmaoBuf.size=wdma_out_w*wdma_out_h*2; mpImemDrv->allocVirtBuf(&p2b_wdmaoBuf); memset((MUINT8*)p2b_wdmaoBuf.virtAddr, 0xffffffff, p2b_wdmaoBuf.size); MUINT32 p2b_bufStridesInBytes_3[3] = {wdma_out_w, wdma_out_w/2, wdma_out_w/2}; PortBufInfo_v1 p2b_portBufInfo_3 = PortBufInfo_v1( p2b_wdmaoBuf.memID,p2b_wdmaoBuf.virtAddr,0,p2b_wdmaoBuf.bufSecu, p2b_wdmaoBuf.bufCohe); IImageBufferAllocator::ImgParam p2b_imgParam_3 = IImageBufferAllocator::ImgParam((eImgFmt_YV12), MSize(wdma_out_w, wdma_out_h), p2b_bufStridesInBytes_3, bufBoundaryInBytes, 3); sp<ImageBufferHeap> p2b_pHeap_3 = ImageBufferHeap::create( LOG_TAG, p2b_imgParam_3,p2b_portBufInfo_3,true); IImageBuffer* p2b_outBuffer2 = p2b_pHeap_3->createImageBuffer(); p2b_outBuffer2->incStrong(p2b_outBuffer2); p2b_outBuffer2->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output p2b_dst; p2b_dst.mPortID=WDMAO; p2b_dst.mBuffer=p2b_outBuffer2; p2b_dst.mPortID.group=0; p2benqueParams.mvOut.push_back(p2b_dst); // p2b_wrotoBuf.size=wrot_out_w*wrot_out_h*2; mpImemDrv->allocVirtBuf(&p2b_wrotoBuf); memset((MUINT8*)p2b_wrotoBuf.virtAddr, 0xffffffff, p2b_wrotoBuf.size); MUINT32 p2b_bufStridesInBytes_4[3] = {wrot_out_w*2,0,0}; PortBufInfo_v1 p2b_portBufInfo_4 = PortBufInfo_v1( p2b_wrotoBuf.memID,p2b_wrotoBuf.virtAddr,0,p2b_wrotoBuf.bufSecu, p2b_wrotoBuf.bufCohe); IImageBufferAllocator::ImgParam p2b_imgParam_4 = IImageBufferAllocator::ImgParam((eImgFmt_YUY2), MSize(wrot_out_w, wrot_out_h), p2b_bufStridesInBytes_4, bufBoundaryInBytes, 1); sp<ImageBufferHeap> p2b_pHeap_4 = ImageBufferHeap::create( LOG_TAG, p2b_imgParam_4,p2b_portBufInfo_4,true); IImageBuffer* p2b_outBuffer3 = p2b_pHeap_4->createImageBuffer(); p2b_outBuffer3->incStrong(p2b_outBuffer3); p2b_outBuffer3->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output p2b_dst2; p2b_dst2.mPortID=WROTO; p2b_dst2.mBuffer=p2b_outBuffer3; p2b_dst2.mPortID.group=0; p2benqueParams.mvOut.push_back(p2b_dst2); //buffer operation mpImemDrv->cacheFlushAll(); printf("(%d) : p2b enque\n",i); ret=pP2BStream->enque(p2benqueParams); if(!ret) { printf("(%d) : p2b ERR enque fail\n",i); } else { printf("(%d) : p2b enque done\n",i); } QParams p2bdequeParams; ret=pP2BStream->deque(p2bdequeParams); if(!ret) { printf("(%d) : p2b ERR deque fail\n",i); } else { printf("(%d) : p2b deque done\n",i); } printf("(%d) : (CAM_CTL_TILE 0x%x) \n",i,ISP_READ_REG_NOPROTECT(mpIspDrv,CAM_CTL_TILE)); //dump image sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case1_p2b_%d_wdmao_%dx%d.yuv",i, wdma_out_w,wdma_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(p2bdequeParams.mvOut[0].mBuffer->getBufVA(0)), wdma_out_w *wdma_out_h * 2); sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case1_p2b_%d_wroto_%dx%d.yuv",i, wrot_out_w,wrot_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(p2bdequeParams.mvOut[1].mBuffer->getBufVA(0)), wrot_out_w *wrot_out_h * 2); printf("(%d) : --- p2b done ---\n", i); //unmap and free buffer //p2a outBuffer->unlockBuf(LOG_TAG); outBuffer2->unlockBuf(LOG_TAG); outBuffer3->unlockBuf(LOG_TAG); mpImemDrv->freeVirtBuf(&img3oBuf); mpImemDrv->freeVirtBuf(&wdmaoBuf); mpImemDrv->freeVirtBuf(&wrotoBuf); //p2b p2b_outBuffer2->unlockBuf(LOG_TAG); p2b_outBuffer3->unlockBuf(LOG_TAG); mpImemDrv->freeVirtBuf(&p2b_wdmaoBuf); mpImemDrv->freeVirtBuf(&p2b_wrotoBuf); } // pP2AStream->uninit(); pP2AStream->destroyInstance(LOG_TAG); pP2BStream->uninit(); pP2BStream->destroyInstance(LOG_TAG); mpImemDrv->uninit(); mpImemDrv->destroyInstance(); mpIspDrv->uninit(LOG_TAG); mpIspDrv->destroyInstance(); return ret; }
int case0(int type) { int ret=0; MBOOL isV3 = MFALSE; //temp disable tuning path cuz tuning function not ready NSCam::NSIoPipe::NSPostProc::INormalStream* pCCStream; pCCStream= NSCam::NSIoPipe::NSPostProc::INormalStream::createInstance(LOG_TAG, NSCam::NSIoPipe::NSPostProc::ENormalStreamTag_Prv,0xFFFF, isV3); pCCStream->init(); IMemDrv* mpImemDrv=NULL; mpImemDrv=IMemDrv::createInstance(); mpImemDrv->init(); IspDrv* mpIspDrv=NULL; mpIspDrv=IspDrv::createInstance(); mpIspDrv->init(LOG_TAG); // QParams enqueParams; enqueParams.mvPrivaData.push_back(NULL); enqueParams.mvMagicNo.push_back(0); //input image IMEM_BUF_INFO imgiBuf; MINT32 bufBoundaryInBytes[3] = {0, 0, 0}; IImageBuffer* srcBuffer; MUINT32 bufStridesInBytes[3] = {1600, 0, 0}; imgiBuf.size=sizeof(g_imgi_array_1280x720_b10); mpImemDrv->allocVirtBuf(&imgiBuf); memcpy( (MUINT8*)(imgiBuf.virtAddr), (MUINT8*)(g_imgi_array_1280x720_b10), imgiBuf.size); //imem buffer 2 image heap PortBufInfo_v1 portBufInfo = PortBufInfo_v1( imgiBuf.memID,imgiBuf.virtAddr,0,imgiBuf.bufSecu, imgiBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER10),MSize(1280, 720), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,true); srcBuffer = pHeap->createImageBuffer(); srcBuffer->incStrong(srcBuffer); srcBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Input src; src.mPortID=IMGI; src.mBuffer=srcBuffer; enqueParams.mvIn.push_back(src); //crop information MCrpRsInfo crop; crop.mGroupID=1; MCrpRsInfo crop2; crop2.mGroupID=2; MCrpRsInfo crop3; crop3.mGroupID=3; IImageBuffer* outBuffer=NULL; for(int i=0;i<5;i++) { enqueParams.mvOut.clear(); enqueParams.mvCropRsInfo.clear(); crop.mCropRect.p_fractional.x=0; crop.mCropRect.p_fractional.y=0; crop.mCropRect.p_integral.x=0; crop.mCropRect.p_integral.y=0; crop.mCropRect.s.w=1280; crop.mCropRect.s.h=720; crop.mResizeDst.w=1280; crop.mResizeDst.h=720; int wdma_out_w=0,wdma_out_h=0; int wrot_out_w=0,wrot_out_h=0; switch(type) { case 0: default: //same crop for mdp 2 output crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=1280; crop2.mCropRect.s.h=720; crop2.mResizeDst.w=1280; crop2.mResizeDst.h=720; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=0; crop3.mCropRect.p_integral.y=0; crop3.mCropRect.s.w=1280; crop3.mCropRect.s.h=720; crop3.mResizeDst.w=1280; crop3.mResizeDst.h=720; wdma_out_w=1280; wdma_out_h=720; wrot_out_w=1280; wrot_out_h=720; break; case 1: //different crop/same dst size crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=1000; crop2.mCropRect.s.h=600; crop2.mResizeDst.w=1280; crop2.mResizeDst.h=720; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=280; crop3.mCropRect.p_integral.y=120; crop3.mCropRect.s.w=1000; crop3.mCropRect.s.h=600; crop3.mResizeDst.w=1280; crop3.mResizeDst.h=720; wdma_out_w=1280; wdma_out_h=720; wrot_out_w=1280; wrot_out_h=720; break; case 2: //different crop/different dst size (wroto rotate) crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=700; crop2.mCropRect.s.h=400; crop2.mResizeDst.w=640; crop2.mResizeDst.h=480; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=280; crop3.mCropRect.p_integral.y=120; crop3.mCropRect.s.w=1000; crop3.mCropRect.s.h=600; crop3.mResizeDst.w=960; crop3.mResizeDst.h=640; wdma_out_w=640; wdma_out_h=480; wrot_out_w=640; wrot_out_h=960; break; case 3: if(i%2==0) { crop.mCropRect.p_fractional.x=0; crop.mCropRect.p_fractional.y=0; crop.mCropRect.p_integral.x=100; crop.mCropRect.p_integral.y=100; crop.mCropRect.s.w=700; crop.mCropRect.s.h=350; crop.mResizeDst.w=320; crop.mResizeDst.h=240; crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=0; crop2.mCropRect.p_integral.y=0; crop2.mCropRect.s.w=700; crop2.mCropRect.s.h=400; crop2.mResizeDst.w=640; crop2.mResizeDst.h=480; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=280; crop3.mCropRect.p_integral.y=120; crop3.mCropRect.s.w=1000; crop3.mCropRect.s.h=600; crop3.mResizeDst.w=960; crop3.mResizeDst.h=640; wdma_out_w=640; wdma_out_h=480; wrot_out_w=640; wrot_out_h=960; } else { crop.mCropRect.p_fractional.x=0; crop.mCropRect.p_fractional.y=0; crop.mCropRect.p_integral.x=300; crop.mCropRect.p_integral.y=200; crop.mCropRect.s.w=500; crop.mCropRect.s.h=250; crop.mResizeDst.w=320; crop.mResizeDst.h=240; crop2.mCropRect.p_fractional.x=0; crop2.mCropRect.p_fractional.y=0; crop2.mCropRect.p_integral.x=250; crop2.mCropRect.p_integral.y=200; crop2.mCropRect.s.w=700; crop2.mCropRect.s.h=400; crop2.mResizeDst.w=640; crop2.mResizeDst.h=480; crop3.mCropRect.p_fractional.x=0; crop3.mCropRect.p_fractional.y=0; crop3.mCropRect.p_integral.x=0; crop3.mCropRect.p_integral.y=0; crop3.mCropRect.s.w=1000; crop3.mCropRect.s.h=600; crop3.mResizeDst.w=960; crop3.mResizeDst.h=640; wdma_out_w=640; wdma_out_h=480; wrot_out_w=640; wrot_out_h=960; } break; } enqueParams.mvCropRsInfo.push_back(crop); enqueParams.mvCropRsInfo.push_back(crop2); enqueParams.mvCropRsInfo.push_back(crop3); //output buffer IMEM_BUF_INFO img2oBuf; if(type==3) { //simulate fd buffer from img2o img2oBuf.size=320*240*2; mpImemDrv->allocVirtBuf(&img2oBuf); memset((MUINT8*)img2oBuf.virtAddr, 0x0, img2oBuf.size); MUINT32 bufStridesInBytes_1[3] = {320*2,0,0}; PortBufInfo_v1 portBufInfo_1 = PortBufInfo_v1( img2oBuf.memID,img2oBuf.virtAddr,0,img2oBuf.bufSecu, img2oBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_1 = IImageBufferAllocator::ImgParam((eImgFmt_YUY2), MSize(320,240), bufStridesInBytes_1, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap_1 = ImageBufferHeap::create( LOG_TAG, imgParam_1,portBufInfo_1,true); outBuffer = pHeap_1->createImageBuffer(); outBuffer->incStrong(outBuffer); outBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst; dst.mPortID=IMG2O; dst.mBuffer=outBuffer; dst.mPortID.group=0; enqueParams.mvOut.push_back(dst); } IMEM_BUF_INFO wdmaoBuf; IMEM_BUF_INFO wrotoBuf; wdmaoBuf.size=wdma_out_w*wdma_out_h*2; mpImemDrv->allocVirtBuf(&wdmaoBuf); memset((MUINT8*)wdmaoBuf.virtAddr, 0x0, wdmaoBuf.size); MUINT32 bufStridesInBytes_3[3] = {wdma_out_w, wdma_out_w/2, wdma_out_w/2}; PortBufInfo_v1 portBufInfo_3 = PortBufInfo_v1( wdmaoBuf.memID,wdmaoBuf.virtAddr,0,wdmaoBuf.bufSecu, wdmaoBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_3 = IImageBufferAllocator::ImgParam((eImgFmt_YV12), MSize(wdma_out_w, wdma_out_h), bufStridesInBytes_3, bufBoundaryInBytes, 3); sp<ImageBufferHeap> pHeap_3 = ImageBufferHeap::create( LOG_TAG, imgParam_3,portBufInfo_3,true); IImageBuffer* outBuffer2 = pHeap_3->createImageBuffer(); outBuffer2->incStrong(outBuffer2); outBuffer2->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst2; dst2.mPortID=WDMAO; dst2.mBuffer=outBuffer2; dst2.mPortID.group=0; enqueParams.mvOut.push_back(dst2); // wrotoBuf.size=wrot_out_w*wrot_out_h*2; mpImemDrv->allocVirtBuf(&wrotoBuf); memset((MUINT8*)wrotoBuf.virtAddr, 0x0, wrotoBuf.size); MUINT32 bufStridesInBytes_4[3] = {wrot_out_w*2,0,0}; PortBufInfo_v1 portBufInfo_4 = PortBufInfo_v1( wrotoBuf.memID,wrotoBuf.virtAddr,0,wrotoBuf.bufSecu, wrotoBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam_4 = IImageBufferAllocator::ImgParam((eImgFmt_YUY2), MSize(wrot_out_w, wrot_out_h), bufStridesInBytes_4, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap_4 = ImageBufferHeap::create( LOG_TAG, imgParam_4,portBufInfo_4,true); IImageBuffer* outBuffer3 = pHeap_4->createImageBuffer(); outBuffer3->incStrong(outBuffer3); outBuffer3->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); Output dst3; dst3.mPortID=WROTO; dst3.mBuffer=outBuffer3; dst3.mPortID.group=0; if(type==2 || type==3) { dst3.mTransform=eTransform_ROT_90; } enqueParams.mvOut.push_back(dst3); //buffer operation mpImemDrv->cacheFlushAll(); printf(": enque\n"); ret=pCCStream->enque(enqueParams); if(!ret) { printf(" : ERR enque fail\n"); } else { printf(": enque done\n"); } QParams dequeParams; ret=pCCStream->deque(dequeParams); if(!ret) { printf(" : ERR deque fail\n"); } else { printf(": deque done\n"); } printf("(CAM_CTL_TILE %d):",ISP_READ_REG_NOPROTECT(mpIspDrv,CAM_CTL_TILE)); //dump image char filename[256]; if(type==3) { sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case0_%d_%d_img2o_%dx%d.yuv",type,i, 320,240); saveBufToFile(filename, reinterpret_cast<MUINT8*>(img2oBuf.virtAddr), 320 *240 * 2); } sprintf(filename, "/sdcard/Pictures/P2UT_DiffViewAngle_case0_%d_%d_wdmao_%dx%d.yuv",type,i, wdma_out_w,wdma_out_h); saveBufToFile(filename, reinterpret_cast<MUINT8*>(wdmaoBuf.virtAddr), wdma_out_w *wdma_out_h * 2); char filename2[256]; sprintf(filename2, "/sdcard/Pictures/P2UT_DiffViewAngle_case0_%d_%d_wroto_%dx%d.yuv",type,i, wrot_out_w,wrot_out_h); saveBufToFile(filename2, reinterpret_cast<MUINT8*>(wrotoBuf.virtAddr), wrot_out_w *wrot_out_h * 2); // if(type==3) { outBuffer->unlockBuf(LOG_TAG); mpImemDrv->freeVirtBuf(&img2oBuf); } outBuffer2->unlockBuf(LOG_TAG); outBuffer3->unlockBuf(LOG_TAG); mpImemDrv->freeVirtBuf(&wdmaoBuf); mpImemDrv->freeVirtBuf(&wrotoBuf); // } // pCCStream->uninit(); pCCStream->destroyInstance(LOG_TAG); mpImemDrv->uninit(); mpImemDrv->destroyInstance(); mpIspDrv->uninit(LOG_TAG); mpIspDrv->destroyInstance(); return ret; }
MBOOL CapPass2:: getPass2Buffer(vector<p2data>& vP2data) { MBOOL haveDst = MFALSE; p2data one; IImageBuffer* pSrcBuf = NULL; // src { Mutex::Autolock lock(mLock); // if( mlPostBufData.size() == 0 ) { MY_LOGE("no posted buf"); return MFALSE; } // one.src = mlPostBufData.front(); pSrcBuf = one.src.buf; mlPostBufData.pop_front(); } // get output bufffers for(MUINT32 i=0; i<MAX_DST_PORT_NUM; i++) { MBOOL ret; ImgRequest outRequest; // if(muDequeOrder[i] == 0) break; ret = getDstBuffer( muDequeOrder[i], &outRequest); // if(ret) { haveDst = MTRUE; one.vDstReq.push_back(outRequest); one.vDstData.push_back(muDequeOrder[i]); } } if( one.vDstReq[0].mTransform & eTransform_ROT_90 ) //90, 270 { MSize temp = one.vDstReq[0].mBuffer->getImgSize(); one.dstSize.w = temp.h; one.dstSize.h = temp.w; } else { one.dstSize = one.vDstReq[0].mBuffer->getImgSize(); } if( muNRType == 0 ) { one.doCrop = MTRUE; } else { MBOOL alloc_ret = MTRUE; ImgRequest outRequest; // // allocate internal buffers if ( muNRType == 1 ) { // allocate internal buffer if( mpInternalNR1Buf.get() == NULL && !allocMemory( pSrcBuf, eImgFmt_YUY2, mpInternalNR1Buf) ) { MY_LOGE("failed to allocate memory, nr1"); alloc_ret = MFALSE; } if( mpInternalNR2Buf.get() == NULL && !allocMemory( pSrcBuf, eImgFmt_YUY2, mpInternalNR2Buf) ) { MY_LOGE("failed to allocate memory, nr2"); alloc_ret = MFALSE; } } else if ( muNRType == 2 ) { if( mpInternalNR1Buf.get() == NULL && !allocMemory( pSrcBuf, eImgFmt_I420, mpInternalNR1Buf) ) { MY_LOGE("failed to allocate memory, nr1"); alloc_ret = MFALSE; } } if( alloc_ret ) { one.doCrop = MFALSE; // // keep request mvOutRequest = one.vDstReq; mvOutData = one.vDstData; one.vDstReq.clear(); one.vDstData.clear(); if( mpInternalNR1Buf.get() ) { outRequest.mBuffer = mpInternalNR1Buf.get(); outRequest.mTransform = 0; outRequest.mUsage = NSIoPipe::EPortCapbility_Cap; } one.vDstReq.push_back(outRequest); one.vDstData.push_back(PASS2_CAP_DST_1); { MUINT32 magicNum; MVOID* pPrivateData; MUINT32 privateDataSize; MCropRect p2InCrop; if( mpIspSyncCtrlHw->getPass2Info( pSrcBuf, one.dstSize, magicNum, pPrivateData, privateDataSize, p2InCrop) ) { mCapCrop.p = p2InCrop.p_integral; mCapCrop.s = p2InCrop.s; } else { MY_LOGE("can't get p2 crop info"); mCapCrop.p = MPoint(0); mCapCrop.s = pSrcBuf->getImgSize(); } } } else { MY_LOGW("cannot alloc memory, no NR path"); //error handling one.doCrop = MTRUE; muNRType = 0; if( !freeMemory(mpInternalNR1Buf) ) { MY_LOGE("free memory failed"); } if( !freeMemory(mpInternalNR2Buf) ) { MY_LOGE("free memory failed"); } } } // if( !haveDst ) { MY_LOGW("no dst buffer, skip data %d, buf 0x%x", one.src.data, one.src.buf); handleReturnBuffer(one.src.data, (MUINT32)one.src.buf); return MFALSE; //return false if no buffer } // vP2data.push_back(one); return MTRUE; }
/******************************************************************************* * Config CamIO Pipe /floria ********************************************************************************/ int Ts_UT:: main_ts_IOPipe_ZSD(int count) { // int count = 1000; //enque, deque loop iterations printf("[iopipetest] E\n"); //for Enqueue, raw buf MUINT32 u4RawBufSize = (u4SensorWidth * u4SensorHeight * 2 + L1_CACHE_BYTES-1) & ~(L1_CACHE_BYTES-1); //for buffer per frame int BufIdx = BUF_NUM, nCt = BUF_NUM; #ifdef USE_IMAGEBUF_HEAP MUINT32 bufStridesInBytes[3] = {1600, 0, 0}; MINT32 bufBoundaryInBytes[3] = {0, 0, 0}; #endif #if 0 ringbuffer* mpRingImgo = new ringbuffer( 2,//PASS1_FULLRAW PORT_IMGO, 0//fakeResized ? PASS1_RESIZEDRAW : 0 ); #endif MY_LOGD("+"); /*------------------------------ * (1) Create Instance *-----------------------------*/ /* eScenarioID_VSS, eScenarioFmt_RAW */ MUINT mSensorIdx = 0;//0:MAIN const char Name = '1'; MUINT mIspEnquePeriod = 1; prepareSensor();//test IHalSensor printf("[iopipetest] INormalPipe::createInstance\n"); mpCamIO = (INormalPipe*)INormalPipe::createInstance(mSensorIdx, &Name, mIspEnquePeriod); #if 0//camera 3.0, should create INormalPipe_FrmB class instance mpCamIO = (IHalCamIO*)INormalPipe_FrmB::createInstance(mSensorIdx, &Name, mIspEnquePeriod); #endif /*------------------------------ test 3A build pass ------------------------------*/ #if 0 MINT32 handle; MBOOL fgRet = mpCamIO->sendCommand(NSImageio_FrmB::NSIspio_FrmB::EPIPECmd_GET_MODULE_HANDLE, NSImageio_FrmB::NSIspio_FrmB::EModule_AF, (MINT32)&handle, (MINT32)(&("AFMgr::setFlkWinConfig()"))); MINT32 wintmp; IOPIPE_SET_MODUL_REG(handle, CAM_AF_WINX01, wintmp); #endif /*------------------------------ * (2) init *-----------------------------*/ printf("[iopipetest] mpCamIO->init\n"); if(!mpCamIO->init()) { printf("[iopipetest] mpCamIO->init failed!!\n"); } /*------------------------------ * (3). Config pipe + RAW10 *-----------------------------*/ MSize mDstSize; mDstSize.w = u4SensorWidth; mDstSize.h = u4SensorHeight; //prepare sensor config vector<IHalSensor::ConfigParam> vSensorCfg; IHalSensor::ConfigParam sensorCfg = { mSensorIdx, /* index */ mDstSize, /* crop no reference in NormalPipe */ u4Scenario, /* scenarioId */ 0, /* isBypassScenario */ 1, /* isContinuous */ 0, /* iHDROn */ 0, /* framerate */ 0, /* two pixel on */ 0, /* debugmode */ }; vSensorCfg.push_back(sensorCfg); printf("[iopipetest] sensor %dx%d, sce %d, bypass %d, con %d, hdr %d, fps %d, twopxl %d\n", sensorCfg.crop.w, sensorCfg.crop.h, sensorCfg.scenarioId, sensorCfg.isBypassScenario, sensorCfg.isContinuous, sensorCfg.HDRMode, sensorCfg.framerate, sensorCfg.twopixelOn); // vector<portInfo> vPortInfo; // portInfo OutPort( PORT_IMGO, eImgFmt_BAYER10, mDstSize, //dst size 0, //pPortCfg->mCrop, //crop u4SensorWidth, //pPortCfg->mStrideInByte[0], 0, //pPortCfg->mStrideInByte[1], 0, //pPortCfg->mStrideInByte[2], 0, // pureraw MTRUE //packed ); vPortInfo.push_back(OutPort); printf("[iopipetest] config portID(0x%x), fmt(%u), size(%dx%d), crop(%u,%u,%u,%u)\n", OutPort.mPortID, OutPort.mFmt, OutPort.mDstSize.w, OutPort.mDstSize.h, OutPort.mCropRect.p.x, OutPort.mCropRect.p.y, OutPort.mCropRect.s.w, OutPort.mCropRect.s.h); printf("[iopipetest] stride(%u,%u,%u), pureRaw(%u), pack(%d)\n", OutPort.mStride[0], OutPort.mStride[1], OutPort.mStride[2], OutPort.mPureRaw, OutPort.mPureRawPak); // QInitParam halCamIOinitParam( 0, u4Bitdepth, vSensorCfg, vPortInfo); printf("[iopipetest] mpCamIO->configPipe\n"); if(!mpCamIO->configPipe(halCamIOinitParam, eScenarioID_VSS)) { printf("[iopipetest] mpCamIO->configPipe failed!!\n"); goto TEST_EXIT; } /*------------------------------ * (4). Enqueue * 4.1, raw buf *-----------------------------*/ #ifdef _USE_THREAD_QUE_ if(vRawMem.size() > 0) { freeRawMem(); TS_Thread_UnInit(); } nCt--; #else // int nReplace; printf("*****************************************\n"); printf("Buffer per frame(1:y; else:n)\n"); scanf("%d", &nReplace); printf("*****************************************\n"); if(nReplace != 1) { nCt--; } #endif /* * * * * * * * * * * * * buffer per frame * nReplace = 1 * size = BUF_NUM + 1 *(replace buffer) * * * * * * * * * * * * * sequential buffer * nReplace != 1 * size = BUF_NUM *(no replace buffer) * * * * * * * * * * * */ printf("[iopipetest] allocMem: RawBuff\n"); for (int i = 0; i <= nCt; i++) //BUF_NUM=3 { IMEM_BUF_INFO rBuf; rBuf.size = u4RawBufSize; allocMem(rBuf); #ifdef USE_IMAGEBUF_HEAP PortBufInfo_v1 portBufInfo = PortBufInfo_v1( rBuf.memID,rBuf.virtAddr,0,rBuf.bufSecu, rBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER10), MSize(1280, 720), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,MTRUE); IImageBuffer* tempBuffer = pHeap->createImageBuffer(); tempBuffer->incStrong(tempBuffer); tempBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); // BufInfo rBufInfo; rBufInfo.mPortID = PORT_IMGO; rBufInfo.mBuffer = tempBuffer; rBufInfo.FrameBased.mMagicNum_tuning = 0; rBufInfo.FrameBased.mDstSize = mDstSize; rBufInfo.FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop rRawBuf.mvOut.push_back(rBufInfo); #endif vRawMem.push_back(rBuf); printf("[iopipetest] vRawMem(%d)PA(0x%x)VA(0x%x)\n", i, vRawMem.at(i).phyAddr,vRawMem.at(i).virtAddr); } //for deque for (int i = 0; i <= 0; i++) { IMEM_BUF_INFO rBuf; rBuf.size = u4RawBufSize; allocMem(rBuf); #ifdef USE_IMAGEBUF_HEAP PortBufInfo_v1 portBufInfo = PortBufInfo_v1( rBuf.memID,rBuf.virtAddr,0,rBuf.bufSecu, rBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER10), MSize(1280, 720), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,MTRUE); IImageBuffer* tempBuffer = pHeap->createImageBuffer(); tempBuffer->incStrong(tempBuffer); tempBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); // BufInfo rBufInfo; rBufInfo.mPortID = PORT_IMGO; rBufInfo.mBuffer = tempBuffer; rDequeBuf.mvOut.push_back(rBufInfo); #endif vDequeMem.push_back(rBuf); printf("[iopipetest] vDequeMem(%d)PA(0x%x)VA(0x%x)\n", i, vDequeMem.at(i).phyAddr, vDequeMem.at(i).virtAddr); } /* enque 3 buffers */ for (int i = 0; i < BUF_NUM; i++) { #if 1 QBufInfo rInBuf; rInBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rBufInfo(PORT_IMGO, rRawBuf.mvOut.at(i).mBuffer, rRawBuf.mvOut.at(i).mSize, rRawBuf.mvOut.at(i).mVa, rRawBuf.mvOut.at(i).mPa); #else BufInfo rBufInfo(PORT_IMGO, NULL, vRawMem.at(i).size, vRawMem.at(i).virtAddr, vRawMem.at(i).phyAddr); #endif rInBuf.mvOut.push_back(rBufInfo); rInBuf.mvOut.at(0).FrameBased.mMagicNum_tuning = 0; rInBuf.mvOut.at(0).FrameBased.mDstSize = mDstSize; rInBuf.mvOut.at(0).FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop #ifdef USE_IMAGEBUF_HEAP printf("[iopipetest] enque.PA(0x%x)VA(0x%x)buf(0x%x)\n", rInBuf.mvOut.at(0).mBuffer->getBufPA(0), rInBuf.mvOut.at(0).mBuffer->getBufVA(0), rInBuf.mvOut.at(0).mBuffer); #else printf("[iopipetest] enque.PA(0x%x)VA(0x%x)\n", rInBuf.mvOut.at(0).mPa, rInBuf.mvOut.at(0).mVa); #endif printf("[iopipetest] enque(%d)\n", i); if(!mpCamIO->enque(rInBuf)) { printf("[iopipetest] enque failed!!\n"); goto TEST_EXIT; } #else /* * * * * * * * * * * * * * * * * * * * * * * * * * * test: * if enque a buffer,and it's port is not IMGO, * mpCamIO->enque(rRawBuf)will return MFALSE * * * * * * * * * * * * * * * * * * * * * * * * * */ QBufInfo rInBuf; rInBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rBufInfo2(PORT_IMGO, rRawBuf.mvOut.at(i).mBuffer, rRawBuf.mvOut.at(i).mSize, rRawBuf.mvOut.at(i).mVa, rRawBuf.mvOut.at(i).mPa); #else BufInfo rBufInfo2(PORT_IMG2O, NULL, vRawMem.at(i).size, vRawMem.at(i).virtAddr, vRawMem.at(i).phyAddr); #endif rInBuf.mvOut.push_back(rBufInfo2); printf("[iopipetest] enque(%d)\n", i); if(!mpCamIO->enque(rInBuf)){//try to enque IMGO port printf("[iopipetest] enque(%d) again\n", i); rInBuf.mvOut.clear(); BufInfo rBufInfo(PORT_IMGO, NULL, vRawMem.at(i).size, vRawMem.at(i).virtAddr, vRawMem.at(i).phyAddr); rInBuf.mvOut.push_back(rBufInfo); if(!mpCamIO->enque(rInBuf)) { printf("[iopipetest] enque failed!!\n"); goto TEST_EXIT; } } #endif } /*------------------------------ * (5). start *-----------------------------*/ printf("[iopipetest] mpCamIO->start\n"); if(!mpCamIO->start()) { printf("[iopipetest] mpCamIO->start failed!!\n"); goto TEST_EXIT; } #if 0//for debug // test: wait VSYNC printf("[iopipetest] mpCamIO->irq(VSYNC)\n"); if(!mpCamIO->wait(mSensorIdx, EPipeSignal_SOF)) { printf("[iopipetest] wait VSYNC failed!!\n"); goto TEST_EXIT; } // test: wait pass1 done printf("[iopipetest] mpCamIO->irq(p1done)\n"); if(!mpCamIO->wait(mSensorIdx, EPipeSignal_EOF)) { printf("[iopipetest] wait p1done failed!!\n"); goto TEST_EXIT; } #endif /*------------------------------ * (6). deque/enque loop * --> dequeue * --> enqueue *-----------------------------*/ #ifdef _USE_THREAD_QUE_ TS_Thread_Init(count); #else do { printf("-------------------------------------------\n"); QBufInfo halCamIOOutQBuf; QBufInfo rEnBuf; // halCamIOOutQBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rDeBufInfo(PORT_IMGO, rDequeBuf.mvOut.at(0).mBuffer, rDequeBuf.mvOut.at(0).mSize, rDequeBuf.mvOut.at(0).mVa, rDequeBuf.mvOut.at(0).mPa); #else BufInfo rDeBufInfo(PORT_IMGO, NULL, vDequeMem.at(0).size, vDequeMem.at(0).virtAddr, vDequeMem.at(0).phyAddr); #endif halCamIOOutQBuf.mvOut.push_back(rDeBufInfo); #ifdef USE_IMAGEBUF_HEAP //do nothing #else printf("[iopipetest] dequeBuf.PA(0x%x)VA(0x%x)size(%d)\n", halCamIOOutQBuf.mvOut.at(0).mPa, halCamIOOutQBuf.mvOut.at(0).mVa, halCamIOOutQBuf.mvOut.size()); #endif // printf("[iopipetest] dequeBuf count(%d)\n", count); if(!mpCamIO->deque(halCamIOOutQBuf)) { printf("[iopipetest] deque failed!!\n"); goto TEST_EXIT; } #ifdef USE_IMAGEBUF_HEAP printf("[iopipetest] dequeBuf.PA(0x%x)VA(0x%x)buf(0x%x)\n", halCamIOOutQBuf.mvOut.at(0).mBuffer->getBufPA(0), halCamIOOutQBuf.mvOut.at(0).mBuffer->getBufVA(0), halCamIOOutQBuf.mvOut.at(0).mBuffer); #else printf("[iopipetest] dequeBuf.PA(0x%x)VA(0x%x)\n", halCamIOOutQBuf.mvOut.at(0).mPa, halCamIOOutQBuf.mvOut.at(0).mVa); #endif /* * * * * * * * * * * * * get ResultMetadata * * * * * * * * * * * */ ResultMetadata result = halCamIOOutQBuf.mvOut.at(0).mMetaData; /* * * * * * * * * * * * * check dummy frame * * * * * * * * * * * */ if(halCamIOOutQBuf.mvOut.at(0).mMetaData.m_bDummyFrame == MTRUE) { printf("[iopipetest] this is a dummy frame\n"); } /* * * * * * * * * * * * * sequential buffer *(no replace buffer) * * * * * * * * * * * */ if(nReplace != 1) { rEnBuf.mvOut.clear(); BufInfo rBufInfo(PORT_IMGO, #ifdef USE_IMAGEBUF_HEAP halCamIOOutQBuf.mvOut.at(0).mBuffer, #else NULL, #endif halCamIOOutQBuf.mvOut.at(0).mSize, halCamIOOutQBuf.mvOut.at(0).mVa, halCamIOOutQBuf.mvOut.at(0).mPa); rEnBuf.mvOut.push_back(rBufInfo); } /* * * * * * * * * * * * * buffer per frame *(replace buffer) * * * * * * * * * * * */ else { rEnBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rBufInfo(PORT_IMGO, rRawBuf.mvOut.at(BufIdx).mBuffer, rRawBuf.mvOut.at(BufIdx).mSize, rRawBuf.mvOut.at(BufIdx).mVa, rRawBuf.mvOut.at(BufIdx).mPa); #else BufInfo rBufInfo(PORT_IMGO, NULL, vRawMem.at(BufIdx).size, vRawMem.at(BufIdx).virtAddr, vRawMem.at(BufIdx).phyAddr); #endif rEnBuf.mvOut.push_back(rBufInfo); } #ifdef USE_IMAGEBUF_HEAP printf("[iopipetest] enqueBuf.PA(0x%x)VA(0x%x),BufId(%d)\n", rEnBuf.mvOut.at(0).mBuffer->getBufPA(0), rEnBuf.mvOut.at(0).mBuffer->getBufVA(0), BufIdx); #else printf("[iopipetest] enqueBuf.PA(0x%x)VA(0x%x),BufId(%d)\n", rEnBuf.mvOut.at(0).mPa, rEnBuf.mvOut.at(0).mVa, BufIdx); #endif /* * * * * * * * * * * * * setting before enque * * * * * * * * * * * */ rEnBuf.mvOut.at(0).FrameBased.mMagicNum_tuning = 0; rEnBuf.mvOut.at(0).FrameBased.mDstSize = mDstSize; rEnBuf.mvOut.at(0).FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop // printf("[iopipetest] enque count(%d)\n", count); if(!mpCamIO->enque(rEnBuf)) { printf("[iopipetest] enque failed!!\n"); goto TEST_EXIT; } // if(++BufIdx > BUF_NUM) BufIdx = 0; // } while(--count > 0); #endif /*------------------------------ * (7). Stop *-----------------------------*/ printf("[iopipetest] mpCamIO->stop\n"); mpCamIO->stop(); TEST_EXIT: /*------------------------------ * (8). uninit *-----------------------------*/ printf("[iopipetest] mpCamIO->uninit\n"); if( !mpCamIO->uninit() ) { MY_LOGE("uninit failed"); } /*------------------------------ * (9). destory instance *-----------------------------*/ printf("[iopipetest] mpCamIO->destroyInstance\n"); mpCamIO->destroyInstance(&Name); mpCamIO = NULL; printf("[iopipetest] X\n"); return 0; }
MBOOL EngBufHandlerImpl:: enqueBuffer(MUINT32 const data, IImageBuffer const * pImageBuffer) { Mutex::Autolock _l(mLock); // MINT32 i, bufQueIdx = mapNode2Dst(data); ImgBufQueNode keepImgBufQueNode; // #if 0 MY_LOGD("data(0x%08X)",data); #endif // if(bufQueIdx == -1) { return MFALSE; } // if(bufQueIdx >= 0) { if(mvBufQueNode[bufQueIdx].size() > 0) { keepImgBufQueNode = mvBufQueNode[bufQueIdx][0]; } else { MY_LOGE("mvBufQueNode[%d] size(%d) = 0", bufQueIdx, mvBufQueNode[bufQueIdx].size()); return MFALSE; } } else { MY_LOGE("bufQueIdx(%d) < 0",bufQueIdx); } // MUINTPTR keepAddr = (MUINTPTR)(mvBufQueNode[bufQueIdx][0].getImgBuf()->getVirAddr()); MUINTPTR enqueAddr = (MUINTPTR)(GET_IIMAGEBUFFER_BUF_VA(pImageBuffer, 0)); // #if 0 MY_LOGD("Addr(0x%08X/0x%08X),Port(%d)", keepAddr, enqueAddr, mvBufQueNode[bufQueIdx][0].getCookieDE()); #endif // if(keepAddr == enqueAddr) { MBOOL isAPClientFromFD = MFALSE; sp<IImgBufProvider> bufProvider = NULL; IImageBuffer* tempBuffer = const_cast<IImageBuffer*>(pImageBuffer); // switch(keepImgBufQueNode.getCookieDE()) { case eBuf_Disp: { bufProvider = mspImgBufProvidersMgr->getDisplayPvdr(); break; } case eBuf_Rec: { bufProvider = mspImgBufProvidersMgr->getRecCBPvdr(); break; } case eBuf_AP: { bufProvider = mspImgBufProvidersMgr->getPrvCBPvdr(); const_cast<ImgBufQueNode*>(&keepImgBufQueNode)->setCookieDE(0); // 0 for preview break; } case eBuf_Generic: { bufProvider = mspImgBufProvidersMgr->getGenericBufPvdr(); break; } case eBuf_FD: { bufProvider = mspImgBufProvidersMgr->getFDBufPvdr(); isAPClientFromFD = MTRUE; break; } case eBuf_OT: { bufProvider = mspImgBufProvidersMgr->getOTBufPvdr(); break; } default: { MY_LOGE("unknown port(%d)",keepImgBufQueNode.getCookieDE()); return MFALSE; } } // if (bufProvider == NULL) { MY_LOGW("bufProvider(%d) is not available, drop it!", keepImgBufQueNode.getCookieDE()); tempBuffer->unlockBuf(LOG_TAG); tempBuffer->decStrong(tempBuffer); mvBufQueNode[bufQueIdx].erase(mvBufQueNode[bufQueIdx].begin()); return MTRUE; } else { const_cast<ImgBufQueNode*>(&(keepImgBufQueNode))->setStatus(ImgBufQueNode::eSTATUS_DONE); const_cast<ImgBufQueNode*>(&(keepImgBufQueNode))->getImgBuf()->setTimestamp(pImageBuffer->getTimestamp()); // char debugMsg[150]; sprintf(debugMsg, "buf(%p),heap(%p),VA(0x%08X),BS(%d),Id(%d),TS(%d.%06d),F(0x%08X),S(%dx%d),Str(%d,%d,%d)", pImageBuffer, pImageBuffer->getImageBufferHeap(), GET_IIMAGEBUFFER_BUF_VA(pImageBuffer, 0), ( GET_IIMAGEBUFFER_BUF_SIZE(pImageBuffer, 0)+ GET_IIMAGEBUFFER_BUF_SIZE(pImageBuffer, 1)+ GET_IIMAGEBUFFER_BUF_SIZE(pImageBuffer, 2)), pImageBuffer->getFD(0), (MUINT32)((pImageBuffer->getTimestamp()/1000)/1000000), (MUINT32)((pImageBuffer->getTimestamp()/1000)%1000000), pImageBuffer->getImgFormat(), pImageBuffer->getImgSize().w, pImageBuffer->getImgSize().h, GET_IIMAGEBUFFER_BUF_STRIDE_IN_BYTE(pImageBuffer, 0), GET_IIMAGEBUFFER_BUF_STRIDE_IN_BYTE(pImageBuffer, 1), GET_IIMAGEBUFFER_BUF_STRIDE_IN_BYTE(pImageBuffer, 2)); // tempBuffer->unlockBuf(LOG_TAG); tempBuffer->decStrong(tempBuffer); // bufProvider->enqueProvider(keepImgBufQueNode); // only dequeue is not from APClient if(isAPClientFromFD) { // If APClient exists, copy to it sp<IImgBufProvider> pBufProvider; pBufProvider = mspImgBufProvidersMgr->getAPClientBufPvdr(); ImgBufQueNode APClientnode; if (pBufProvider != 0 && pBufProvider->dequeProvider(APClientnode)) { MY_LOGD("APClient size:%d, fdClient size:%d", APClientnode.getImgBuf()->getBufSize() , keepImgBufQueNode.getImgBuf()->getBufSize()); //if ( APClientnode.getImgBuf()->getBufSize() >= keepImgBufQueNode.getImgBuf()->getBufSize()) if (1) { MY_LOGD("APClient addr:0x%x, FDCLient addr:0x%x", APClientnode.getImgBuf()->getVirAddr(), keepImgBufQueNode.getImgBuf()->getVirAddr()); memcpy(APClientnode.getImgBuf()->getVirAddr(), keepImgBufQueNode.getImgBuf()->getVirAddr(), APClientnode.getImgBuf()->getBufSize()); //keepImgBufQueNode.getImgBuf()->getBufSize()); const_cast<ImgBufQueNode*>(&APClientnode)->setStatus(ImgBufQueNode::eSTATUS_DONE); } else { MY_LOGE("APClient buffer size < FD buffer size"); const_cast<ImgBufQueNode*>(&APClientnode)->setStatus(ImgBufQueNode::eSTATUS_CANCEL); } // pBufProvider->enqueProvider(APClientnode); } } // mvBufQueNode[bufQueIdx].erase(mvBufQueNode[bufQueIdx].begin()); // #if 1 MY_LOGD("%s",debugMsg); #endif // return MTRUE; } } else { MY_LOGE("Addr(0x%X != 0x%X),Port(%d), drop it!", keepAddr, enqueAddr, mvBufQueNode[bufQueIdx][0].getCookieDE()); return MFALSE; } }
MBOOL EngBufHandlerImpl:: dequeBuffer(MUINT32 const data, ImgRequest * pImgReq) { Mutex::Autolock _l(mLock); // MBOOL isDequeProvider = MFALSE; MBOOL doCacheInvalid = MFALSE; MINT32 bufQueIdx = mapNode2Dst(data); ImgBufQueNode node; list<MAP_PORT_INFO>::iterator iterMapPort; // #if 0 MY_LOGD("data(0x%08X)",data); #endif // if(bufQueIdx == -1) { return MFALSE; } // for(iterMapPort = mlMapPort[bufQueIdx].begin(); iterMapPort != mlMapPort[bufQueIdx].end(); iterMapPort++) { #if 0 MY_LOGD("bufQueIdx(%d),data(%d,%d),bufType(%d)", bufQueIdx,data, (*iterMapPort).nodeType, (*iterMapPort).bufType); #endif if(data == (*iterMapPort).nodeType) { sp<IImgBufProvider> bufProvider = NULL; pImgReq->mUsage = NSIoPipe::EPortCapbility_None; switch((*iterMapPort).bufType) { case eBuf_Disp: { bufProvider = mspImgBufProvidersMgr->getDisplayPvdr(); pImgReq->mUsage = NSIoPipe::EPortCapbility_Disp; break; } case eBuf_Rec: { bufProvider = mspImgBufProvidersMgr->getRecCBPvdr(); pImgReq->mUsage = NSIoPipe::EPortCapbility_Rcrd; break; } case eBuf_AP: { bufProvider = mspImgBufProvidersMgr->getPrvCBPvdr(); doCacheInvalid = MTRUE; break; } case eBuf_Generic: { bufProvider = mspImgBufProvidersMgr->getGenericBufPvdr(); break; } case eBuf_FD: { bufProvider = mspImgBufProvidersMgr->getFDBufPvdr(); break; } case eBuf_OT: { bufProvider = mspImgBufProvidersMgr->getOTBufPvdr(); break; } default: { MY_LOGE("un-supported bufType(%d)",(*iterMapPort).bufType); return MFALSE; } } // if(bufProvider != 0 && bufProvider->dequeProvider(node)) { node.setCookieDE((*iterMapPort).bufType); mvBufQueNode[bufQueIdx].push_back(node); isDequeProvider = MTRUE; break; } } } // if(isDequeProvider) { size_t bufStridesInBytes[] = { GET_IIMGBUF_IMG_STRIDE_IN_BYTE(node.getImgBuf(), 0), GET_IIMGBUF_IMG_STRIDE_IN_BYTE(node.getImgBuf(), 1), GET_IIMGBUF_IMG_STRIDE_IN_BYTE(node.getImgBuf(), 2)}; size_t bufBoundaryInBytes[] = {0,0,0}; IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam( Format::queryImageFormat(node.getImgBuf()->getImgFormat().string()), MSize( node.getImgBuf()->getImgWidth(), node.getImgBuf()->getImgHeight()), bufStridesInBytes, bufBoundaryInBytes, Format::queryPlaneCount(Format::queryImageFormat(node.getImgBuf()->getImgFormat().string()))); PortBufInfo_v1 portBufInfo = PortBufInfo_v1( node.getImgBuf()->getIonFd(), (MUINTPTR)node.getImgBuf()->getVirAddr(), 0, node.getImgBuf()->getBufSecu(), node.getImgBuf()->getBufCohe()); // sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam, portBufInfo, mbEnableIImageBufferLog); if(pHeap == 0) { MY_LOGE("pHeap is NULL"); return MFALSE; } // IImageBuffer* tempBuffer = pHeap->createImageBuffer(); tempBuffer->incStrong(tempBuffer); tempBuffer->lockBuf( LOG_TAG, eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); if( doCacheInvalid ) { if( !tempBuffer->syncCache(eCACHECTRL_INVALID) ) MY_LOGE("invalid cache failed imgbuf 0x%x", tempBuffer); } pImgReq->mBuffer = tempBuffer; if(mbIsForceRotation) { pImgReq->mTransform = mRotationAnagle == 0 ? 0 : mRotationAnagle == 90 ? eTransform_ROT_90 : mRotationAnagle == 180 ? eTransform_ROT_180 : eTransform_ROT_270; } else { pImgReq->mTransform = node.getRotation() == 0 ? 0 : node.getRotation() == 90 ? eTransform_ROT_90 : node.getRotation() == 180 ? eTransform_ROT_180 : eTransform_ROT_270; } // #if 0 MY_LOGD("Node:DE(%d),VA(0x%08X),S(%d),Id(%d)", node.getCookieDE(), (MUINT32)node.getImgBuf()->getVirAddr(), node.getImgBuf()->getBufSize(), node.getImgBuf()->getIonFd()); MY_LOGD("Node:F(%s),W(%d),H(%d),Str(%d,%d,%d),Rot(%d)", node.getImgBuf()->getImgFormat().string(), node.getImgBuf()->getImgWidth(), node.getImgBuf()->getImgHeight(), GET_IIMGBUF_IMG_W_STRIDE(node.getImgBuf(), 0), GET_IIMGBUF_IMG_W_STRIDE(node.getImgBuf(), 1), GET_IIMGBUF_IMG_W_STRIDE(node.getImgBuf(), 2), node.getRotation()); #endif // #if 1 MY_LOGD("buf(%p),heap(%p),VA(0x%08X/0x%08X/0x%08X),PA(0x%08X/0x%08X/0x%08X),BS(%d=%d+%d+%d),Id(%d),F(0x%08X),S(%dx%d),Str(%d,%d,%d),R(%d),U(%d)", pImgReq->mBuffer, pImgReq->mBuffer->getImageBufferHeap(), GET_IIMAGEBUFFER_BUF_VA(pImgReq->mBuffer, 0), GET_IIMAGEBUFFER_BUF_VA(pImgReq->mBuffer, 1), GET_IIMAGEBUFFER_BUF_VA(pImgReq->mBuffer, 2), GET_IIMAGEBUFFER_BUF_PA(pImgReq->mBuffer, 0), GET_IIMAGEBUFFER_BUF_PA(pImgReq->mBuffer, 1), GET_IIMAGEBUFFER_BUF_PA(pImgReq->mBuffer, 2), ( GET_IIMAGEBUFFER_BUF_SIZE(pImgReq->mBuffer, 0)+ GET_IIMAGEBUFFER_BUF_SIZE(pImgReq->mBuffer, 1)+ GET_IIMAGEBUFFER_BUF_SIZE(pImgReq->mBuffer, 2)), GET_IIMAGEBUFFER_BUF_SIZE(pImgReq->mBuffer, 0), GET_IIMAGEBUFFER_BUF_SIZE(pImgReq->mBuffer, 1), GET_IIMAGEBUFFER_BUF_SIZE(pImgReq->mBuffer, 2), pImgReq->mBuffer->getFD(), pImgReq->mBuffer->getImgFormat(), pImgReq->mBuffer->getImgSize().w, pImgReq->mBuffer->getImgSize().h, GET_IIMAGEBUFFER_BUF_STRIDE_IN_BYTE(pImgReq->mBuffer, 0), GET_IIMAGEBUFFER_BUF_STRIDE_IN_BYTE(pImgReq->mBuffer, 1), GET_IIMAGEBUFFER_BUF_STRIDE_IN_BYTE(pImgReq->mBuffer, 2), pImgReq->mTransform, pImgReq->mUsage); #endif // return MTRUE; } // #if 0 MY_LOGD("empty data(0x%08X)",data); #endif return MFALSE; }
MBOOL Pass2NodeImpl:: enquePass2(MBOOL const doCallback) { //workaround for start/stop recording Mutex::Autolock lock(mRecordingLock); NG_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; } // NG_TRACE_FMT_BEGIN("enqP2:%d", trace_begin); if( !mpPostProcPipe->enque(enqueParams) ) { NG_TRACE_FMT_END(); MY_LOGE("enque pass2 failed"); AEE_ASSERT("ISP pass2 enque fail"); return MFALSE; } NG_TRACE_FMT_END(); return MTRUE; }
void Test_ImageBufferAllocator() { CAM_LOGD("++++++++++++++++ Test_ImageBufferAllocator ++++++++++++++++"); // // size_t bufStridesInBytes[3] = {2000, 1920, 960}; size_t bufBoundaryInBytes[3] = {0, 0, 0}; IImageBufferAllocator::ImgParam imgParam( eImgFmt_YV12, MSize(1920, 1080), bufStridesInBytes, bufBoundaryInBytes, 3 ); // MUINT32 size = 2048; IImageBufferAllocator::ImgParam imgParam_blob(size, 0); // MUINT32 buffer_size = 1280*720; IImageBufferAllocator::ImgParam imgParam_jpeg( MSize(1280, 720), buffer_size, 0 ); // //// raw pointer { // IImageBufferAllocator *allocator = IImageBufferAllocator::getInstance(); // //// blob IImageBuffer* pImgBuf_blob = allocator->alloc("Test_Allocator_raw_blob", imgParam_blob); OBJ_CHECK(pImgBuf_blob); test_imgbuf_blob(pImgBuf_blob->getMagicName(), pImgBuf_blob, size); allocator->free(pImgBuf_blob); // //// yuv 3p IImageBuffer* pImgBuf = allocator->alloc("Test_Allocator_raw_yuv3p", imgParam); OBJ_CHECK(pImgBuf); test_imgbuf_yuv420_3p(pImgBuf->getMagicName(), pImgBuf, imgParam); allocator->free(pImgBuf); // //// jpeg 1p IImageBuffer* pImgBuf_jpeg = allocator->alloc("Test_Allocator_raw_jpeg1p", imgParam_jpeg); OBJ_CHECK(pImgBuf_jpeg); test_imgbuf_jpeg_1p(pImgBuf_jpeg->getMagicName(), pImgBuf_jpeg, imgParam_jpeg); // MY_CHECK(buffer_size==pImgBuf_jpeg->getBitstreamSize(), "%d", pImgBuf_jpeg->getBitstreamSize()); MY_CHECK(!pImgBuf_jpeg->setBitstreamSize(7200000), "can not setBitstreamSize()"); MY_CHECK(buffer_size==pImgBuf_jpeg->getBitstreamSize(), "%d", pImgBuf_jpeg->getBitstreamSize()); MY_CHECK(pImgBuf_jpeg->setBitstreamSize(720000), "can setBitstreamSize()"); MY_CHECK(720000==pImgBuf_jpeg->getBitstreamSize(), "%d", pImgBuf_jpeg->getBitstreamSize()); allocator->free(pImgBuf_jpeg); // } // //// strong pointer { // IImageBufferAllocator *allocator = IImageBufferAllocator::getInstance(); // //// blob sp<IImageBuffer> spImgBuf_blob = allocator->alloc("Test_Allocator_sp_blob", imgParam_blob); OBJ_CHECK(spImgBuf_blob); allocator->free(spImgBuf_blob.get()); test_imgbuf_blob(spImgBuf_blob->getMagicName(), spImgBuf_blob.get(), size); // //// yuv 3p sp<IImageBuffer> spImgBuf = allocator->alloc("Test_Allocator_sp_yuv3p", imgParam); OBJ_CHECK(spImgBuf); allocator->free(spImgBuf.get()); test_imgbuf_yuv420_3p(spImgBuf->getMagicName(), spImgBuf.get(), imgParam); // } // CAM_LOGD("---------------- Test_ImageBufferAllocator ----------------"); }