Example #1
0
/**
 * VpInitRing()
 *  This function is used to initialize Ringing and CID profile to a given line.
 * See VP-API reference guide for more information.
 *
 * Preconditions:
 *  The line context and device context should be created initialized. The boot
 * image should be downloaded before calling this function (for applicable
 * devices).
 *
 * Postconditions:
 *  Applies the Caller ID and Ringing profile.
 */
VpStatusType
VpInitRing(
    VpLineCtxType *pLineCtx,        /**< Line context */
    VpProfilePtrType pCadProfile,   /**< Ringing cadence profile */
    VpProfilePtrType pCidProfile)   /**< Caller ID profile */
{
    VpStatusType status;
    VP_API_ENTER(VpLineCtxType, pLineCtx, "InitRing");

    /* Basic argument checking */
    if (pCadProfile == VP_NULL && pCidProfile != VP_NULL) {
        /* It doesn't make sense to load a caller ID profile with
         * no ring cadence */
        VP_ERROR(VpLineCtxType, pLineCtx, ("VpInitRing(): Cannot use a NULL ring cadence with a non-NULL caller ID profile"));
        status = VP_STATUS_INVALID_ARG;
    } else if (pLineCtx == VP_NULL) {
        VP_ERROR(VpLineCtxType, pLineCtx, ("VpInitRing(): Invalid NULL pLineCtx"));
        status = VP_STATUS_INVALID_ARG;
    } else {
        VpDevCtxType *pDevCtx = pLineCtx->pDevCtx;
        status = VP_CALL_DEV_FUNC(InitRing, (pLineCtx, pCadProfile, pCidProfile));
    }

    VP_API_EXIT(VpLineCtxType, pLineCtx, "InitRing", status);
    return status;
} /* VpInitRing() */
/**  VpSetDevTimerInt()
  This function calls a device specific function to control a device timer.

  The device timer could be an actual hardware timer or a tick-based software
  timer.  When the timer expires, the device-specific layer should call
  VpProcessTimers().

  If there are timers in the queue, the timer is set to the duration of the
  soonest timer to expire (the front).  If the queue is empty, the device
  timer can be deactivated (enable == FALSE).
*/
void
VpSetDevTimerInt(
    VpDevCtxType *pDevCtx,
    VpTimerQueueInfoType *pInfo,
    VpTimerQueueNodeType *pNodes)
{
    bool enable;
    uint32 duration;
    VpTimerQueueNodeType *firstTimer = &(pNodes[pInfo->index]);

    if (firstTimer->active == FALSE) {
        enable = FALSE;
        duration = 0;
    } else {
        enable = TRUE;
        duration = firstTimer->duration;
    }

    VP_INFO(VpDevCtxType, pDevCtx, ("VpSetDevTimerInt: %s %lu ", (enable ? "Enable" : "Disable"), duration));

    switch (pDevCtx->deviceType) {
#ifdef VP_CC_886_SERIES
    case VP_DEV_886_SERIES:
    case VP_DEV_887_SERIES:
        Vp886SetDeviceTimer(pDevCtx, enable, duration);
        break;
#endif /* VP_CC_886_SERIES */
    default:
        VP_ERROR(VpDevCtxType, pDevCtx, ("VpSetDevTimerInt: How did we get here? "));
        break;

    }
} /* VpSetDevTimerInt */
Example #3
0
/*
 * VpInitDevice()
 *  This function calibrates the device and initializes all lines (for which
 * line context has been created and intialized) on the device with the AC, DC,
 * and Ringing parameters passed. See VP-API reference guide for more
 * information.
 *
 * Preconditions:
 *  This function should be called only after creating and initializing the
 * device context and line context (atleast for those lines which need service).
 *
 * Postconditions:
 *  Device is calibrated and all lines (for whom line context has been created
 * and initialized) associated with this device are initialized with the AC, DC,
 * and Ringing Paramaters passed (DC and Ringing apply to FXS type lines only).
 */
