source: svn/newcon3bcm2_21bu/dta/src/app/ntia/chan_mgr.h @ 44

Last change on this file since 44 was 44, checked in by megakiss, 11 years ago

광주방송 OTC 주파수 369Mhz로 변경

  • Property svn:executable set to *
File size: 13.8 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 "bapp_freq_table.h"
36
37#include "psip_vct.h"
38#include "psip_stt.h"
39#include "psip_rrt.h"
40#include "psip_mgt.h"
41#include "psip_eit.h"
42
43#define MAX_CHANNELS            128
44#define MAX_CH_NAME_CHARS               32
45#define MAX_CH_SHORT_NAME_CHARS 7               /* short name in VCT */
46#define MAX_LONG_NAME_CHARS     128
47#define MAX_TIME_STR_CHARS      32
48#define MAX_RATING_STR_CHARS    32
49#define MAX_EIT_NUM             9               /* make it multiple of detailed EPG entry size 9 for each page */
50#define EIT_CURRENT             0
51#define EIT_NEXT                1
52#define MAX_CMD_HIST                    128
53
54/* for SCTE 127 VBI */
55#ifdef  HAS_VBI
56#include "pmt_desc_scte_127.h"
57#include "scte_127.h"
58#endif
59#define EAS_BUF_LEN                             (1024 + 188)
60
61#define MAX_RRT_DIM             128
62#define RRT_BUF_LEN             (1024 + 188)
63
64#define MAX_CHM_EVENT           32
65#define MAX_TITLE_CHARS         96
66#define MAX_DESC_CHARS          256
67#define MAX_TIME_STR_CHARS      32
68#define MAX_CC_SERVICES                 6
69
70/*
71Summary:
72    Internal state.
73*/
74typedef enum chm_state_t
75{
76    eCHM_GET_STT,
77    eCHM_GET_VCT,
78    eCHM_GET_MGT,
79    eCHM_PROCESS_MGT,
80    eCHM_PROG_IDLE
81}chm_state_t;
82
83/*
84Summary:
85    Command enumeration to control channel manager.
86*/
87typedef enum chm_cmd_t
88{
89    eCHM_CANCEL,
90    eCHM_TUNE,
91    eCHM_INFO,
92    eCHM_STOP,
93    eCHM_CHECK_SIGNAL,
94    eCHM_HUNT,
95        eCHM_GUIDE,
96        eCHM_SAP
97}chm_cmd_t;
98/* Command event structure */
99typedef struct chm_cmd_event_t
100{
101    chm_cmd_t           cmd_id;         /* Command ID */
102        unsigned char   data[32];
103}chm_cmd_event_t;
104/*
105Summary:
106    Types of tune commands.
107*/
108typedef enum chm_tune_type_t
109{
110    eCHM_UP,
111    eCHM_DOWN,
112    eCHM_CURRENT,
113    eCHM_CH_NUM,
114        eCHM_FREQ,
115}chm_tune_type_t;
116
117/*
118Summary:
119    Tune command event structure.
120*/
121typedef struct chm_tune_event_t
122{
123    chm_cmd_t           cmd_id;         /* Command ID */
124        chm_tune_type_t type;           /* Type of tune command */
125        unsigned int    data;           /* Frequency in Hz, or channel number depending on type */
126}chm_tune_event_t;
127
128/*
129Summary:
130    Command enumeration to control channel manager.
131*/
132typedef enum chm_status_t
133{
134        eCHM_STATUS_HUNT,
135        eCHM_STATUS_CHMAP,
136        eCHM_STATUS_NORMAL,
137        eCHM_STATUS_PAT,
138        eCHM_STATUS_NOPAT,
139        eCHM_STATUS_TUNE_MS,
140        eCHM_STATUS_SI_MS,
141}chm_status_t;
142/*
143Summary:
144    Command enumeration to control channel manager.
145*/
146typedef enum chm_evt_type_t
147{
148    eCHM_EVT_CANCEL,
149    eCHM_EVT_DONE,
150    eCHM_EVT_REDRAW,
151    eCHM_EVT_PROGRESS,
152    eCHM_EVT_SIGNAL,            /* Provide CA information, id - signal strength, data: SNR (32 bits), freq hz (32 bits) */
153    eCHM_EVT_EAS,
154    eCHM_EVT_STATUS,            /* Provide status information, id - 0 Hunt Mode, 1 Pending Init Mode, 2 new ch map, 3 PAT, 4 PAT failed */
155    eCHM_EVT_AV_MUTE,           /* change AV Mute, id - 0 Unmute, 1 mute */
156    eCHM_EVT_SAVE,                      /* save settings message */
157    eCHM_EVT_TIME,                  /* system time message, id - system time - GPS_offset , data: host clock offset (32 bits) */
158    eCHM_EVT_RRT,               /* RRT event */
159    eCHM_EVT_CAD,               /* content advisory descriptor event */
160    eCHM_EVT_BLOCK,                     /* block event from XDS packet */
161    eCHM_EVT_SET_SCREEN,    /* captioning service information */
162        eCHM_EVT_SNR,                   /* SNR event */
163        eCHM_EVT_RESET,         /* reset message, id - 0 nop, 1 reboot, 2 partial reset, 3 full reset */
164    eCHM_EVT_MAX,               /* Number of eCHM_EVTs */
165}chm_evt_type_t;
166
167/*  event structure for signaling application */
168typedef struct chm_event_t
169{
170    chm_evt_type_t      type;
171    unsigned int        id;
172        unsigned int    ticks;
173        unsigned char   data[256];
174}chm_event_t;
175
176/* Screen event structure */
177typedef struct chm_time_event_t
178{
179    chm_evt_type_t      type;
180    unsigned int        system_time;
181    unsigned int        system_offset;
182    unsigned int        utc_offset;
183}chm_time_event_t;
184
185/* Signal structure */
186typedef struct chm_signal_event_t
187{
188    chm_evt_type_t      type;
189    unsigned int        lock;
190    unsigned int        power;
191        unsigned int    ticks;
192        unsigned int    SNR;
193        unsigned int    freq_hz;
194        unsigned int    signal_quality;
195        int mode;
196}chm_signal_event_t;
197
198/*
199Summary:
200        Structure to help associate a stream and video PID
201*/
202typedef struct chm_stream_t
203{
204    bstream_t           stream;
205        unsigned int            freq_hz;
206        unsigned short          pid;
207}chm_stream_t;
208
209/* EIT Info structure */
210typedef struct chm_eit_t
211{
212    unsigned int        start_time;
213    unsigned int        length;
214    unsigned short      event_id;
215    unsigned char       prog_title[MAX_TITLE_CHARS + 1];
216    unsigned char       prog_desc[MAX_DESC_CHARS + 1];
217    PSIP_CSD_service    cc_service[MAX_CC_SERVICES];
218}chm_eit_t;
219
220/* Channel info structure */
221typedef struct chm_info_t
222{
223    unsigned short      source_id;
224    unsigned short      major;
225    unsigned short      minor;
226    unsigned short      program_number;
227    unsigned char               ch_name[MAX_CH_NAME_CHARS];
228    unsigned char       ext_ch_name[MAX_LONG_NAME_CHARS + 1];
229    //unsigned char       vct_name[MAX_LONG_NAME_CHARS + 1];
230    chm_eit_t           eit_info[MAX_EIT_NUM];
231    bool                got_vct;
232    unsigned char               psip_rating_str[MAX_RATING_STR_CHARS];  /* remember psip rating string associated with EIT */
233}chm_info_t;
234
235typedef enum time_source_t
236{
237    eTS_NONE,
238    eTS_TSID,
239    eTS_XDS,
240    eTS_FIXED,
241}time_source_t;
242
243/* MGT state constants */
244typedef enum chm_mgt_state_t
245{
246    eMGT_EIT,
247    eMGT_ETT,
248}chm_mgt_state_t;
249
250/* flag indication what type of eit found */
251typedef enum chm_eit_found_t
252{
253    eEIT_NONE =         0x00,
254    eEIT_CURRENT =      0x01,
255    eEIT_NEXT =         0x02,
256    eEIT_BOTH =         0x03,
257    eEIT_CONT =         0x04,   /* EIT/ETT beyond current and next */
258}chm_eit_found_t;
259
260/* rrt event structure */
261typedef struct chm_rrt_event_t
262{
263        chm_evt_type_t  type;
264        unsigned int    size;
265        unsigned char   rrt[RRT_BUF_LEN];
266} chm_rrt_event_t;
267
268#define MAX_MSG_EVENTS 10
269/*
270Summary:
271    Command enumeration to control channel manager.
272*/
273typedef struct chm_mgr_t
274{
275    chm_cmd_t           cmd;                    /* Current channel manager state */
276    chm_state_t         state;                  /* state controls data acquisition priority */
277    b_task_t            task;
278    unsigned int        *stack;
279
280    unsigned char       *stt_buf;
281    unsigned char       *pat_buf;
282    unsigned char       *pmt_buf;
283    unsigned char       *eas_buf;
284    b_queue_t           queue;
285    b_event_t           event[MAX_CHM_EVENT];
286    chm_event_t         chm_evt;
287    chm_event_t         chm_pat_evt;
288    chm_event_t         chm_pending_evt;
289    chm_event_t         chm_hunt_evt;
290    chm_event_t         chm_eas_evt;
291    chm_event_t         status_evt;
292    chm_time_event_t    time_evt;
293        chm_event_t             chmap_evt;
294    chm_cmd_event_t             cancel_cmd;
295    chm_signal_event_t  signal_evt;
296    chm_event_t         reset_evt;
297    chm_event_t         redraw_evt;
298    void                *p_app;
299
300    b_mutex_t           mutex;
301    b_mutex_t           ch_map_mutex;
302
303    char                tmp_text[MAX_TITLE_CHARS + 1];
304
305    smessage_stream_t   stt_msg;
306    smessage_stream_t   eas_msg;
307
308    char                        eas_timer_started;      /* EAS timer support */
309    uint16_t            sequence_number;    /* sequence number (% 32) */
310    uint16_t            EAS_event_ID;           /* EAS event ID */
311        bool                    eas_reset;                      /* flag indicates eas is reset (will accept new eas without checking parameters) */
312
313    unsigned int        select_idx;
314        unsigned int            hunt_cnt;
315
316    b_queue_t           gen_queue;
317    b_event_t           gen_event[MAX_MSG_EVENTS];
318    unsigned int        pat_crc;
319    unsigned int        pmt_crc;
320
321    ch_map_t                    ch_map;
322
323    btuner_t            tuner;
324    smessage_stream_t   smsg;
325        btuner_params           tuner_params;
326        bapp_freq_table_type_t fe_type;
327        unsigned int            *freq_table;
328        unsigned int            num_freq;
329
330    chm_stream_t        chm_stream[BSETTOP_MAX_STREAMS];
331    bstream_mpeg        mpeg[BSETTOP_MAX_STREAMS];
332        chm_stream_t            *curr_stream;
333    bband_t             band;
334    smessage_stream_params_t msg_params;
335        bool                            decoding_video;
336        bool                            decoding_audio;
337
338        unsigned short          network_pid;
339    unsigned int                vendor_id;
340    unsigned int                hardware_version_id;
341    unsigned int        last_freq_hz;
342
343    unsigned int        force_tune;             /* force to tune even last frequency is same */
344       
345        /* Status counts */
346        unsigned short          ccm_cnt;
347        unsigned short          amm_cnt;
348        unsigned short          acm_even_cnt;
349        unsigned short          acm_odd_cnt;
350        unsigned short          key_table_cnt;
351        unsigned short          cds_cnt;
352        unsigned short          mms_cnt;
353        unsigned short          sns_cnt;
354        unsigned short          dcm_cnt;
355        unsigned short          vcm_cnt;
356        unsigned short          stt_cnt;
357        unsigned short          ops_cnt;
358        unsigned short          cfg_cnt;
359        unsigned short          eas_cnt;
360        unsigned short          em_cnt;
361        unsigned short          pat_cnt;
362        unsigned short          pmt_cnt;
363        unsigned short          refresh_count;
364        unsigned short          system_id_errors;
365
366        /* STT */
367        PSIP_STT_header     stt;
368    unsigned int        sys_time;           /* UTC seconds minus UTC offset in STT */
369    unsigned int        sys_UTC_offset;     /* UTC offset in STT */
370    unsigned int        sys_offset;         /* System seconds from gettimeofday when STT came in  */
371        bool                            got_stt;
372
373        /* eit */
374    smessage_stream_t   eit_msg;
375    unsigned char       *eit_buf;
376        unsigned short          eit_cnt;
377        bool                            got_eit;
378    unsigned int        eit_start_time;
379    unsigned int        eit_length;
380    unsigned int        eit_crc;
381
382        /* mgt */
383    smessage_stream_t   mgt_msg;
384    unsigned char       *mgt_buf;
385        unsigned short          mgt_cnt;
386        bool                            got_mgt;
387    b_timeval                   mgt_tv;                         /* Time we finished processing MGT  */
388    chm_mgt_state_t     mgt_state;          /* state of MGT processing */
389    unsigned int        mgt_crc;
390
391        /* vct */
392    smessage_stream_t   vct_msg;
393    unsigned char       *vct_buf;
394        unsigned short          vct_cnt;
395        bool                            got_vct;
396    unsigned int        vct_crc;
397        PSIP_VCT_channel        prev_vct;       /* in Mexico broacast, some stations even encoding VCT wrong, e.g. duplication of VCT entry */
398
399        /* ett */
400    unsigned char       *ett_buf;
401        unsigned short          ett_cnt;
402        bool                            got_ett;
403
404        /* rrt */
405    smessage_stream_t   rrt_msg;
406    unsigned char       *rrt_buf;
407        unsigned short          rrt_cnt;
408        bool                            got_rrt;
409    unsigned int        rrt_crc;
410        chm_rrt_event_t         rrt_evt;
411
412    time_source_t       local_time_source;      /* Identifies method used to obtain local time */           
413    int                 local_offset;       /* local time offset from UTC time to obtain standard time */
414    char                local_dst_obs;      /* local DST observance */
415        unsigned short          TSID;                           /* remember latest TSID */
416
417    unsigned int        mgt_size;
418    unsigned int        mgt_idx;
419
420    chm_info_t          cur_info;
421    chm_info_t          *p_info;
422    unsigned int        max_info_num;
423   
424    unsigned int        rrt_size;
425    unsigned int        last_rrt;
426
427        chm_event_t                     snr_evt;
428       
429        b_timeval           guide_tv;                   /* time guide was retrieved */
430        int                 cur_ch_num;                 /* current channel number */
431        int                 cur_epg_ch_num;             /* track current channel number for addtional EPG display */
432        int                 epg_update_ch_num;  /* the channel number that the EPG screen will start to update */
433
434        bool                            not_check_cancel;       /* don't check cancel event */
435        bool                            first_pat_pmt;          /* flag indicate if we have make a first check of PAT/PMT */
436}chm_mgr_t;
437
438extern unsigned int g_xds_time_offset;
439extern bool g_xds_dst;
440
441/*
442Summary:
443Initialization.
444 */
445void chm_init(chm_mgr_t *p_chm, void *p_app);
446
447/*
448Summary:
449Function to pass a command to the channel manager.
450Any results and notification is handled by passing events to the app via
451the msg_queue.
452
453 */
454void chm_cmd(chm_mgr_t *p_chm,chm_cmd_event_t *p_cmd_evt);
455
456
457/*
458Summary:
459Get the current UTC time, local offset and dst flag.
460Returns non-zero when it is not possible to determine local time.
461
462 */
463int chm_get_time_info(chm_mgr_t *p_chm, 
464                unsigned int *utc_secs,           /* Current UTC time in seconds */
465                int *local_offset,                /* Local time offset from UTC time in seconds */
466                bool *dst                         /* Daylight savings flag */
467                );
468
469/*
470Summary:
471process the MMS string and associated tables.
472Returns non-zero on failure.
473 */
474int chm_process_mss(chm_mgr_t *p_chm,               /* Channel manager reference */
475                PSIP_MSS_string p_mms,          /* Pointer to MMS */
476                unsigned char* mms_buf,         /* string buffer */
477                unsigned int mms_len            /* string buffer length */
478                );
479
480
481/*
482Summary:
483Return the hunt mode progress in percent.
484 */
485int chm_get_hunt_progress(chm_mgr_t *p_chm);
486
487/* get current channel information */
488void chm_get_cur_ch_info( chm_mgr_t *p_chm, chm_info_t *p_info, bstream_mpeg *p_mpeg);
489
490bool chm_GetScanStatusFinish(void);
491typedef enum chm_msg_filter_t
492{
493    eCHM_MSG_FILTER_STT = 0x0001,
494    eCHM_MSG_FILTER_RRT = 0x0002,       /* downloadable RRT */
495    eCHM_MSG_FILTER_MGT = 0x0004,
496    eCHM_MSG_FILTER_EAS = 0x0008               
497} chm_msg_filter_t;
498
499void chm_start_filter_monitoring(chm_mgr_t *p_chm, chm_msg_filter_t which);
500void chm_stop_filter_monitoring(chm_mgr_t *p_chm, chm_msg_filter_t which);
501
502int chm_clear_current(chm_mgr_t *p_chm);
503
504bool chm_has_valid_cc_service(chm_mgr_t *p_chm, bool *wide_aspect_ratio);
505
506#ifdef CONFIG_NXP_TDA182I4
507void NXP_TDA182I4_SetStandby();
508#endif
509
510#ifdef TUNER_DEBUG
511int chm_scan_psi_a_freq(chm_mgr_t *p_chm, unsigned int freq);
512#endif
513
514bool chm_check_program_end_time(chm_mgr_t *p_chm);
515
516#endif /* CHAN_MGR_H__ */
Note: See TracBrowser for help on using the repository browser.