source: svn/trunk/newcon3bcm2_21bu/nexus/app/nanotv/chan_mgr.h

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 8.0 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2006, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile:  $
11 * $brcm_Revision:  $
12 * $brcm_Date: $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log:  $
19 *
20 ***************************************************************************/
21#ifndef CHAN_MGR_H__
22#define CHAN_MGR_H__
23
24#include "bsettop_stream.h"
25#include "bsettop_message.h"
26#include "bstd.h"
27#include "ts_psi.h"
28#include "ts_pat.h"
29#include "ts_pmt.h"
30#include "psip_vct.h"
31#include "psip_stt.h"
32#include "psip_rrt.h"
33#include "psip_mgt.h"
34#include "psip_eit.h"
35#include "psip_mss.h"
36#include "psip_descriptor.h"
37#include "bos.h"
38
39#ifdef BQAM_SCRIPT
40#define MAX_CHANNELS            256
41#else
42#define MAX_CHANNELS            128
43#endif
44
45#define MAX_CHM_EVENT           16
46#define MAX_LONG_NAME_CHARS     128
47#define MAX_TITLE_CHARS         96
48#define MAX_DESC_CHARS          256
49#define MAX_TIME_STR_CHARS      32
50#define MAX_RATING_STR_CHARS    32
51#define MAX_CH_NAME_CHARS       7
52#define MAX_EIT_NUM             2
53#define EIT_CURRENT             0
54#define EIT_NEXT                1
55#define MAX_CMD_HIST                    128
56#define MAX_CC_SERVICES                 6
57        #define RRT_BUF_LEN        (1024 + 188)
58
59
60/*
61Summary:
62    Internal state.
63*/
64typedef enum chm_state_t
65{
66    eCHM_GET_STT,
67    eCHM_GET_VCT,
68    eCHM_GET_MGT,
69    eCHM_PROCESS_MGT,
70    eCHM_PROG_IDLE,
71    eCHM_GET_RRT,
72}chm_state_t;
73
74/*
75Summary:
76    Command enumeration to control channel manager.
77*/
78typedef enum chm_cmd_t
79{
80    eCHM_CANCEL,
81    eCHM_SCAN,
82    eCHM_TUNE,
83    eCHM_INFO,
84    eCHM_GUIDE,
85    eCHM_STOP,
86    eCHM_CHECK_SIGNAL
87}chm_cmd_t;
88
89
90/*
91Summary:
92    Command enumeration to control channel manager.
93*/
94typedef enum chm_evt_type_t
95{
96    eCHM_EVT_CANCEL,
97    eCHM_EVT_DONE,
98    eCHM_EVT_REDRAW,
99    eCHM_PROGRESS,
100    eCHM_EVT_BLOCK,
101    eCHM_EVT_CAD,
102    eCHM_EVT_RRT,
103    eCHM_EVT_CSD,
104    eCHM_EVT_SIGNAL
105}chm_evt_type_t;
106
107/* Screen event structure */
108typedef struct chm_event_t
109{
110    chm_evt_type_t   type;
111    unsigned int     id;
112        unsigned int     ticks;
113        unsigned char   data[32];
114}chm_event_t;
115
116/* Signal structure */
117typedef struct chm_signal_event_t
118{
119    chm_evt_type_t      type;
120    unsigned int        lock;
121    float       power;
122        unsigned int    ticks;
123        unsigned int    SNR;
124        unsigned int    freq_hz;
125#if (BCHP_CHIP == 3543)
126        BQAM_B_Mode     qam_b_mode;
127#elif (BCHP_CHIP == 7002)
128    btuner_qam_mode qam_b_mode;
129#endif
130}chm_signal_event_t;
131
132/* EIT Info structure */
133typedef struct chm_eit_t
134{
135    unsigned int        start_time;
136    unsigned int        length;
137    unsigned short      event_id;
138    unsigned char       prog_title[MAX_TITLE_CHARS + 1];
139    unsigned char       prog_desc[MAX_DESC_CHARS + 1];
140        PSIP_CSD_service        cc_service[MAX_CC_SERVICES];
141}chm_eit_t;
142
143/* Channel info structure */
144typedef struct chm_info_t
145{
146    unsigned short      source_id;
147    unsigned short      major;
148    unsigned short      minor;
149    unsigned short      program_number;
150    unsigned short      ch_name[MAX_CH_NAME_CHARS];
151    unsigned char       ext_ch_name[MAX_LONG_NAME_CHARS + 1];
152    unsigned char       vct_name[MAX_LONG_NAME_CHARS + 1];
153    chm_eit_t           eit_info[MAX_EIT_NUM];
154    bool                got_vct;
155}chm_info_t;
156
157typedef enum time_source_t
158{
159    eTS_NONE,
160    eTS_TSID,
161    eTS_XDS,
162    eTS_FIXED,
163}time_source_t;
164
165/* MGT state constants */
166typedef enum chm_mgt_state_t
167{
168    eMGT_EIT,
169    eMGT_ETT,
170}chm_mgt_state_t;
171
172/* flag indication what type of eit found */
173typedef enum chm_eit_found_t
174{
175    eEIT_NONE = 0,
176    eEIT_CURRENT = 1,
177    eEIT_NEXT = 2,
178    eEIT_BOTH = 3,
179}chm_eit_found_t;
180
181/* smart antenna command history */
182typedef struct cmd_hist_t
183{
184        unsigned int locked             : 1;
185        unsigned int cmd                : 7;
186        unsigned int snr                : 8;
187}cmd_hist_t;
188
189#define MAX_MSG_EVENTS 10
190/*
191Summary:
192    Command enumeration to control channel manager.
193*/
194typedef struct chm_mgr_t
195{
196    chm_cmd_t           cmd;                    /* Current channel manager state */
197    chm_state_t         state;                  /* state controls data acquisition priority */
198    chm_mgt_state_t     mgt_state;              /* state of MGT processing */
199    bapp_task_t            task;
200    unsigned int        *stack;
201
202    unsigned char       *eit_buf;
203    unsigned char       *ett_buf;
204    unsigned char       *mgt_buf;
205    unsigned char       *vct_buf;
206    unsigned char       *new_rrt_buf;
207    unsigned char       *stt_buf;
208    unsigned char       *pat_buf;
209    unsigned char       *pmt_buf;
210       
211    chm_info_t          cur_info;
212
213    bstream_mpeg        mpeg;
214    bapp_task_queue_t           queue;
215    bapp_task_event_t           event[MAX_CHM_EVENT];
216    chm_event_t         chm_evt;
217    chm_signal_event_t  signal_evt;
218    void                *p_app;
219   
220    bapp_task_mutex_t           mutex;
221
222    PSIP_STT_header     stt;
223    unsigned int        sys_time;                   /* UTC seconds minus UTC offset in STT */
224    unsigned int        sys_UTC_offset;             /* UTC offset in STT */
225    unsigned int        sys_offset;                 /* System seconds from gettimeofday when STT came in  */
226    struct timeval              mgt_tv;                         /* Time we finished processing MGT  */
227    bool                got_stt;                    /* Flag indicating stt was received on current channel */
228
229    time_source_t       local_time_source;          /* Identifies method used to obtain local time */           
230    int                 local_offset;               /* local time offset from UTC time to obtain standard time */
231    char                local_dst_obs;              /* local DST observance */
232
233    unsigned int        mgt_size;
234    unsigned int        mgt_idx;
235
236    chm_info_t          *p_info;
237    unsigned int        max_info_num;
238   
239    unsigned char       cur_ch_num;
240    unsigned int        rrt_size;
241    unsigned int        last_rrt;
242    struct timeval      guide_tv;                   /* time guide was retrieved */
243        cmd_hist_t                      cmd_hist[MAX_CMD_HIST];
244        unsigned char           ant_cmd;
245
246
247    char                tmp_text[MAX_TITLE_CHARS + 1];
248    unsigned int        eit_start_time;
249    unsigned int        eit_length;
250
251    smessage_stream_t   stt_msg;
252    smessage_stream_t   rrt_msg;
253
254    bapp_task_queue_t           gen_queue;
255    bapp_task_event_t           gen_event[MAX_MSG_EVENTS];
256}chm_mgr_t;
257
258extern unsigned int g_xds_time_offset;
259extern bool g_xds_dst;
260
261/*
262Summary:
263    Initialization.
264*/
265void chm_init(chm_mgr_t *p_chm, void *p_app);
266
267/*
268Summary:
269    Function to pass a command to the channel manager.
270    Any results and notification is handled by passing events to the app via
271    the msg_queue.
272   
273*/
274void chm_cmd(chm_mgr_t *p_chm,chm_cmd_t cmd);
275
276
277/*
278Summary:
279    Get a copy of the current channel manager info structure.
280   
281*/
282void chm_get_cur_ch_info(chm_mgr_t *p_chm,
283                         chm_info_t *p_info,
284                         bstream_mpeg *p_mpeg);
285
286/*
287Summary:
288    Get the current UTC time, local offset and dst flag.
289    Returns non-zero when it is not possible to determine local time.
290   
291*/
292int chm_get_time_info(chm_mgr_t *p_chm, 
293                      unsigned int *utc_secs,           /* Current UTC time in seconds */
294                      int *local_offset,                /* Local time offset from UTC time in seconds */
295                      bool *dst                         /* Daylight savings flag */
296                      );
297
298/*
299Summary:
300    process the MMS string and associated tables.
301    Returns non-zero on failure.
302*/
303int chm_process_mss(chm_mgr_t *p_chm,               /* Channel manager reference */
304                    PSIP_MSS_string p_mms,          /* Pointer to MMS */
305                    unsigned char* mms_buf,         /* string buffer */
306                    unsigned int mms_len            /* string buffer length */
307                   );
308
309#endif /* CHAN_MGR_H__ */
310
Note: See TracBrowser for help on using the repository browser.