/*************************************************************************** * 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_tuner.h" #include "bsettop_smessage.h" #include "bstd.h" #include "ts_psi.h" #include "ts_pat.h" #include "ts_pmt.h" #include "psip_mss.h" #include "psip_descriptor.h" #include "bos.h" #include "ch_map.h" #include "si.h" #include "si_nit.h" #include "si_ntt.h" #include "si_stt.h" #include "si_svct.h" #include "dsmcc.h" #include "bapp_freq_table.h" #ifdef CONFIG_DVB #include "dvb_parser.h" #endif #ifdef CONFIG_DVB_SUBTITLE #include "dvb_subtitle.h" #endif /* for SCTE 127 VBI */ #ifdef HAS_VBI #include "pmt_desc_scte_127.h" #include "scte_127.h" #endif #define EAS_BUF_LEN (1024 + 188) #define MAX_RRT_DIM 128 #define RRT_BUF_LEN (1024 + 188) #define MAX_CHM_EVENT 32 #define MAX_TITLE_CHARS 96 #define MAX_DESC_CHARS 256 #define MAX_TIME_STR_CHARS 32 #define MAX_CC_SERVICES 6 /* Summary: Internal state. */ typedef enum chm_state_t { eCHM_PROG_INIT, eCHM_PROG_SCTE65, eCHM_PROG_UPDATING, eCHM_PROG_CAT, eCHM_PROG_IDLE }chm_state_t; /* Summary: Command enumeration to control channel manager. */ typedef enum chm_cmd_t { eCHM_CANCEL, eCHM_TUNE, eCHM_INFO, eCHM_STOP, eCHM_CHECK_SIGNAL, eCHM_HUNT, eCHM_HUNTING, eCHM_PENDING_INIT, eCHM_DOWNLOAD, eCHM_SAP, eCHM_DSUB, }chm_cmd_t; /* Command event structure */ typedef struct chm_cmd_event_t { chm_cmd_t cmd_id; /* Command ID */ unsigned char data[32]; }chm_cmd_event_t; /* Summary: Types of tune commands. */ typedef enum chm_tune_type_t { eCHM_UP, eCHM_DOWN, eCHM_CURRENT, eCHM_CH_NUM, eCHM_FREQ, }chm_tune_type_t; /* Summary: Tune command event structure. */ typedef struct chm_tune_event_t { chm_cmd_t cmd_id; /* Command ID */ chm_tune_type_t type; /* Type of tune command */ unsigned int data; /* Frequency in Hz, or channel number depending on type */ }chm_tune_event_t; /* Summary: Command enumeration to control channel manager. */ typedef enum chm_status_t { eCHM_STATUS_HUNT, eCHM_STATUS_PENDING_INIT, eCHM_STATUS_CHMAP, eCHM_STATUS_NORMAL, eCHM_STATUS_PAT, eCHM_STATUS_NOPAT, eCHM_STATUS_TUNE_MS, eCHM_STATUS_SI_MS, }chm_status_t; /* Summary: Command enumeration to control channel manager. */ typedef enum chm_evt_type_t { eCHM_EVT_CANCEL, eCHM_EVT_DONE, eCHM_EVT_REDRAW, eCHM_EVT_PROGRESS, eCHM_EVT_SIGNAL, /* Provide CA information, id - signal strength, data: SNR (32 bits), freq hz (32 bits) */ eCHM_EVT_DOWNLOAD, eCHM_EVT_EAS, eCHM_EVT_CA, /* Provide CA information, id - CA_System_ID, data: emm PID (16 bits) , freq_khz (32 bits)*/ eCHM_EVT_NETWORK, /* Provide Network PID, id - Network PID */ eCHM_EVT_STATUS, /* Provide status information, id - 0 Hunt Mode, 1 Pending Init Mode, 2 new ch map, 3 PAT, 4 PAT failed */ eCHM_EVT_AV_MUTE, /* change AV Mute, id - 0 Unmute, 1 mute */ eCHM_EVT_ACTIVATION, /* activation message, id - 0 Deactivate, 1 Activate */ eCHM_EVT_CONFIGURATION, /* config message, id - location code, data: timeout in hours (16 bits), VCT_ID (16 bits) */ eCHM_EVT_VCT_ID, /* config message, id - VCT_ID */ eCHM_EVT_LOCATION, /* location message, id - location code */ eCHM_EVT_TIMEZONE, /* timezone message, id - UTC offset, data: entry UTC (32 bits), exit UTC (32 bits), delta (8 bits) */ eCHM_EVT_PHONENUMBER, /* phone number message, data: 8 bit ASCII phone number (8 bytes)*/ eCHM_EVT_RESET, /* reset message, id - 0 nop, 1 reboot, 2 partial reset, 3 full reset */ eCHM_EVT_SAVE, /* save settings message */ eCHM_EVT_TIME, /* system time message, id - system time - GPS_offset , data: host clock offset (32 bits) */ eCHM_EVT_PAIRING, /* RF4CE Pairing */ eCHM_EVT_RRT, /* RRT event */ eCHM_EVT_CAD, /* content advisory descriptor event */ eCHM_EVT_BLOCK, /* block event from XDS packet */ eCHM_EVT_AMM, /* scp amm message event */ eCHM_EVT_SCC_AMM, /* scc amm message event */ eCHM_EVT_CAP_SERVICE, /* captioning service information */ eCHM_EVT_SET_SCREEN, /* captioning service information */ eCHM_EVT_MAX, /* Number of eCHM_EVTs */ }chm_evt_type_t; /* event structure for signaling application */ typedef struct chm_event_t { chm_evt_type_t type; unsigned int id; unsigned int ticks; unsigned char data[256]; }chm_event_t; /* Screen event structure */ typedef struct chm_time_event_t { chm_evt_type_t type; unsigned int system_time; unsigned int system_offset; unsigned int utc_offset; }chm_time_event_t; /* Signal structure */ typedef struct chm_signal_event_t { chm_evt_type_t type; unsigned int lock; unsigned int power; unsigned int ticks; unsigned int SNR; unsigned int freq_hz; int mode; }chm_signal_event_t; /* CA structure */ typedef struct chm_ca_event_t { chm_evt_type_t type; unsigned int CA_System_ID; unsigned int ticks; unsigned int freq_khz; unsigned short EMM_PID; unsigned short EMM_Provider_ID; unsigned char SCP_operating_mode; }chm_ca_event_t; /* configuration structure */ typedef struct chm_config_event_t { chm_evt_type_t type; unsigned int location; unsigned int ticks; unsigned short timeout; unsigned short VCT_ID; unsigned short timeout_policy; unsigned short max_location_errors; }chm_config_event_t; /* timezone structure */ typedef struct chm_tz_event_t { chm_evt_type_t type; unsigned int utc_offset; unsigned int ticks; unsigned int dst_entry; unsigned int dst_exit; unsigned char dst_delta; }chm_tz_event_t; /* Summary: Structure to help associate a stream and video PID */ typedef struct chm_stream_t { bstream_t stream; unsigned int freq_hz; unsigned short pid; }chm_stream_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 */ b_task_t task; unsigned int *stack; unsigned char *nit_buf; unsigned char *ntt_buf; unsigned char *svct_buf; unsigned char *stt_buf; unsigned char *pat_buf; unsigned char *pmt_buf; unsigned char *eas_buf; unsigned char *cvt_buf; unsigned char *cat_buf; unsigned char *emm_buf; #ifdef CONFIG_DVB unsigned char *dvb_nit_buf; unsigned char *dvb_sdt_buf; unsigned char *dvb_eit_buf; unsigned char *dvb_tdt_buf; #endif b_queue_t queue; b_event_t event[MAX_CHM_EVENT]; chm_event_t chm_evt; chm_event_t chm_pat_evt; chm_event_t chm_network_evt; chm_event_t chm_pending_evt; chm_event_t chm_hunt_evt; chm_event_t chm_eas_evt; chm_event_t status_evt; chm_event_t download_evt; chm_time_event_t time_evt; chm_event_t chmap_evt; chm_cmd_event_t cancel_cmd; chm_signal_event_t signal_evt; chm_tz_event_t tz_evt; chm_config_event_t config_evt; chm_event_t vct_id_evt; chm_event_t reset_evt; chm_event_t phone_evt; chm_event_t activate_evt; chm_event_t location_evt; chm_ca_event_t ca_evt; void *p_app; b_mutex_t mutex; b_mutex_t ch_map_mutex; char tmp_text[MAX_TITLE_CHARS + 1]; smessage_stream_t stt_msg; smessage_stream_t eas_msg; smessage_stream_t cvt_msg; smessage_stream_t nit_msg; smessage_stream_t ntt_msg; smessage_stream_t svct_msg; smessage_stream_t emm_msg; smessage_stream_t cat_msg; char eas_timer_started; /* EAS timer support */ uint16_t sequence_number; /* sequence number (% 32) */ uint16_t EAS_event_ID; /* EAS event ID */ #ifdef HAS_VBI smessage_stream_t scte127_msg; pscte_127_handle pscte_127; unsigned char *scte127_buf; int scte127_buf_size; #endif #ifdef CONFIG_DVB_SUBTITLE smessage_stream_t subtitle_msg; unsigned char *subtitle_buf; int subtitle_buf_size; #endif unsigned int select_idx; unsigned int hunt_cnt; b_queue_t gen_queue; b_event_t gen_event[MAX_MSG_EVENTS]; vch_t vch; st_t st; freq_t freq; unsigned int pat_crc; unsigned int pmt_crc; bool cvt_valid; struct cvt_info_t cvt; SI_SVCT_VCM_Callback_t vcm_cb; SI_NTT_SNS_Callback_t sns_cb; SI_CDS_Callback_t cds_cb; SI_MMS_Callback_t mms_cb; bool vcm_changed; bool sns_changed; bool cds_changed; bool mms_changed; bool mms_flag; ch_map_t ch_map; btuner_t tuner; smessage_stream_t smsg; btuner_params tuner_params; bapp_freq_table_type_t fe_type; unsigned int *freq_table; unsigned int num_freq; chm_stream_t chm_stream[BSETTOP_MAX_STREAMS]; bstream_mpeg mpeg[BSETTOP_MAX_STREAMS]; chm_stream_t *curr_stream; bband_t band; smessage_stream_params_t msg_params; bool decoding_video; bool decoding_audio; unsigned short network_pid; unsigned int vendor_id; unsigned int hardware_version_id; unsigned int last_freq_hz; unsigned int force_tune; /* force to tune even last frequency is same */ /* Status counts */ unsigned short ccm_cnt; unsigned short amm_cnt; unsigned short acm_even_cnt; unsigned short acm_odd_cnt; unsigned short key_table_cnt; unsigned short eas_filter_cnt; unsigned short cds_cnt; unsigned short mms_cnt; unsigned short sns_cnt; unsigned short dcm_cnt; unsigned short vcm_cnt; unsigned short stt_cnt; unsigned short emm_cnt; unsigned short ops_cnt; unsigned short cfg_cnt; unsigned short eas_cnt; unsigned short em_cnt; unsigned short cat_cnt; unsigned short pat_cnt; unsigned short pmt_cnt; unsigned short cvt_cnt; unsigned short refresh_count; unsigned short emm_count; unsigned short system_id_errors; #ifdef CONFIG_DVB smessage_stream_t dvb_nit_msg; smessage_stream_t dvb_sdt_msg; smessage_stream_t dvb_eit_msg; smessage_stream_t dvb_tdt_msg; dvb_sdt_cb_t dvb_sdt_cb; dvb_nit_cb_t dvb_nit_cb; #endif }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_event_t *p_cmd_evt); /* 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 */ ); /* Summary: Return the hunt mode progress in percent. */ int chm_get_hunt_progress(chm_mgr_t *p_chm); #endif /* CHAN_MGR_H__ */