⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xp_osi_chann.c

📁 IBM source for pallas/vulcan/vesta
💻 C
📖 第 1 页 / 共 3 页
字号:
        }        if(wIndex < XP_CHANNEL_PES_MIN)        {            wIndex = XP_ERROR_CHANNEL_INUSE;        }        break;    }    /*------------------------------------------------------------------------+    |  Check for channel unavailable    |  Initialize the queue to disable    +------------------------------------------------------------------------*/    if(wIndex >= 0)    {        pGlobal->ChannInfo.XpChannelData[wIndex].Status         = XP_CHANNEL_DISABLED;        pGlobal->ChannInfo.XpChannelData[wIndex].UnloadType     = XP_CHANNEL_UNLOAD_UNDEFINED;        pGlobal->ChannInfo.XpChannelData[wIndex].Descram        = XP_DESCRAMBLE_OFF;        pGlobal->ChannInfo.XpChannelData[wIndex].uwKeyId        = 0;        flag = os_enter_critical_section();        xp_atom_dcr_reset_queue(pGlobal->uDeviceIndex,wIndex);        os_leave_critical_section(flag);    }//  xp_os_semaphore_signal();    return(wIndex);}/*----------------------------------------------------------------------------+|  xp0_channel_control+-----------------------------------------------------------------------------+||  DESCRIPTION:  define a queue for data unloaded on this channel||  PROTOTYPE  :  SHORT xp0_channel_control(|                SHORT wChannelId,|                XP_CHANNEL_CONTROL_TYPE Cmd)||  ARGUMENTS  :  wChannelId    -  the channel id as returned from the|                                 xp0_channel_allocate().|                Cmd           -  XP_CHANNEL_CONTROL_ENABLE|                                 XP_CHANNEL_CONTROL_DISABLE|                                 XP_CHANNEL_CONTROL_RESET||  RETURNS    :  0 if successful, or non-zero if an error occurs||  ERRORS     :  XP_ERROR_CHANNEL_INVALID  -  channel id is not defined||  COMMENTS   :  The XP_CHANNEL_CONTROL_ENABLE writes the pid filter in the|                demux hardware.  If the queue is properly set up, data is|                delivered to memory.|                The XP_CHANNEL_CONTROL_DISABLE writes the pid filter to NULL|                which prevents the arrival and processing of data.|                The XP_CHANNEL_CONTROL_RESET stops the current channel, and|                reset's the queue.|+----------------------------------------------------------------------------*/SHORT xp_osi_channel_control(GLOBAL_RESOURCES *pGlobal, SHORT wChannelId,                             XP_CHANNEL_CONTROL_TYPE Cmd){    SHORT wRc;    ULONG ulData;    UINT32  flag;//    xp_os_semaphore_wait();   PDEBUG("entering into xp_osi_channel_control\n");    wRc = xp_osi_channel_valid(pGlobal,wChannelId);    if(wRc == 0)    {        switch(Cmd)        {        case XP_CHANNEL_CONTROL_ENABLE:            pGlobal->ChannInfo.XpChannelData[wChannelId].Status = XP_CHANNEL_ENABLED;            PDEBUG("before xp_osi_channel_restart\n");            wRc = xp_osi_channel_restart(pGlobal,wChannelId);            PDEBUG("after xp_osi_channel_restart\n");            PDEBUG("after1 xp_osi_channel_restart\n");            PDEBUG("after2 xp_osi_channel_restart\n");            PDEBUG("after3 xp_osi_channel_restart\n");            PDEBUG("after4 xp_osi_channel_restart\n");            break;        case XP_CHANNEL_CONTROL_DISABLE:        /*------------------------------------------------------------+        |  Write the "stops" register to stop any "in-process" packets        |  from being delivered        |  clear any pending filter operations        |  clear the interrupts to get rid of any latent interrupts        +------------------------------------------------------------*/            ulData = (1 << (31 - wChannelId));            flag = os_enter_critical_section();            xp_atom_dcr_write(pGlobal->uDeviceIndex,XP_DCR_ADDR_QSTOPS, ulData);            os_leave_critical_section(flag);            xp_osi_filter_process_pending(pGlobal,wChannelId);            wRc = xp_osi_interrupt_channel_control(pGlobal,wChannelId,                                XP_INTERRUPT_CONTROL_RESET);              /*------------------------------------------------------------+              |  Disable the bucket pid              |  Stop packets in the front-end by              |  Setting the channel Pid to NULL              +------------------------------------------------------------*/            if(wChannelId == pGlobal->ChannInfo.wXpChannelBucketId)            {                flag = os_enter_critical_section();                xp_atom_dcr_write_register(pGlobal->uDeviceIndex,XP_BUCKET1Q_REG_BVALID, 0);                os_leave_critical_section(flag);            }            else            {                flag = os_enter_critical_section();                xp_atom_dcr_write_register_channel(pGlobal->uDeviceIndex,XP_PID_FILTER_REG_PIDV,                    wChannelId, XP_CHANNEL_NULL_PID);                os_leave_critical_section(flag);            }              pGlobal->ChannInfo.XpChannelData[wChannelId].Status = XP_CHANNEL_DISABLED;              break;        case XP_CHANNEL_CONTROL_RESET:              /*------------------------------------------------------------+              |  Disable the channel, and then reset the queue              +------------------------------------------------------------*/            if(pGlobal->ChannInfo.XpChannelData[wChannelId].Status != XP_CHANNEL_DISABLED)            {                xp_osi_channel_control(pGlobal,wChannelId, XP_CHANNEL_CONTROL_DISABLE);            }            wRc = xp_osi_queue_control(pGlobal,wChannelId, XP_QUEUE_CONTROL_RESET);            break;        default:            break;        }    }    PDEBUG("before return from xp_osi_channel_control\n");//  xp_os_semaphore_signal();    return(wRc);}/*----------------------------------------------------------------------------+|  xp0_channel_free+-----------------------------------------------------------------------------+||  DESCRIPTION:  free an allocated channel||  PROTOTYPE  :  SHORT xp0_channel_free(|                SHORT wChannelId)||  ARGUMENTS  :  wChannelId    -  id returned from xp0_channel_allocate()||  RETURNS    :  zero if channel was freed, non-zero if an error occurs||  ERRORS     :  XP_ERROR_CHANNEL_INVALID||  COMMENTS   :  This releases all resouwRces (queue's, filters) associated|                with this channel id.  Data is no longer delivered for|                this channel.|+----------------------------------------------------------------------------*/SHORT xp_osi_channel_free(GLOBAL_RESOURCES *pGlobal, SHORT wChannelId){    SHORT wRc;//    xp_os_semaphore_wait();    /*------------------------------------------------------------------------+    |  Check that the channel is valid, and then disable the channel    +------------------------------------------------------------------------*/    wRc = xp_osi_channel_control(pGlobal,wChannelId, XP_CHANNEL_CONTROL_DISABLE);    if(wRc == 0)    {    /*--------------------------------------------------------------------+    |  Remove all interrupt notification registrations    |  Free the queue and all filters    +--------------------------------------------------------------------*/        xp_osi_interrupt_channel_free(pGlobal,wChannelId);        xp_osi_queue_free(pGlobal,wChannelId);        xp_osi_filter_free_channel(pGlobal,wChannelId);        pGlobal->ChannInfo.XpChannelData[wChannelId].Status = XP_CHANNEL_UNUSED;		        if(wChannelId == pGlobal->ChannInfo.wXpChannelBucketId)          pGlobal->ChannInfo.wXpChannelBucketId = XP_CHANNEL_COUNT;    }//    xp_os_semaphore_signal();    return(wRc);}/*----------------------------------------------------------------------------+|  xp0_channel_get_available+----------------------------------------------------------------------------*/SHORT xp_osi_channel_get_available(GLOBAL_RESOURCES *pGlobal, XP_CHANNEL_TYPE Type){    SHORT wI;    SHORT wCount;//    xp_os_semaphore_wait();    switch(Type)    {    case XP_CHANNEL_TYPE_AUDIO:        wCount = (pGlobal->ChannInfo.XpChannelData[XP_CHANNEL_AUDIO].Status == XP_CHANNEL_UNUSED) ? 1 : 0;        break;    case XP_CHANNEL_TYPE_VIDEO:        wCount = (pGlobal->ChannInfo.XpChannelData[XP_CHANNEL_VIDEO].Status == XP_CHANNEL_UNUSED) ? 1 : 0;        break;    case XP_CHANNEL_TYPE_SUBTITLE:        wCount = (pGlobal->ChannInfo.XpChannelData[XP_CHANNEL_SUBTITLE].Status == XP_CHANNEL_UNUSED) ? 1 : 0;        break;    case XP_CHANNEL_TYPE_TELETEXT:        wCount = (pGlobal->ChannInfo.XpChannelData[XP_CHANNEL_TELETEXT].Status == XP_CHANNEL_UNUSED) ? 1 : 0;        break;    default:        for(wI=XP_CHANNEL_PES_MIN, wCount=0; wI<=XP_CHANNEL_PES_MAX; wI++)        {            if(pGlobal->ChannInfo.XpChannelData[wI].Status == XP_CHANNEL_UNUSED)            {                wCount++;            }        }        break;    }//  xp_os_semaphore_signal();    return(wCount);}/*----------------------------------------------------------------------------+|  xp0_channel_get_key+-----------------------------------------------------------------------------+||  DESCRIPTION:  get a packet identifier for the channel||  PROTOTYPE  :  SHORT xp0_channel_get_key(|                SHORT wChannelId,|                XP_CHANNEL_DESCRAMBLE *descram,|                USHORT *keyId)||  ARGUMENTS  :  wChannelId    -  id returned from xp0_channel_allocate()|                descram       -  type of descrambling for this channel|                keyId         -  key set number for descrambling keys||  RETURNS    :  zero if successful, non-zero if an error occurs||  ERRORS     :  XP_ERROR_CHANNEL_INVALID||  COMMENTS   :  The 'descram' and keyId value are returned.|+----------------------------------------------------------------------------*/SHORT xp_osi_channel_get_key(          /* get the current descrambling values  */                          GLOBAL_RESOURCES *pGlobal,                          SHORT wChannelId,                          XP_CHANNEL_DESCRAMBLE *pDescram,     /* 0=ts level, 1=PES, 2=none            */                          USHORT *pKeyId)              /* key number to use                    */{    SHORT     wRc;    ULONG     ulValue;    XP_PID_FILTER_REGP p;    UINT32  flag;//    xp_os_semaphore_wait();    wRc = xp_osi_channel_valid(pGlobal,wChannelId);    if(wRc == 0)    {        flag = os_enter_critical_section();        ulValue = xp_atom_dcr_read(pGlobal->uDeviceIndex,XP_DCR_ADDR_BASE_PID + wChannelId);        os_leave_critical_section(flag);        p = (XP_PID_FILTER_REGP)(void *)&ulValue;        if(p->denbl == 0)        {            *pDescram = XP_DESCRAMBLE_OFF;        }        else if(p->pesl == 0)        {            *pDescram = XP_DESCRAMBLE_TS;        }        else        {            *pDescram = XP_DESCRAMBLE_PES;        }        *pKeyId = p->kid;    }//    xp_os_semaphore_signal();    return(wRc);}/*----------------------------------------------------------------------------+|  xp0_channel_get_pid+-----------------------------------------------------------------------------+||  DESCRIPTION:  get a packet identifier for the channel||  PROTOTYPE  :  SHORT xp0_channel_get_pid(|                SHORT wChannelId,|                USHORT *p_pid)||  ARGUMENTS  :  wChannelId    -  id returned from xp0_channel_allocate()|                pid           -  packet identifier||  RETURNS    :  zero if successful, non-zero if an error occurs||  ERRORS     :  XP_ERROR_CHANNEL_INVALID||  COMMENTS   :  The pid value is returned at the location pointed to by|                the p_pid parameter.|+----------------------------------------------------------------------------*/SHORT xp_osi_channel_get_pid(GLOBAL_RESOURCES *pGlobal, SHORT wChannelId, USHORT *pPid){    SHORT wRc;//    xp_os_semaphore_wait();    wRc = xp_osi_channel_valid(pGlobal,wChannelId);    if(wRc == 0)    {        *pPid = pGlobal->ChannInfo.XpChannelData[wChannelId].uwPid;    }//    xp_os_semaphore_signal();    return(wRc);}/*----------------------------------------------------------------------------+|  xp0_channel_get_unload_type+-----------------------------------------------------------------------------+||  DESCRIPTION:  query the type of data to unload on this channel||  PROTOTYPE  :  SHORT xp0_channel_get_unload_type(|                SHORT wChannelId,|                XP_CHANNEL_UNLOAD_PTR p_unload_type)||  ARGUMENTS  :  wChannelId    -  the channel id as returned from the|                                 xp_channel_allocate().|                unload_type   -  type of data to unload||  RETURNS    :  0 if successful, or non-zero if an error occurs

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -