📄 xp_osd_drv.c
字号:
switch (pDmxfilter->type) { case FILTER_TYPE_SEC: os_get_mutex(hMutex); rc = xp_osi_filter_control(pGlobal,(short)pDmxfilter->fid, XP_FILTER_CONTROL_ENABLE); os_release_mutex(hMutex); if (rc) { printk("DemuxFilterStart(): Error enabling Section filter\n"); return(-1); } if ((pDmxfilter->chid != ILLEGAL_CHANNEL) && (pDemuxDev->chid[pDmxfilter->chid].state != XP_CHANNEL_ENABLED)) { os_get_mutex(hMutex); rc = xp_osi_channel_control(pGlobal,(short)pDmxfilter->chid, XP_CHANNEL_CONTROL_ENABLE); os_release_mutex(hMutex); if (rc) { printk("DemuxFilterStart(): Error enabling section channel\n"); return(-1); } pDemuxDev->chid[pDmxfilter->chid].state = XP_CHANNEL_ENABLED; } break; case FILTER_TYPE_TS: os_get_mutex(hMutex); rc = xp_osi_channel_control(pGlobal,(short)pDmxfilter->chid, XP_CHANNEL_CONTROL_ENABLE); os_release_mutex(hMutex); if (rc) { printk("DemuxFilterStart(): Error enabling TS channel\n"); return(-1); } xp_osi_start_parse_bypass(pGlobal); break; case FILTER_TYPE_PES: //If the PES type is PCR, enable the pcr processing if (pDmxfilter->pes_para.pesType == DMX_PES_PCR) { os_get_mutex(hMutex); xp_osi_pcr_cchan_auto(pGlobal,pDmxfilter->pid); os_release_mutex(hMutex); break; } os_get_mutex(hMutex); rc = xp_osi_channel_control(pGlobal,(short)pDmxfilter->chid, XP_CHANNEL_CONTROL_ENABLE); os_release_mutex(hMutex); if (rc) { printk("DemuxFilterStart(): Error enabling PES channel\n"); return(-1); } break; case FILTER_TYPE_BUCKET: //osi reg = 0; pBucket = (void *)® pBucket->bqdt = 1; pBucket->bvalid = 1; pBucket->indx = pDmxfilter->chid; flag = os_enter_critical_section(); xp_atom_dcr_write(pGlobal->uDeviceIndex,XP_DCR_ADDR_BUCKET1Q,reg); os_leave_critical_section(flag); break; default: return(-EINVAL); } pDmxfilter->states = FILTER_STAT_START; return(0);}/*----------------------------------------------------------------------------+| DemuxFilterReset|| DESCRIPTION: This function is used to reset the filter to its initial state+----------------------------------------------------------------------------*/static int DemuxFilterReset( GLOBAL_RESOURCES *pGlobal, DEMUX_FILTER *pDmxfilter){ int rc = 0; DEMUX_DEVICE *pDemuxDev; PDEBUG("DemuxFilterReset(): Entering - pDmxfilter->type=%d\n", pDmxfilter->type); pDemuxDev = pDemux_dev[pGlobal->uDeviceIndex]; switch (pDmxfilter->type) { case FILTER_TYPE_SEC: if (pDmxfilter->states > FILTER_STAT_READY) { DemuxFilterStop(pGlobal,pDmxfilter); } os_get_mutex(hMutex); if (pDmxfilter->chid != ILLEGAL_CHANNEL) { pDemuxDev->chid[pDmxfilter->chid].inuse--; } os_release_mutex(hMutex); interruptible_sleep_on_timeout(&temp_queue,40); os_get_mutex(hMutex); if ((pDmxfilter->chid != ILLEGAL_CHANNEL) && (pDemuxDev->chid[pDmxfilter->chid].inuse == 0)) { xp_osi_channel_free(pGlobal,pDmxfilter->chid); pDemuxDev->chid[pDmxfilter->chid].state = XP_CHANNEL_UNUSED; } else { if ((pDmxfilter->fid != ILLEGAL_FILTER) && (pDemuxDev->chid[pDmxfilter->chid].inuse >0)) { if (xp_osi_filter_delete_from_channel(pGlobal, pDmxfilter->chid, pDmxfilter->fid)) { printk("DemuxFilterReset(): Error deleting section filter from channel\n"); } if (xp_osi_filter_free(pGlobal,pDmxfilter->fid)) { printk("DemuxFilterReset(): Error freeing section filter\n"); } } } os_release_mutex(hMutex); pDmxfilter->chid = (short) ILLEGAL_CHANNEL; pDmxfilter->fid = (short) ILLEGAL_FILTER; break; case FILTER_TYPE_PES: if (pDmxfilter->states > FILTER_STAT_READY) { DemuxFilterStop(pGlobal,pDmxfilter); } if (pDmxfilter->chid != (short) ILLEGAL_CHANNEL && pDmxfilter->pes_para.output == OUT_MEMORY) { os_get_mutex(hMutex); xp_osi_channel_free(pGlobal,pDmxfilter->chid); os_release_mutex(hMutex); } pDmxfilter->chid = (short) ILLEGAL_CHANNEL; break; case FILTER_TYPE_TS: if (pDmxfilter->states > FILTER_STAT_READY) { DemuxFilterStop(pGlobal,pDmxfilter); } os_get_mutex(hMutex); xp_osi_channel_free(pGlobal,pDmxfilter->chid); os_release_mutex(hMutex); pDmxfilter->chid = (short) ILLEGAL_CHANNEL; break; case FILTER_TYPE_BUCKET: if (pDmxfilter->states > FILTER_STAT_READY) { DemuxFilterStop(pGlobal,pDmxfilter); } os_get_mutex(hMutex); xp_osi_channel_free(pGlobal,pDmxfilter->chid); os_release_mutex(hMutex); pDmxfilter->chid = (short) ILLEGAL_CHANNEL; break; default: rc = -EINVAL; break; } //re-init the circular buffer pDmxfilter->buffer.ulRead = 0; pDmxfilter->buffer.ulWrite = -1; pDmxfilter->buffer.count = 0; pDmxfilter->states = FILTER_STAT_ALLOC; return(rc);}/*----------------------------------------------------------------------------+| DemuxChannelAcquire+----------------------------------------------------------------------------*/static short DemuxChannelAcquire( GLOBAL_RESOURCES *pGlobal, DEMUX_FILTER *pDmxfilter, DEMUX_CHANNEL_ACQUIRE_PTR pDemuxAcq){ DEMUX_DEVICE *pDemuxDev; UINT32 flag; short rc=0; pDemuxDev = pDemux_dev[pGlobal->uDeviceIndex]; pDmxfilter->chid = ILLEGAL_CHANNEL; os_get_mutex(hMutex); /*------------------------------------------------------------------------+ | Allocate Channel and set Unload Type +------------------------------------------------------------------------*/ rc = xp_osi_channel_allocate(pGlobal,pDemuxAcq->channel_type); if (rc >= 0) { pDmxfilter->chid = rc; rc = 0; } if (rc == 0) { if (pDemuxAcq->unload_type != XP_CHANNEL_UNLOAD_UNDEFINED) { rc = xp_osi_channel_set_unload_type(pGlobal,pDmxfilter->chid, pDemuxAcq->unload_type); } } /*------------------------------------------------------------------------+ | Allocate and Enable Queue +------------------------------------------------------------------------*/ if (pDemuxAcq->queue_size > 0) { if (rc == 0) { rc = xp_osi_queue_allocate(pGlobal,pDmxfilter->chid,pDemuxAcq->queue_size); } if (rc == 0) { rc = xp_osi_queue_get_config(pGlobal,pDmxfilter->chid, &pDmxfilter->buffer.plBQueue, &pDmxfilter->buffer.plEQueue); } /*---------------------------------------------------------------------+ | Set Notification Function +---------------------------------------------------------------------*/ if (rc == 0) { if (pDemuxAcq->notify_data_fn != NULL) { rc = xp_osi_channel_set_notification_fn(pGlobal,pDmxfilter->chid, pDemuxAcq->notify_data_fn); } } /*---------------------------------------------------------------------+ | Set Boundary Threshold +---------------------------------------------------------------------*/ if (rc == 0) { flag = os_enter_critical_section(); xp_atom_dcr_write_register_channel(pGlobal->uDeviceIndex, XP_QCONFIGA_REG_BTHRES,pDmxfilter->chid,pDemuxAcq->bthreshold); os_leave_critical_section(flag); } if (rc == 0) { rc = xp_osi_queue_control(pGlobal,pDmxfilter->chid,XP_QUEUE_CONTROL_ENABLE); } } /*------------------------------------------------------------------------+ | Set PID and Disable Channel +------------------------------------------------------------------------*/ if (rc == 0) { if (pDemuxAcq->pid <= XP_CHANNEL_NULL_PID) { rc = xp_osi_channel_set_pid(pGlobal,pDmxfilter->chid,pDemuxAcq->pid); } } if (rc == 0) { rc = xp_osi_channel_control(pGlobal,pDmxfilter->chid,XP_CHANNEL_CONTROL_DISABLE); } /*------------------------------------------------------------------------+ | Check and Process Errors +------------------------------------------------------------------------*/ if (rc != 0) { if (pDmxfilter->chid != ILLEGAL_CHANNEL) { xp_osi_channel_free(pGlobal,pDmxfilter->chid); pDmxfilter->chid = ILLEGAL_CHANNEL; } } os_release_mutex(hMutex); if (pDemuxAcq->queue_size < pDemuxAcq->bthreshold*256) { PDEBUG("DemuxChannelAcquire(): Warning - Queue is less than Threshold\n"); } PDEBUG("DemuxChannelAcquire(): pDmxfilter->chid=%d, pDemuxAcq->pid=0x%x\n", pDmxfilter->chid, pDemuxAcq->pid); return(rc);}/*----------------------------------------------------------------------------+| DemuxFilterAcquire+----------------------------------------------------------------------------*/static short DemuxFilterAcquire( GLOBAL_RESOURCES *pGlobal, DEMUX_FILTER *pDmxfilter){ short rc=0; os_get_mutex(hMutex); /*------------------------------------------------------------------------+ | Allocate filter, set filter values and add to channel +------------------------------------------------------------------------*/ if (pDmxfilter->fid == ILLEGAL_FILTER) { rc = xp_osi_filter_allocate(pGlobal,pDmxfilter->para.filter_length); if (rc >= 0) { pDmxfilter->fid = rc; rc = 0; } } if (rc == 0) { rc = xp_osi_filter_set(pGlobal,(short)pDmxfilter->fid, pDmxfilter->para.filter_length, (unsigned char *)pDmxfilter->para.filter, (unsigned char *)pDmxfilter->para.mask, (unsigned char *)pDmxfilter->para.positive); } if (rc == 0) { rc = xp_osi_filter_add_to_channel(pGlobal, (short)pDmxfilter->chid, (short)pDmxfilter->fid); if(rc >=0) { pDmxfilter->ulMatchWord = (0x80000000)>>rc; rc = 0; } } if (rc == 0) { rc = xp_osi_filter_control(pGlobal,(short)pDmxfilter->fid, XP_FILTER_CONTROL_DISABLE); } /*------------------------------------------------------------------------+ | Check and Process Errors +------------------------------------------------------------------------*/ if (rc != 0) { if (pDmxfilter->fid != ILLEGAL_FILTER) { xp_osi_filter_free(pGlobal,pDmxfilter->fid); pDmxfilter->fid = ILLEGAL_FILTER; } } os_release_mutex(hMutex); PDEBUG("DemuxFilterAcquire(): pDmxfilter->fid = %d\n", pDmxfilter->fid); return(rc);}/*----------------------------------------------------------------------------+| DemuxFilterSectionSet+----------------------------------------------------------------------------*/static int DemuxFilterSectionSet( GLOBAL_RESOURCES *pGlobal, DEMUX_FILTER *pDmxfilter){ DEMUX_DEVICE *pDemuxDev; DEMUX_CHANNEL_ACQUIRE_TYPE DemuxAcq; int rc=0; int i; PDEBUG("DemuxFilterSectionSet(): Entering\n"); pDemuxDev = pDemux_dev[pGlobal->uDeviceIndex]; /*----------------------------------------------------------------------------+ | Reset Filter if alaready started +----------------------------------------------------------------------------*/ if (pDmxfilter->states >= FILTER_STAT_SET) { if(pDmxfilter->flags & FILTER_FLAG_MMAPPED) { printk("DemuxFilterSectionSet(): Error - filter is mmapped\n"); return(-1); } DemuxFilterReset(pGlobal,pDmxfilter); } /*----------------------------------------------------------------------------+ | Determine if the filter's pid is already allocated to a channel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -