Пример #1
0
/*******************************************************************************
Description:
   sets CID buffer request size
Arguments:
   pCh      - pointer to the channel structure
   nSize    - Cid data size
Return:
   IFX_SUCCESS or IFX_ERROR
*******************************************************************************/
IFX_LOCAL IFX_int32_t setBrsCoef (VINETIC_CHANNEL *pCh, IFX_uint8_t nSize)
{
   VINETIC_DEVICE *pDev = pCh->pParent;
   IFX_uint16_t   pCmd [2] = {0}, pCoefs [6] = {0};
   IFX_int32_t    err = IFX_SUCCESS;

   /* disable cid sender */
   err = Dsp_SetCidSender (pCh, IFX_FALSE);
   /* read CID coefs and set BRS */
   if (err == IFX_SUCCESS)
   {
     /* set CID Coef read Command : ch = nResNr */
      pCmd [0] = (CMD1_EOP | (pCh->nChannel - 1));
      pCmd [1] = ECMD_CID_COEF;
      /* read CID sender Coefficients */
      err = CmdRead (pDev, pCmd, pCoefs, 4);
      /* set BRS and write back */
      if (err == IFX_SUCCESS)
      {
         /* overwrite BRS */
         if (nSize >= MAX_CID_LOOP_DATA)
            pCoefs [5] = MAX_CID_LOOP_DATA;
         else
            pCoefs [5] = nSize % MAX_CID_LOOP_DATA;
         /* write coefficients back */
         err = CmdWrite (pDev, pCoefs, 4);
      }
   }

   return err;
}
/**
   read CRC Value of DRAM/PRAM Firmware
\param
   pDev         - pointer to the device interface
\param
   ram          - P_RAM or D_RAM
\param
   StartAddr    - start address of sector
\param
   StopAddr     - stop address of the sector
\param
   count        - number of words to write
\param
   pCrc         - ptr to Crc value
\return
   IFX_SUCCESS or IFX_ERROR
Remark :
   following applies to calculate the PRAM stop address by given start address
   and number of words to write:

   - Pram addresses are even : 0x0, 0x2, ....., 0x2*n
   - Every instruction is 48 bits : 1 instruction = 3 Words
   - Every PRAM address points to 1 instruction : 0x2n -> Word1, Word2, Word3

   a PRAM buffer looks as follows:
   \code
   addresses |    Instructions

   0x0       ->  0xXXXX, 0xXXXX, 0xXXXX
   0x2       ->  0xXXXX, 0xXXXX, 0xXXXX
   0x4       ->  0xXXXX, 0xXXXX, 0xXXXX
   0x6       ->  0xXXXX, 0xXXXX, 0xXXXX
   0x8       ->  0xXXXX, 0xXXXX, 0xXXXX
   .
   .
   .
   0x2n      ->  0xXXXX, 0xXXXX, 0xXXXX
   \endcode
   so, if 9 Words are written at address 0x2, the stop address is 0x6 as example
*/
IFX_LOCAL IFX_int32_t readEdspCrc (VINETIC_DEVICE *pDev, VINETIC_FW_RAM ram,
                                   IFX_uint32_t StartAddr, IFX_uint32_t StopAddr,
                                   IFX_int32_t count, IFX_uint16_t *pCrc)
{
   IFX_int32_t err = IFX_SUCCESS;
   IFX_uint16_t pCmd[2] = {0}, pData [3] = {0};

   if (count == 0)
      return IFX_SUCCESS;

   /* fill command */
   pCmd[0] = CMD1_RD | CMD1_EOP | MEM_PAGE;
   /* set the crc-check variable */
   switch(ram)
   {
   case D_RAM:
      /* set CMD 1*/
      pCmd[1] = ECMD_CRC_DRAM;
      /* end addr = start addr + (word_length - 1) for one sector */
      if (StopAddr == 0)
         StopAddr = StartAddr + ((IFX_uint32_t)count - 1);
      break;
   case P_RAM:
      /* set cmd 1 */
      pCmd[1] = ECMD_CRC_PRAM;
      /* calculate stop address under following considerations :
         1-  instruction number = (words number / 3)
         2-  address jump   = 2 (even addresses)
         3-  address Offset = (instruction number - 1) * Address jump
         4-  stop address = Start address + address offset
      */
      if (StopAddr == 0)
      {
         StopAddr = StartAddr + ((((IFX_uint32_t)count/WORD_PER_INSTRUCT) - 1) *
                                PRAM_ADDRESS_JUMP);
      }
      if(StartAddr % 2 != 0 || StopAddr % 2 != 0)
      {
         SET_ERROR (ERR_FUNC_PARM);
         err = IFX_ERROR;
         TRACE (VINETIC, DBG_LEVEL_HIGH,
               ("ERROR: Given PRAM Start/Stop address not even!\n\r"));
      }
      break;
   }
   /* Set the RAM area for CRC calculation */
   if (err == IFX_SUCCESS)
      err = Dwld_setRAM(pDev, ram, StartAddr,StopAddr);
   /* Read the CRC */
   if (err == IFX_SUCCESS)
      err = CmdRead (pDev, pCmd, pData, 1);
   /* set CRC value */
   if (err == IFX_SUCCESS)
      *pCrc = pData [2];

   return err;
}
/**
   Write command to read data
\param
   pDev  - pointer to the device interface
\param
   pCmd  - pointer to command data
\return
    IFX_SUCCESS if no error, otherwise IFX_ERROR
*/
IFX_int32_t VINETIC_Read_Cmd (VINETIC_DEVICE * pDev, VINETIC_IO_MB_CMD * pCmd)
{
   IFX_int32_t err = CmdRead (pDev, (IFX_uint16_t *) pCmd,
                              (IFX_uint16_t *) pCmd, pCmd->cmd2 & CMD2_LEN);

   /* if read failed set the cmd length to 0 */
   if (err != IFX_SUCCESS)
      pCmd->cmd2 = 0;

   return err;
}
/*********************************************************************************
Description:
   This service enables or disables a high level path of a phone channel.
Arguments:
   pChannel - handle to TAPI_CONNECTION structure
   bEnable  - The parameter represent a boolean value of \ref IFX_TAPI_LINE_LEVEL_t.
               - 0: IFX_TAPI_LINE_LEVEL_DISABLE, disable the high level path.
               - 1: IFX_TAPI_LINE_LEVEL_ENABLE, enable the high level path.
Return:
   IFX_SUCCESS or IFX_ERROR
Remarks:
   This service is intended for phone channels only and must be used in
   combination with IFX_TAPI_PHONE_VOLUME_SET or IFX_TAPI_PCM_VOLUME_SET
   to set the max. level (IFX_TAPI_LINE_VOLUME_HIGH) or to restore level
*******************************************************************************/
IFX_int32_t TAPI_LL_Phone_High_Level(TAPI_CONNECTION *pChannel,
                                     IFX_int32_t bEnable)
{
   VINETIC_DEVICE  *pDev = (VINETIC_DEVICE *)pChannel->pDevice;
   VINETIC_CHANNEL *pCh  = &pDev->pChannel[pChannel->nChannel];
   IFX_int32_t      ret;

   CMD_OpMode_t     opmod;

   /* sanity check */
   if (pChannel->nChannel >= pDev->nAnaChan)
   {
      return(IFX_SUCCESS);
   }

   memset (&opmod, 0, sizeof (CMD_OpMode_t));
   opmod.RW      = VIN_CMD_RD;
   opmod.CMD     = VIN_CMD_ALM;
   opmod.MOD     = VIN_MOD_DCCTL;
   opmod.ECMD    = VIN_ECMD_OPMOD;
   opmod.CH      = pCh->nChannel -1;
   opmod.LENGTH  = 1;

   /* check current configuration */
   ret = CmdRead (pDev, (IFX_uint16_t *) &opmod, (IFX_uint16_t *) &opmod, 1);
   if (ret != IFX_SUCCESS)
      goto error;

   Vinetic_IrqLockDevice(pDev);
   opmod.RW      = VIN_CMD_WR;
   opmod.HOWLER  = bEnable ? VIN_OPMOD_HOWLER_ON : VIN_OPMOD_HOWLER_OFF;

   /* check if linemode was possibly set in interrupt context after reading
      the current status (onOvertemp it might have been changed to power down */
   if ((pChannel->TapiOpControlData.nLineMode
        == IFX_TAPI_LINE_FEED_DISABLED) &&
       (opmod.OP_MODE != VIN_OPMOD_PDH))
   {
      /* line has been switched to power down in the meantime */
      ret = IFX_ERROR;
   }
   else
   {
      IFXOS_MutexLock (pDev->mbxAcc);
      ret = CmdWriteIsr (pDev, (IFX_uint16_t *)((IFX_void_t *) &opmod), 1);
      IFXOS_MutexUnlock (pDev->mbxAcc);
   }
   Vinetic_IrqUnlockDevice(pDev);

error:
   return ret;
}
/**
This service generates an on or off hook event for the low level driver.
\param pChannel Handle to TAPI_CONNECTION structure
\return Return value according to IFX_return_t
   - IFX_ERROR if an error occured
   - IFX_SUCCESS if successful
\remarks
   The hook event then gets to the hook state machine for
   validation. Depending on the timing of calling this interface
   also hook flash and pulse dialing can be verified. */
