source: svn/trunk/newcon3bcm2_21bu/dta/src/app/nanotv/bapp.h @ 2

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

first commit

  • Property svn:executable set to *
File size: 13.5 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 BAPP_H__
22#define BAPP_H__
23
24#include "bsettop.h"
25#include "fstore.h"
26#include "bscreen.h"
27#include "bapp_util.h"
28#include "bsettop_stream.h"
29#include "chan_mgr.h"
30#include "ch_map.h"
31#include "led.h"
32#include "bsettop_hdmi.h"
33#ifdef CONFIG_EIA_708
34#include "bapp_eia708.h"
35#endif
36#include "bsettop_rfm.h"
37#ifdef CONFIG_DVB_SUBTITLE
38#include "dvb_subtitle.h"
39#endif
40#define SCREEN_MAX_STR_WIDTH    1024
41
42#define MAX_MSG_EVENT           128
43#define MAX_RATING_STR          128
44#define MAX_TIME_STR            32
45
46#define TUNE_DURATION    (3 * 1000) /* Milliseconds */
47
48#define CONFIG_ACTIVE_STANDBY
49
50#define MAX_PHONE_LEN   255
51#define MAX_RRT_VAL                             16
52
53/*
54 * Application states
55 */
56typedef enum bapp_state_t
57{
58    eAPP_STATE_DEFAULT,         /* Default init state */
59    eAPP_STATE_HUNT,            /* Needs channel map or authorization to operated */
60    eAPP_STATE_PENDING,         /* Needs channel map or authorization to operated */
61        eAPP_STATE_NORMAL,              /* Has channel map and can tune channels */
62        eAPP_STATE_DOWNLOAD,    /* Temporarily in download state */
63        eAPP_STATE_FACTORY,             /* Factory Test State */
64        eAPP_STATE_DONE,                /* Last state, should never occur  */
65}bapp_state_t;
66
67
68/*
69 * Color palettes
70 */
71typedef enum bapp_palette_t
72{
73    ePALETTE_DEFAULT,
74    ePALETTE_SCREENSAVER,
75}bapp_palette_t;
76
77/**
78Summary:
79        Stream format type
80**/
81
82typedef struct bapp_av_stream_type_t
83{
84        unsigned char format;
85        unsigned int codec_id;
86        unsigned int transport_id; /* not used */
87        char format_name[32];
88}bapp_av_stream_type_t;
89
90typedef struct rrt_settings_t {
91    unsigned int rrt_status            : 2;
92    unsigned int rrt_size              : 14;
93    unsigned int last_rrt_id           : 16;
94    unsigned int pin                   : 32;
95    unsigned short ratings_rrt[MAX_RRT_DIM];
96    unsigned char rrt[RRT_BUF_LEN];
97}rrt_settings_t;
98
99typedef struct ratings_settings_t {
100    unsigned int ratings_lock          : 2;
101    unsigned int ratings_tv            : 18;
102    unsigned int ratings_movies        : 7;
103    unsigned int content_d             : 1;
104    unsigned int content_l             : 1;
105    unsigned int content_s             : 1;
106    unsigned int content_v             : 1;
107}ratings_settings_t;
108
109typedef struct dcc_settings_t {
110    unsigned int captions_basic        : 4;
111    unsigned int captions_font         : 3;
112    unsigned int captions_font_size    : 2;
113    unsigned int captions_font_style   : 2;
114    unsigned int captions_font_color   : 4;
115    unsigned int captions_font_opacity : 3;
116    unsigned int captions_back_color   : 4;
117    unsigned int captions_back_opacity : 3;
118    unsigned int captions_edge_color   : 4;
119    unsigned int captions_edge_type    : 3;
120        unsigned char captions_analog      : 4;
121        unsigned char captions_digital     : 4;
122}dcc_settings_t;
123
124typedef struct hd_config_settings_t {
125    unsigned int aspect_ratio       : 2;     /* display aspect radio, currently 4x3, 16x9 */
126    unsigned int output_format      : 3;     /* hd output format for HDMI */
127    unsigned int hd_options         : 3;     /* hd output options */
128    unsigned char sharpness;                 /* sharpness (0-25) for HDMI 480i/480p */
129} hd_config_settings_t;
130
131#define MAX_LONG_NAME_CHARS     128
132#define MAX_TITLE_CHARS         96
133#define MAX_DESC_CHARS          256
134#define MAX_TIME_STR_CHARS      32
135#define MAX_RATING_STR_CHARS    32
136#define MAX_CH_NAME_CHARS       11//7
137#define MAX_EIT_NUM             2
138#define EIT_CURRENT             0
139#define EIT_NEXT                1
140
141/* EIT Info structure */
142typedef struct chm_eit_t
143{
144    unsigned int        start_time;
145    unsigned int        length;
146    unsigned short      event_id;
147    unsigned char       prog_title[MAX_TITLE_CHARS + 1];
148    unsigned char       prog_desc[MAX_DESC_CHARS + 1];
149    PSIP_CSD_service    cc_service[MAX_CC_SERVICES];
150}chm_eit_t;
151
152/* Channel info structure */
153typedef struct chm_info_t
154{
155    unsigned short      source_id;
156    unsigned short      major;
157    unsigned short      minor;
158    unsigned short      program_number;
159    unsigned short      ch_name[MAX_CH_NAME_CHARS];
160    unsigned char       ext_ch_name[MAX_LONG_NAME_CHARS + 1];
161    unsigned char       vct_name[MAX_LONG_NAME_CHARS + 1];
162    chm_eit_t           eit_info[MAX_EIT_NUM];
163    bool                got_vct;
164}chm_info_t;
165
166/*
167 * State data structure, because this structure is saved to NVM
168 * options should be combined to make best use of storage space
169 */
170typedef struct bapp_settings_t
171{
172    unsigned int sound                 : 2;
173    unsigned int picture               : 1;
174    unsigned int language              : 2;
175    unsigned int wiz_completed         : 1;
176    unsigned int ratings_lock          : 2;
177    unsigned int ratings_tv            : 18;
178    unsigned int ratings_movies        : 7;
179    unsigned int content_d             : 1;
180    unsigned int content_l             : 1;
181    unsigned int content_s             : 1;
182    unsigned int content_v             : 1;
183        unsigned int auto_power_off        : 1;
184        unsigned int rrt_status            : 2;
185        unsigned int time_zone             : 4;
186        unsigned int dst                       : 1;
187        unsigned int last_rrt_id           : 16;
188    unsigned int pin                   : 32;
189
190    unsigned int activated             : 1;
191    unsigned int deactivated           : 1;
192    unsigned int standby               : 1;
193    unsigned int has_CAT               : 1;
194    unsigned int av_mute               : 1;
195        unsigned int psi_scan              : 1;
196    unsigned int audio_vol             : 7;
197    unsigned int state                 : 4;
198        unsigned int dst_delta             : 8;
199        unsigned int timeout_policy        : 8;
200        unsigned int SCP_operating_mode    : 8;
201// site_errors:16
202// prev_site_errors:16
203// max_site_errors:16
204    unsigned int CA_System_ID          : 16;
205    unsigned int EMM_Provider_ID       : 16;
206    unsigned int EMM_PID               : 16;
207    unsigned int VCT_ID                : 16;
208    unsigned int network_PID           : 16;
209        unsigned int hunt_cnt              : 16;
210        unsigned int download_failed_cnt   : 16;
211        unsigned int download_invalid_cnt  : 16;
212        unsigned int timeout               : 16;
213    unsigned int max_location_errors   : 16;
214    unsigned int location_errors       : 16;
215        unsigned int message_time          : 32;
216    unsigned int turn_on_freq_khz      : 32;
217        unsigned int addressable_time      : 32;
218        unsigned int timeout_cnt           : 32;
219        unsigned int location              : 32;
220        int utc_offset                             : 32;
221    unsigned int auto_power            : 32;
222        unsigned int dst_entry             : 32;
223        unsigned int dst_exit              : 32;
224        unsigned int reserved_0            : 32;
225        unsigned int reserved_1            : 32;
226        unsigned int reserved_2            : 32;
227        unsigned int reserved_3            : 32;
228        unsigned char phonenumber[MAX_PHONE_LEN];
229    unsigned short ratings_rrt[MAX_RRT_DIM];
230    unsigned char rrt[RRT_BUF_LEN];
231    ch_map_t    ch_map;
232//      ratings_settings_t ratings;
233//      rrt_settings_t rrt_settings;
234        dcc_settings_t dcc;
235    hd_config_settings_t hd_config;
236    unsigned int sd_options                             : 3;
237#ifdef CONFIG_DVB
238        unsigned char dvb_scan;
239#endif
240}bapp_settings_t;
241
242/*
243 * Main data structure containing references to all interfaces
244 * required throughout the application.
245 */
246
247typedef struct bapp_t
248{
249        bapp_state_t            state;
250        enum led_mode_t         led_mode;
251    unsigned int        yield_ms;
252    unsigned char*      osd_mem;
253    unsigned int        osd_mem_size;
254    bapp_settings_t     settings;
255    uint32_t            settings_dirty;
256    bgfx_palette_t      palette;
257    uint16_t            width; 
258    uint16_t            height;
259       
260        b_timeval               timeout_tv;
261
262    bgfx_surf_t         surf;
263    bdisplay_t          display;
264    bgraphics_t         graphics;
265    bdecode_window_t    window[2];
266    bdecode_t           decode;
267    baudio_decode_t     audio;
268    buser_input_t       user_io;
269        bsettop_hdmi_t          hdmi;
270    brfm_t              p_rfm;
271
272    bin_read_t          br;
273    bscreen_t          *p_screens;
274    int                 num_screens;
275    unsigned int        last_keypress_tick;
276    bapp_screen_id_t    screen_id;
277    bapp_screen_id_t    last_screen_id;
278    bapp_lang_t         lang;
279    unsigned int        tmp_str[SCREEN_MAX_STR_WIDTH];
280    unsigned int        tmp_value;
281    unsigned int        tmp_cnt;
282    bgfx_font_t         *p_font[eLANG_MAX][eFONT_SIZE_MAX];
283    b_queue_t           msg_queue;
284    b_event_t           msg_event[MAX_MSG_EVENT];
285        bool                            is_muted;
286    bool                system_mute;
287    unsigned char       audio_vol;
288    unsigned char       audio_mute;
289    unsigned char       power;
290    unsigned char       decoding;
291    unsigned int        last_tune_tick;
292    unsigned int        eas_timeout;
293    unsigned int        eas_text;               /* EAS text scrolling flag */
294    chm_mgr_t           chm;
295        unsigned int            poweron_ms;
296        unsigned int            snr;
297        unsigned int            tuned_freq;
298        bool                            check_poweron;
299        bool                            lock;
300    bool                                has_PAT;
301
302        unsigned int            power_level;
303#if (BCHP_CHIP == 3543)
304        BQAM_B_Mode         qam_b_mode;
305#elif (BCHP_CHIP == 7002)
306    btuner_qam_mode     qam_b_mode;
307#endif
308
309        unsigned int            system_time;
310        unsigned int            system_offset;
311        bool                            have_time;
312       
313        unsigned int            tune_ms;
314        unsigned int            si_ms;
315        unsigned int            location;
316
317        vch_t                           prev_vch;
318        vch_t                           cur_vch;
319        st_t                            cur_st;
320        freq_t                          cur_freq;
321        b_mutex_t           ch_map_mutex;
322        b_mutex_t                       flash_mutex;
323        chm_cmd_event_t         chm_cmd;
324        chm_tune_event_t        tune_cmd;
325        bIR_codes_t             last_key_down;
326        b_timeval                       last_key_tv;
327        fstore_t                        flash_storage;
328        unsigned char           eas_buf[EAS_BUF_LEN];
329        unsigned int            eas_buf_size;
330        unsigned char           *logo;
331        unsigned int            logo_size;
332    unsigned char       prog_time_str[MAX_TIME_STR];
333    unsigned char       prog_rating_str[MAX_RATING_STR];
334    unsigned char       psip_rating_str[MAX_RATING_STR];
335    unsigned int        last_rating_tick;
336    unsigned int        last_cad;
337    unsigned int        last_xds;
338    unsigned char       ratings_region;
339    unsigned char       ratings_dim;
340    unsigned char       ratings_val;
341    unsigned char       tv_rating;
342    unsigned char       movie_rating;
343
344        p_timing_profile_t      ptp_tune;               /* profile tune/acquire */
345        p_timing_profile_t      ptp_psi;                /* profile psi (PAT/PMT) */
346        p_timing_profile_t      ptp_first_pts;  /* profile start decode to first PTS */
347        p_timing_profile_t      ptp_decode;             /* profile start decode to sequence header */
348    char                last_rating_block_status;
349    char                last_psip_rating_block_status;
350    unsigned char       ratings_override;
351        bool                            ratings_override_set;
352        bool                pin_limit_override; /* for channel change */
353        uint32_t                        pin_limit_timeout;      /* pin limit time out */
354    chm_info_t          tmp_info;
355
356#ifdef CONFIG_EIA_708
357        bapp_eia708_t           eia708;
358#endif
359#ifdef CONFIG_DVB_SUBTITLE
360        bapp_dsub_t                     dsub;
361#endif
362}bapp_t;
363
364extern const unsigned short s_ch_to_freq[];
365
366int bin_read( void *buffer, int size, int count, void *fp );
367
368void bapp_init(bapp_t *p_app);
369void bapp_run(bapp_t *p_app);
370void bapp_idle(bapp_t *p_app);
371void bapp_sync(bapp_t *p_app);
372void bapp_handle_event(bapp_t *p_app, bscreen_event_t *p_event);
373void bapp_flush_screen(bapp_t *p_app);
374void bapp_set_current_screen(bapp_t *p_app, bapp_screen_id_t id, bapp_screen_id_t save_last);
375bscreen_t * bapp_get_current_screen(bapp_t *p_app);
376void bapp_goto_last_screen(bapp_t *p_app);
377int bapp_change_channel(bapp_t *p_app, int ch_up, int tune);
378int bapp_tune(bapp_t *p_app);
379int bapp_tune_prev(bapp_t *p_app);
380int bapp_set_channel(bapp_t *p_app, int channel);
381void bapp_enable_cc(bapp_t *p_app, int enable);
382void bapp_reset_settings(bapp_t *p_app);
383void bapp_save_settings(bapp_t *p_app);
384void bapp_av_mute(bapp_t *p_app, int mute);
385void bapp_audio_mute(bapp_t *p_app, int mute);
386void bapp_video_mute(bapp_t *p_app, int mute);
387void bapp_set_audio_volume(bapp_t *p_app, uint8_t level);
388void bapp_set_palette(bapp_t *p_app, bapp_palette_t palette);
389bool bapp_get_signal_status(bapp_t *p_app);
390int bapp_rotate_audio_sap(bapp_t *p_app);
391void bapp_do_poweroff(bapp_t *p_app);
392ch_map_t *bapp_cur_ch_map(bapp_t *p_app);
393
394int bapp_rotate_dsub(bapp_t *p_app);
395void bapp_audio_do_mute(bapp_t *p_app, int mute);
396void bapp_flush_screen_partial(bapp_t *p_app, int id);
397void bapp_select_primary_output(bapp_t *p_app, int mode);
398void bapp_select_scaler_coefficient(bapp_t *p_app, bool horizontal, int output, int coeff_idx);
399void bapp_power(bapp_t *p_app, bool power);
400bool bapp_get_block_status(bapp_t *p_app);
401void bapp_set_oob_flag(int oob);
402void bapp_get_avl_settings(int *target, int *low, int *boost);
403void bapp_set_avl_settings(int target, int low, int boost);
404
405#define DIRTY_MISC                      0x1
406#define DIRTY_CHANNEL           0x2
407#define DIRTY_EAS                       0x4
408#define DIRTY_PHONE                     0x8
409#define DIRTY_CHANNEL_MAP       0x10
410#define DIRTY_SCREEN            0x20
411//#define DIRTY_DCC           0x20
412#define DIRTY_RRT           0x40
413#define DIRTY_RATINGS       0x80
414#define DIRTY_CC            0x100
415
416#define DIRTY_HD_CONFIG     0x200
417#define DIRTY_DEBUG_CONFIG  0x400
418
419#define DIRTY_ALL       (DIRTY_MISC | DIRTY_CHANNEL | DIRTY_EAS | DIRTY_PHONE | DIRTY_CHANNEL_MAP | DIRTY_RRT | \
420                        DIRTY_RATINGS | DIRTY_CC | DIRTY_HD_CONFIG | DIRTY_DEBUG_CONFIG)
421
422#endif /* BAPP_H__ */
Note: See TracBrowser for help on using the repository browser.