source: svn/trunk/newcon3bcm2_21bu/dta/src/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: 12.3 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_tuner.h"
26#include "bsettop_smessage.h"
27#include "bstd.h"
28#include "ts_psi.h"
29#include "ts_pat.h"
30#include "ts_pmt.h"
31#include "psip_mss.h"
32#include "psip_descriptor.h"
33#include "bos.h"
34#include "ch_map.h"
35#include "si.h"
36#include "si_nit.h"
37#include "si_ntt.h"
38#include "si_stt.h"
39#include "si_svct.h"
40#include "dsmcc.h"
41#include "bapp_freq_table.h"
42#ifdef CONFIG_DVB
43#include "dvb_parser.h"
44#endif
45#ifdef CONFIG_DVB_SUBTITLE
46#include "dvb_subtitle.h"
47#endif
48/* for SCTE 127 VBI */
49#ifdef  HAS_VBI
50#include "pmt_desc_scte_127.h"
51#include "scte_127.h"
52#endif
53#define EAS_BUF_LEN     (1024 + 188)
54
55#define MAX_RRT_DIM             128
56#define RRT_BUF_LEN             (1024 + 188)
57
58#define MAX_CHM_EVENT           32
59#define MAX_TITLE_CHARS         96
60#define MAX_DESC_CHARS          256
61#define MAX_TIME_STR_CHARS      32
62#define MAX_CC_SERVICES                 6
63
64/*
65Summary:
66    Internal state.
67*/
68typedef enum chm_state_t
69{
70    eCHM_PROG_INIT,
71        eCHM_PROG_SCTE65,
72        eCHM_PROG_UPDATING,
73        eCHM_PROG_CAT,
74    eCHM_PROG_IDLE
75}chm_state_t;
76
77/*
78Summary:
79    Command enumeration to control channel manager.
80*/
81typedef enum chm_cmd_t
82{
83    eCHM_CANCEL,
84    eCHM_TUNE,
85    eCHM_INFO,
86    eCHM_STOP,
87    eCHM_CHECK_SIGNAL,
88    eCHM_HUNT,
89    eCHM_HUNTING,
90    eCHM_PENDING_INIT,
91    eCHM_DOWNLOAD,
92        eCHM_SAP,
93        eCHM_DSUB,
94}chm_cmd_t;
95/* Command event structure */
96typedef struct chm_cmd_event_t
97{
98    chm_cmd_t           cmd_id;         /* Command ID */
99        unsigned char   data[32];
100}chm_cmd_event_t;
101/*
102Summary:
103    Types of tune commands.
104*/
105typedef enum chm_tune_type_t
106{
107    eCHM_UP,
108    eCHM_DOWN,
109    eCHM_CURRENT,
110    eCHM_CH_NUM,
111        eCHM_FREQ,
112}chm_tune_type_t;
113
114/*
115Summary:
116    Tune command event structure.
117*/
118typedef struct chm_tune_event_t
119{
120    chm_cmd_t           cmd_id;         /* Command ID */
121        chm_tune_type_t type;           /* Type of tune command */
122        unsigned int    data;           /* Frequency in Hz, or channel number depending on type */
123}chm_tune_event_t;
124
125/*
126Summary:
127    Command enumeration to control channel manager.
128*/
129typedef enum chm_status_t
130{
131        eCHM_STATUS_HUNT,
132        eCHM_STATUS_PENDING_INIT,
133        eCHM_STATUS_CHMAP,
134        eCHM_STATUS_NORMAL,
135        eCHM_STATUS_PAT,
136        eCHM_STATUS_NOPAT,
137        eCHM_STATUS_TUNE_MS,
138        eCHM_STATUS_SI_MS,
139}chm_status_t;
140/*
141Summary:
142    Command enumeration to control channel manager.
143*/
144typedef enum chm_evt_type_t
145{
146    eCHM_EVT_CANCEL,
147    eCHM_EVT_DONE,
148    eCHM_EVT_REDRAW,
149    eCHM_EVT_PROGRESS,
150    eCHM_EVT_SIGNAL,            /* Provide CA information, id - signal strength, data: SNR (32 bits), freq hz (32 bits) */
151    eCHM_EVT_DOWNLOAD,
152    eCHM_EVT_EAS,
153    eCHM_EVT_CA,                    /* Provide CA information, id - CA_System_ID, data: emm PID (16 bits) , freq_khz (32 bits)*/
154    eCHM_EVT_NETWORK,           /* Provide Network PID, id - Network PID */
155    eCHM_EVT_STATUS,            /* Provide status information, id - 0 Hunt Mode, 1 Pending Init Mode, 2 new ch map, 3 PAT, 4 PAT failed */
156    eCHM_EVT_AV_MUTE,           /* change AV Mute, id - 0 Unmute, 1 mute */
157    eCHM_EVT_ACTIVATION,        /* activation message, id - 0 Deactivate, 1 Activate */
158    eCHM_EVT_CONFIGURATION,     /* config message, id - location code, data: timeout in hours (16 bits), VCT_ID (16 bits) */
159    eCHM_EVT_VCT_ID,            /* config message, id - VCT_ID */
160    eCHM_EVT_LOCATION,          /* location message, id - location code */
161    eCHM_EVT_TIMEZONE,          /* timezone message, id - UTC offset, data:  entry UTC (32 bits), exit UTC (32 bits), delta (8 bits) */
162    eCHM_EVT_PHONENUMBER,       /* phone number message, data:  8 bit ASCII phone number (8 bytes)*/
163    eCHM_EVT_RESET,                     /* reset message, id - 0 nop, 1 reboot, 2 partial reset, 3 full reset */
164    eCHM_EVT_SAVE,                      /* save settings message */
165    eCHM_EVT_TIME,                  /* system time message, id - system time - GPS_offset , data: host clock offset (32 bits) */
166    eCHM_EVT_PAIRING,       /* RF4CE Pairing */
167    eCHM_EVT_RRT,               /* RRT event */
168    eCHM_EVT_CAD,               /* content advisory descriptor event */
169    eCHM_EVT_BLOCK,                     /* block event from XDS packet */
170    eCHM_EVT_AMM,           /* scp amm message event */
171    eCHM_EVT_SCC_AMM,       /* scc amm message event */
172    eCHM_EVT_CAP_SERVICE,   /* captioning service information */
173    eCHM_EVT_SET_SCREEN,    /* captioning service information */
174    eCHM_EVT_MAX,               /* Number of eCHM_EVTs */
175}chm_evt_type_t;
176
177/*  event structure for signaling application */
178typedef struct chm_event_t
179{
180    chm_evt_type_t      type;
181    unsigned int        id;
182        unsigned int    ticks;
183        unsigned char   data[256];
184}chm_event_t;
185
186/* Screen event structure */
187typedef struct chm_time_event_t
188{
189    chm_evt_type_t      type;
190    unsigned int        system_time;
191    unsigned int        system_offset;
192    unsigned int        utc_offset;
193}chm_time_event_t;
194
195/* Signal structure */
196typedef struct chm_signal_event_t
197{
198    chm_evt_type_t      type;
199    unsigned int        lock;
200    unsigned int        power;
201        unsigned int    ticks;
202        unsigned int    SNR;
203        unsigned int    freq_hz;
204        int mode;
205}chm_signal_event_t;
206
207/* CA structure */
208typedef struct chm_ca_event_t
209{
210    chm_evt_type_t      type;
211    unsigned int        CA_System_ID;
212        unsigned int    ticks;
213        unsigned int    freq_khz;
214        unsigned short  EMM_PID;
215        unsigned short  EMM_Provider_ID;
216        unsigned char   SCP_operating_mode;
217}chm_ca_event_t;
218
219/* configuration structure */
220typedef struct chm_config_event_t
221{
222    chm_evt_type_t      type;
223    unsigned int        location;
224        unsigned int    ticks;
225        unsigned short  timeout;
226        unsigned short  VCT_ID;
227        unsigned short  timeout_policy;
228        unsigned short  max_location_errors;
229}chm_config_event_t;
230
231/* timezone structure */
232typedef struct chm_tz_event_t
233{
234    chm_evt_type_t      type;
235    unsigned int        utc_offset;
236        unsigned int    ticks;
237        unsigned int    dst_entry;
238        unsigned int    dst_exit;
239        unsigned char   dst_delta;
240}chm_tz_event_t;
241
242/*
243Summary:
244        Structure to help associate a stream and video PID
245*/
246typedef struct chm_stream_t
247{
248    bstream_t           stream;
249        unsigned int            freq_hz;
250        unsigned short          pid;
251}chm_stream_t;
252
253#define MAX_MSG_EVENTS 10
254/*
255Summary:
256    Command enumeration to control channel manager.
257*/
258typedef struct chm_mgr_t
259{
260    chm_cmd_t           cmd;                    /* Current channel manager state */
261    chm_state_t         state;                  /* state controls data acquisition priority */
262    b_task_t            task;
263    unsigned int        *stack;
264
265    unsigned char       *nit_buf;
266    unsigned char       *ntt_buf;
267    unsigned char       *svct_buf;
268    unsigned char       *stt_buf;
269    unsigned char       *pat_buf;
270    unsigned char       *pmt_buf;
271    unsigned char       *eas_buf;
272    unsigned char       *cvt_buf;
273    unsigned char       *cat_buf;
274    unsigned char       *emm_buf;
275#ifdef CONFIG_DVB
276        unsigned char       *dvb_nit_buf;
277        unsigned char       *dvb_sdt_buf; 
278        unsigned char       *dvb_eit_buf;
279        unsigned char       *dvb_tdt_buf;
280#endif
281    b_queue_t           queue;
282    b_event_t           event[MAX_CHM_EVENT];
283    chm_event_t         chm_evt;
284    chm_event_t         chm_pat_evt;
285    chm_event_t         chm_network_evt;
286    chm_event_t         chm_pending_evt;
287    chm_event_t         chm_hunt_evt;
288    chm_event_t         chm_eas_evt;
289    chm_event_t         status_evt;
290    chm_event_t         download_evt;
291    chm_time_event_t    time_evt;
292        chm_event_t             chmap_evt;
293    chm_cmd_event_t             cancel_cmd;
294    chm_signal_event_t  signal_evt;
295    chm_tz_event_t              tz_evt;
296    chm_config_event_t  config_evt;
297    chm_event_t                 vct_id_evt;
298    chm_event_t         reset_evt;
299    chm_event_t         phone_evt;
300    chm_event_t         activate_evt;
301    chm_event_t                 location_evt;
302        chm_ca_event_t          ca_evt;
303    void                *p_app;
304
305    b_mutex_t           mutex;
306    b_mutex_t           ch_map_mutex;
307
308    char                tmp_text[MAX_TITLE_CHARS + 1];
309
310    smessage_stream_t   stt_msg;
311    smessage_stream_t   eas_msg;
312    smessage_stream_t   cvt_msg;
313
314    smessage_stream_t   nit_msg;
315    smessage_stream_t   ntt_msg;
316    smessage_stream_t   svct_msg;
317    smessage_stream_t   emm_msg;
318    smessage_stream_t   cat_msg;
319
320    char                        eas_timer_started;      /* EAS timer support */
321    uint16_t            sequence_number;        /* sequence number (% 32) */
322    uint16_t            EAS_event_ID;           /* EAS event ID */
323
324#ifdef  HAS_VBI
325    smessage_stream_t   scte127_msg;
326    pscte_127_handle    pscte_127;
327    unsigned char       *scte127_buf;
328    int                 scte127_buf_size;
329#endif
330
331#ifdef CONFIG_DVB_SUBTITLE
332        smessage_stream_t   subtitle_msg;
333        unsigned char       *subtitle_buf;
334        int                 subtitle_buf_size; 
335#endif 
336
337    unsigned int        select_idx;
338        unsigned int            hunt_cnt;
339
340    b_queue_t           gen_queue;
341    b_event_t           gen_event[MAX_MSG_EVENTS];
342    vch_t                               vch;
343    st_t                                st;
344    freq_t                              freq;
345    unsigned int        pat_crc;
346    unsigned int        pmt_crc;
347
348    bool                        cvt_valid;
349    struct cvt_info_t   cvt;
350
351    SI_SVCT_VCM_Callback_t      vcm_cb;
352    SI_NTT_SNS_Callback_t       sns_cb;
353    SI_CDS_Callback_t           cds_cb;
354    SI_MMS_Callback_t           mms_cb;
355    bool                                vcm_changed;
356    bool                                sns_changed;
357    bool                                cds_changed;
358    bool                                mms_changed;
359    bool                                mms_flag;
360    ch_map_t                    ch_map;
361
362    btuner_t            tuner;
363    smessage_stream_t   smsg;
364        btuner_params           tuner_params;
365        bapp_freq_table_type_t fe_type;
366        unsigned int            *freq_table;
367        unsigned int            num_freq;
368
369    chm_stream_t        chm_stream[BSETTOP_MAX_STREAMS];
370    bstream_mpeg        mpeg[BSETTOP_MAX_STREAMS];
371        chm_stream_t            *curr_stream;
372    bband_t             band;
373    smessage_stream_params_t msg_params;
374        bool                            decoding_video;
375        bool                            decoding_audio;
376
377        unsigned short          network_pid;
378    unsigned int                vendor_id;
379    unsigned int                hardware_version_id;
380    unsigned int        last_freq_hz;
381
382    unsigned int        force_tune;             /* force to tune even last frequency is same */
383       
384        /* Status counts */
385        unsigned short          ccm_cnt;
386        unsigned short          amm_cnt;
387        unsigned short          acm_even_cnt;
388        unsigned short          acm_odd_cnt;
389        unsigned short          key_table_cnt;
390        unsigned short          eas_filter_cnt;
391        unsigned short          cds_cnt;
392        unsigned short          mms_cnt;
393        unsigned short          sns_cnt;
394        unsigned short          dcm_cnt;
395        unsigned short          vcm_cnt;
396        unsigned short          stt_cnt;
397        unsigned short          emm_cnt;
398        unsigned short          ops_cnt;
399        unsigned short          cfg_cnt;
400        unsigned short          eas_cnt;
401        unsigned short          em_cnt;
402        unsigned short          cat_cnt;
403        unsigned short          pat_cnt;
404        unsigned short          pmt_cnt;
405        unsigned short          cvt_cnt;
406        unsigned short          refresh_count;
407        unsigned short          emm_count;
408        unsigned short          system_id_errors;
409#ifdef CONFIG_DVB
410        smessage_stream_t   dvb_nit_msg;
411        smessage_stream_t   dvb_sdt_msg;
412        smessage_stream_t   dvb_eit_msg;
413        smessage_stream_t   dvb_tdt_msg;
414        dvb_sdt_cb_t        dvb_sdt_cb;
415        dvb_nit_cb_t        dvb_nit_cb;
416#endif
417
418}chm_mgr_t;
419
420extern unsigned int g_xds_time_offset;
421extern bool g_xds_dst;
422
423/*
424Summary:
425Initialization.
426 */
427void chm_init(chm_mgr_t *p_chm, void *p_app);
428
429/*
430Summary:
431Function to pass a command to the channel manager.
432Any results and notification is handled by passing events to the app via
433the msg_queue.
434
435 */
436void chm_cmd(chm_mgr_t *p_chm,chm_cmd_event_t *p_cmd_evt);
437
438
439/*
440Summary:
441Get the current UTC time, local offset and dst flag.
442Returns non-zero when it is not possible to determine local time.
443
444 */
445int chm_get_time_info(chm_mgr_t *p_chm, 
446                unsigned int *utc_secs,           /* Current UTC time in seconds */
447                int *local_offset,                /* Local time offset from UTC time in seconds */
448                bool *dst                         /* Daylight savings flag */
449                );
450
451/*
452Summary:
453process the MMS string and associated tables.
454Returns non-zero on failure.
455 */
456int chm_process_mss(chm_mgr_t *p_chm,               /* Channel manager reference */
457                PSIP_MSS_string p_mms,          /* Pointer to MMS */
458                unsigned char* mms_buf,         /* string buffer */
459                unsigned int mms_len            /* string buffer length */
460                );
461
462
463/*
464Summary:
465Return the hunt mode progress in percent.
466 */
467int chm_get_hunt_progress(chm_mgr_t *p_chm);
468
469
470#endif /* CHAN_MGR_H__ */
471
Note: See TracBrowser for help on using the repository browser.