IFX_return_t TAPI_LL_TestLoop (TAPI_CONNECTION *pChannel,
                               IFX_TAPI_TEST_LOOP_t* pLoop)
{
   VINETIC_DEVICE    *pDev = pChannel->pDevice;
   CMD_DCCTL_Debug_t  debugCfg;
   IFX_int32_t        err         = IFX_SUCCESS;

   memset (&debugCfg, 0, sizeof (CMD_DCCTL_Debug_t));
   debugCfg.CMD     = VIN_CMD_ALM;
   debugCfg.MOD     = VIN_MOD_DCCTL;
   debugCfg.ECMD    = CMD_DCCTL_DEBUG;

   /* read out first */
   debugCfg.RW      = VIN_CMD_RD;
   debugCfg.CH      = pChannel->nChannel;
   debugCfg.LENGTH  = 5;
   err = CmdRead (pDev, (IFX_uint16_t *)((IFX_void_t *)&debugCfg),
                        (IFX_uint16_t *)((IFX_void_t *)&debugCfg), 5);


   if (err != IFX_SUCCESS)
      goto error;

   /* enable or disable testloop */
   debugCfg.RW     = VIN_CMD_WR;

   if (pLoop->bAnalog)
   {
      debugCfg.data1  = 0x0001;
      debugCfg.data3 |= 0x8040;
   }
   else
   {
      debugCfg.data1  = 0x0000;
      debugCfg.data3 &= ~0x0040;
   }
   err = CmdWrite (pDev, (IFX_uint16_t *)((IFX_void_t *)&debugCfg), 5);

error:
   return err;
}
/*******************************************************************************
Description:
   Prepare parameters and call the Target Configuration Function to switch the
   line mode.
Arguments:
   pChannel        - handle to TAPI_CONNECTION structure
   nMode           - linefeed mode
Return:
   IFX_SUCCESS or IFX_ERROR
*******************************************************************************/
IFX_int32_t TAPI_LL_Phone_SwitchLine (TAPI_CONNECTION *pChannel,
                                      IFX_int32_t nMode)
{
   VINETIC_DEVICE  *pDev = (VINETIC_DEVICE *)pChannel->pDevice;
   VINETIC_CHANNEL *pCh  = &pDev->pChannel[pChannel->nChannel];
   IFX_int32_t      ret;
   CMD_OpMode_t     opmod;

   /* sanity check */
   if (pChannel->nChannel >= pDev->nAnaChan)
   {
      return(IFX_SUCCESS);
   }

   memset (&opmod, 0, sizeof (CMD_OpMode_t));
   opmod.RW      = VIN_CMD_RD;
   opmod.CMD     = VIN_CMD_ALM;
   opmod.MOD     = VIN_MOD_DCCTL;
   opmod.ECMD    = VIN_ECMD_OPMOD;
   opmod.CH      = pCh->nChannel -1;
   opmod.LENGTH  = 1;

   /* check current configuration */
   ret = CmdRead (pDev, (IFX_uint16_t *)((IFX_void_t *) &opmod),
                  (IFX_uint16_t *)((IFX_void_t *) &opmod), 1);
   if (ret != IFX_SUCCESS)
      goto error;

   /* check if transition is valid, prepare command */
   opmod.RW      = VIN_CMD_WR;

   switch (nMode)
   {
      case IFX_TAPI_LINE_FEED_ACTIVE:
      case IFX_TAPI_LINE_FEED_RING_PAUSE:
      /* for backward compatibility only */
      case IFX_TAPI_LINE_FEED_NORMAL_AUTO:
      case IFX_TAPI_LINE_FEED_ACTIVE_LOW:
      case IFX_TAPI_LINE_FEED_ACTIVE_BOOSTED:
         switch (opmod.OP_MODE)
         {
            case VIN_OPMOD_ACT:
            case VIN_OPMOD_RING:
            case VIN_OPMOD_ONHOOK:
               opmod.OP_MODE = VIN_OPMOD_ACT;
               /* in case of ring pause, leave reverse
                  polarity bit as is */
               if (nMode != IFX_TAPI_LINE_FEED_RING_PAUSE)
                  opmod.REV_POL = VIN_OPMOD_POL_NORMAL;
               break;
            default:
               ret = IFX_ERROR;
               goto error;
         }
         break;
      case IFX_TAPI_LINE_FEED_ACTIVE_REV:
      /* for backward compatibility only */
      case IFX_TAPI_LINE_FEED_REVERSED_AUTO:
      case IFX_TAPI_LINE_FEED_PARKED_REVERSED:
         switch (opmod.OP_MODE)
         {
            case VIN_OPMOD_ACT:
            case VIN_OPMOD_RING:
            case VIN_OPMOD_ONHOOK:
               opmod.OP_MODE = VIN_OPMOD_ACT;
               opmod.REV_POL = VIN_OPMOD_POL_REVERSE;
               break;
            default:
               ret = IFX_ERROR;
               goto error;
         }
         break;
      case IFX_TAPI_LINE_FEED_STANDBY:
         switch (opmod.OP_MODE)
         {
            case VIN_OPMOD_ACT:
            case VIN_OPMOD_RING:
            case VIN_OPMOD_ONHOOK:
            case VIN_OPMOD_PDH:
               opmod.OP_MODE = VIN_OPMOD_ONHOOK;
               opmod.REV_POL = VIN_OPMOD_POL_NORMAL;
               break;
            default:
               ret = IFX_ERROR;
               goto error;
         }
         break;
      case IFX_TAPI_LINE_FEED_DISABLED:
         opmod.OP_MODE = VIN_OPMOD_PDH;
         opmod.REV_POL = VIN_OPMOD_POL_NORMAL;
         break;
      case IFX_TAPI_LINE_FEED_RING_BURST:
         switch (opmod.OP_MODE)
         {
            case VIN_OPMOD_ACT:        /* check for hook in case of active? */
            case VIN_OPMOD_RING:
            case VIN_OPMOD_ONHOOK:
               /* leave reversal bit as is */
               opmod.OP_MODE = VIN_OPMOD_RING;
               break;
            default:
               ret = IFX_ERROR;
               goto error;
         }
         break;
      /* unsupported linemodes */
      case IFX_TAPI_LINE_FEED_HIGH_IMPEDANCE:
      case IFX_TAPI_LINE_FEED_GROUND_START:
      case IFX_TAPI_LINE_FEED_METER:
      case IFX_TAPI_LINE_FEED_ACT_TEST:
      case IFX_TAPI_LINE_FEED_ACT_TESTIN:
      case IFX_TAPI_LINE_FEED_DISABLED_RESISTIVE_SWITCH:
      default:
         ret = IFX_ERROR;
         goto error;
   }

   Vinetic_IrqLockDevice(pDev);
   /* now that we are protected against interrupts, check if linemode was
      possibly set in interrupt context after reading the current status
      (onOvertemp it might have been changed to power down).
      All automatic mode changes are save and would allow changes to
      other operating modes. */

   if ((pChannel->TapiOpControlData.nLineMode
        == IFX_TAPI_LINE_FEED_DISABLED) &&
       (opmod.OP_MODE != VIN_OPMOD_PDH))
   {
      ret = IFX_ERROR;
   }
   else
   {
      IFXOS_MutexLock (pDev->mbxAcc);
      ret = CmdWriteIsr (pDev, (IFX_uint16_t *)((IFX_void_t *) &opmod), 1);
      IFXOS_MutexUnlock (pDev->mbxAcc);
   }

   Vinetic_IrqUnlockDevice(pDev);

error:
   return ret;
}
Пример #7
0
void handle_request(LIBBASETYPEPTR LIBBASE, struct IOSana2Req *request)
{
    BOOL complete;

    switch(request->ios2_Req.io_Command)
    {
        case CMD_READ:
            complete = CmdRead(LIBBASE, request);
            break;

        case CMD_WRITE:
        case S2_MULTICAST:
            complete = CmdWrite(LIBBASE, request);
            break;

        case CMD_FLUSH:
            complete = CmdFlush(LIBBASE, (struct IORequest *)request);
            break;

        case S2_DEVICEQUERY:
            complete = CmdS2DeviceQuery(LIBBASE, request);
            break;

        case S2_GETSTATIONADDRESS:
            complete = CmdGetStationAddress(LIBBASE, request);
            break;

        case S2_CONFIGINTERFACE:
            complete = CmdConfigInterface(LIBBASE, request);
            break;

        case S2_BROADCAST:
            complete = CmdBroadcast(LIBBASE, request);
            break;

        case S2_TRACKTYPE:
            complete = CmdTrackType(LIBBASE, request);
            break;

        case S2_UNTRACKTYPE:
            complete = CmdUntrackType(LIBBASE, request);
            break;

        case S2_GETTYPESTATS:
            complete = CmdGetTypeStats(LIBBASE, request);
            break;

        case S2_GETGLOBALSTATS:
            complete = CmdGetGlobalStats(LIBBASE, request);
            break;

        case S2_ONEVENT:
            complete = CmdOnEvent(LIBBASE, request);
            break;

        case S2_READORPHAN:
            complete = CmdReadOrphan(LIBBASE, request);
            break;

        case S2_ONLINE:
            complete = CmdOnline(LIBBASE, request);
            break;

        case S2_OFFLINE:
            complete = CmdOffline(LIBBASE, request);
            break;

        case S2_ADDMULTICASTADDRESS:
        case S2_ADDMULTICASTADDRESSES:
            complete = CmdAddMulticastAddresses(LIBBASE, request);
            break;

        case S2_DELMULTICASTADDRESS:
        case S2_DELMULTICASTADDRESSES:
            complete = CmdDelMulticastAddresses(LIBBASE, request);
            break;

        case NSCMD_DEVICEQUERY:
            complete = CmdDeviceQuery(LIBBASE, (struct IOStdReq *)request);
            break;

        default:
            complete = CmdInvalid(LIBBASE, request);
    }

    if(complete && (request->ios2_Req.io_Flags & IOF_QUICK) == 0)
        ReplyMsg((APTR)request);

    ReleaseSemaphore(&((struct SiS900Unit *)request->ios2_Req.io_Unit)->sis900u_unit_lock);
}
Пример #8
0
VOID ServiceRequest(struct IOSana2Req *request, struct DevBase *base)
{
   BOOL complete;

   switch(request->ios2_Req.io_Command)
   {
   case CMD_READ:
      complete = CmdRead(request, base);
      break;
   case CMD_WRITE:
      complete = CmdWrite(request, base);
      break;
   case CMD_FLUSH:
      complete = CmdFlush((APTR)request, base);
      break;
   case S2_DEVICEQUERY:
      complete = CmdS2DeviceQuery(request, base);
      break;
   case S2_GETSTATIONADDRESS:
      complete = CmdGetStationAddress(request, base);
      break;
   case S2_CONFIGINTERFACE:
      complete = CmdConfigInterface(request, base);
      break;
   case S2_ADDMULTICASTADDRESS:
      complete = CmdAddMulticastAddresses(request, base);
      break;
   case S2_DELMULTICASTADDRESS:
      complete = CmdDelMulticastAddresses(request, base);
      break;
   case S2_MULTICAST:
      complete = CmdWrite(request, base);
      break;
   case S2_BROADCAST:
      complete = CmdBroadcast(request, base);
      break;
   case S2_TRACKTYPE:
      complete = CmdTrackType(request, base);
      break;
   case S2_UNTRACKTYPE:
      complete = CmdUntrackType(request, base);
      break;
   case S2_GETTYPESTATS:
      complete = CmdGetTypeStats(request, base);
      break;
   case S2_GETSPECIALSTATS:
      complete = CmdGetSpecialStats(request, base);
      break;
   case S2_GETGLOBALSTATS:
      complete = CmdGetGlobalStats(request, base);
      break;
   case S2_ONEVENT:
      complete = CmdOnEvent(request, base);
      break;
   case S2_READORPHAN:
      complete = CmdReadOrphan(request, base);
      break;
   case S2_ONLINE:
      complete = CmdOnline(request, base);
      break;
   case S2_OFFLINE:
      complete = CmdOffline(request, base);
      break;
   case NSCMD_DEVICEQUERY:
      complete = CmdDeviceQuery((APTR)request, base);
      break;
   case S2_ADDMULTICASTADDRESSES:
      complete = CmdAddMulticastAddresses(request, base);
      break;
   case S2_DELMULTICASTADDRESSES:
      complete = CmdDelMulticastAddresses(request, base);
      break;
   case P2_GETSIGNALQUALITY:
      complete = CmdGetSignalQuality(request, base);
      break;
   default:
      complete = CmdInvalid(request, base);
   }

   if(complete && ((request->ios2_Req.io_Flags & IOF_QUICK) == 0))
      ReplyMsg((APTR)request);

   ReleaseSemaphore(
      &((struct DevUnit *)request->ios2_Req.io_Unit)->access_lock);
   return;
}