📄 ttx_drv.c
字号:
} else { ttxstat->stax.no_pusi++; } /*--------------------------------------------------------------------------+ | Now MBUF is validated | No PTS, so chain it to previous MBUF chain. +--------------------------------------------------------------------------*/ if (ttx_mbuf->pts == 0) { ttx_m_cat(ttx_ctrl->last_mb, mb); } else { if (ttx_ctrl->last_chain) { ttxstat->stax.out_pusi++; st = beginCriticalSection(); ttx_m_enq(&ttxstat->pes_queue, ttx_ctrl->last_chain); endCriticalSection(st); } ttx_ctrl->last_chain = mb; } /*--------------------------------------------------------------------------+ | If later MBUF does not have PTS, it will be chained to this. +--------------------------------------------------------------------------*/ ttx_ctrl->last_mb = mb; /*--------------------------------------------------------------------------+ | If the packets which already processed by VSYNC handler, free them +--------------------------------------------------------------------------*/ st = beginCriticalSection(); if (ttxstat->done_queue) { ttx_m_free_q(&ttxstat->done_queue); } endCriticalSection(st); return(0);}/*----------------------------------------------------------------------------+| XXXXXXX XXX XXX XXXXXX XXXXXXX XXXXXX XX XX XX XXXX| XX X XX XX X XX X XX X XX XX XXX XX XXXX XX| XX X XXX XX XX X XX XX XXXX XX XX XX XX| XXXX X XX XXXX XXXXX XX XXXX XX XX XX| XX X XXX XX XX X XX XX XX XXX XXXXXX XX| XX X XX XX XX XX X XX XX XX XX XX XX XX XX| XXXXXXX XXX XXX XXXX XXXXXXX XXX XX XX XX XX XX XXXXXXX+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| XX XXXXXX XXXXXX XXXXX| XXXX XX XX XX XX XX| XX XX XX XX XX XX| XX XX XXXXX XX XX| XXXXXX XX XX XX| XX XX XX XX XX XX| XX XX XX XXXXXX XXXXX+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| ttx_stats_get+----------------------------------------------------------------------------*/void ttx_stats_get(unsigned long tstat_ptr){ copy_to_user((ttx_stax_t *)tstat_ptr, &ttxstat->stax, sizeof(ttx_stax_t));}/*----------------------------------------------------------------------------+| ttx_stats_clear+----------------------------------------------------------------------------*/void ttx_stats_clear(void){ memset(&ttxstat->stax, 0, sizeof(ttx_stax_t));}/*----------------------------------------------------------------------------+| ttx_insert_pid| Start PID subscription for teletext driver.+----------------------------------------------------------------------------*/int ttx_insert_pid(unsigned short pid){ int ttx_list_size = 1; Ttx_ctrl_entry ttx_ctrl = ttxstat->ttx_ctrl; Ttx_list_entry ttx_list = ttxstat->ttx_list; if (!ttxstat->ioenabled) { return(E_TTX_NOT_INITIALIZED); } /*--------------------------------------------------------------------------+ | Look down to end of entry +--------------------------------------------------------------------------*/ ttxstat->num_ttx = 0; while (ttx_list_size-- > 0) { ttx_ctrl->last_chain = ttx_ctrl->last_mb = NULL; ttx_ctrl->last_pts = 0; ttx_list->pid = pid; ttxstat->num_ttx++; ttx_ctrl++; ttx_list++; } return(0);}/*----------------------------------------------------------------------------+| ttx_delete_pid| Stop PID subscription for teletext driver.+----------------------------------------------------------------------------*/int ttx_delete_pid(void){ kernel_state st; Ttx_ctrl_entry ttx_ctrl = ttxstat->ttx_ctrl; Ttx_list_entry ttx_list = ttxstat->ttx_list; if (!ttxstat->ioenabled) { return(E_TTX_NOT_INITIALIZED); } /*--------------------------------------------------------------------------+ | Remove all PIDs +--------------------------------------------------------------------------*/ while (ttxstat->num_ttx) { ttx_ctrl->last_mb = NULL; ttx_ctrl->last_pts = 0; ttx_m_free_p(ttx_ctrl->last_chain); ttx_ctrl->last_chain = NULL; ttx_list->pid = XP_CHANNEL_NULL_PID; ttxstat->num_ttx--; ttx_list++; ttx_ctrl++; } st = beginCriticalSection(); ttx_m_free_q(&ttxstat->done_queue); ttx_m_free_q(&ttxstat->pes_queue); endCriticalSection(st); return(0);}/*----------------------------------------------------------------------------+| ttx_write+----------------------------------------------------------------------------*/int ttx_write(void *buffer, size_t length){ int err; Ttx_ctrl_entry ttx_ctrl = ttxstat->ttx_ctrl; Mbuf cur_mb; Ttx_mbuf_t ttx_mbuf; /*--------------------------------------------------------------------------+ | Set Next Buffer +--------------------------------------------------------------------------*/ while (length >= TS_PACKET_SIZE) { cur_mb = ttx_m_getn(sizeof(ttx_mbuf_t), &err); if (cur_mb == NULL) { return(E_TTX_NOMEM); } ttx_mbuf = (Ttx_mbuf_t)DATA_PTR(cur_mb); copy_from_user(ttx_mbuf->buf, buffer, TS_PACKET_SIZE); ttxstat->stax.in_pkt++; ttx_mbuf->ttx_ctrl = ttx_ctrl; cur_mb->m_type = MBT_DATA; process_ttx_pes(cur_mb); length -= TS_PACKET_SIZE; buffer += TS_PACKET_SIZE; } /*--------------------------------------------------------------------------+ | Buffer Length Should be Multiple of Transport Packet Size +--------------------------------------------------------------------------*/ if (length > 0) { return(E_TTX_BAD_LENGTH); } return(0);}/*----------------------------------------------------------------------------+| ttx_initialize| Initialize teletext driver.+----------------------------------------------------------------------------*/int ttx_initialize(void){ int err; unsigned char *addr; if (ttxstat->ioenabled) { return(0); } /*--------------------------------------------------------------------------+ | Allocate & init memory +--------------------------------------------------------------------------*/ ttxstat->mem_size = (sizeof(ttx_list_entry) + sizeof(ttx_ctrl_entry))* MAX_TTX_LIST_SIZE; if ((ttxstat->mem_ptr = MALLOC(ttxstat->mem_size)) == NULL) { return(E_TTX_NOMEM); } addr = ttxstat->mem_ptr; ttxstat->ttx_list = (Ttx_list_entry)addr; addr += sizeof(ttx_list_entry)*MAX_TTX_LIST_SIZE; ttxstat->ttx_ctrl = (Ttx_ctrl_entry)addr; addr += sizeof(ttx_ctrl_entry)*MAX_TTX_LIST_SIZE; ttxstat->num_ttx = 0; /*--------------------------------------------------------------------------+ | Initialize Video decorder and DENC for teletext +--------------------------------------------------------------------------*/ if ((err = ttx_vbi_init()) != 0) { FREE(ttxstat->mem_ptr); return(err); } ttxstat->ioenabled = 1; /*--------------------------------------------------------------------------+ | Setup DENC to enable teletext processing +--------------------------------------------------------------------------*/ ttx_insert_pid(0x1fff); ttx_on(); return(0);}/*----------------------------------------------------------------------------+| ttx_terminate| Terminate teletext driver.+----------------------------------------------------------------------------*/int ttx_terminate(void){ if (!ttxstat->ioenabled) { return(0); } /*--------------------------------------------------------------------------+ | Disable teletext function of DENC +--------------------------------------------------------------------------*/ ttx_off(); /*--------------------------------------------------------------------------+ | Disable teletext function of video decorder +--------------------------------------------------------------------------*/ ttx_vbi_term(); /*--------------------------------------------------------------------------+ | Free the allocated memory. +--------------------------------------------------------------------------*/ FREE(ttxstat->mem_ptr); ttxstat->ioenabled = 0; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -