예제 #1
0
MBOOL
SyncNodeImpl::
pushBuf(MUINT32 const data, IImageBuffer* const buf, MUINT32 const ext)
{
    Mutex::Autolock lock(mLock);
    MY_LOGD("data(%d), buf(0x%x)", data, buf);
    MBOOL ret = MTRUE;
    PostBufInfo postBufData = {data, buf, ext};
    switch (data)
    {
    case SYNC_SRC_0:
        mlPostBuf_0.push_back(postBufData);
        break;
    case SYNC_SRC_1:
        mlPostBuf_1.push_back(postBufData);
        break;
    default:
        MY_LOGE("Unsupported data(%d)", data);
        handleReturnBuffer(data, (MUINTPTR)buf);
        ret = MFALSE;
        break;
    }
    //
    if( isReadyToPostBuf() )
    {
        muFrameCnt++;
        //
        PostBufInfo postBuf_0   = mlPostBuf_0.front();
        PostBufInfo postBuf_1   = mlPostBuf_1.front();
        mlPostBuf_0.pop_front();
        mlPostBuf_1.pop_front();
        //
        MY_LOGD("muFrameCnt(%d), buf(ID:%d/0x%x; ID:%d/0x%x)", muFrameCnt,
                postBuf_0.buf->getFD(), postBuf_0.buf,
                postBuf_1.buf->getFD(), postBuf_1.buf);
        handlePostBuffer(SYNC_DST_0, (MUINTPTR)postBuf_0.buf);
        handlePostBuffer(SYNC_DST_1, (MUINTPTR)postBuf_1.buf);
    }
    else
    {
        PostBufInfo retBufData;
        while( mlPostBuf_0.size() > 1 ) {
            retBufData = mlPostBuf_0.front();
            mlPostBuf_0.pop_front();
            handleReturnBuffer(retBufData.data, (MUINTPTR)retBufData.buf);
        }
        while( mlPostBuf_1.size() > 1 ) {
            retBufData = mlPostBuf_1.front();
            mlPostBuf_1.pop_front();
            handleReturnBuffer(retBufData.data, (MUINTPTR)retBufData.buf);
        }
    }
    //
    return ret;
}
예제 #2
0
MBOOL
ExtImgProcNodeImpl::
onStop()
{
    FUNC_START;
    MBOOL ret = syncWithThread(); //wait for jobs done

    Mutex::Autolock lock(mLock);
    {
        list<PostBufInfo>::iterator iter;
        for(iter = mlPostBufData.begin(); iter != mlPostBufData.end(); iter++)
        {
            MY_LOGD("ReturnBuffer:data(%d), buf(0x%x)",
                    (*iter).data,
                    (*iter).buf);
            handleReturnBuffer(
                (*iter).data,
                (MUINT32)((*iter).buf),
                0);
        }
    }

    FUNC_END;
    return ret;
}
예제 #3
0
MBOOL
StereoNodeImpl::
onStop()
{
    FUNC_START;
    MBOOL ret = syncWithThread(); //wait for jobs done

    Mutex::Autolock lock(mLock);
    {
        list<PostBufInfo>::iterator iter;
        for(iter = mlPostBufData.begin(); iter != mlPostBufData.end(); iter++)
        {
            MY_LOGD("ReturnBuffer:data(%d), buf(0x%x)",
                    (*iter).data,
                    (*iter).buf);
            handleReturnBuffer(
                (*iter).data,
                (MUINTPTR)((*iter).buf),
                0);
        }
    }
    while(muEnqFrameCnt > muDeqFrameCnt)
    {
        MY_LOGD("wait lock enq %d > deq %d", muEnqFrameCnt, muDeqFrameCnt);
        mCondDeque.wait(mLock);
        MY_LOGD("wait done");
    }
    //
    freeBuffers();
    //
    FUNC_END;
    return ret;
}
예제 #4
0
MBOOL
ExtImgProcNodeImpl::
onReturnBuffer(MUINT32 const data, MUINT32 const buf, MUINT32 const ext)
{
    NG_TRACE_CALL();
    handleReturnBuffer(EXTIMGPROC_SRC, buf);
    return MTRUE;
}
예제 #5
0
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;
}
예제 #6
0
MBOOL
SyncNodeImpl::
onStop()
{
    FUNC_START;
    Mutex::Autolock lock(mLock);
    {
        list<PostBufInfo>::iterator iter;
        for(iter = mlPostBuf_0.begin(); iter != mlPostBuf_0.end(); iter++)
        {
            MY_LOGD("ReturnBuffer:data(%d), buf(0x%x)", (*iter).data, (*iter).buf);
            handleReturnBuffer( (*iter).data, (MUINTPTR)((*iter).buf));
        }
        for(iter = mlPostBuf_1.begin(); iter != mlPostBuf_1.end(); iter++)
        {
            MY_LOGD("ReturnBuffer:data(%d), buf(0x%x)", (*iter).data, (*iter).buf);
            handleReturnBuffer( (*iter).data, (MUINTPTR)((*iter).buf));
        }
    }
    FUNC_END;
    return MTRUE;
}
예제 #7
0
MBOOL 
Pass2NodeImpl::
onStop()
{
    FUNC_START;
    MBOOL ret = MTRUE;
    
    if( !syncWithThread() ) //wait for jobs done
    {
        MY_LOGE("sync with thread failed");
        ret = MFALSE;
    }

    #if PASS2_CALLBACL_ENABLE
    Mutex::Autolock lock(mLock);

    {
        list<PostBufInfo>::iterator iter;
        for(iter = mlPostBufData.begin(); iter != mlPostBufData.end(); iter++)
        {
            MY_LOGD("ReturnBuffer:data(%d), buf(0x%x)",
                    (*iter).data,
                    (*iter).buf);
            handleReturnBuffer(
                (*iter).data,
                (MUINT32)((*iter).buf),
                0);
        }
    }

    while(muEnqFrameCnt > muDeqFrameCnt)
    {
        MY_LOGD("wait lock enq %d > deq %d", muEnqFrameCnt, muDeqFrameCnt);
        mCondDeque.wait(mLock);
        MY_LOGD("wait done");
    }
    #endif

    if( !moduleStop() )
    {
        MY_LOGE("moduleStop failed");
        ret = MFALSE;
    }

    FUNC_END;
    return ret;
}
예제 #8
0
MBOOL
Pass2NodeImpl::
handleP2Done(QParams& rParams)
{
    NG_TRACE_FMT_BEGIN("deqP2:%d", muDeqFrameCnt);
    MBOOL ret = MFALSE;
    Vector<Input>::const_iterator iterIn;
    Vector<Output>::const_iterator iterOut;
    vector<IImageBuffer*> vpDstBufAddr;
    //
    if(rParams.mDequeSuccess == MFALSE)
    {
        MY_LOGE("type %d pass2 cnt %d: deque fail",
                mPass2Type,
                muDeqFrameCnt);
        AEE_ASSERT("ISP pass2 deque fail");
    }
    //
    MY_LOGD("type %d: cnt %d in %d out %d",
            mPass2Type,
            muDeqFrameCnt,
            rParams.mvIn.size(),
            rParams.mvOut.size());
    //
    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++ )
    {
        //MY_LOGD("In PortID(0x%08X)",portId);
        MUINT32 nodeDataType = mapToNodeDataType( iterIn->mPortID );
        handleReturnBuffer( nodeDataType, (MUINT32)iterIn->mBuffer, 0 );
        //
    }
    //
    vpDstBufAddr.clear();
    for( iterOut = rParams.mvOut.begin() ; iterOut != rParams.mvOut.end() ; iterOut++ )
    {
        MBOOL bFind = MFALSE;
        for(MUINT32 i=0; i<vpDstBufAddr.size(); i++)
        {
            if(vpDstBufAddr[i] == iterOut->mBuffer)
            {
                MY_LOGD("Buf(0x%08X) has been posted",(MUINT32)iterOut->mBuffer);
                bFind = MTRUE;
                break;
            }
        }
        if(!bFind)
        {
            //MY_LOGD("Out PortID(0x%08X)",portId);
            MUINT32 nodeDataType = mapToNodeDataType( iterOut->mPortID );
            handlePostBuffer( nodeDataType, (MUINT32)iterOut->mBuffer, 0 );
            vpDstBufAddr.push_back(iterOut->mBuffer);
        }
    }

    {
        Mutex::Autolock lock(mLock);
        muDeqFrameCnt += rParams.mvIn.size();
        mCondDeque.broadcast();
    }

    ret = MTRUE;
lbExit:
    NG_TRACE_FMT_END();
    return ret;

}
예제 #9
0
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;

}
예제 #10
0
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;
}