static int vpapi_cal_line(unsigned long arg) { VpApiModCalLnType data; VpLineIdType lineId; VpDeviceIdType deviceId; /* Get user data */ if(copy_from_user(&data, (void*)arg, sizeof(VpApiModCalLnType))) { printk("%s: copy_from_user failed\n", __func__); return -EFAULT; } lineId = GET_LINE(data.lineId); deviceId = GET_DEVICE(data.lineId); data.status = VpCalLine(&pLineCtx[deviceId][lineId]); if(data.status == VP_STATUS_SUCCESS) { total_lines++; REGISTER_LINE(data.lineId); } /* Copy status back to user */ if(copy_to_user((void*)arg, &data, sizeof(VpApiModCalLnType))) { printk("%s: copy_to_user failed\n", __func__); return -EFAULT; } return 0; }
/** * Function: alarmHandle() * * Description: This function is called at a periodic rate to perform all * required API operations. It implements the functional requirements of the * application mentioned in the header. */ void alarmHandle(int val) { VpStatusType status; VpEventType event; static bool deviceInitialized = FALSE; static uint8 cmpCounter = 0; /* * This loop will query the FXS device for events, and when an event is * found, it will parse the event and perform further operations. */ while(VpGetEvent(&devCtx, &event)) { /* Print the incoming event */ UtilPrintEvent(&event); /* See "../common/utils.c" */ /* * A channel under test should process all line events without * passing the events over to the main event handling loop */ if ((plineCtxUnderTest != NULL) && (plineCtxUnderTest == event.pLineCtx)) { ProcessLineTestEvent(&event); continue; } /* Parse the RESPONSE category */ if (event.eventCategory == VP_EVCAT_RESPONSE) { if(event.eventId == VP_DEV_EVID_DEV_INIT_CMP) { uint8 lineNum = 0; InitSetMasks(); QS_DEBUG("Device Initialization completed\n"); for (; lineNum < NB_LINE; lineNum++) { status = VpSetLineState(&lineCtx[lineNum], VP_LINE_STANDBY); if (status != VP_STATUS_SUCCESS) { QS_DEBUG("Error setting lineNum %i to VP_LINE_STANDBY: %s\n", lineNum, MapStatus(status)); exit(-1); } status = VpCalLine(&lineCtx[lineNum]); QS_DEBUG("Starting Calibration on lineNum %i\n", lineNum); if (status != VP_STATUS_SUCCESS) { QS_DEBUG("Error calling VpCalLine on lineNum %i:: %s\n", lineNum, MapStatus(status)); exit(-1); } } } else if (event.eventId == VP_EVID_CAL_CMP) { if (++cmpCounter == NB_LINE) { deviceInitialized = TRUE; QS_DEBUG("Calibration completed on both lines ... starting Line Test\n\n"); StartLineTest(0, LT_TID_LINE_V); } } } } /* end while(VpGetEvent(&devCtx, &event)) */ return; }
/* ** API : RtkInitFxsLine() ** Desp : Init Zarlink FXS line obj/ctx ** input : Realtek Line obj pointer ** return : SUCCESS/FAILED */ static BOOL RtkInitFxsLine(RTKLineObj *pLine) { VpStatusType status; VpOptionTimeslotType timeslot; PRINT_MSG("Initializing line %d\n",pLine->ch_id); /* Initialize the line with proper profile settings */ status = VpInitLine( pLine->pLineCtx, pLine->pAC_profile, pLine->pDCfxo_profile, pLine->pRing_profile); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpInitLine #%d failed (%d) \n",pLine->ch_id, status); return FAILED; } status = VpMapLineId (pLine->pLineCtx, pLine->ch_id); /* Set the initial line state */ status = VpSetLineState( pLine->pLineCtx, VP_LINE_STANDBY ); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpSetLineState failed (%d) \n", status); return FAILED; } /* Check if VP_LINE_EVID_LINE_INIT_CMP occurred */ if( TRUE != zarlinkWaitForEvent( pLine->pDev->pDevCtx, VP_EVCAT_RESPONSE, VP_LINE_EVID_LINE_INIT_CMP ) ) { PRINT_R("SLIC: ERROR: Line initialization was not completed\n"); return FAILED; } // Zarkink FAE said: cal of line may skip for 89 series /* Calibrate the line */ status = VpCalLine(pLine->pLineCtx); if ( (status != VP_STATUS_SUCCESS) && (status != VP_STATUS_FUNC_NOT_SUPPORTED) ) { PRINT_R("SLIC ERROR: %s line%d, status = %d \n", __FUNCTION__, __LINE__, status); return FAILED; } #if 1 //TODO vincent else if ( status == VP_STATUS_SUCCESS ) { /* Check if VP_EVID_CAL_CMP occurred */ if( TRUE != zarlinkWaitForEvent( pLine->pDev->pDevCtx, VP_EVCAT_RESPONSE, VP_EVID_CAL_CMP ) ) { PRINT_R("SLIC: ERROR: Line calibration was not completed\n"); return FAILED; } } #endif timeslot.tx = (uint8)pLine->slot_tx; timeslot.rx = (uint8)pLine->slot_rx; PRINT_MSG("FXS line TX/RX timeslot = %d/%d\n", pLine->slot_tx, pLine->slot_rx); /* Don't give device context (just give NULL) * if you are configuring any parameters for a specific line */ status = VpSetOption( pLine->pLineCtx, VP_NULL, VP_OPTION_ID_TIMESLOT, (void*)×lot ); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpSetOption for timeslot failed (%d) \n", status); } /* First time always try whatever codec type is set. ** If we get an invalid argument error we try linear */ status = VpSetOption( pLine->pLineCtx, VP_NULL, VP_OPTION_ID_CODEC, (void*)&pLine->codec_type ); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpSetOption for codec type failed. status = %d\n", status); return FAILED; } /* Thlin add for init ring cadence */ //PRINT_G("update ring cad profile = 0x%p, dev=%d\n", // ring_cad_profile, deviceId); status = VpInitRing( pLine->pLineCtx, pLine->pRing_cad_profile, VP_PTABLE_NULL); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpInitRing failed (%d) \n", status); return FAILED; } /* Thlin add for talk */ status = VpSetLineState( pLine->pLineCtx, VP_LINE_OHT ); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpSetLineState failed (%d) \n", status); return FAILED; } pLine->line_st = LINE_S_READY; PRINT_MSG("FXS #%d line initialized OK\n",pLine->ch_id); return SUCCESS; }