static int vpapi_map_line_id(unsigned long arg) { VpApiModMapLnIdType data; VpLineIdType lineId; VpDeviceIdType deviceId; /* Get user data */ if(copy_from_user(&data, (void*)arg, sizeof(VpApiModMapLnIdType))) { printk("%s: copy_from_user failed\n", __func__); return -EFAULT; } lineId = GET_LINE(data.lineId); deviceId = GET_DEVICE(data.lineId); data.status = VpMapLineId(&pLineCtx[deviceId][lineId], data.lineId); /* Copy status back to user */ if(copy_to_user((void*)arg, &data, sizeof(VpApiModMapLnIdType))) { printk("%s: copy_to_user failed\n", __func__); return -EFAULT; } return 0; }
/* ** 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; }