| 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 "bgfx.h" |
|---|
| 25 | #include "bapp_util.h" |
|---|
| 26 | #include "bscreen.h" |
|---|
| 27 | #include "chan_mgr.h" |
|---|
| 28 | #include "led.h" |
|---|
| 29 | #include "bapp_remote.h" |
|---|
| 30 | #include "bapp_settings.h" |
|---|
| 31 | #include "bapp_store.h" |
|---|
| 32 | #include "bapp_nexus.h" |
|---|
| 33 | |
|---|
| 34 | #define SCREEN_MAX_STR_WIDTH 1024 |
|---|
| 35 | |
|---|
| 36 | #define MAX_MSG_EVENT 4 |
|---|
| 37 | #define MAX_TIME_STR 32 |
|---|
| 38 | |
|---|
| 39 | #define TUNE_DURATION (3 * 1000) /* Milliseconds */ |
|---|
| 40 | |
|---|
| 41 | #define CONFIG_ACTIVE_STANDBY |
|---|
| 42 | |
|---|
| 43 | /* |
|---|
| 44 | * Application states |
|---|
| 45 | */ |
|---|
| 46 | typedef enum bapp_state_t |
|---|
| 47 | { |
|---|
| 48 | eAPP_STATE_DEFAULT, /* Default init state */ |
|---|
| 49 | eAPP_STATE_HUNT, /* Needs channel map or authorization to operated */ |
|---|
| 50 | eAPP_STATE_PENDING, /* Needs channel map or authorization to operated */ |
|---|
| 51 | eAPP_STATE_NORMAL, /* Has channel map and can tune channels */ |
|---|
| 52 | eAPP_STATE_DOWNLOAD, /* Temporarily in download state */ |
|---|
| 53 | eAPP_STATE_FACTORY, /* Factory Test State */ |
|---|
| 54 | eAPP_STATE_DONE, /* Last state, should never occur */ |
|---|
| 55 | }bapp_state_t; |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | /* |
|---|
| 59 | * Color palettes |
|---|
| 60 | */ |
|---|
| 61 | typedef enum bapp_palette_t |
|---|
| 62 | { |
|---|
| 63 | ePALETTE_DEFAULT, |
|---|
| 64 | ePALETTE_SCREENSAVER, |
|---|
| 65 | }bapp_palette_t; |
|---|
| 66 | |
|---|
| 67 | /* |
|---|
| 68 | * Main data structure containing references to all interfaces |
|---|
| 69 | * required throughout the application. |
|---|
| 70 | */ |
|---|
| 71 | |
|---|
| 72 | typedef struct bapp_t |
|---|
| 73 | { |
|---|
| 74 | bapp_state_t state; |
|---|
| 75 | enum led_mode_t led_mode; |
|---|
| 76 | unsigned int yield_ms; |
|---|
| 77 | unsigned char* osd_mem; |
|---|
| 78 | unsigned int osd_mem_size; |
|---|
| 79 | bapp_settings_t settings; |
|---|
| 80 | bool settings_dirty; |
|---|
| 81 | bgfx_palette_t palette; |
|---|
| 82 | uint16_t width; |
|---|
| 83 | uint16_t height; |
|---|
| 84 | |
|---|
| 85 | struct timeval timeout_tv; |
|---|
| 86 | |
|---|
| 87 | bgfx_surf_t surf; |
|---|
| 88 | #if 0 |
|---|
| 89 | bdisplay_t display; |
|---|
| 90 | bgraphics_t graphics; |
|---|
| 91 | bdecode_window_t window; |
|---|
| 92 | bdecode_t decode; |
|---|
| 93 | baudio_decode_t audio; |
|---|
| 94 | buser_input_t user_io; |
|---|
| 95 | #else |
|---|
| 96 | bapp_nexus_t nexus; |
|---|
| 97 | bapp_remote_t remote; |
|---|
| 98 | #endif |
|---|
| 99 | fstore_t flash_storage; |
|---|
| 100 | |
|---|
| 101 | bin_read_t br; |
|---|
| 102 | bscreen_t *p_screens; |
|---|
| 103 | int num_screens; |
|---|
| 104 | unsigned int last_keypress_tick; |
|---|
| 105 | bapp_screen_id_t screen_id; |
|---|
| 106 | bapp_screen_id_t last_screen_id; |
|---|
| 107 | bapp_lang_t lang; |
|---|
| 108 | unsigned int tmp_str[SCREEN_MAX_STR_WIDTH]; |
|---|
| 109 | unsigned int tmp_value; |
|---|
| 110 | bgfx_font_t *p_font[eLANG_MAX][eFONT_SIZE_MAX]; |
|---|
| 111 | bapp_task_queue_t msg_queue; |
|---|
| 112 | bapp_task_event_t msg_event[MAX_MSG_EVENT]; |
|---|
| 113 | bool is_muted; |
|---|
| 114 | unsigned char audio_vol; |
|---|
| 115 | unsigned char audio_mute; |
|---|
| 116 | unsigned char power; |
|---|
| 117 | unsigned char decoding; |
|---|
| 118 | unsigned int last_tune_tick; |
|---|
| 119 | unsigned int eas_timeout; |
|---|
| 120 | unsigned int eas_text; /* EAS text scrolling flag */ |
|---|
| 121 | chm_mgr_t chm; |
|---|
| 122 | unsigned int poweron_ms; |
|---|
| 123 | unsigned int snr; |
|---|
| 124 | unsigned int tuned_freq; |
|---|
| 125 | bool check_poweron; |
|---|
| 126 | bool lock; |
|---|
| 127 | bool has_PAT; |
|---|
| 128 | unsigned int signal_level; |
|---|
| 129 | int mode; |
|---|
| 130 | |
|---|
| 131 | unsigned int system_time; |
|---|
| 132 | unsigned int system_offset; |
|---|
| 133 | bool have_time; |
|---|
| 134 | |
|---|
| 135 | unsigned int tune_ms; |
|---|
| 136 | unsigned int si_ms; |
|---|
| 137 | unsigned int location; |
|---|
| 138 | |
|---|
| 139 | vch_t prev_vch; |
|---|
| 140 | vch_t cur_vch; |
|---|
| 141 | st_t cur_st; |
|---|
| 142 | freq_t cur_freq; |
|---|
| 143 | bapp_task_mutex_t ch_map_mutex; |
|---|
| 144 | chm_cmd_event_t chm_cmd; |
|---|
| 145 | chm_tune_event_t tune_cmd; |
|---|
| 146 | bIR_codes_t last_key_down; |
|---|
| 147 | struct timeval last_key_tv; |
|---|
| 148 | }bapp_t; |
|---|
| 149 | |
|---|
| 150 | extern const unsigned short s_ch_to_freq[]; |
|---|
| 151 | |
|---|
| 152 | int bin_read( void *buffer, int size, int count, void *fp ); |
|---|
| 153 | |
|---|
| 154 | void bapp_init(bapp_t *p_app); |
|---|
| 155 | void bapp_run(bapp_t *p_app); |
|---|
| 156 | void bapp_idle(bapp_t *p_app); |
|---|
| 157 | void bapp_sync(bapp_t *p_app); |
|---|
| 158 | void bapp_handle_event(bapp_t *p_app, bscreen_event_t *p_event); |
|---|
| 159 | void bapp_flush_screen(bapp_t *p_app); |
|---|
| 160 | void bapp_set_current_screen(bapp_t *p_app, bapp_screen_id_t id, bapp_screen_id_t save_last); |
|---|
| 161 | bscreen_t * bapp_get_current_screen(bapp_t *p_app); |
|---|
| 162 | void bapp_goto_last_screen(bapp_t *p_app); |
|---|
| 163 | int bapp_change_channel(bapp_t *p_app, int ch_up, int tune); |
|---|
| 164 | int bapp_tune(bapp_t *p_app); |
|---|
| 165 | int bapp_tune_prev(bapp_t *p_app); |
|---|
| 166 | int bapp_set_channel(bapp_t *p_app, int channel); |
|---|
| 167 | void bapp_enable_cc(bapp_t *p_app, int enable); |
|---|
| 168 | void bapp_reset_settings(bapp_t *p_app); |
|---|
| 169 | void bapp_save_settings(bapp_t *p_app); |
|---|
| 170 | void bapp_av_mute(bapp_t *p_app, int mute); |
|---|
| 171 | void bapp_audio_mute(bapp_t *p_app, int mute); |
|---|
| 172 | void bapp_set_audio_volume(bapp_t *p_app, uint8_t level); |
|---|
| 173 | void bapp_set_palette(bapp_t *p_app, bapp_palette_t palette); |
|---|
| 174 | bool bapp_get_signal_status(bapp_t *p_app); |
|---|
| 175 | int bapp_rotate_audio_sap(bapp_t *p_app); |
|---|
| 176 | void bapp_do_poweroff(bapp_t *p_app); |
|---|
| 177 | ch_map_t *bapp_cur_ch_map(bapp_t *p_app); |
|---|
| 178 | bapp_t *bapp_get_app(void); |
|---|
| 179 | bapp_result_t bapp_post_event(bapp_task_event_t event); |
|---|
| 180 | |
|---|
| 181 | #endif /* BAPP_H__ */ |
|---|