VpStatusType
VpInitDevice(
    VpDevCtxType *pDevCtx,          /**< Pointer to device context for the
                                     * device that will be initialized
                                     */
    VpProfilePtrType pDevProfile,   /**< Pointer to Device Profile */
    VpProfilePtrType pAcProfile,    /**< Pointer to AC Profile that is applied
                                     * to all FXS lines on this device
                                     */
    VpProfilePtrType pDcProfile,    /**< Pointer to DC Profile that is applied
                                     * to all FXS lines on this device
                                     */
    VpProfilePtrType pRingProfile,  /**< Pointer to Ringing Profile that is
                                     * applied to all FXS lines on this device
                                     */
    VpProfilePtrType pFxoAcProfile, /**< Pointer to AC Profile that is applied
                                     * to all FXO lines on this device
                                     */
    VpProfilePtrType pFxoCfgProfile)/**< Pointer to Config Profile that is
                                     * applied to all FXO lines on this device
                                     */
{
    VpStatusType status;
    VP_API_ENTER(VpDevCtxType, pDevCtx, "InitDevice");

#if (VP_CC_DEBUG_SELECT & VP_DBG_INFO)
    VpPrintVpApiVersion();
#endif

    /* Basic argument checking */
    if (pDevCtx == VP_NULL) {
        VP_ERROR(VpDevCtxType, pDevCtx, ("InitDevice: Null Device Profile"));
        status = VP_STATUS_INVALID_ARG;
    } else {
        status = VP_CALL_DEV_FUNC(InitDevice, (pDevCtx, pDevProfile, pAcProfile, pDcProfile, pRingProfile, pFxoAcProfile, pFxoCfgProfile));
    }

    VP_API_EXIT(VpDevCtxType, pDevCtx, "InitDevice", status);
    return status;
} /* VpInitDevice() */
OMX_ERRORTYPE VideoProcessorComponent::VideoProcessor_ProcessData( OMX_PTR buf)
{
    OMX_ERRORTYPE eRetVal = OMX_ErrorNone;
    OMX_BUFFERHEADERTYPE *pOutBuffer;
    OMX_U32 size = 0;
    int ret;

    VP_DEBUG(" Process data %p\n",buf);

    /* call ipu task */
    ret = mxc_ipu_lib_task_buf_update(&ipu_handle, (int)buf, NULL, NULL, ipu_output_cb, this);
    if(ret < 0)
    {
        VP_ERROR("mxc_ipu_lib_task_buf_update failed.\n");
        SendEvent(OMX_EventError, OMX_ErrorHardware, 0, NULL);
        return OMX_ErrorHardware;
    }

    /* check if processing buffer is empty */
    if(pInBufHdr[0] == NULL)
    {
        VP_ERROR("processing buffer queue is empty.\n");
        SendEvent(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
        return OMX_ErrorUndefined;
    }

    if(bUseEGLImage == OMX_TRUE)
    {
        pOutBuffer = pOutBufHdr[0];
        pOutBufHdr[0] = pOutBufHdr[1];
        pOutBufHdr[1] = NULL;
    }
    else
        ports[VP_OUT_PORT]->GetBuffer(&pOutBuffer);

    pOutBuffer->nTimeStamp = pInBufHdr[0]->nTimeStamp;
    pOutBuffer->nFlags = pInBufHdr[0]->nFlags;

    /* return processed input buffer */
    ports[VP_IN_PORT]->SendBuffer(pInBufHdr[0]);
    pInBufHdr[0] = pInBufHdr[1];
    pInBufHdr[1] = NULL;

    if(pInBufHdr[0]->nFlags & OMX_BUFFERFLAG_EOS)
    {
        printf("VPP send EOS buffer.\n");
        pOutBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
    }

    /* check if need to flush previous frame */
    if(bFlush == OMX_FALSE)
    {
        size = (nOutWidth&(~7)) * nOutHeight * pxlfmt2bpp(eOutColorFmt)/8;
        if(bUseEGLImage != OMX_TRUE)
            fsl_osal_memcpy(pOutBuffer->pBuffer, ipu_handle.outbuf_start[nOutBufIdx], size);
        pOutBuffer->nFilledLen = size;
        pOutBuffer->nOffset = 0;
        nOutFrames++ ;

        //printf("Send eglImage: %p\n", pOutBuffer->pPlatformPrivate);

        ports[VP_OUT_PORT]->SendBuffer(pOutBuffer);
    }
    else
        bFlush = OMX_FALSE;

    VP_DEBUG(" Exit process data\n");
    return eRetVal;
}
OMX_ERRORTYPE VideoProcessorComponent::VideoProcessor_init( )
{
    OMX_ERRORTYPE eRetVal = OMX_ErrorNone;
    OMX_PARAM_PORTDEFINITIONTYPE sPortDef;
    OMX_BUFFERHEADERTYPE *pBufHdr;
    OMX_U32 nEGLImageWidth, nEGLImageHeight;
    int mode, ret;

    VP_DEBUG(" Begin Init\n");
    /* Get In/Out port format */
    omxSetHeader(&sPortDef,sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
    sPortDef.nPortIndex = VP_IN_PORT;
    ports[VP_IN_PORT]->GetPortDefinition( &sPortDef);
    nInWidth = sPortDef.format.video.nFrameWidth;
    nInHeight = sPortDef.format.video.nFrameHeight;
    eInColorFmt = sPortDef.format.video.eColorFormat;

    sPortDef.nPortIndex = VP_OUT_PORT;
    ports[VP_OUT_PORT]->GetPortDefinition(&sPortDef);
    nOutWidth = sPortDef.format.video.nFrameWidth;
    nOutHeight = sPortDef.format.video.nFrameHeight;
    eOutColorFmt = sPortDef.format.video.eColorFormat;

    if(sInRect.nWidth==0 && sInRect.nHeight==0)
    {
        sInRect.nWidth = nInWidth;
        sInRect.nHeight = nInHeight;
    }

    if( nOutWidth == 0 ||nOutHeight ==0 )
    {
        nOutWidth = 1024;
        sPortDef.format.video.nFrameWidth = nOutWidth;
        nOutHeight =  768;
        sPortDef.format.video.nFrameHeight = nOutHeight;
        eOutColorFmt = OMX_COLOR_Format16bitRGB565;
        sPortDef.format.video.eColorFormat = eOutColorFmt;
        ports[VP_OUT_PORT]->SetPortDefinition(&sPortDef);
    }

    /* set ipu task in parameter */
    sInParam.width = nInWidth;
    sInParam.height = nInHeight;
    sInParam.fmt = omx2ipu_pxlfmt(eInColorFmt);
    sInParam.input_crop_win.pos.x = (sInRect.nLeft + 7)/8*8;
    sInParam.input_crop_win.pos.y = sInRect.nTop;
    sInParam.input_crop_win.win_w = (sInRect.nWidth
                                     - (sInParam.input_crop_win.pos.x - sInRect.nLeft))/8*8;
    sInParam.input_crop_win.win_h = sInRect.nHeight;

    OMX_PTR pPhyAddr;
    ports[VP_IN_PORT]->GetBuffer( &pBufHdr);
    GetHwBuffer(pBufHdr->pBuffer, &pPhyAddr);
    sInParam.user_def_paddr[0] = (int)pPhyAddr;
    pInBufHdr[0] = pBufHdr;
    VP_DEBUG("VP Inbuffer 0 %p, offset %p\n",pBufHdr,pPhyAddr);
    ports[VP_IN_PORT]->GetBuffer( &pBufHdr);
    GetHwBuffer(pBufHdr->pBuffer, &pPhyAddr);
    sInParam.user_def_paddr[1] = (int)pPhyAddr;
    pInBufHdr[1] = pBufHdr;
    VP_DEBUG("VP Inbuffer 1 %p, offset %p\n",pBufHdr,pPhyAddr);

    VP_DEBUG("VP sInParam width %d, height %d,crop x %d, y %d, w %d, h %d, color %d\n",
             sInParam.width,sInParam.height ,
             sInParam.input_crop_win.pos.x,sInParam.input_crop_win.pos.y,
             sInParam.input_crop_win.win_w,sInParam.input_crop_win.win_h,
             sInParam.fmt
            );

    if(bUseEGLImage == OMX_TRUE)
    {
        ports[VP_OUT_PORT]->GetBuffer( &pBufHdr);
        EGLImageKHRInternal * eglImage = (EGLImageKHRInternal *)pBufHdr->pPlatformPrivate;
        sOutParam.user_def_paddr[0] = (int)eglImage->phyAddr;
        pOutBufHdr[0] = pBufHdr;

        nEGLImageWidth = eglImage->width;
        nEGLImageHeight = eglImage->height;
        OMX_S32 nImageSize = nEGLImageWidth * nEGLImageHeight * eglImage->bitsPerPixel / 8;
        fsl_osal_memset(eglImage->virtAddr, 0, nImageSize);

        ports[VP_OUT_PORT]->GetBuffer( &pBufHdr);
        eglImage = (EGLImageKHRInternal *)pBufHdr->pPlatformPrivate;
        sOutParam.user_def_paddr[1] = (int)eglImage->phyAddr;
        pOutBufHdr[1] = pBufHdr;
        fsl_osal_memset(eglImage->virtAddr,0,nImageSize);
    }

    /* set ipu task out parameter */
    sOutParam.width = nOutWidth;
    sOutParam.height = nOutHeight;
    sOutParam.fmt = omx2ipu_pxlfmt(eOutColorFmt);

    if(sOutRect.nWidth==0 && sOutRect.nHeight==0)
    {
        sOutRect.nWidth = nOutWidth;
        sOutRect.nHeight = nOutHeight;
    }

    /* calc out pos according to in fmt*/
    if(sInParam.input_crop_win.win_w * sOutRect.nHeight
            >= sInParam.input_crop_win.win_h * sOutRect.nWidth)
    {
        /* keep target width*/
        OMX_U32 height = sOutRect.nWidth
                         * sInParam.input_crop_win.win_h / sInParam.input_crop_win.win_w;
        sOutParam.output_win.win_w = sOutRect.nWidth;
        sOutParam.output_win.win_h = height;
        sOutParam.output_win.pos.x = 0;
        sOutParam.output_win.pos.y = (sOutRect.nHeight - height)/2;
    }
    else
    {
        /* keep target height*/
        OMX_U32 width = sOutRect.nHeight
                        * sInParam.input_crop_win.win_w / sInParam.input_crop_win.win_h;
        sOutParam.output_win.win_w = width;
        sOutParam.output_win.win_h = sOutRect.nHeight;
        sOutParam.output_win.pos.x = (( sOutRect.nWidth - width)/2 + 7)/8*8;
        sOutParam.output_win.pos.y = 0;
    }

    if(bUseEGLImage == OMX_TRUE)
    {
        sOutParam.width = nEGLImageWidth;
        sOutParam.height = nEGLImageHeight;
    }

    VP_DEBUG("VP sOutParam width %d, height %d,crop x %d, y %d, w %d, h %d,color %d\n",
             sOutParam.width,sOutParam.height ,
             sOutParam.output_win.pos.x,sOutParam.output_win.pos.y,
             sOutParam.output_win.win_w,sOutParam.output_win.win_h,
             sOutParam.fmt
            );
    /* ipu lib task init */
    mode = OP_STREAM_MODE;
    ret = mxc_ipu_lib_task_init(&sInParam, NULL, &sOutParam, mode, &ipu_handle);
    if(ret < 0)
    {
        VP_ERROR("mxc_ipu_lib_task_init failed!\n");
        return OMX_ErrorHardware;
    }
    nInFrames = 0;
    nOutFrames = 0;
    VP_DEBUG(" Exit Init\n");
    return eRetVal;
}
VpStatusType
Vp792MakeDeviceCtx(
    VpDevCtxType *pDevCtx,
    Vp792DeviceObjectType *pDevObj)
{
    uint8 channelCount;

    /* redundant checking of the object and context */
    if((pDevCtx == VP_NULL) || (pDevObj == VP_NULL)) {
        VP_ERROR(None, VP_NULL, ("VpMakeVp792DeviceCtx(): Device context and device object cannot be NULL"));
        return VP_STATUS_INVALID_ARG;
    }

    /* Initialize the members of device context */
    pDevCtx->pDevObj = pDevObj;
    pDevCtx->deviceType = VP_DEV_792_SERIES;

    /* Initialize all of the line context pointers to null */
    for (channelCount = 0; channelCount < pDevObj->maxChannels; channelCount++) {
        pDevCtx->pLineCtx[channelCount] = VP_NULL;
    }

    /* System Configuration function pointers */
    pDevCtx->funPtrsToApiFuncs.MakeLineObject = Vp792MakeLineObject;

    /* Initialization function pointers */
    pDevCtx->funPtrsToApiFuncs.InitDevice = Vp792InitDevice;
    pDevCtx->funPtrsToApiFuncs.InitLine = Vp792InitLine;
    pDevCtx->funPtrsToApiFuncs.ConfigLine = Vp792ConfigLine;
    pDevCtx->funPtrsToApiFuncs.CalCodec = Vp792CalCodec;
    pDevCtx->funPtrsToApiFuncs.CalLine = Vp792CalLine;
    pDevCtx->funPtrsToApiFuncs.InitRing = Vp792InitRing;
    pDevCtx->funPtrsToApiFuncs.InitCid = Vp792InitCid;
    pDevCtx->funPtrsToApiFuncs.InitMeter = Vp792InitMeter;
    pDevCtx->funPtrsToApiFuncs.InitProfile = Vp792InitProfile;
    pDevCtx->funPtrsToApiFuncs.SetBatteries = Vp792SetBatteries;

    /* Control function pointers */
    pDevCtx->funPtrsToApiFuncs.SetLineState = Vp792SetLineState;
    pDevCtx->funPtrsToApiFuncs.SetLineTone = Vp792SetLineTone;
    pDevCtx->funPtrsToApiFuncs.SetRelayState = Vp792SetRelayState;
    pDevCtx->funPtrsToApiFuncs.SetRelGain = Vp792SetRelGain;
    pDevCtx->funPtrsToApiFuncs.SendSignal = Vp792SendSignal;
    pDevCtx->funPtrsToApiFuncs.SendCid = Vp792SendCid;
    pDevCtx->funPtrsToApiFuncs.ContinueCid = Vp792ContinueCid;
    pDevCtx->funPtrsToApiFuncs.SetOption = Vp792SetOption;
    pDevCtx->funPtrsToApiFuncs.DeviceIoAccessExt = Vp792DeviceIoAccessExt;
    pDevCtx->funPtrsToApiFuncs.LineIoAccess = Vp792LineIoAccess;
    pDevCtx->funPtrsToApiFuncs.SetBFilter = Vp792SetBFilter;
    pDevCtx->funPtrsToApiFuncs.LowLevelCmd16 = Vp792LowLevelCmd16;
    pDevCtx->funPtrsToApiFuncs.StartMeter32Q = Vp792StartMeter32Q;

#ifdef VP792_INCLUDE_TESTLINE_CODE
    /* An incomplete imlementation of VpGenTimerCtrl() is used by the VoicePath
       Test Library.  VpGenTimerCtrl() is undocumented and not supported for
       VE792 devices. */
    pDevCtx->funPtrsToApiFuncs.GenTimerCtrl = Vp792GenTimerCtrl;
#endif

    /* Status and Query function pointers */
    pDevCtx->funPtrsToApiFuncs.GetEvent = Vp792GetEvent;
    pDevCtx->funPtrsToApiFuncs.GetLineStatus = Vp792GetLineStatus;
    pDevCtx->funPtrsToApiFuncs.GetDeviceStatusExt = Vp792GetDeviceStatusExt;
    pDevCtx->funPtrsToApiFuncs.GetLoopCond = Vp792GetLoopCond;
    pDevCtx->funPtrsToApiFuncs.GetOption = Vp792GetOption;
    pDevCtx->funPtrsToApiFuncs.FlushEvents = Vp792FlushEvents;
    pDevCtx->funPtrsToApiFuncs.GetResults = Vp792GetResults;
    pDevCtx->funPtrsToApiFuncs.ClearResults = Vp792ClearResults;
#if (VP_CC_DEBUG_SELECT && VP_DBG_INFO)
    pDevCtx->funPtrsToApiFuncs.ObjectDump = Vp792ObjectDump;
#endif

#ifdef VP792_INCLUDE_TESTLINE_CODE
    pDevCtx->funPtrsToApiFuncs.TestLine = Vp792TestLine;
#endif

    VP_API_INT_EXIT(None, VP_NULL, "Vp792MakeDeviceCtx", VP_STATUS_SUCCESS);
    return VP_STATUS_SUCCESS;
} /* VpMakeVp792DeviceCtx() */
Example #7
0
/*******************************************************************************
 * VpMakeVp890DeviceCtx()
 * This function initializes the device context to handle VP890 functionality.
 *
 * Arguments:
 *
 *  pDevCtx         -   Device Context to be initialized by other input
 *  pDevObj         -   Device Object to be pointed to by device context
 *
 * Preconditions:
 * This function should be called after initializing the device object. This
 * function can be called more than once without modifying the contents of the
 * device object.
 *
 * Postconditions:
 * Initializes device context to be able to handle VP890 functionality.
 ******************************************************************************/
VpStatusType
VpMakeVp890DeviceCtx(
    VpDevCtxType            *pDevCtx,
    Vp890DeviceObjectType   *pDevObj)
{
    uint8 channelCount, maxChan;

    /* redundant checking of the object and context */
    if((pDevCtx == VP_NULL) || (pDevObj == VP_NULL)) {
        VP_ERROR(None, VP_NULL, ("VpMakeVp890DeviceCtx() - Device context and device object cannot be NULL"));
        return VP_STATUS_INVALID_ARG;
    }
    /* Initialize the members of device context */
    pDevCtx->pDevObj    = pDevObj;
    pDevCtx->deviceType = VP_DEV_890_SERIES;

    /*
     * Initialize all of the line context pointers to null in the device context
     */
    maxChan = pDevObj->staticInfo.maxChannels;
    for (channelCount = 0; channelCount < maxChan; channelCount++) {
        pDevCtx->pLineCtx[channelCount] = VP_NULL;
    }

    /* System Configuration function pointers */
    pDevCtx->funPtrsToApiFuncs.MakeLineObject   = Vp890MakeLineObject;

    /* Initialization function pointers */
    pDevCtx->funPtrsToApiFuncs.InitDevice       = Vp890InitDevice;
    pDevCtx->funPtrsToApiFuncs.InitLine         = Vp890InitLine;
    pDevCtx->funPtrsToApiFuncs.ConfigLine       = Vp890ConfigLine;
    pDevCtx->funPtrsToApiFuncs.CalLine          = Vp890CalLine;
    pDevCtx->funPtrsToApiFuncs.Cal              = Vp890Cal;
    pDevCtx->funPtrsToApiFuncs.FreeRun   = Vp890FreeRun;

#ifdef CSLAC_SEQ_EN
    pDevCtx->funPtrsToApiFuncs.InitRing         = Vp890InitRing;
    pDevCtx->funPtrsToApiFuncs.InitCid          = Vp890InitCid;
    pDevCtx->funPtrsToApiFuncs.DtmfDigitDetected = VpCSLACDtmfDigitDetected;
    pDevCtx->funPtrsToApiFuncs.SendSignal       = Vp890SendSignal;
    pDevCtx->funPtrsToApiFuncs.SendCid          = Vp890SendCid;
    pDevCtx->funPtrsToApiFuncs.ContinueCid      = Vp890ContinueCid;
#endif
    pDevCtx->funPtrsToApiFuncs.InitProfile      = Vp890InitProf;

    /* Control function pointers */
    pDevCtx->funPtrsToApiFuncs.ApiTick          = Vp890ApiTick;
    pDevCtx->funPtrsToApiFuncs.VirtualISR       = Vp890VirtualISR;
    pDevCtx->funPtrsToApiFuncs.SetLineState     = Vp890SetLineState;
    pDevCtx->funPtrsToApiFuncs.SetLineTone      = Vp890SetLineTone;
    pDevCtx->funPtrsToApiFuncs.SetRelayState    = Vp890SetRelayState;
    pDevCtx->funPtrsToApiFuncs.SetRelGain       = Vp890SetRelGain;

    pDevCtx->funPtrsToApiFuncs.SetOption        = Vp890SetOption;
    pDevCtx->funPtrsToApiFuncs.DeviceIoAccess   = Vp890DeviceIoAccess;
    pDevCtx->funPtrsToApiFuncs.LowLevelCmd      = Vp890LowLevelCmd;

    /* Status and Query function pointers */
    pDevCtx->funPtrsToApiFuncs.GetEvent         = Vp890GetEvent;
    pDevCtx->funPtrsToApiFuncs.GetLineStatus    = VpCSLACGetLineStatus;
    pDevCtx->funPtrsToApiFuncs.GetDeviceStatus  = Vp890GetDeviceStatus;
    pDevCtx->funPtrsToApiFuncs.GetOption        = Vp890GetOption;
    pDevCtx->funPtrsToApiFuncs.FlushEvents      = Vp890FlushEvents;
    pDevCtx->funPtrsToApiFuncs.GetResults       = Vp890GetResults;
    pDevCtx->funPtrsToApiFuncs.ClearResults     = VpCSLACClearResults;
    pDevCtx->funPtrsToApiFuncs.GetRelayState    = Vp890GetRelayState;
#if 1//def VP_DEBUG
    pDevCtx->funPtrsToApiFuncs.RegisterDump     = Vp890RegisterDump;
#endif
    pDevCtx->funPtrsToApiFuncs.RegisterReadWrite= Vp890RegisterReadWrite;

#ifdef VP890_INCLUDE_TESTLINE_CODE
    pDevCtx->funPtrsToApiFuncs.TestLine         = Vp890TestLine;
    pDevCtx->funPtrsToApiFuncs.TestLineInt      = Vp890TestLineInt;
    pDevCtx->funPtrsToApiFuncs.TestLineCallback = Vp890TestLineCallback;
#endif

    return VP_STATUS_SUCCESS;
} /* VpMakeVp890DeviceCtx() */
Example #8
0
/*******************************************************************************
 * Vp890MakeLineObject()
 * This function
 *
 * Arguments:
 *
 * Preconditions:
 *
 * Postconditions:
 ******************************************************************************/
VpStatusType
Vp890MakeLineObject(
    VpTermType              termType,
    uint8                   channelId,
    VpLineCtxType           *pLineCtx,
    void                    *pVoidLineObj,
    VpDevCtxType            *pDevCtx)
{
    Vp890LineObjectType       *pLineObj = pVoidLineObj;
    Vp890DeviceObjectType     *pDevObj = pDevCtx->pDevObj;
    VpDeviceIdType            deviceId = pDevObj->deviceId;

    /* Basic error checking */
    if (channelId >= pDevObj->staticInfo.maxChannels) {
        VP_ERROR(VpDevCtxType, pDevCtx, ("Vp890MakeLineObject() - Bad channelId"));
        return VP_STATUS_INVALID_ARG;
    }
    if (VP_NUM_TERM_TYPES < termType) {
        VP_ERROR(VpDevCtxType, pDevCtx, ("Vp890MakeLineObject() - Termination type outside range"));
        return  VP_STATUS_ERR_VTD_CODE;
    }

    VpSysEnterCritical(deviceId, VP_CODE_CRITICAL_SEC);

    InitLineObject(pLineObj);

    /* Figure out if the line is an FXO or FXS */
    switch (termType) {
        case VP_TERM_FXO_GENERIC:
            if (channelId != 1) {
                VpSysExitCritical(deviceId, VP_CODE_CRITICAL_SEC);
                return VP_STATUS_INVALID_ARG;
            }
            pLineObj->status |= VP890_IS_FXO;

            /* FXO is always physical line 1 ([0:1] range). */
            pLineObj->channelId = 1;
            break;

        case VP_TERM_FXS_ISOLATE_LP:
        case VP_TERM_FXS_LOW_PWR:
        case VP_TERM_FXS_SPLITTER_LP:
            pDevObj->stateInt |= (VP890_LINE0_LP | VP890_LINE1_LP);

        case VP_TERM_FXS_GENERIC:
        case VP_TERM_FXS_SPLITTER:
        case VP_TERM_FXS_ISOLATE:
            pLineObj->channelId = channelId;
            pLineObj->status = VP890_INIT_STATUS;
            break;

        default:
            VP_ERROR(VpDevCtxType, pDevCtx, ("Vp890MakeLineObject() - Unsupported termination type"));
            VpSysExitCritical(deviceId, VP_CODE_CRITICAL_SEC);
            return VP_STATUS_ERR_VTD_CODE;
    }

    /* Initialize line context */
    pLineCtx->pLineObj  = pLineObj;
    pLineCtx->pDevCtx   = pDevCtx;

    /* Establish the link between device context to line context */
    pDevCtx->pLineCtx[channelId] = pLineCtx;

    /* Initialize line object */
    pLineObj->termType  = termType;

    /* Note that we are not initializing the 'lineId' member because we do not
     * know what it should be initialized (that information is not provided
     * through the VpMakeLineObj() function) and the basic type of this member
     * is defined by the customer and hence this variable could not have one
     * default value. */

    VpSysExitCritical(deviceId, VP_CODE_CRITICAL_SEC);

    return VP_STATUS_SUCCESS;
}  /* Vp890MakeLineObject() */