/*************************************************************************** * 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" #define SCREEN_MAX_STR_WIDTH 1024 #define MAX_MSG_EVENT 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 #define MAX_EAS_TEXT 256 /* support for user defined frequencies in diagnostic screen */ #define MAX_USER_FREQ 16 /* * Application states */ typedef enum bapp_state_t { eAPP_STATE_DEFAULT, /* Default init state */ eAPP_STATE_HUNT, /* Needs channel map to operate */ eAPP_STATE_NORMAL, /* Has channel map and can tune channels */ eAPP_STATE_FACTORY, /* Factory Test State */ eAPP_STATE_DONE, /* Last state, should never occur */ }bapp_state_t; /* * RRT status */ typedef enum bapp_rrt_status_t { eRRT_UNAVAILABLE = 0x0, eRRT_AVAILABLE = 0x1, }bapp_rrt_status_t; /* * Structure defining blocked setting for an RRT dim/value pair. */ typedef enum bapp_rrt_rating_state_t { eRRT_UNBLOCK = 0x0, eRRT_BLOCK = 0x1 }bapp_rrt_rating_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; /* separate pin for RRT or same pin for whole app? */ 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 EIT_CURRENT 0 #define EIT_NEXT 1 /* * Structure defining a unit of data storage */ typedef struct bapp_ch_t { unsigned int major : 10; unsigned int minor : 10; unsigned int freq_idx : 8; unsigned int psi : 1; unsigned int pcr_pid : 13; unsigned int video_pid : 13; unsigned int has_lang : 3; /* NOTE that we can have muximum of 3 languages */ unsigned int hidden : 1; unsigned short video_type : 8; /* we need support more video format, e.g. AVC */ unsigned short program_num : 8; /* program number */ unsigned short num_audio : 8; /* number of audio channels */ unsigned short audio_pid[MAX_AUDIO_PIDS]; unsigned short ch_name[MAX_CH_SHORT_NAME_CHARS]; /* VCT short defined 7 as max, but we have more */ unsigned short audio_type[MAX_AUDIO_PIDS]; /* for MPEG audio support */ unsigned char audio_lang[MAX_CH_NAME_CHARS][3]; unsigned int frequency_khz; /* frequency in khz for the channel */ unsigned short cur_audio; unsigned short source_id; /* we need to save source id */ /* new feature */ unsigned int skip : 1; /* skip chennel */ unsigned int favorite : 1; /* favorite channel, use the CH+/- to browse */ }bapp_ch_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 auto_power_off : 2; /* handle "no signal" case */ unsigned int time_zone : 4; unsigned int dst : 1; unsigned int standby : 1; unsigned int rfm : 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 analog_captioning : 1; unsigned int sd_options : 3; 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; ratings_settings_t ratings; rrt_settings_t rrt_settings; dcc_settings_t dcc; unsigned char num_channels; /* number of channels scanned */ bapp_ch_t ch[MAX_CHANNELS]; #ifdef HAS_HDMI hd_config_settings_t hd_config; #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; unsigned int power_saver_tick; /* keep track the power saver 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 */ char eas_str[MAX_EAS_TEXT]; /* eas string including activation message and alert mesage */ unsigned char eas_char_width[MAX_EAS_TEXT]; int eas_str_len; /* lengthe of p_app->eas_str */ int eas_activation_str_len; /* length of eas_activation_str inside p_app->eas_text */ int eas_activation_str_width; /* pixel width of eas_activation_str inside p_app->eas_text */ int eas_src_start_idx; /* required for scrolling */ int eas_src_end_idx; int eas_src_start_x; int eas_src_end_x; int eas_dsp_x; bool eas_activation_text; bool eas_one_iteration; bool eas_started; bool eas_ch_found; /* valid source id on EAS msg */ 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; unsigned int system_time; unsigned int system_offset; bool have_time; unsigned int tune_ms; unsigned int si_ms; unsigned int location; /* VSB */ bapp_ch_t prev_ch; bapp_ch_t cur_ch; int cur_ch_num; /* current channel number */ b_mutex_t ch_map_mutex; b_mutex_t flash_mutex; chm_cmd_event_t chm_cmd; chm_cmd_event_t hunt_cmd; chm_tune_event_t tune_cmd; bIR_codes_t last_key_down; b_timeval last_key_tv; b_timeval last_save_tv; /* reduce check on save to flash */ 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_CHARS]; unsigned char psip_rating_str[MAX_RATING_STR_CHARS]; 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 */ char last_ch_block_status; chm_info_t tmp_info; bool re_tune; /* re-tune flag */ unsigned int signal_level; /* signal level */ int num_sap; /* for draw SAP indicator if any */ int current_sap; /* for draw SAP indicator if any */ bool check_signal; #ifdef CONFIG_STANDBY bool active_standby; #endif btuner_status tuner_status; /* remember tuner status if any */ /* DCC */ #ifdef CONFIG_EIA_708 bapp_eia708_t eia708; #endif #if 1 /*ChengYu@20120808: for factory test*/ bool factory_test; #endif bool scan_in_progress; unsigned short captions_basic; /* for simple On switch CC switch */ bool cc_enabled; /* cc enabled or not */ bool wide_aspect_ratio; /* wide aspect ratio flag from Closed Captioning descriptor */ unsigned int signal_quality; /* signal quality */ bool no_signal; /* flag to indicate the box are in no signal condition */ int sd_options; /* temp sd_options that set from the AR remote button */ unsigned char *dolby_logo; /* dolby logo to show in the banner screen */ unsigned int dolby_logo_size; unsigned char *dst_logo; unsigned int dst_logoSize; /* audio only channel screen support */ uint32_t audio_channel_draw_timeout; /* audio only channel draw timeout */ b_timeval audio_channel_tm; /* initial timeout to enter audio only channel event handler */ }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_change_channel_fav(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, bapp_ch_t *pch); int bapp_set_channel_by_major(bapp_t *p_app, int major, int minor); 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_audio_SetDolbyDrc_mode(bapp_t *p_app, baudio_dolby_drc_mode mode); void bapp_audio_GetDolbyDrc_mode(bapp_t *p_app, baudio_dolby_drc_mode mode); 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); bapp_ch_t *bapp_is_channel_valid(bapp_t *p_app); #define DIRTY_MISC 0x1 #define DIRTY_CHANNEL 0x2 #define DIRTY_EAS 0x4 #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_CHANNEL_MAP | DIRTY_RRT | \ DIRTY_RATINGS | DIRTY_CC | DIRTY_HD_CONFIG | DIRTY_DEBUG_CONFIG) /* Summary: Reset the closed captioning settings to the default values. */ void bapp_reset_cc_config_settings(bapp_t *p_app); void bapp_channel_scan(bapp_t *p_app); /* * Summary: * Set closed captions CS options * Description: * Set closed captions CS options */ void bapp_set_captions_options(bapp_t *p_app); void bapp_P_enable_avl(bapp_t *p_app, bool enable); void bapp_enable_avl(bool enable); bapp_t *bapp_get_app_instance(void); int bapp_get_wide_aspect_ratio_cb(void); void bapp_set_wide_aspect_ratio(bapp_t *p_app); #ifdef TUNER_DEBUG /* helper function for frontend tuner performance measurement */ void bapp_scan_psi_a_freq(uint32_t freq_khz); void bapp_get_tuner_status(void); #endif void bapp_brfm_set_ch3(bool); void bapp_bdisplay_setRfOutput(bool isOutput); void bapp_audio_1k_TONE(void); /*janzy@20121113,audio,video start/stop ctrl begin*/ void bapp_audio_stop(void); void bapp_video_stop(void); void bapp_AV_start(unsigned int vid,unsigned int aud,unsigned int pcr); /*end*/ void bapp_Set_ColorBars(bool enable);/*janzy@20121113,add ColorBars*/ void bapp_do_exit();/*janzy@20121115,OSD TimeOut*/ void bapp_set_ar_options(bapp_t *p_app); /* dolby logo support */ bool bapp_is_dolby_type(bapp_t *p_app); #endif /* BAPP_H__ */