/*************************************************************************** * Copyright (c) 2003-2006, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ***************************************************************************/ #ifndef CHAN_MGR_H__ #define CHAN_MGR_H__ #include "bsettop_stream.h" #include "bsettop_message.h" #include "bstd.h" #include "ts_psi.h" #include "ts_pat.h" #include "ts_pmt.h" #include "psip_vct.h" #include "psip_stt.h" #include "psip_rrt.h" #include "psip_mgt.h" #include "psip_eit.h" #include "psip_mss.h" #include "psip_descriptor.h" #include "bos.h" #ifdef BQAM_SCRIPT #define MAX_CHANNELS 256 #else #define MAX_CHANNELS 128 #endif #define MAX_CHM_EVENT 16 #define MAX_LONG_NAME_CHARS 128 #define MAX_TITLE_CHARS 96 #define MAX_DESC_CHARS 256 #define MAX_TIME_STR_CHARS 32 #define MAX_RATING_STR_CHARS 32 #define MAX_CH_NAME_CHARS 7 #define MAX_EIT_NUM 2 #define EIT_CURRENT 0 #define EIT_NEXT 1 #define MAX_CMD_HIST 128 #define MAX_CC_SERVICES 6 #define RRT_BUF_LEN (1024 + 188) /* Summary: Internal state. */ typedef enum chm_state_t { eCHM_GET_STT, eCHM_GET_VCT, eCHM_GET_MGT, eCHM_PROCESS_MGT, eCHM_PROG_IDLE, eCHM_GET_RRT, }chm_state_t; /* Summary: Command enumeration to control channel manager. */ typedef enum chm_cmd_t { eCHM_CANCEL, eCHM_SCAN, eCHM_TUNE, eCHM_INFO, eCHM_GUIDE, eCHM_STOP, eCHM_CHECK_SIGNAL }chm_cmd_t; /* Summary: Command enumeration to control channel manager. */ typedef enum chm_evt_type_t { eCHM_EVT_CANCEL, eCHM_EVT_DONE, eCHM_EVT_REDRAW, eCHM_PROGRESS, eCHM_EVT_BLOCK, eCHM_EVT_CAD, eCHM_EVT_RRT, eCHM_EVT_CSD, eCHM_EVT_SIGNAL }chm_evt_type_t; /* Screen event structure */ typedef struct chm_event_t { chm_evt_type_t type; unsigned int id; unsigned int ticks; unsigned char data[32]; }chm_event_t; /* Signal structure */ typedef struct chm_signal_event_t { chm_evt_type_t type; unsigned int lock; float power; unsigned int ticks; unsigned int SNR; unsigned int freq_hz; #if (BCHP_CHIP == 3543) BQAM_B_Mode qam_b_mode; #elif (BCHP_CHIP == 7002) btuner_qam_mode qam_b_mode; #endif }chm_signal_event_t; /* EIT Info structure */ typedef struct chm_eit_t { unsigned int start_time; unsigned int length; unsigned short event_id; unsigned char prog_title[MAX_TITLE_CHARS + 1]; unsigned char prog_desc[MAX_DESC_CHARS + 1]; PSIP_CSD_service cc_service[MAX_CC_SERVICES]; }chm_eit_t; /* Channel info structure */ typedef struct chm_info_t { unsigned short source_id; unsigned short major; unsigned short minor; unsigned short program_number; unsigned short ch_name[MAX_CH_NAME_CHARS]; unsigned char ext_ch_name[MAX_LONG_NAME_CHARS + 1]; unsigned char vct_name[MAX_LONG_NAME_CHARS + 1]; chm_eit_t eit_info[MAX_EIT_NUM]; bool got_vct; }chm_info_t; typedef enum time_source_t { eTS_NONE, eTS_TSID, eTS_XDS, eTS_FIXED, }time_source_t; /* MGT state constants */ typedef enum chm_mgt_state_t { eMGT_EIT, eMGT_ETT, }chm_mgt_state_t; /* flag indication what type of eit found */ typedef enum chm_eit_found_t { eEIT_NONE = 0, eEIT_CURRENT = 1, eEIT_NEXT = 2, eEIT_BOTH = 3, }chm_eit_found_t; /* smart antenna command history */ typedef struct cmd_hist_t { unsigned int locked : 1; unsigned int cmd : 7; unsigned int snr : 8; }cmd_hist_t; #define MAX_MSG_EVENTS 10 /* Summary: Command enumeration to control channel manager. */ typedef struct chm_mgr_t { chm_cmd_t cmd; /* Current channel manager state */ chm_state_t state; /* state controls data acquisition priority */ chm_mgt_state_t mgt_state; /* state of MGT processing */ bapp_task_t task; unsigned int *stack; unsigned char *eit_buf; unsigned char *ett_buf; unsigned char *mgt_buf; unsigned char *vct_buf; unsigned char *new_rrt_buf; unsigned char *stt_buf; unsigned char *pat_buf; unsigned char *pmt_buf; chm_info_t cur_info; bstream_mpeg mpeg; bapp_task_queue_t queue; bapp_task_event_t event[MAX_CHM_EVENT]; chm_event_t chm_evt; chm_signal_event_t signal_evt; void *p_app; bapp_task_mutex_t mutex; PSIP_STT_header stt; unsigned int sys_time; /* UTC seconds minus UTC offset in STT */ unsigned int sys_UTC_offset; /* UTC offset in STT */ unsigned int sys_offset; /* System seconds from gettimeofday when STT came in */ struct timeval mgt_tv; /* Time we finished processing MGT */ bool got_stt; /* Flag indicating stt was received on current channel */ time_source_t local_time_source; /* Identifies method used to obtain local time */ int local_offset; /* local time offset from UTC time to obtain standard time */ char local_dst_obs; /* local DST observance */ unsigned int mgt_size; unsigned int mgt_idx; chm_info_t *p_info; unsigned int max_info_num; unsigned char cur_ch_num; unsigned int rrt_size; unsigned int last_rrt; struct timeval guide_tv; /* time guide was retrieved */ cmd_hist_t cmd_hist[MAX_CMD_HIST]; unsigned char ant_cmd; char tmp_text[MAX_TITLE_CHARS + 1]; unsigned int eit_start_time; unsigned int eit_length; smessage_stream_t stt_msg; smessage_stream_t rrt_msg; bapp_task_queue_t gen_queue; bapp_task_event_t gen_event[MAX_MSG_EVENTS]; }chm_mgr_t; extern unsigned int g_xds_time_offset; extern bool g_xds_dst; /* Summary: Initialization. */ void chm_init(chm_mgr_t *p_chm, void *p_app); /* Summary: Function to pass a command to the channel manager. Any results and notification is handled by passing events to the app via the msg_queue. */ void chm_cmd(chm_mgr_t *p_chm,chm_cmd_t cmd); /* Summary: Get a copy of the current channel manager info structure. */ void chm_get_cur_ch_info(chm_mgr_t *p_chm, chm_info_t *p_info, bstream_mpeg *p_mpeg); /* Summary: Get the current UTC time, local offset and dst flag. Returns non-zero when it is not possible to determine local time. */ int chm_get_time_info(chm_mgr_t *p_chm, unsigned int *utc_secs, /* Current UTC time in seconds */ int *local_offset, /* Local time offset from UTC time in seconds */ bool *dst /* Daylight savings flag */ ); /* Summary: process the MMS string and associated tables. Returns non-zero on failure. */ int chm_process_mss(chm_mgr_t *p_chm, /* Channel manager reference */ PSIP_MSS_string p_mms, /* Pointer to MMS */ unsigned char* mms_buf, /* string buffer */ unsigned int mms_len /* string buffer length */ ); #endif /* CHAN_MGR_H__ */