/** @file DHL_MMM.c @brief PHOENIX HAL library ÀÌ ¸ðµâ¿¡ ´ëÇÑ °£´ÜÇÑ ¼³¸í.. ex: AudioVideo decoding/capture/output implementation Copyright 2006~2010 Digital STREAM Technology, Inc. All Rights Reserved */ #include "DHL_OSAL.h" #include "DHL_DBG.h" #include "DHL_PSI.h" #include "DHL_PSI_Priv.h" #include "DHL_OSAL_Config.h" // for task priority #include "bsettop_smessage.h" //#include ////#include /* ¸ðµç Çì´õ ÆÄÀÏÀ» Æ÷ÇÔÇÏÁö´Â ¾ÊÀ¸¸ç, compile timeÀ» ÁÙÀ̱â À§ÇØ °¢ ¸ðµâÀº ÇÊ¿äÇÑ ¸¸Å­ÀÇ Çì´õ¸¦ ¼±¾ðÇϵµ·Ï ÇÔ. */ /* DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í: DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ. API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë. µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â) */ //DHL_MODULE("*psi", 0); #if COMMENT ____Config____(){} #endif #define SECTION_TID 0 /* TID index */ #define SECTION_LEN_HI 1 /* length hi index */ #define SECTION_LEN_LO 2 /* length lo index */ #define SECTION_TID_EXT_HI 3 /* Table ID extension high index*/ #define SECTION_TID_EXT_LO 4 /* Table ID extension low index */ #define SECTION_VERSION 5 /* version number index */ #define SECTION_NUM 6 /* section number index */ #define SECTION_NUM_LAST 7 /* last section number index */ #define SECTION_HEADER_LENGTH 8 /* number of bytes in section header */ #define MAX_SECTION_FILTER 64 // Ĩ¿¡¼­´Â 64°³±îÁö Áö¿øÇÏÁö¸¸ 32°³·Î Á¦ÇÑ #define SECT_RCV_INFO_BUF_LEN (32*4) // megakiss 32 -> 32*4 /* section ¼ö½Å½Ã °¢ ¼½¼ÇÀÇ ³¡¿¡ ºÙ´Â TagBytesÀÇ Å©±â TagBytes : 5 bytes of TagBytes are appended to each section data. TagBytes begins with CRC check result code followed by 4 bytes of PAT value. CRC check result code of 0x00 indicates CRC valid and 0x80 indicates CRC invalid. */ #define SIZE_TAG_BYTES 5 // ŽºÅ© ½ºÅÃÀÌ ¾ó¸¶³ª ³Ë³ËÇÑÁö´Â ÇöÀç °¡´ÆÇϱ⠾î·Á¿ò. // ³ªÁß¿¡ stack check ÇÏ´Â ±â´É ±¸Çö Àü±îÁö´Â ÃæºÐÇÏ°Ô ÇÒ´çÇÏÀÚ. // #define PSI_RX_TASK_STACK_SIZE 0x4000 // <-- 0x1000 // #define PSI_RX_TASK_PRIORITY TASK_PRI_DHL_PSIPRX #define SECTION_BUF_SIZE (0x1000 + 0x10) // 4KB #define SECTION_BUF_NF_MARGIN 0x800 // 2KB #ifndef min #define min(a,b) ((a)<(b) ? (a):(b)) #endif #if COMMENT ____Types____(){} #endif /* ÀÌ ¸ðµâ ³»ºÎ¿¡¼­ »ç¿ëµÇ´Â structure ¹× enumerations. */ typedef struct { void* FltId; UINT8 pbuf[4096]; UINT32 size; } SECT_RCV_INFO_t; //typedef tDHL_PSI_FiltCtl* tDHL_PSI_ControlHandle; #if COMMENT ____Variables____(){} #endif /* global·Î Àû¿ëµÇ´Â variable Á¤ÀÇ. °¢ function º°·Î Ư¼öÇÑ ¿ëµµÀÇ variableÀº °¢ functionX block ¿¡¼­ Á¤ÀÇ °¡´É. */ tDHL_PSI_FiltCtl g_fc[MAX_SECTION_FILTER]; SECT_RCV_INFO_t g_sect_rcv_info_buf[SECT_RCV_INFO_BUF_LEN]; UINT32 g_sect_rcv_info_buf_h = 0, g_sect_rcv_info_buf_t = 0; #if COMMENT ____PSI_ControlHandle____(){} #endif /* psi filter controlÀ» µ¿±âÈ­ Çϱâ À§ÇÑ ¹ÂÅØ½º psi filter controlÀ» »ç¿ëÇÏ´Â ¸ðµç ŽºÅ© »çÀÌÀÇ race conditionÀ» ¹æÁöÇÑ´Ù. ÄÚµå ³»¿¡¼­´Â flt_ctrl_lockÀ» Á÷Á¢ È£ÃâÇÏ¸é ¾ÈµÇ¸ç ²À lock_FiltCtl() ¿Í unlock_FiltCtl() ¸¦ ÀÌ¿ëÇÏ¿© ÄÁÆ®·Ñ. */ static DHL_OS_SEMA_ID flt_ctrl_mtx; #define flt_ctrl_lock() DHL_OS_TakeSemaphore(flt_ctrl_mtx, DHL_TIMEOUT_FOREVER) #define flt_ctrl_unlock() DHL_OS_GiveSemaphore(flt_ctrl_mtx) /* todo : zooyouny 100903 g_psi_uid_of_control_handle[] ÀÌ ²À ÇÊ¿äÇѰ¡? ÀÌ Å×À̺íÀ» »ç¿ëÇÏ´Â ¸ñÀûÀÌ handle validity¸¦ À§ÇÑ °ÍÀ̶ó¸é g_fc¿¡ ÀÖ´Â handle °ªÀ» ÂüÁ¶Çصµ µÇÁö ¾ÊÀ»±î? */ /* psi control handleÀÇ unique id unique id°¡ 0À̶ó´Â °ÍÀº psi control handleÀÌ ¾ÆÁ÷ »ý¼º µÇÁö ¾Ê¾Ò°Å³ª, »ç¿ëÀÌ ³¡³ª releaseµÇ¾úÀ½À» ÀÇ¹Ì */ static UINT16 g_psi_uid_of_control_handle[MAX_SECTION_FILTER]; static UINT16 g_psi_control_handle_unique_id = 1; #define PSI_CTL_HANDLE_ARRAY_MASK 0x0000ffff #define PSI_CTL_HANDLE_UID_MASK 0xffff0000 #define PSI_CTL_HANDLE_UID_SHIFT 16 // PSI_CTL_HANDLE_UID_MASK °ª¿¡ µû¶ó ´Þ¶óÁü #define PSI_CTL_HANDLE_GET_ARRAY_ID(handle) \ ((UINT32)(handle) & PSI_CTL_HANDLE_ARRAY_MASK) #define PSI_CTL_HANDLE_GET_UID(handle) \ (((UINT32)(handle)&PSI_CTL_HANDLE_UID_MASK)>>PSI_CTL_HANDLE_UID_SHIFT) /* tDHL_PSI_ControlHandle À» »ý¼ºÇÑ´Ù. ¸ð´ÏÅ͸µÀÌ Á¾·áµÉ¶§ ¹Ýµå½Ã release µÇ¾î¾ß ÇÑ´Ù. ¹Ýµå½Ã lock_FiltCtl() ¿Í unlock_FiltCtl() ¾È¿¡¼­ ¼öÇàµÇ¾î¾ß ÇÔ. */ static tDHL_PSI_ControlHandle get_psi_control_handle() { int i; UINT32 handle = 0; { // 1. »ç¿ë °¡´ÉÇÑ g_fc ¹è¿­ À妽º(i) ȹµæ // MAX_SECTION_FILTER°¡ handle¿¡¼­ ¹è¿­ À妽º·Î »ç¿ëÇÏ´Â ¹üÀ§¸¦ ³Ñ¾î¼­¸é ¾ÈµÈ´Ù. // ÇöÀç´Â handleÀÇ ¹è¿­ À妽º ¹üÀ§°¡ 0~65535 for (i = 0; i < MAX_SECTION_FILTER; i++) if(g_psi_uid_of_control_handle[i] == 0) break; if (i == MAX_SECTION_FILTER) // no more section filter to give return 0; // 2. unique ID »ý¼º /* ÇâÈÄ handle validity check¸¦ À§ÇØ unique id¸¦ g_psi_uid_of_control_handle¿¡ ÀúÀå*/ g_psi_uid_of_control_handle[i] = g_psi_control_handle_unique_id; g_psi_control_handle_unique_id++; if (g_psi_control_handle_unique_id == 0) g_psi_control_handle_unique_id = 1; // 3. ÃÖÁ¾ Control Handle »ý¼º handle |= (i & PSI_CTL_HANDLE_ARRAY_MASK); handle |= (g_psi_uid_of_control_handle[i] << PSI_CTL_HANDLE_UID_SHIFT); } return (tDHL_PSI_ControlHandle)handle; } /* tDHL_PSI_ControlHandle À» release ¹Ýµå½Ã lock_FiltCtl() ¿Í unlock_FiltCtl() ¾È¿¡¼­ ¼öÇàµÇ¾î¾ß ÇÔ. */ static DHL_RESULT release_psi_control(tDHL_PSI_ControlHandle handle) { DHL_RESULT res = DHL_OK; int id = PSI_CTL_HANDLE_GET_ARRAY_ID(handle); // handle validity check if (handle == 0 || id >= MAX_SECTION_FILTER || id < 0) return DHL_FAIL_INVALID_PARAM; { if (g_psi_uid_of_control_handle[id] == 0) /* ÀÌ¹Ì release µÇ¾ú°Å³ª »ç¿ëµÈ ÀûÀÌ ¾ø´Â ÇÚµéÀÓ */ res = DHL_FAIL_INVALID_HANDLE; else if (g_psi_uid_of_control_handle[id] != PSI_CTL_HANDLE_GET_UID(handle)) /* handleÀÇ uid¿Í uid list¿¡ ÀúÀåµÈ unique id°¡ ÀÏÄ¡ ÇÏÁö ¾ÊÀ½. ´Ù¸¥ filter controlÀÌ ÇÒ´ç µÈ °æ¿ìÀÓ. */ res = DHL_FAIL_NOT_AVAILABLE; else g_psi_uid_of_control_handle[id] = 0; } if (res != DHL_OK) printf( "invalid handle(%0x) used in release_psi_control!!", handle); return res; } /* tDHL_PSI_ControlHandle À» ÀÌ¿ëÇÏ¿© section info °¡ µé¾îÀÖ´Â tDHL_PSI_FiltCtl À» °¡Á®¿È. handle ÀÌ release µÈ °æ¿ì NULL À» ¹Ýȯ. ¹Ýµå½Ã lock_FiltCtl() ¿Í unlock_FiltCtl() ¾È¿¡¼­ ¼öÇàµÇ¾î¾ß ÇÔ. */ static tDHL_PSI_FiltCtl* get_FiltCtl(tDHL_PSI_ControlHandle handle) { int id = PSI_CTL_HANDLE_GET_ARRAY_ID(handle); // handle validity check if (handle == 0 || id >= MAX_SECTION_FILTER || id < 0) return NULL; { if (g_psi_uid_of_control_handle[id] == 0) /* ÀÌ¹Ì release µÇ¾ú°Å³ª »ç¿ëµÈ ÀûÀÌ ¾ø´Â ÇÚµéÀÓ */ goto label_err; else if (g_psi_uid_of_control_handle[id] != PSI_CTL_HANDLE_GET_UID(handle)) /* handleÀÇ uid¿Í uid list¿¡ ÀúÀåµÈ unique id°¡ ÀÏÄ¡ ÇÏÁö ¾ÊÀ½. ´Ù¸¥ filter controlÀÌ ÇÒ´ç µÈ °æ¿ìÀÓ. */ goto label_err; } return &g_fc[id]; label_err: printf( "invalid handle(%0x) is used in lock_FiltCtl..!!\n", handle); return NULL; } /* g_psi_uid_of_control_handle ¿Í g_fc ¸¦ º¸È£Çϱâ À§ÇÑ lock api. g_psi_uid_of_control_handle ¿Í g_fc ¸¦ ÄÁÆ®·Ñ ÇÏ´Â ¸ðµç api ´Â lock_FiltCtl() ¿Í unlock_FiltCtl() À¸·Î º¸È£ µÇ¾î¾ß ÇÔ. */ static void lock_FiltCtl(void) { flt_ctrl_lock(); } static void unlock_FiltCtl(void) { flt_ctrl_unlock(); } static void p_filter_control_reset(tDHL_PSI_FiltCtl* pFlt, int index) { memset(pFlt, 0, sizeof(tDHL_PSI_FiltCtl)); pFlt->index = index; pFlt->curVersion = -1; } #if COMMENT ____Rx____(){} #endif //static char *psi_tid_str(UINT8 t) //{ // static char buf[10]; // return // (t)==0x00 ? "pat" : \ // (t)==0x02 ? "pmt" : \ // (t)==0xC7 ? "mgt" : \ // (t)==0xC8 ? "tvt" : \ // (t)==0xC9 ? "cvt" : \ // (t)==0xCA ? "rrt" : \ // (t)==0xCB ? "eit" : \ // (t)==0xCC ? "ett" : \ // (t)==0xCD ? "stt" : \ // (t)==0xD8 ? "eas" : \ // (sprintf(buf, "x%02x", t), buf); //} static void* dhl_psi_rx_cb(void * context, size_t size) { if (size == 0 || size > 4096) { printf("%s|ERR|size == %d\n", __func__, size); return 0; } if (context == 0) { printf("%s|ERR|context == %d\n", __func__, context); return 0; } tDHL_PSI_FiltCtl * pFltCtl = (tDHL_PSI_FiltCtl *)context; if (pFltCtl->pRawBuff == 0) { printf("%s|pFltCtl->pRawBuff == 0\n", __func__); return 0; } g_sect_rcv_info_buf[g_sect_rcv_info_buf_h].FltId = pFltCtl->Filter_ID; g_sect_rcv_info_buf[g_sect_rcv_info_buf_h].size = size; memcpy(g_sect_rcv_info_buf[g_sect_rcv_info_buf_h].pbuf, pFltCtl->pRawBuff, size); g_sect_rcv_info_buf_h = (g_sect_rcv_info_buf_h >= SECT_RCV_INFO_BUF_LEN-1) ? 0 : g_sect_rcv_info_buf_h+1; // printf("g_sect_rcv_info_buf_h = %d\n", g_sect_rcv_info_buf_h); return (void*)(pFltCtl->pRawBuff); } static void dhl_psi_rx_process(SECT_RCV_INFO_t *info) { int i; for (i = 0; i < MAX_SECTION_FILTER; i++) { if (g_fc[i].active == FALSE) continue; if (g_fc[i].isPaused == TRUE) continue; if (g_fc[i].Filter_ID != info->FltId) continue; tDHL_PSI_FiltCtl* fltCtl = get_FiltCtl(g_fc[i].handle); if (fltCtl == NULL) // ÀÌ¹Ì release µÇ¾ú°Å³ª À߸øµÈ ÇÚµéÀÓ { printf( "!! invalid psi control handle..!!"); continue; } int sect_size = 0; tDHL_PSI_Event psi_event = dhl_psi_post_data_received(fltCtl, info->pbuf, info->size, §_size); if (psi_event != ePSIEVENT_DATARECEIVED) continue; if (fltCtl->param.eventProc ==0) continue; fltCtl->param.eventProc(psi_event, (tDHL_PSI_ControlHandle)fltCtl->handle, fltCtl->param.userParam); } } #if COMMENT ____Task____(){} #endif // µå¶óÀ̹ö¿¡¼­ »ç¿ëÇÏ´Â ´Ù¸¥ event flag¿Í °ãÄ¡¸é ¾ÈµÈ´Ù. #define PSI_RX_TASK_STOP_EVENT 0x80000000 static DHL_OS_TASK_ID g_psi_rx_tid; static void psi_rx_task(void* arg) { printf( "psi rx task start..\n"); while(1) { if (g_sect_rcv_info_buf_t == g_sect_rcv_info_buf_h) { DHL_OS_Delay(10); continue; } lock_FiltCtl(); dhl_psi_rx_process(&g_sect_rcv_info_buf[g_sect_rcv_info_buf_t]); unlock_FiltCtl(); g_sect_rcv_info_buf_t = (g_sect_rcv_info_buf_t >= SECT_RCV_INFO_BUF_LEN-1) ? 0 : g_sect_rcv_info_buf_t+1; // printf("g_sect_rcv_info_buf_t = %d\n", g_sect_rcv_info_buf_t); } printf( "\n== psi rx task end\n"); DHL_OS_SelfDeleteTask(); } void dhl_psi_start_task(void) { if (g_psi_rx_tid) { printf( "!! already task running\n"); } else { g_psi_rx_tid = DHL_OS_CreateTask(psi_rx_task, "psirx", PSI_RX_TASK_PRIORITY, PSI_RX_TASK_STACK_SIZE, 0); if (!g_psi_rx_tid) { printf( "!! task create err\n"); } else { printf( "psi rx task started..\n"); } } } void dhl_psi_stop_task(void) { } #if COMMENT ____Group2____(){} #endif void update_psi_filter(tDHL_PSI_FiltCtl *pFltCtl) { if (pFltCtl == NULL) return; //errexit: } #if COMMENT ____Resume_Pause____(){} #endif /* one shot filter¿¡¼­ section ¼ö½Å ÈÄ ´õÀÌ»ó ¼ö½ÅÀ» ÇÏÁö ¾ÊÀ» °æ¿ì È£ÃâµÈ´Ù. resumeµÇ¸é ´Ù½Ã µ¿ÀÛ ÇÔ. */ void pause_psi_filter(tDHL_PSI_FiltCtl* pFltCtl) { if (!pFltCtl) { printf( "!! %s: invalid handle\n", __func__); goto errexit; } pFltCtl->isPaused = 1; errexit: ; } void resume_psi_filter(tDHL_PSI_FiltCtl* pFltCtl) { if (!pFltCtl) { printf( "!! %s: invalid handle\n", __func__); goto errexit; } pFltCtl->isPaused = 0; errexit: ; } #if COMMENT ____Start_Stop____(){} #endif /* API ½ÃÀ۽à ¹Ýµå½Ã lock_FiltCtl() ·Î º¸È£µÇ¾î¾ß Çϸç API °¡ Á¾·áµÇ¸é ¹Ýµå½Ã unlock_FiltCtl() ·Î unlock µÇ¾î¾ß ÇÔ. */ DHL_RESULT dhl_psi_start( tDHL_TSD tsd, UINT16 pid, tDHL_PSI_Filter *pref, tDHL_PSI_StartParam *param, tDHL_PSI_ControlHandle *pHandle) { DHL_RESULT dhr = DHL_OK; // UINT8 tid_mask; // UINT16 tid_ext_mask; // UINT8 sdec_tid; // UINT16 sdec_tid_ext; void* idxFlt; tDHL_PSI_FiltCtl *pFltCtl = NULL; int i; if (pHandle == NULL) return DHL_FAIL_INVALID_PARAM; lock_FiltCtl(); *pHandle = get_psi_control_handle(); // stop monitorÇÒ ¶§ ¹Ýµå½Ã release µÇ¾î¾ß ÇÔ if (*pHandle == 0) { dhr = DHL_FAIL_TOO_MANY_INSTANCES; goto err_handle; } pFltCtl = get_FiltCtl(*pHandle); if (pFltCtl == NULL) // ÀÌ¹Ì release µÇ¾ú°Å³ª À߸øµÈ ÇÚµéÀÓ { printf( "!! invalid psi control handle..!!"); dhr = DHL_FAIL_NOT_AVAILABLE; goto err; } // °°Àº Á¶°ÇÀÇ filter °¡ ÀÌ¹Ì °É·Á ÀÖ´ÂÁö À̰÷¿¡¼­ °Ë»ç for (i = 0; i < MAX_SECTION_FILTER; i++) { if (g_fc[i].active == TRUE && g_fc[i].pid == pid && #if 1//BRCM g_fc[i].pFltData->coef[0] == pref->coef[0]) #else g_fc[i].pFltData->data[0] == pref->data[0]) #endif { break; } } p_filter_control_reset(pFltCtl, pFltCtl->index); if (i < MAX_SECTION_FILTER) { // ÀÖÀ¸¸é idxFlt = g_fc[i].Filter_ID; } else { #ifndef TUNER_BAND #define TUNER_BAND 0 #endif smessage_stream_params_t msg_params; smessage_stream_t msg_idx= smessage_open(smessage_format_psi); if (msg_idx == NULL) { dhr = DHL_FAIL_TOO_MANY_INSTANCES; goto err_handle; } idxFlt = (void*) msg_idx; smessage_stream_params_init(&msg_params, NULL); msg_params.band = TUNER_BAND; //ÀÏ´Ü ¹Þ¾ÆÁü.. msg_params.pid = pid; memcpy(msg_params.filter.coef, pref->coef, FILTER_MAX_BYTE); memcpy(msg_params.filter.mask, pref->mask, FILTER_MAX_BYTE); memcpy(msg_params.filter.excl, pref->excl, FILTER_MAX_BYTE); pFltCtl->pRawBuff = msg_params.buffer = DHL_OS_Malloc(param->maxData); msg_params.buffer_size = param->maxData; /* processing is done in callback */ msg_params.data_ready_callback = dhl_psi_rx_cb; msg_params.overflow = NULL; msg_params.crc_disabled = 0; //BKTODO: pFltCtlÀº »ç½Ç ¹Ø¿¡¼­ ÃʱâÈ­ µÈ´Ù. ¸ÕÀú callbackÀÌ ¶ß¸é ¹®Á¦ µÊ.task priority °ËÅä ÇÊ¿ä. msg_params.callback_context = (void *)pFltCtl; if (b_ok != smessage_start(&msg_params, msg_idx)) { printf("FATAL: %s:%d\n",__FILE__, __LINE__); if(msg_params.buffer) DHL_OS_Free(&msg_params.buffer); dhr = DHL_FAIL_TOO_MANY_INSTANCES; goto err_handle; } } pFltCtl->handle = (int)*pHandle; pFltCtl->Filter_ID = idxFlt; pFltCtl->pid = pid; pFltCtl->pFltData = pref; // ÂüÁ¶, ±âÁ¸ ÄÚµå(NEO)ÀÇ ¼öÁ¤À» ÃÖ¼ÒÈ­ Çϱâ À§ÇØ ÂüÁ¶·Î ÇÏ¿´À½. pFltCtl->param = *param; // ÂüÁ¶°¡ ¾Æ´Ï¶ó º¹»ç!! pFltCtl->isPaused = 0; pFltCtl->active = 1; if (0) { DHL_OS_Printf("|%s| pid : 0x%x\n", __FUNCTION__, pFltCtl->pid); DHL_OS_Printf("|%s| data : ", __FUNCTION__); for (i = 0; i < FILTER_MAX_BYTE; i++) { DHL_OS_Printf("%2x ", pFltCtl->pFltData->coef[i]); } DHL_OS_Printf("\n"); DHL_OS_Printf("|%s| mask : ", __FUNCTION__); for (i = 0; i < FILTER_MAX_BYTE; i++) { DHL_OS_Printf("%2x ", pFltCtl->pFltData->mask[i]); } DHL_OS_Printf("\n"); DHL_OS_Printf("|%s| mode : ", __FUNCTION__); for (i = 0; i < FILTER_MAX_BYTE; i++) { DHL_OS_Printf("%2x ", pFltCtl->pFltData->excl[i]); } DHL_OS_Printf("\n"); DHL_OS_Printf("|%s| filter id : 0x%x\n", __FUNCTION__, pFltCtl->Filter_ID); } printf( "psi start success\n"); unlock_FiltCtl(); return dhr; err: //yhkim, 111222, handle ÀÌ »ý¼ºµÈ ÈÄ error °¡ ¹ß»ýÇÑ °æ¿ì ¹Ýµå½Ã handle À» release ÇØÁÜ. release_psi_control(*pHandle); err_handle: unlock_FiltCtl(); return dhr; } /* API ½ÃÀ۽à ¹Ýµå½Ã lock_FiltCtl() ·Î º¸È£µÇ¾î¾ß Çϸç API °¡ Á¾·áµÇ¸é ¹Ýµå½Ã unlock_FiltCtl() ·Î unlock µÇ¾î¾ß ÇÔ. */ void dhl_psi_stop(tDHL_PSI_ControlHandle handle) { // DHL_RESULT dhr; tDHL_PSI_FiltCtl *pFltCtl = NULL; // SINT8 ret; int i; if (handle == 0) return; lock_FiltCtl(); pFltCtl = get_FiltCtl(handle); if (!pFltCtl) // ÀÌ¹Ì release µÇ¾ú°Å³ª À߸øµÈ ÇÚµéÀÓ { printf( "!! %s: invalid handle %x\n", __func__, handle); goto err_handle; } pFltCtl->active = 0; // °°Àº Á¶°ÇÀÇ filter °¡ ÀÌ¹Ì °É·Á ÀÖ´ÂÁö À̰÷¿¡¼­ °Ë»ç for (i = 0; i < MAX_SECTION_FILTER; i++) { #if 0 if (g_fc[i].active == TRUE && g_fc[i].pid == pFltCtl->pid) #else if (g_fc[i].active == TRUE && g_fc[i].pid == pFltCtl->pid && #if 1//BRCM g_fc[i].pFltData->coef[0] == pFltCtl->pFltData->coef[0]) #else g_fc[i].pFltData->data[0] == pFltCtl->pFltData->data[0]) #endif #endif { break; } } if (i < MAX_SECTION_FILTER) { // ÀÖÀ¸¸é } else { if (b_ok != smessage_stop((smessage_stream_t)pFltCtl->Filter_ID)) { printf("FATAL: %s:%d\n",__FILE__, __LINE__); return; } smessage_close((smessage_stream_t)pFltCtl->Filter_ID); if(pFltCtl->pRawBuff) { DHL_OS_Free((void **)&pFltCtl->pRawBuff); } } //label_exit: if (pFltCtl->pFltData) { DHL_PSI_FreeFilter(pFltCtl->pFltData); pFltCtl->pFltData = NULL; } if (pFltCtl->curDataArray) { dhl_psi_free_data_array(pFltCtl->curDataArray); pFltCtl->curDataArray = NULL; } if (pFltCtl->nextDataArray) { dhl_psi_free_data_array(pFltCtl->nextDataArray); pFltCtl->nextDataArray = NULL; } p_filter_control_reset(pFltCtl, pFltCtl->index); //errexit: //yhkim, 111222, handle À» release ÇÒ °æ¿ì ¹Ýµå½Ã unlock_FiltCtl() Àü¿¡ ÇØÁÖµµ·Ï ÇÔ. release_psi_control(handle); err_handle: unlock_FiltCtl(); } #if COMMENT ____PSI_Data____(){} #endif /* API ½ÃÀ۽à ¹Ýµå½Ã lock_FiltCtl() ·Î º¸È£µÇ¾î¾ß Çϸç API °¡ Á¾·áµÇ¸é ¹Ýµå½Ã unlock_FiltCtl() ·Î unlock µÇ¾î¾ß ÇÔ. */ DHL_RESULT dhl_psi_read_data(tDHL_PSI_ControlHandle handle, tDHL_PSI_DataArray **ppData) { DHL_RESULT res = DHL_OK; tDHL_PSI_FiltCtl* pFltCtl; int id = PSI_CTL_HANDLE_GET_ARRAY_ID(handle); // int i; if (handle == 0 || id >= MAX_SECTION_FILTER || id < 0) return DHL_FAIL_INVALID_PARAM; lock_FiltCtl(); pFltCtl = get_FiltCtl(handle); if (!pFltCtl) // ÀÌ¹Ì release µÇ¾ú°Å³ª À߸øµÈ ÇÚµéÀÓ { printf( "!! %s: psi data is not available..\n", __func__); res = DHL_FAIL_NOT_AVAILABLE; goto err; } if (pFltCtl->curDataArray) { *ppData = pFltCtl->curDataArray; pFltCtl->curDataArray = NULL; } else { *ppData = NULL; res = DHL_FAIL_NOT_FOUND; } err: unlock_FiltCtl(); return res; } #if COMMENT ____Debug____(){} #endif /* API ½ÃÀ۽à ¹Ýµå½Ã lock_FiltCtl() ·Î º¸È£µÇ¾î¾ß Çϸç API °¡ Á¾·áµÇ¸é ¹Ýµå½Ã unlock_FiltCtl() ·Î unlock µÇ¾î¾ß ÇÔ. */ void dhl_psi_show() { int i; tDHL_PSI_FiltCtl *pFltCtl; int nActiveFlt = 0; DHL_OS_Printf("---- dhl psi statistics!!! ----\n"); lock_FiltCtl(); for (i=0; iactive == 0) continue; DHL_OS_Printf("(%2d) fid %x, pid %04x, tid %02x, mode %s %d\n", i, pFltCtl->Filter_ID, pFltCtl->pid, pFltCtl->pFltData->coef[0], // tid // pFltCtl->pFltData->data[0], // tid pFltCtl->param.psiMode==ePSIMODE_SECTION ? "sec" : "tbl", pFltCtl->param.updateMode, 0); nActiveFlt++; } unlock_FiltCtl(); DHL_OS_Printf("total %d active filters\n\n", nActiveFlt); } #if COMMENT ____Demux____(){} #endif // À̰÷ÀÇ Demux ¼³Á¤ ÄÚµå´Â DHL_Demux ·Î À̵¿.. #if COMMENT ____Symbol____(){} #endif #if DHL_REGISTER_DEUBG_SYMBOLS static DHL_SymbolTable _symbols[] = { /* however, if you want typing short-cut, it is good usage. DHL_FNC_SYM_ENTRY2("epg_start", App_EpgUpdateStart), DHL_FNC_SYM_ENTRY2("epg_stop", App_EpgUpdateCancel), DHL_FNC_SYM_ENTRY2("epg_list", Dmc_EpgPrintAllTables), DHL_FNC_SYM_ENTRY2("epg_delete", App_EpgDeleteAll), DHL_VAR_SYM_ENTRY(g_XX_TestMode), */ 0, }; #endif /* DHL_REGISTER_DEUBG_SYMBOLS */ #if COMMENT ____Init____(){} #endif void dhl_psi_init(void) { int i; #if DHL_REGISTER_DEUBG_SYMBOLS DHL_DBG_RegisterSymbols(_symbols, DHL_NUMSYMBOLS(_symbols)); #endif memset(&g_fc, 0, sizeof(g_fc)); for (i=0; i