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

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 16.9 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
38#define SCREEN_MAX_STR_WIDTH    1024
39
40#define MAX_MSG_EVENT           128
41#define MAX_TIME_STR            32
42
43#define TUNE_DURATION                   (3 * 1000) /* Milliseconds */
44
45#define CONFIG_ACTIVE_STANDBY
46
47#define MAX_PHONE_LEN                   255
48#define MAX_RRT_VAL                             16
49#define MAX_EAS_TEXT                    256
50
51/* support for user defined frequencies in diagnostic screen */
52#define MAX_USER_FREQ                   16
53
54/*
55 * Application states
56 */
57typedef enum bapp_state_t
58{
59    eAPP_STATE_DEFAULT,         /* Default init state */
60    eAPP_STATE_HUNT,            /* Needs channel map to operate */
61        eAPP_STATE_NORMAL,              /* Has channel map and can tune channels */
62        eAPP_STATE_FACTORY,             /* Factory Test State */
63        eAPP_STATE_DONE,                /* Last state, should never occur  */
64}bapp_state_t;
65
66/*
67 * RRT status
68 */
69typedef enum bapp_rrt_status_t
70{
71    eRRT_UNAVAILABLE = 0x0,
72        eRRT_AVAILABLE   = 0x1,
73}bapp_rrt_status_t;
74
75/*
76 * Structure defining blocked setting for an RRT dim/value pair.
77*/
78typedef enum bapp_rrt_rating_state_t
79{
80        eRRT_UNBLOCK = 0x0,
81        eRRT_BLOCK   = 0x1
82}bapp_rrt_rating_state_t;
83
84/*
85 * Color palettes
86 */
87typedef enum bapp_palette_t
88{
89    ePALETTE_DEFAULT,
90    ePALETTE_SCREENSAVER,
91}bapp_palette_t;
92
93/**
94Summary:
95        Stream format type
96**/
97
98typedef struct bapp_av_stream_type_t
99{
100        unsigned char format;
101        unsigned int codec_id;
102        unsigned int transport_id; /* not used */
103        char format_name[32];
104}bapp_av_stream_type_t;
105
106typedef struct rrt_settings_t {
107    unsigned int rrt_status            : 2;
108    unsigned int rrt_size              : 14;
109    unsigned int last_rrt_id           : 16;
110    unsigned int pin;                           /* separate pin for RRT or same pin for whole app? */
111    unsigned short ratings_rrt[MAX_RRT_DIM];
112    unsigned char rrt[RRT_BUF_LEN];
113}rrt_settings_t;
114
115typedef struct ratings_settings_t {
116    unsigned int ratings_lock          : 2;
117    unsigned int ratings_tv            : 18;
118    unsigned int ratings_movies        : 7;
119    unsigned int content_d             : 1;
120    unsigned int content_l             : 1;
121    unsigned int content_s             : 1;
122    unsigned int content_v             : 1;
123}ratings_settings_t;
124
125typedef struct dcc_settings_t {
126    unsigned int captions_basic        : 4;
127    unsigned int captions_font         : 3;
128    unsigned int captions_font_size    : 2;
129    unsigned int captions_font_style   : 2;
130    unsigned int captions_font_color   : 4;
131    unsigned int captions_font_opacity : 3;
132    unsigned int captions_back_color   : 4;
133    unsigned int captions_back_opacity : 3;
134    unsigned int captions_edge_color   : 4;
135    unsigned int captions_edge_type    : 3;
136        unsigned char captions_analog      : 4;
137        unsigned char captions_digital     : 4;
138}dcc_settings_t;
139
140typedef struct hd_config_settings_t {
141    unsigned int aspect_ratio       : 2;     /* display aspect radio, currently 4x3, 16x9 */
142    unsigned int output_format      : 3;     /* hd output format for HDMI */
143    unsigned int hd_options         : 3;     /* hd output options */
144    unsigned char sharpness;                 /* sharpness (0-25) for HDMI 480i/480p */
145} hd_config_settings_t;
146
147#define MAX_LONG_NAME_CHARS     128
148#define MAX_TITLE_CHARS         96
149#define MAX_DESC_CHARS          256
150#define MAX_TIME_STR_CHARS      32
151#define EIT_CURRENT             0
152#define EIT_NEXT                1
153
154/*
155 * Structure defining a unit of data storage
156 */
157typedef struct bapp_ch_t
158{
159    unsigned int major          : 10;
160    unsigned int minor          : 10;
161    unsigned int freq_idx       : 8;
162    unsigned int psi            : 1;
163    unsigned int pcr_pid        : 13;
164    unsigned int video_pid      : 13;
165    unsigned int has_lang       : 3;                                    /* NOTE that we can have muximum of 3 languages */
166    unsigned int hidden         : 1;
167    unsigned short video_type   : 8;                                    /* we need support more video format, e.g. AVC */
168        unsigned short program_num      : 8;                                    /* program number */
169        unsigned short num_audio        : 8;                                    /* number of audio channels */
170    unsigned short audio_pid[MAX_AUDIO_PIDS];
171    unsigned short ch_name[MAX_CH_SHORT_NAME_CHARS];    /* VCT short defined 7 as max, but we have more */
172    unsigned short audio_type[MAX_AUDIO_PIDS];                  /* for MPEG audio support */
173    unsigned char audio_lang[MAX_CH_NAME_CHARS][3];     
174        unsigned int frequency_khz;                                                     /* frequency in khz for the channel */
175        unsigned short cur_audio;
176        unsigned short source_id;                                                       /* we need to save source id */
177        /* new feature */
178        unsigned int skip                       : 1;                                    /* skip chennel */
179        unsigned int favorite           : 1;                                    /* favorite channel, use the CH+/- to browse */
180}bapp_ch_t;
181
182/*
183 * State data structure, because this structure is saved to NVM
184 * options should be combined to make best use of storage space
185 */
186typedef struct bapp_settings_t
187{
188    unsigned int sound                 : 2;
189    unsigned int picture               : 1;
190    unsigned int language              : 2;
191    unsigned int wiz_completed         : 1;
192        unsigned int auto_power_off        : 2;         /* handle "no signal" case */
193        unsigned int time_zone             : 4;
194        unsigned int dst                       : 1;
195
196    unsigned int standby               : 1;
197    unsigned int rfm                       : 1;
198    unsigned int av_mute               : 1;
199        unsigned int psi_scan              : 1;
200    unsigned int audio_vol             : 7;
201    unsigned int state                 : 4;
202        unsigned int dst_delta             : 8;
203        unsigned int timeout_policy        : 8;
204        unsigned int analog_captioning     : 1;
205    unsigned int sd_options                        : 3;
206        unsigned int hunt_cnt              : 16;
207        unsigned int download_failed_cnt   : 16;
208        unsigned int download_invalid_cnt  : 16;
209        unsigned int timeout               : 16;
210    unsigned int max_location_errors   : 16;
211    unsigned int location_errors       : 16;
212        unsigned int message_time          : 32;
213    unsigned int turn_on_freq_khz      : 32;
214        unsigned int addressable_time      : 32;
215        unsigned int timeout_cnt           : 32;
216        unsigned int location              : 32;
217        int utc_offset                             : 32;
218    unsigned int auto_power            : 32;
219        unsigned int dst_entry             : 32;
220        unsigned int dst_exit              : 32;
221        unsigned int reserved_0            : 32;
222        unsigned int reserved_1            : 32;
223        unsigned int reserved_2            : 32;
224        unsigned int reserved_3            : 32;
225        ratings_settings_t ratings;
226        rrt_settings_t rrt_settings;
227        dcc_settings_t dcc;
228
229    unsigned char num_channels;                 /* number of channels scanned */
230        bapp_ch_t ch[MAX_CHANNELS];
231
232#ifdef HAS_HDMI
233    hd_config_settings_t hd_config;
234#endif
235}bapp_settings_t;
236
237/*
238 * Main data structure containing references to all interfaces
239 * required throughout the application.
240 */
241
242typedef struct bapp_t
243{
244        bapp_state_t            state;
245        enum led_mode_t         led_mode;
246    unsigned int        yield_ms;
247    unsigned char*      osd_mem;
248    unsigned int        osd_mem_size;
249    bapp_settings_t     settings;
250    uint32_t            settings_dirty;
251    bgfx_palette_t      palette;
252    uint16_t            width; 
253    uint16_t            height;
254       
255        b_timeval               timeout_tv;
256
257    bgfx_surf_t         surf;
258    bdisplay_t          display;
259    bgraphics_t         graphics;
260    bdecode_window_t    window[2];
261    bdecode_t           decode;
262    baudio_decode_t     audio;
263    buser_input_t       user_io;
264        bsettop_hdmi_t          hdmi;
265    brfm_t              p_rfm;
266
267    bin_read_t          br;
268    bscreen_t          *p_screens;
269    int                 num_screens;
270    unsigned int        last_keypress_tick;
271    unsigned int        power_saver_tick;               /* keep track the power saver tick */
272    bapp_screen_id_t    screen_id;
273    bapp_screen_id_t    last_screen_id;
274    bapp_lang_t         lang;
275    unsigned int        tmp_str[SCREEN_MAX_STR_WIDTH];
276    unsigned int        tmp_value;
277    unsigned int        tmp_cnt;
278    bgfx_font_t         *p_font[eLANG_MAX][eFONT_SIZE_MAX];
279    b_queue_t           msg_queue;
280    b_event_t           msg_event[MAX_MSG_EVENT];
281        bool                            is_muted;
282    bool                system_mute;
283    unsigned char       audio_vol;
284    unsigned char       audio_mute;
285    unsigned char       power;
286    unsigned char       decoding;
287    unsigned int        last_tune_tick;
288    unsigned int        eas_timeout;
289    unsigned int        eas_text;                                       /* EAS text scrolling flag */
290    char                eas_str[MAX_EAS_TEXT];          /* eas string including activation message and alert mesage */
291    unsigned char       eas_char_width[MAX_EAS_TEXT];
292    int                 eas_str_len;                            /* lengthe of p_app->eas_str */
293    int                 eas_activation_str_len;         /* length of eas_activation_str inside p_app->eas_text */
294    int                 eas_activation_str_width;       /* pixel width of eas_activation_str inside p_app->eas_text */
295    int                 eas_src_start_idx;                      /* required for scrolling */
296    int                 eas_src_end_idx;
297    int                 eas_src_start_x;
298    int                 eas_src_end_x;
299    int                 eas_dsp_x;
300    bool                eas_activation_text;
301    bool                eas_one_iteration;
302    bool                eas_started;
303    bool                eas_ch_found; /* valid source id on EAS msg */
304
305    chm_mgr_t           chm;
306        unsigned int            poweron_ms;
307        unsigned int            snr;
308        unsigned int            tuned_freq;
309        bool                            check_poweron;
310        bool                            lock;
311    bool                                has_PAT;
312
313        unsigned int            power_level;
314
315        unsigned int            system_time;
316        unsigned int            system_offset;
317        bool                            have_time;
318       
319        unsigned int            tune_ms;
320        unsigned int            si_ms;
321        unsigned int            location;
322        /* VSB */
323        bapp_ch_t                       prev_ch;
324        bapp_ch_t                       cur_ch;
325        int                                     cur_ch_num;             /* current channel number */
326
327        b_mutex_t           ch_map_mutex;
328        b_mutex_t                       flash_mutex;
329        chm_cmd_event_t         chm_cmd;
330        chm_cmd_event_t         hunt_cmd;
331        chm_tune_event_t        tune_cmd;
332        bIR_codes_t             last_key_down;
333        b_timeval                       last_key_tv;
334        b_timeval                       last_save_tv;           /* reduce check on save to flash */
335        fstore_t                        flash_storage;
336        unsigned char           eas_buf[EAS_BUF_LEN];
337        unsigned int            eas_buf_size;
338        unsigned char           *logo;
339        unsigned int            logo_size;
340    unsigned char       prog_time_str[MAX_TIME_STR];
341    unsigned char       prog_rating_str[MAX_RATING_STR_CHARS];
342    unsigned char       psip_rating_str[MAX_RATING_STR_CHARS];
343    unsigned int        last_rating_tick;
344    unsigned int        last_cad;
345    unsigned int        last_xds;
346    unsigned char       ratings_region;
347    unsigned char       ratings_dim;
348    unsigned char       ratings_val;
349    unsigned char       tv_rating;
350    unsigned char       movie_rating;
351
352        p_timing_profile_t      ptp_tune;               /* profile tune/acquire */
353        p_timing_profile_t      ptp_psi;                /* profile psi (PAT/PMT) */
354        p_timing_profile_t      ptp_first_pts;  /* profile start decode to first PTS */
355        p_timing_profile_t      ptp_decode;             /* profile start decode to sequence header */
356    char                last_rating_block_status;
357    char                last_psip_rating_block_status;
358    unsigned char       ratings_override;
359        bool                            ratings_override_set;
360        bool                pin_limit_override; /* for channel change */
361        uint32_t                        pin_limit_timeout;      /* pin limit time out */
362    char                last_ch_block_status;
363    chm_info_t          tmp_info;
364       
365        bool                            re_tune;                /* re-tune flag */
366        unsigned int        signal_level;       /* signal level */
367        int                                     num_sap;                /* for draw SAP indicator if any */
368        int                                     current_sap;    /* for draw SAP indicator if any */
369        bool                            check_signal;
370#ifdef CONFIG_STANDBY
371        bool                            active_standby;
372#endif
373        btuner_status           tuner_status;   /* remember tuner status if any */
374
375    /* DCC */
376#ifdef CONFIG_EIA_708
377        bapp_eia708_t           eia708;
378#endif
379
380#if 1 /*ChengYu@20120808: for factory test*/
381    bool                factory_test;
382#endif
383        bool scan_in_progress; 
384        unsigned short          captions_basic; /* for simple On switch CC switch */
385        bool cc_enabled;                                        /* cc enabled or not */
386        bool wide_aspect_ratio;                         /* wide aspect ratio flag from Closed Captioning descriptor */
387        unsigned int            signal_quality; /* signal quality */
388        bool no_signal;                                         /* flag to indicate the box are in no signal condition */
389        int sd_options;                                         /* temp sd_options that set from the AR remote button */
390
391        unsigned char           *dolby_logo;    /* dolby logo to show in the banner screen */
392        unsigned int            dolby_logo_size;
393        unsigned char           *dst_logo;
394        unsigned int            dst_logoSize;
395
396        /* audio only channel screen support */
397        uint32_t        audio_channel_draw_timeout;     /* audio only channel draw timeout */   
398    b_timeval   audio_channel_tm;                       /* initial timeout to enter audio only channel event handler */ 
399}bapp_t;
400
401extern const unsigned short s_ch_to_freq[];
402
403int bin_read( void *buffer, int size, int count, void *fp );
404
405void bapp_init(bapp_t *p_app);
406void bapp_run(bapp_t *p_app);
407void bapp_idle(bapp_t *p_app);
408void bapp_sync(bapp_t *p_app);
409void bapp_handle_event(bapp_t *p_app, bscreen_event_t *p_event);
410void bapp_flush_screen(bapp_t *p_app);
411void bapp_set_current_screen(bapp_t *p_app, bapp_screen_id_t id, bapp_screen_id_t save_last);
412bscreen_t * bapp_get_current_screen(bapp_t *p_app);
413void bapp_goto_last_screen(bapp_t *p_app);
414int bapp_change_channel(bapp_t *p_app, int ch_up, int tune);
415int bapp_change_channel_fav(bapp_t *p_app, int ch_up, int tune);
416
417int bapp_tune(bapp_t *p_app);
418int bapp_tune_prev(bapp_t *p_app);
419int bapp_set_channel(bapp_t *p_app, bapp_ch_t *pch);
420int bapp_set_channel_by_major(bapp_t *p_app, int major, int minor);
421void bapp_enable_cc(bapp_t *p_app, int enable);
422void bapp_reset_settings(bapp_t *p_app);
423void bapp_save_settings(bapp_t *p_app);
424void bapp_av_mute(bapp_t *p_app, int mute);
425void bapp_audio_mute(bapp_t *p_app, int mute);
426void bapp_audio_SetDolbyDrc_mode(bapp_t *p_app, baudio_dolby_drc_mode mode);
427void bapp_audio_GetDolbyDrc_mode(bapp_t *p_app, baudio_dolby_drc_mode mode);
428void bapp_video_mute(bapp_t *p_app, int mute);
429void bapp_set_audio_volume(bapp_t *p_app, uint8_t level);
430void bapp_set_palette(bapp_t *p_app, bapp_palette_t palette);
431bool bapp_get_signal_status(bapp_t *p_app);
432int bapp_rotate_audio_sap(bapp_t *p_app);
433void bapp_do_poweroff(bapp_t *p_app);
434ch_map_t *bapp_cur_ch_map(bapp_t *p_app);
435
436int bapp_rotate_dsub(bapp_t *p_app);
437void bapp_audio_do_mute(bapp_t *p_app, int mute);
438void bapp_flush_screen_partial(bapp_t *p_app, int id);
439void bapp_select_primary_output(bapp_t *p_app, int mode);
440void bapp_select_scaler_coefficient(bapp_t *p_app, bool horizontal, int output, int coeff_idx);
441void bapp_power(bapp_t *p_app, bool power);
442bool bapp_get_block_status(bapp_t *p_app);
443void bapp_set_oob_flag(int oob);
444void bapp_get_avl_settings(int *target, int *low, int *boost);
445void bapp_set_avl_settings(int target, int low, int boost);
446
447bapp_ch_t *bapp_is_channel_valid(bapp_t *p_app);
448
449#define DIRTY_MISC                      0x1
450#define DIRTY_CHANNEL           0x2
451#define DIRTY_EAS                       0x4
452#define DIRTY_CHANNEL_MAP       0x10
453#define DIRTY_SCREEN            0x20
454#define DIRTY_DCC           0x20
455#define DIRTY_RRT           0x40
456#define DIRTY_RATINGS       0x80
457#define DIRTY_CC            0x100
458
459#define DIRTY_HD_CONFIG     0x200
460#define DIRTY_DEBUG_CONFIG  0x400
461
462#define DIRTY_ALL       (DIRTY_MISC | DIRTY_CHANNEL | DIRTY_EAS | DIRTY_CHANNEL_MAP | DIRTY_RRT | \
463                        DIRTY_RATINGS | DIRTY_CC | DIRTY_HD_CONFIG | DIRTY_DEBUG_CONFIG)
464
465/*
466Summary:
467        Reset the closed captioning settings to the default values.
468*/
469void bapp_reset_cc_config_settings(bapp_t *p_app);
470
471void bapp_channel_scan(bapp_t *p_app);
472
473/*
474 * Summary:
475 *     Set closed captions CS options
476 *     Description:
477 *         Set closed captions CS options
478 */
479void bapp_set_captions_options(bapp_t *p_app);
480
481void bapp_P_enable_avl(bapp_t *p_app, bool enable);
482void bapp_enable_avl(bool enable);
483
484bapp_t *bapp_get_app_instance(void);
485
486int bapp_get_wide_aspect_ratio_cb(void);
487
488void bapp_set_wide_aspect_ratio(bapp_t *p_app);
489
490#ifdef TUNER_DEBUG
491/* helper function for frontend tuner performance measurement */
492void bapp_scan_psi_a_freq(uint32_t freq_khz);
493void bapp_get_tuner_status(void);
494#endif
495void bapp_brfm_set_ch3(bool);
496void bapp_bdisplay_setRfOutput(bool isOutput);
497void bapp_audio_1k_TONE(void);
498/*janzy@20121113,audio,video start/stop ctrl begin*/
499void bapp_audio_stop(void);
500void bapp_video_stop(void);
501void bapp_AV_start(unsigned int vid,unsigned int aud,unsigned int pcr);
502/*end*/
503void bapp_Set_ColorBars(bool enable);/*janzy@20121113,add ColorBars*/
504void bapp_do_exit();/*janzy@20121115,OSD TimeOut*/
505
506void bapp_set_ar_options(bapp_t *p_app);
507
508/* dolby logo support */
509bool bapp_is_dolby_type(bapp_t *p_app);
510
511#endif /* BAPP_H__ */
Note: See TracBrowser for help on using the repository browser.