void InitSetMasks(void) { VpOptionEventMaskType eventMask; /* mask everything */ VpMemSet(&eventMask, 0xFF, sizeof(VpOptionEventMaskType)); /* unmask only the events the application is interested in */ eventMask.faults = VP_EVCAT_FAULT_UNMASK_ALL; eventMask.signaling = VP_EVCAT_SIGNALING_UNMASK_ALL | VP_DEV_EVID_TS_ROLLOVER; eventMask.response = VP_EVCAT_RESPONSE_UNMASK_ALL; eventMask.test = VP_EVCAT_TEST_UNMASK_ALL; eventMask.process = VP_EVCAT_PROCESS_UNMASK_ALL; /* inform the API of the mask */ VpSetOption(VP_NULL, &devCtx, VP_OPTION_ID_EVENT_MASK, &eventMask); return; }
/* ** API : RtkInitFxoLine() ** Desp : Init Zarlink FXO line obj/ctx ** input : Realtek Line obj pointer ** return : SUCCESS/FAILED */ static BOOL RtkInitFxoLine(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 failed (%d) \n", status); return FAILED; } /* Set the initial line state */ status = VpSetLineState( pLine->pLineCtx, VP_LINE_FXO_OHT ); 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; } /* TODO Calibrate the line if needing */ timeslot.tx = (uint8)pLine->slot_tx; timeslot.rx = (uint8)pLine->slot_rx; PRINT_MSG("FXO 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 talk */ status = VpSetLineState( pLine->pLineCtx, VP_LINE_FXO_OHT ); if ( status != VP_STATUS_SUCCESS ) { PRINT_R("VpSetLineState failed (%d) \n", status); return FAILED; } pLine->line_st = LINE_S_READY; PRINT_MSG("FXO #%d line initialized OK\n",pLine->ch_id); return SUCCESS; }
/* ** 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; }
static int vpapi_set_option(unsigned long arg) { VpApiModSetOptionType data; u8 lineRequest; VpLineIdType lineId; VpDeviceIdType deviceId; VpOptionIdType option; void *pOptInfo; long size; /* Get user data */ if(copy_from_user(&data, (void*)arg, sizeof(VpApiModSetOptionType))) { printk("%s: copy_from_user failed\n", __func__); return -EFAULT; } option = data.option; lineRequest = data.lineRequest; deviceId = data.deviceId; lineId = GET_LINE(data.lineId); switch(option) { case VP_OPTION_ID_TIMESLOT: size = sizeof(VpOptionTimeslotType); pOptInfo = (VpOptionTimeslotType*)kmalloc(size, GFP_KERNEL); break; case VP_OPTION_ID_CODEC: size = sizeof(VpOptionCodecType); pOptInfo = (VpOptionCodecType*)kmalloc(size, GFP_KERNEL); break; case VP_OPTION_ID_LOOPBACK: size = sizeof(VpOptionLoopbackType); pOptInfo = (VpOptionLoopbackType*)kmalloc(size, GFP_KERNEL); break; case VP_OPTION_ID_EVENT_MASK: size = sizeof(VpOptionEventMaskType); pOptInfo = (VpOptionEventMaskType*)kmalloc(size, GFP_KERNEL); break; case VP_OPTION_ID_LINE_STATE: size = sizeof(VpOptionLineStateType); pOptInfo = (VpOptionLineStateType*)kmalloc(size, GFP_KERNEL); break; default: printk("%s: option(%d) not supported\n",__func__, option); return -EFAULT; } /* Get option info */ if(copy_from_user(pOptInfo, (void*)data.pValue, size)) { printk("%s: copy_from_user failed\n", __func__); kfree(pOptInfo); return -EFAULT; } /* Set option to line/device */ if(lineRequest) data.status = VpSetOption(&pLineCtx[deviceId][lineId], VP_NULL, option, pOptInfo); else data.status = VpSetOption(VP_NULL, &pDevCtx[deviceId], option, pOptInfo); kfree(pOptInfo); /* Copy status back to user */ if(copy_to_user((void*)arg, &data, sizeof(VpApiModSetOptionType))) { printk("%s: copy_to_user failed\n", __func__); return -EFAULT; } return 0; }