| 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 "bscreen.h" |
|---|
| 26 | #include "bapp_util.h" |
|---|
| 27 | #include "bsettop_stream.h" |
|---|
| 28 | #include "chan_mgr.h" |
|---|
| 29 | #ifdef CONFIG_EIA_708 |
|---|
| 30 | #include "bapp_eia708.h" |
|---|
| 31 | #else |
|---|
| 32 | #define bapp_eia708_enabled(x) false |
|---|
| 33 | |
|---|
| 34 | #endif |
|---|
| 35 | #define SCREEN_MAX_STR_WIDTH 1024 |
|---|
| 36 | |
|---|
| 37 | #define MAX_MSG_EVENT 4 |
|---|
| 38 | #define MAX_TIME_STR 32 |
|---|
| 39 | #define MAX_RATING_STR 128 |
|---|
| 40 | |
|---|
| 41 | #define MAX_RRT_VAL 16 |
|---|
| 42 | |
|---|
| 43 | #define TUNE_DURATION (3 * 1000) /* Milliseconds */ |
|---|
| 44 | |
|---|
| 45 | /* |
|---|
| 46 | * Application states |
|---|
| 47 | */ |
|---|
| 48 | |
|---|
| 49 | typedef enum bapp_state_t |
|---|
| 50 | { |
|---|
| 51 | eAPP_DEFAULT, |
|---|
| 52 | eAPP_CH_SCAN |
|---|
| 53 | }bapp_state_t; |
|---|
| 54 | |
|---|
| 55 | /* |
|---|
| 56 | * Color palettes |
|---|
| 57 | */ |
|---|
| 58 | typedef enum bapp_palette_t |
|---|
| 59 | { |
|---|
| 60 | ePALETTE_DEFAULT, |
|---|
| 61 | ePALETTE_SCREENSAVER, |
|---|
| 62 | ePALETTE_EIA_708 |
|---|
| 63 | }bapp_palette_t; |
|---|
| 64 | |
|---|
| 65 | /* |
|---|
| 66 | * Antenna Types |
|---|
| 67 | */ |
|---|
| 68 | typedef enum bapp_antenna_t |
|---|
| 69 | { |
|---|
| 70 | eBASIC_ANTENNA, |
|---|
| 71 | eSMART_ANTENNA |
|---|
| 72 | }bapp_antenna_t; |
|---|
| 73 | |
|---|
| 74 | /* |
|---|
| 75 | * Channel Scan Types |
|---|
| 76 | */ |
|---|
| 77 | typedef enum bapp_ch_scan_t |
|---|
| 78 | { |
|---|
| 79 | eFULL_SCAN, |
|---|
| 80 | eQUICK_SCAN, |
|---|
| 81 | eFULL_RESCAN, |
|---|
| 82 | eQUICK_RESCAN |
|---|
| 83 | }bapp_ch_scan_t; |
|---|
| 84 | |
|---|
| 85 | /* |
|---|
| 86 | * RRT status |
|---|
| 87 | */ |
|---|
| 88 | typedef enum bapp_rrt_status_t |
|---|
| 89 | { |
|---|
| 90 | eRRT_UNAVAILABLE = 0x0, |
|---|
| 91 | eRRT_AVAILABLE = 0x1, |
|---|
| 92 | }bapp_rrt_status_t; |
|---|
| 93 | #define DTA_TEST |
|---|
| 94 | /* |
|---|
| 95 | * Structure defining a unit of data storage |
|---|
| 96 | */ |
|---|
| 97 | typedef struct bapp_ch_t |
|---|
| 98 | { |
|---|
| 99 | unsigned int major : 10; |
|---|
| 100 | unsigned int minor : 10; |
|---|
| 101 | unsigned int freq_idx : 8; |
|---|
| 102 | unsigned int psi : 1; |
|---|
| 103 | unsigned int pcr_pid : 13; |
|---|
| 104 | unsigned int video_pid : 13; |
|---|
| 105 | unsigned int has_lang : 3; |
|---|
| 106 | unsigned int hidden : 1; |
|---|
| 107 | unsigned short audio_pid[3]; |
|---|
| 108 | unsigned short ch_name[MAX_CH_NAME_CHARS]; |
|---|
| 109 | unsigned char cmd; |
|---|
| 110 | #ifdef DTA_TEST |
|---|
| 111 | unsigned short program_number; |
|---|
| 112 | #endif |
|---|
| 113 | }bapp_ch_t; |
|---|
| 114 | |
|---|
| 115 | /* |
|---|
| 116 | * Structure defining blocked setting for an RRT dim/value pair. |
|---|
| 117 | */ |
|---|
| 118 | typedef enum bapp_rrt_rating_state_t |
|---|
| 119 | { |
|---|
| 120 | eRRT_UNBLOCK = 0x0, |
|---|
| 121 | eRRT_BLOCK = 0x1 |
|---|
| 122 | }bapp_rrt_rating_state_t; |
|---|
| 123 | |
|---|
| 124 | /* |
|---|
| 125 | * State data structure, because this structure is saved to NVM |
|---|
| 126 | * options should be combined to make best use of storage space |
|---|
| 127 | */ |
|---|
| 128 | typedef struct bapp_settings_t |
|---|
| 129 | { |
|---|
| 130 | unsigned int sound : 2; |
|---|
| 131 | unsigned int picture : 1; |
|---|
| 132 | unsigned int language : 2; |
|---|
| 133 | unsigned int auto_power : 2; |
|---|
| 134 | unsigned int wiz_completed : 1; |
|---|
| 135 | unsigned int ratings_lock : 2; |
|---|
| 136 | unsigned int ratings_tv : 18; |
|---|
| 137 | unsigned int ratings_movies : 7; |
|---|
| 138 | unsigned int content_d : 1; |
|---|
| 139 | unsigned int content_l : 1; |
|---|
| 140 | unsigned int content_s : 1; |
|---|
| 141 | unsigned int content_v : 1; |
|---|
| 142 | unsigned int captions_basic : 4; |
|---|
| 143 | unsigned int captions_font : 3; |
|---|
| 144 | unsigned int captions_font_size : 2; |
|---|
| 145 | unsigned int captions_font_style : 2; |
|---|
| 146 | unsigned int captions_font_color : 4; |
|---|
| 147 | unsigned int captions_font_opacity : 3; |
|---|
| 148 | unsigned int captions_back_color : 4; |
|---|
| 149 | unsigned int captions_back_opacity : 3; |
|---|
| 150 | unsigned int captions_edge_color : 4; |
|---|
| 151 | unsigned int captions_edge_type : 3; |
|---|
| 152 | unsigned int auto_power_off : 1; |
|---|
| 153 | unsigned int rrt_status : 2; |
|---|
| 154 | unsigned int time_zone : 4; |
|---|
| 155 | unsigned int dst : 1; |
|---|
| 156 | unsigned int cur_ch_num : 8; |
|---|
| 157 | unsigned int audio_vol : 7; |
|---|
| 158 | unsigned int last_rrt_id : 16; |
|---|
| 159 | unsigned int pin : 32; |
|---|
| 160 | unsigned char num_channels; |
|---|
| 161 | unsigned short ratings_rrt[MAX_RRT_DIM]; |
|---|
| 162 | unsigned char rrt[RRT_BUF_LEN]; |
|---|
| 163 | bapp_ch_t ch[MAX_CHANNELS]; |
|---|
| 164 | }bapp_settings_t; |
|---|
| 165 | |
|---|
| 166 | /* |
|---|
| 167 | * Main data structure containing references to all interfaces |
|---|
| 168 | * required throughout the application. |
|---|
| 169 | */ |
|---|
| 170 | |
|---|
| 171 | typedef struct bapp_t |
|---|
| 172 | { |
|---|
| 173 | int done; |
|---|
| 174 | unsigned int yield_ms; |
|---|
| 175 | unsigned char* osd_mem; |
|---|
| 176 | unsigned int osd_mem_size; |
|---|
| 177 | bapp_settings_t settings; |
|---|
| 178 | bool settings_dirty; |
|---|
| 179 | bool factory_test; |
|---|
| 180 | bool button_numbers; |
|---|
| 181 | bool ui_debug_mode; |
|---|
| 182 | bgfx_palette_t palette; |
|---|
| 183 | uint16_t width; |
|---|
| 184 | uint16_t height; |
|---|
| 185 | bgfx_surf_t surf; |
|---|
| 186 | bdisplay_t display; |
|---|
| 187 | bgraphics_t graphics; |
|---|
| 188 | bdecode_window_t window; |
|---|
| 189 | bdecode_t decode; |
|---|
| 190 | baudio_decode_t audio; |
|---|
| 191 | btuner_t tuner; |
|---|
| 192 | bmessage_stream_t msg; |
|---|
| 193 | btuner_ds_params ds; |
|---|
| 194 | bstream_mpeg mpeg; |
|---|
| 195 | bstream_t stream; |
|---|
| 196 | bband_t band; |
|---|
| 197 | buser_input_t user_io; |
|---|
| 198 | bin_read_t br; |
|---|
| 199 | bscreen_t *p_screens; |
|---|
| 200 | int current_sap; |
|---|
| 201 | int num_sap; |
|---|
| 202 | int num_screens; |
|---|
| 203 | unsigned int last_keypress_tick; |
|---|
| 204 | bapp_screen_id_t screen_id; |
|---|
| 205 | bapp_lang_t lang; |
|---|
| 206 | unsigned char captions_basic; |
|---|
| 207 | unsigned int tmp_str[SCREEN_MAX_STR_WIDTH]; |
|---|
| 208 | unsigned int tmp_value; |
|---|
| 209 | bgfx_font_t *p_font[eLANG_MAX][eFONT_SIZE_MAX]; |
|---|
| 210 | unsigned char cur_ch_num; |
|---|
| 211 | unsigned char last_ch_num; |
|---|
| 212 | char last_rating_block_status; |
|---|
| 213 | char last_psip_rating_block_status; |
|---|
| 214 | unsigned char ratings_override; |
|---|
| 215 | bool ratings_override_set; |
|---|
| 216 | bapp_task_queue_t msg_queue; |
|---|
| 217 | bapp_task_event_t msg_event[MAX_MSG_EVENT]; |
|---|
| 218 | bmessage_stream_params msg_params; |
|---|
| 219 | bool is_muted; |
|---|
| 220 | unsigned char audio_vol; |
|---|
| 221 | unsigned char audio_mute; |
|---|
| 222 | unsigned char power; |
|---|
| 223 | unsigned char decoding; |
|---|
| 224 | unsigned int last_tune_tick; |
|---|
| 225 | chm_mgr_t chm; |
|---|
| 226 | chm_info_t tmp_info; |
|---|
| 227 | unsigned char prog_time_str[MAX_TIME_STR]; |
|---|
| 228 | unsigned char prog_rating_str[MAX_RATING_STR]; |
|---|
| 229 | unsigned char psip_rating_str[MAX_RATING_STR]; |
|---|
| 230 | unsigned int last_rating_tick; |
|---|
| 231 | unsigned int last_cad; |
|---|
| 232 | unsigned int last_xds; |
|---|
| 233 | unsigned char ratings_region; |
|---|
| 234 | unsigned char ratings_dim; |
|---|
| 235 | unsigned char ratings_val; |
|---|
| 236 | unsigned char tv_rating; |
|---|
| 237 | unsigned char movie_rating; |
|---|
| 238 | bapp_ch_scan_t ch_scan_type; |
|---|
| 239 | fstore_t flash_storage; |
|---|
| 240 | unsigned int poweron_ms; |
|---|
| 241 | bool check_poweron; |
|---|
| 242 | #ifdef CONFIG_EIA_708 |
|---|
| 243 | bapp_eia708_t eia708; |
|---|
| 244 | #endif |
|---|
| 245 | smessage_stream_t smsg; |
|---|
| 246 | |
|---|
| 247 | bool lock; |
|---|
| 248 | int signal_level; |
|---|
| 249 | btuner_qam_mode qam_b_mode; |
|---|
| 250 | unsigned int snr; |
|---|
| 251 | unsigned int tuned_freq; |
|---|
| 252 | }bapp_t; |
|---|
| 253 | |
|---|
| 254 | extern const unsigned short s_ch_to_freq[]; |
|---|
| 255 | |
|---|
| 256 | int bin_read( void *buffer, int size, int count, void *fp ); |
|---|
| 257 | |
|---|
| 258 | void bapp_init(bapp_t *p_app); |
|---|
| 259 | void bapp_run(bapp_t *p_app); |
|---|
| 260 | void bapp_idle(bapp_t *p_app); |
|---|
| 261 | void bapp_sync(bapp_t *p_app); |
|---|
| 262 | void bapp_handle_event(bapp_t *p_app, bscreen_event_t *p_event); |
|---|
| 263 | void bapp_flush_screen(bapp_t *p_app); |
|---|
| 264 | void bapp_clear_screen_selection_history(bapp_t *p_app); |
|---|
| 265 | void bapp_set_current_screen(bapp_t *p_app, bapp_screen_id_t id, bapp_screen_id_t save_last); |
|---|
| 266 | void bapp_goto_last_screen(bapp_t *p_app); |
|---|
| 267 | int bapp_change_channel(bapp_t *p_app, int ch_up, int tune); |
|---|
| 268 | int bapp_tune(bapp_t *p_app); |
|---|
| 269 | int bapp_stop_decode(bapp_t *p_app); |
|---|
| 270 | int bapp_restart_decode(bapp_t *p_app); |
|---|
| 271 | int bapp_set_channel(bapp_t *p_app, int major, int minor); |
|---|
| 272 | int bapp_channel_hunt(bapp_t *p_app); |
|---|
| 273 | void bapp_enable_cc(bapp_t *p_app, int enable); |
|---|
| 274 | void bapp_apply_settings(bapp_t *p_app); |
|---|
| 275 | void bapp_reset_settings(bapp_t *p_app); |
|---|
| 276 | void bapp_reset_cc_settings(bapp_t *p_app); |
|---|
| 277 | void bapp_load_settings(bapp_t *p_app); |
|---|
| 278 | void bapp_save_settings(bapp_t *p_app); |
|---|
| 279 | void bapp_new_screen(bapp_t *p_app); |
|---|
| 280 | void bapp_av_mute(bapp_t *p_app, int mute); |
|---|
| 281 | void bapp_audio_mute(bapp_t *p_app, int mute); |
|---|
| 282 | void bapp_set_audio_volume(bapp_t *p_app, uint8_t level); |
|---|
| 283 | void bapp_set_palette(bapp_t *p_app, bapp_palette_t palette); |
|---|
| 284 | bool bapp_get_signal_status(bapp_t *p_app); |
|---|
| 285 | int bapp_handle_blocking(bapp_t *p_app); |
|---|
| 286 | void bapp_power(bapp_t *p_app, bool power); |
|---|
| 287 | void bapp_set_captions_options(bapp_t *p_app); |
|---|
| 288 | int bapp_rotate_audio_sap(bapp_t *p_app); |
|---|
| 289 | void bapp_do_poweroff(bapp_t *p_app); |
|---|
| 290 | int bapp_channel_scan(bapp_t *p_app); |
|---|
| 291 | |
|---|
| 292 | #endif /* BAPP_H__ */ |
|---|