/*************************************************************************** * Copyright (c) 2003-2006, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ***************************************************************************/ #ifndef BAPP_H__ #define BAPP_H__ #include "bsettop.h" #include "fstore.h" #include "bscreen.h" #include "bapp_util.h" #include "bsettop_stream.h" #include "chan_mgr.h" #include "ch_map.h" #include "led.h" #include "bsettop_hdmi.h" #ifdef CONFIG_EIA_708 #include "bapp_eia708.h" #endif #include "bsettop_rfm.h" #ifdef CONFIG_DVB_SUBTITLE #include "dvb_subtitle.h" #endif #define SCREEN_MAX_STR_WIDTH 1024 #define MAX_MSG_EVENT 128 #define MAX_RATING_STR 128 #define MAX_TIME_STR 32 #define TUNE_DURATION (3 * 1000) /* Milliseconds */ #define CONFIG_ACTIVE_STANDBY #define MAX_PHONE_LEN 255 #define MAX_RRT_VAL 16 /* * Application states */ typedef enum bapp_state_t { eAPP_STATE_DEFAULT, /* Default init state */ eAPP_STATE_HUNT, /* Needs channel map or authorization to operated */ eAPP_STATE_PENDING, /* Needs channel map or authorization to operated */ eAPP_STATE_NORMAL, /* Has channel map and can tune channels */ eAPP_STATE_DOWNLOAD, /* Temporarily in download state */ eAPP_STATE_FACTORY, /* Factory Test State */ eAPP_STATE_DONE, /* Last state, should never occur */ }bapp_state_t; /* * Color palettes */ typedef enum bapp_palette_t { ePALETTE_DEFAULT, ePALETTE_SCREENSAVER, }bapp_palette_t; /** Summary: Stream format type **/ typedef struct bapp_av_stream_type_t { unsigned char format; unsigned int codec_id; unsigned int transport_id; /* not used */ char format_name[32]; }bapp_av_stream_type_t; typedef struct rrt_settings_t { unsigned int rrt_status : 2; unsigned int rrt_size : 14; unsigned int last_rrt_id : 16; unsigned int pin : 32; unsigned short ratings_rrt[MAX_RRT_DIM]; unsigned char rrt[RRT_BUF_LEN]; }rrt_settings_t; typedef struct ratings_settings_t { unsigned int ratings_lock : 2; unsigned int ratings_tv : 18; unsigned int ratings_movies : 7; unsigned int content_d : 1; unsigned int content_l : 1; unsigned int content_s : 1; unsigned int content_v : 1; }ratings_settings_t; typedef struct dcc_settings_t { unsigned int captions_basic : 4; unsigned int captions_font : 3; unsigned int captions_font_size : 2; unsigned int captions_font_style : 2; unsigned int captions_font_color : 4; unsigned int captions_font_opacity : 3; unsigned int captions_back_color : 4; unsigned int captions_back_opacity : 3; unsigned int captions_edge_color : 4; unsigned int captions_edge_type : 3; unsigned char captions_analog : 4; unsigned char captions_digital : 4; }dcc_settings_t; typedef struct hd_config_settings_t { unsigned int aspect_ratio : 2; /* display aspect radio, currently 4x3, 16x9 */ unsigned int output_format : 3; /* hd output format for HDMI */ unsigned int hd_options : 3; /* hd output options */ unsigned char sharpness; /* sharpness (0-25) for HDMI 480i/480p */ } hd_config_settings_t; #define MAX_LONG_NAME_CHARS 128 #define MAX_TITLE_CHARS 96 #define MAX_DESC_CHARS 256 #define MAX_TIME_STR_CHARS 32 #define MAX_RATING_STR_CHARS 32 #define MAX_CH_NAME_CHARS 11//7 #define MAX_EIT_NUM 2 #define EIT_CURRENT 0 #define EIT_NEXT 1 /* EIT Info structure */ typedef struct chm_eit_t { unsigned int start_time; unsigned int length; unsigned short event_id; unsigned char prog_title[MAX_TITLE_CHARS + 1]; unsigned char prog_desc[MAX_DESC_CHARS + 1]; PSIP_CSD_service cc_service[MAX_CC_SERVICES]; }chm_eit_t; /* Channel info structure */ typedef struct chm_info_t { unsigned short source_id; unsigned short major; unsigned short minor; unsigned short program_number; unsigned short ch_name[MAX_CH_NAME_CHARS]; unsigned char ext_ch_name[MAX_LONG_NAME_CHARS + 1]; unsigned char vct_name[MAX_LONG_NAME_CHARS + 1]; chm_eit_t eit_info[MAX_EIT_NUM]; bool got_vct; }chm_info_t; /* * State data structure, because this structure is saved to NVM * options should be combined to make best use of storage space */ typedef struct bapp_settings_t { unsigned int sound : 2; unsigned int picture : 1; unsigned int language : 2; unsigned int wiz_completed : 1; unsigned int ratings_lock : 2; unsigned int ratings_tv : 18; unsigned int ratings_movies : 7; unsigned int content_d : 1; unsigned int content_l : 1; unsigned int content_s : 1; unsigned int content_v : 1; unsigned int auto_power_off : 1; unsigned int rrt_status : 2; unsigned int time_zone : 4; unsigned int dst : 1; unsigned int last_rrt_id : 16; unsigned int pin : 32; unsigned int activated : 1; unsigned int deactivated : 1; unsigned int standby : 1; unsigned int has_CAT : 1; unsigned int av_mute : 1; unsigned int psi_scan : 1; unsigned int audio_vol : 7; unsigned int state : 4; unsigned int dst_delta : 8; unsigned int timeout_policy : 8; unsigned int SCP_operating_mode : 8; // site_errors:16 // prev_site_errors:16 // max_site_errors:16 unsigned int CA_System_ID : 16; unsigned int EMM_Provider_ID : 16; unsigned int EMM_PID : 16; unsigned int VCT_ID : 16; unsigned int network_PID : 16; unsigned int hunt_cnt : 16; unsigned int download_failed_cnt : 16; unsigned int download_invalid_cnt : 16; unsigned int timeout : 16; unsigned int max_location_errors : 16; unsigned int location_errors : 16; unsigned int message_time : 32; unsigned int turn_on_freq_khz : 32; unsigned int addressable_time : 32; unsigned int timeout_cnt : 32; unsigned int location : 32; int utc_offset : 32; unsigned int auto_power : 32; unsigned int dst_entry : 32; unsigned int dst_exit : 32; unsigned int reserved_0 : 32; unsigned int reserved_1 : 32; unsigned int reserved_2 : 32; unsigned int reserved_3 : 32; unsigned char phonenumber[MAX_PHONE_LEN]; unsigned short ratings_rrt[MAX_RRT_DIM]; unsigned char rrt[RRT_BUF_LEN]; ch_map_t ch_map; // ratings_settings_t ratings; // rrt_settings_t rrt_settings; dcc_settings_t dcc; hd_config_settings_t hd_config; unsigned int sd_options : 3; #ifdef CONFIG_DVB unsigned char dvb_scan; #endif }bapp_settings_t; /* * Main data structure containing references to all interfaces * required throughout the application. */ typedef struct bapp_t { bapp_state_t state; enum led_mode_t led_mode; unsigned int yield_ms; unsigned char* osd_mem; unsigned int osd_mem_size; bapp_settings_t settings; uint32_t settings_dirty; bgfx_palette_t palette; uint16_t width; uint16_t height; b_timeval timeout_tv; bgfx_surf_t surf; bdisplay_t display; bgraphics_t graphics; bdecode_window_t window[2]; bdecode_t decode; baudio_decode_t audio; buser_input_t user_io; bsettop_hdmi_t hdmi; brfm_t p_rfm; bin_read_t br; bscreen_t *p_screens; int num_screens; unsigned int last_keypress_tick; bapp_screen_id_t screen_id; bapp_screen_id_t last_screen_id; bapp_lang_t lang; unsigned int tmp_str[SCREEN_MAX_STR_WIDTH]; unsigned int tmp_value; unsigned int tmp_cnt; bgfx_font_t *p_font[eLANG_MAX][eFONT_SIZE_MAX]; b_queue_t msg_queue; b_event_t msg_event[MAX_MSG_EVENT]; bool is_muted; bool system_mute; unsigned char audio_vol; unsigned char audio_mute; unsigned char power; unsigned char decoding; unsigned int last_tune_tick; unsigned int eas_timeout; unsigned int eas_text; /* EAS text scrolling flag */ chm_mgr_t chm; unsigned int poweron_ms; unsigned int snr; unsigned int tuned_freq; bool check_poweron; bool lock; bool has_PAT; unsigned int power_level; #if (BCHP_CHIP == 3543) BQAM_B_Mode qam_b_mode; #elif (BCHP_CHIP == 7002) btuner_qam_mode qam_b_mode; #endif unsigned int system_time; unsigned int system_offset; bool have_time; unsigned int tune_ms; unsigned int si_ms; unsigned int location; vch_t prev_vch; vch_t cur_vch; st_t cur_st; freq_t cur_freq; b_mutex_t ch_map_mutex; b_mutex_t flash_mutex; chm_cmd_event_t chm_cmd; chm_tune_event_t tune_cmd; bIR_codes_t last_key_down; b_timeval last_key_tv; fstore_t flash_storage; unsigned char eas_buf[EAS_BUF_LEN]; unsigned int eas_buf_size; unsigned char *logo; unsigned int logo_size; unsigned char prog_time_str[MAX_TIME_STR]; unsigned char prog_rating_str[MAX_RATING_STR]; unsigned char psip_rating_str[MAX_RATING_STR]; unsigned int last_rating_tick; unsigned int last_cad; unsigned int last_xds; unsigned char ratings_region; unsigned char ratings_dim; unsigned char ratings_val; unsigned char tv_rating; unsigned char movie_rating; p_timing_profile_t ptp_tune; /* profile tune/acquire */ p_timing_profile_t ptp_psi; /* profile psi (PAT/PMT) */ p_timing_profile_t ptp_first_pts; /* profile start decode to first PTS */ p_timing_profile_t ptp_decode; /* profile start decode to sequence header */ char last_rating_block_status; char last_psip_rating_block_status; unsigned char ratings_override; bool ratings_override_set; bool pin_limit_override; /* for channel change */ uint32_t pin_limit_timeout; /* pin limit time out */ chm_info_t tmp_info; #ifdef CONFIG_EIA_708 bapp_eia708_t eia708; #endif #ifdef CONFIG_DVB_SUBTITLE bapp_dsub_t dsub; #endif }bapp_t; extern const unsigned short s_ch_to_freq[]; int bin_read( void *buffer, int size, int count, void *fp ); void bapp_init(bapp_t *p_app); void bapp_run(bapp_t *p_app); void bapp_idle(bapp_t *p_app); void bapp_sync(bapp_t *p_app); void bapp_handle_event(bapp_t *p_app, bscreen_event_t *p_event); void bapp_flush_screen(bapp_t *p_app); void bapp_set_current_screen(bapp_t *p_app, bapp_screen_id_t id, bapp_screen_id_t save_last); bscreen_t * bapp_get_current_screen(bapp_t *p_app); void bapp_goto_last_screen(bapp_t *p_app); int bapp_change_channel(bapp_t *p_app, int ch_up, int tune); int bapp_tune(bapp_t *p_app); int bapp_tune_prev(bapp_t *p_app); int bapp_set_channel(bapp_t *p_app, int channel); void bapp_enable_cc(bapp_t *p_app, int enable); void bapp_reset_settings(bapp_t *p_app); void bapp_save_settings(bapp_t *p_app); void bapp_av_mute(bapp_t *p_app, int mute); void bapp_audio_mute(bapp_t *p_app, int mute); void bapp_video_mute(bapp_t *p_app, int mute); void bapp_set_audio_volume(bapp_t *p_app, uint8_t level); void bapp_set_palette(bapp_t *p_app, bapp_palette_t palette); bool bapp_get_signal_status(bapp_t *p_app); int bapp_rotate_audio_sap(bapp_t *p_app); void bapp_do_poweroff(bapp_t *p_app); ch_map_t *bapp_cur_ch_map(bapp_t *p_app); int bapp_rotate_dsub(bapp_t *p_app); void bapp_audio_do_mute(bapp_t *p_app, int mute); void bapp_flush_screen_partial(bapp_t *p_app, int id); void bapp_select_primary_output(bapp_t *p_app, int mode); void bapp_select_scaler_coefficient(bapp_t *p_app, bool horizontal, int output, int coeff_idx); void bapp_power(bapp_t *p_app, bool power); bool bapp_get_block_status(bapp_t *p_app); void bapp_set_oob_flag(int oob); void bapp_get_avl_settings(int *target, int *low, int *boost); void bapp_set_avl_settings(int target, int low, int boost); #define DIRTY_MISC 0x1 #define DIRTY_CHANNEL 0x2 #define DIRTY_EAS 0x4 #define DIRTY_PHONE 0x8 #define DIRTY_CHANNEL_MAP 0x10 #define DIRTY_SCREEN 0x20 //#define DIRTY_DCC 0x20 #define DIRTY_RRT 0x40 #define DIRTY_RATINGS 0x80 #define DIRTY_CC 0x100 #define DIRTY_HD_CONFIG 0x200 #define DIRTY_DEBUG_CONFIG 0x400 #define DIRTY_ALL (DIRTY_MISC | DIRTY_CHANNEL | DIRTY_EAS | DIRTY_PHONE | DIRTY_CHANNEL_MAP | DIRTY_RRT | \ DIRTY_RATINGS | DIRTY_CC | DIRTY_HD_CONFIG | DIRTY_DEBUG_CONFIG) #endif /* BAPP_H__ */