| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, 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 | ***************************************************************************/ |
|---|
| 22 | #if !defined(__BAPP_SETTINGS_H__) |
|---|
| 23 | #define __BAPP_SETTINGS_H__ 1 |
|---|
| 24 | #include "bstd.h" |
|---|
| 25 | #include "bfdb.h" |
|---|
| 26 | #include "bapp.h" |
|---|
| 27 | |
|---|
| 28 | /* definitions for the various settings ids */ |
|---|
| 29 | #define BAST_BASE_ID (1) |
|---|
| 30 | #define BAST_EAS_ID (BAST_BASE_ID) |
|---|
| 31 | #define BAST_MISC_ID (BAST_EAS_ID+1) |
|---|
| 32 | #define BAST_PHONE_NUMBER_ID (BAST_MISC_ID+1) |
|---|
| 33 | #define BAST_CHANNEL_MAP_HEADER_ID (BAST_PHONE_NUMBER_ID+1) |
|---|
| 34 | #define BAST_MMS_ENTRY_ID (BAST_CHANNEL_MAP_HEADER_ID+1) |
|---|
| 35 | #define BAST_FREQ_ENTRY_ID (BAST_MMS_ENTRY_ID+1) |
|---|
| 36 | #define BAST_ST_ENTRY_ID (BAST_FREQ_ENTRY_ID+1) |
|---|
| 37 | #define BAST_VCH_ENTRY_ID (BAST_ST_ENTRY_ID+1) |
|---|
| 38 | #define BAST_CHANNEL_ID (BAST_VCH_ENTRY_ID+1) |
|---|
| 39 | #define BAST_SHARED_KEY_ID (BAST_CHANNEL_ID+1) |
|---|
| 40 | #define BAST_UPK_GENERATOR_ID (BAST_SHARED_KEY_ID+1) |
|---|
| 41 | #if 1 // ONE_REMOTE |
|---|
| 42 | #define BAST_GP_TAG_BASE (BAST_UPK_GENERATOR_ID+1) |
|---|
| 43 | #define BAST_GP_MAX_NBR_TAGS 40 |
|---|
| 44 | #define BAST_DCC_ID (BAST_GP_TAG_BASE+BAST_GP_MAX_NBR_TAGS) |
|---|
| 45 | #else |
|---|
| 46 | #define BAST_GP_NVM_VERSION_ID (BAST_UPK_GENERATOR_ID+1) |
|---|
| 47 | #define BAST_GP_TARGET_INFO_ID (BAST_GP_NVM_VERSION_ID+1) |
|---|
| 48 | #define BAST_GP_NIB_FRAME_CNT_ID (BAST_GP_TARGET_INFO_ID+1) |
|---|
| 49 | #define BAST_GP_NIB_BASE_CH_ID (BAST_GP_NIB_FRAME_CNT_ID+1) |
|---|
| 50 | #define BAST_GP_NIB_POWER_SAVE_ID (BAST_GP_NIB_BASE_CH_ID+1) |
|---|
| 51 | #define BAST_GP_NIB_GENERAL_ID (BAST_GP_NIB_POWER_SAVE_ID+1) |
|---|
| 52 | #define BAST_GP_PAIRING_ID_0 (BAST_GP_NIB_GENERAL_ID+1) |
|---|
| 53 | #define BAST_GP_PAIRING_ID_1 (BAST_GP_PAIRING_ID_0+1) |
|---|
| 54 | #define BAST_GP_PAIRING_ID_2 (BAST_GP_PAIRING_ID_1+1) |
|---|
| 55 | #define BAST_GP_PAIRING_ID_3 (BAST_GP_PAIRING_ID_2+1) |
|---|
| 56 | #define BAST_GP_PAIRING_ID_4 (BAST_GP_PAIRING_ID_3+1) |
|---|
| 57 | #define BAST_GP_PAIRING_ID_5 (BAST_GP_PAIRING_ID_4+1) |
|---|
| 58 | #define BAST_GP_VAL_ID (BAST_GP_PAIRING_ID_5+1) |
|---|
| 59 | #define BAST_GP_KICK_ID (BAST_GP_VAL_ID+1) |
|---|
| 60 | #define BAST_GP_RIB_ID_0 (BAST_GP_KICK_ID+1) |
|---|
| 61 | #define BAST_GP_RIB_ID_1 (BAST_GP_RIB_ID_0+1) |
|---|
| 62 | #define BAST_DCC_ID (BAST_GP_RIB_ID_1+1) |
|---|
| 63 | #endif |
|---|
| 64 | #define BAST_RRT_SETTINGS_ID (BAST_DCC_ID+1) |
|---|
| 65 | #define BAST_RRT_DIM_0 (BAST_RRT_SETTINGS_ID+1) |
|---|
| 66 | #define BAST_RRT_DIM_1 (BAST_RRT_DIM_0+1) |
|---|
| 67 | #define BAST_RRT_DIM_2 (BAST_RRT_DIM_1+1) |
|---|
| 68 | #define BAST_RRT_TBL_0 (BAST_RRT_DIM_2+1) |
|---|
| 69 | #define BAST_RRT_TBL_1 (BAST_RRT_TBL_0+1) |
|---|
| 70 | #define BAST_RRT_TBL_2 (BAST_RRT_TBL_1+1) |
|---|
| 71 | #define BAST_RRT_TBL_3 (BAST_RRT_TBL_2+1) |
|---|
| 72 | #define BAST_RRT_TBL_4 (BAST_RRT_TBL_3+1) |
|---|
| 73 | #define BAST_RATINGS_ID (BAST_RRT_TBL_4+1) |
|---|
| 74 | #define BAST_MPK_KEY_ID (BAST_RATINGS_ID+1) |
|---|
| 75 | #define BAST_SCC_AMM_ID (BAST_MPK_KEY_ID+1) |
|---|
| 76 | |
|---|
| 77 | struct eas_settings_t { |
|---|
| 78 | uint8_t eas_filter_control; |
|---|
| 79 | uint8_t eas_state_code; |
|---|
| 80 | uint8_t eas_county_subdivision; |
|---|
| 81 | uint16_t eas_county_code; |
|---|
| 82 | } __attribute__((packed)); |
|---|
| 83 | |
|---|
| 84 | /* This bitfield is 32 bits long */ |
|---|
| 85 | struct bit_item_t { |
|---|
| 86 | unsigned int activated : 1; |
|---|
| 87 | unsigned int deactivated : 1; |
|---|
| 88 | unsigned int standby : 1; |
|---|
| 89 | unsigned int has_CAT : 1; |
|---|
| 90 | unsigned int av_mute : 1; |
|---|
| 91 | unsigned int psi_scan : 1; |
|---|
| 92 | unsigned int state : 4; |
|---|
| 93 | unsigned int dummy : 22; |
|---|
| 94 | }; |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | /* size of this structure is 62 bytes */ |
|---|
| 99 | struct misc_settings_t { |
|---|
| 100 | struct bit_item_t bits; |
|---|
| 101 | uint8_t dst_delta; |
|---|
| 102 | uint8_t timeout_policy; |
|---|
| 103 | uint8_t SCP_operating_mode; |
|---|
| 104 | uint8_t dummy0; /* align for faster access by mips */ |
|---|
| 105 | uint16_t CA_System_ID; |
|---|
| 106 | uint16_t EMM_Provider_ID; |
|---|
| 107 | uint16_t EMM_PID; |
|---|
| 108 | uint16_t VCT_ID; |
|---|
| 109 | uint16_t network_PID; |
|---|
| 110 | uint16_t hunt_cnt; |
|---|
| 111 | uint16_t download_failed_cnt; |
|---|
| 112 | uint16_t download_state; |
|---|
| 113 | uint16_t timeout; |
|---|
| 114 | uint16_t max_location_errors; |
|---|
| 115 | uint16_t location_errors; |
|---|
| 116 | uint32_t message_time; |
|---|
| 117 | uint32_t turn_on_freq_khz; |
|---|
| 118 | uint32_t addressable_time; |
|---|
| 119 | uint32_t timeout_cnt; |
|---|
| 120 | uint32_t location; |
|---|
| 121 | int32_t utc_offset; |
|---|
| 122 | uint32_t dst_entry; |
|---|
| 123 | uint32_t dst_exit; |
|---|
| 124 | |
|---|
| 125 | uint16_t aspect_ratio; |
|---|
| 126 | uint16_t output_format; |
|---|
| 127 | uint16_t hd_options; |
|---|
| 128 | uint16_t sd_options; |
|---|
| 129 | uint8_t sharpness; |
|---|
| 130 | uint8_t sd_only; |
|---|
| 131 | uint8_t debug_reboot; |
|---|
| 132 | uint8_t rf4ce_disable; |
|---|
| 133 | uint8_t ir_disable; |
|---|
| 134 | uint8_t algo_mode; |
|---|
| 135 | uint8_t ch_locks[64]; |
|---|
| 136 | } __attribute__((packed)); |
|---|
| 137 | |
|---|
| 138 | struct phone_number_settings_t { |
|---|
| 139 | uint8_t size; |
|---|
| 140 | uint8_t data[MAX_PHONE_LEN-2]; |
|---|
| 141 | } __attribute__((packed)); |
|---|
| 142 | |
|---|
| 143 | /* header information about stored channel map */ |
|---|
| 144 | struct channel_map_header_settings_t { |
|---|
| 145 | uint8_t mms_count; |
|---|
| 146 | uint8_t freq_count; |
|---|
| 147 | uint16_t st_count; |
|---|
| 148 | uint16_t vch_count; |
|---|
| 149 | } __attribute__((packed)); |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | struct mms_item_t { |
|---|
| 153 | uint8_t idx; |
|---|
| 154 | uint8_t code_rate; |
|---|
| 155 | uint8_t modulation; |
|---|
| 156 | uint32_t symbol_rate; |
|---|
| 157 | } __attribute__((packed)); |
|---|
| 158 | |
|---|
| 159 | /* we pack 8 mms structures in to one tuple to reduce overhead 56 bytes*/ |
|---|
| 160 | struct mms_entry_settings_t { |
|---|
| 161 | struct mms_item_t mms[8]; |
|---|
| 162 | } __attribute__((packed)); |
|---|
| 163 | |
|---|
| 164 | struct freq_item_t { |
|---|
| 165 | uint8_t idx; |
|---|
| 166 | uint32_t freq_khz; |
|---|
| 167 | } __attribute__((packed)); |
|---|
| 168 | |
|---|
| 169 | /* pack 8 freq structures in to one tuple */ |
|---|
| 170 | struct freq_entry_settings_t { |
|---|
| 171 | struct freq_item_t freq[8]; |
|---|
| 172 | } __attribute__((packed)); |
|---|
| 173 | |
|---|
| 174 | /* 19 bytes */ |
|---|
| 175 | struct st_entry_settings_t { |
|---|
| 176 | uint16_t source_id; |
|---|
| 177 | uint8_t name[17]; |
|---|
| 178 | } __attribute__((packed)); |
|---|
| 179 | |
|---|
| 180 | #define VCH_MAX_AUDIO 4 |
|---|
| 181 | #define VCH_MAX_CS 6 |
|---|
| 182 | /* 43 bytes long */ |
|---|
| 183 | struct vch_entry_settings_t { |
|---|
| 184 | uint16_t ch_num; |
|---|
| 185 | uint16_t source_id; |
|---|
| 186 | uint16_t program_num; |
|---|
| 187 | uint16_t pcr_pid; |
|---|
| 188 | uint16_t scte127_pid; |
|---|
| 189 | uint16_t video_pid; |
|---|
| 190 | uint16_t ca_pid; |
|---|
| 191 | uint16_t audio_pid[VCH_MAX_AUDIO]; |
|---|
| 192 | uint8_t audio_type[VCH_MAX_AUDIO]; |
|---|
| 193 | int8_t audio_lang[VCH_MAX_AUDIO][3]; |
|---|
| 194 | uint8_t freq_idx; |
|---|
| 195 | uint8_t mms_idx; |
|---|
| 196 | uint8_t video_type; |
|---|
| 197 | uint8_t vchflags; |
|---|
| 198 | uint8_t audio_count; |
|---|
| 199 | uint8_t audio_current; |
|---|
| 200 | uint8_t hd_flag; |
|---|
| 201 | uint8_t cs_lang[VCH_MAX_CS][3]; |
|---|
| 202 | } __attribute__((packed)); |
|---|
| 203 | |
|---|
| 204 | /* 3 bytes */ |
|---|
| 205 | struct channel_settings_t { |
|---|
| 206 | uint16_t channel; |
|---|
| 207 | uint8_t volume; |
|---|
| 208 | } __attribute__((packed)); |
|---|
| 209 | |
|---|
| 210 | struct shared_key_settings_t { |
|---|
| 211 | uint8_t decryption_key_type; |
|---|
| 212 | uint8_t shared_key_A [16]; |
|---|
| 213 | uint8_t shared_key_B [16]; |
|---|
| 214 | } __attribute__((packed)); |
|---|
| 215 | |
|---|
| 216 | struct upk_generator_settings_t { |
|---|
| 217 | uint8_t upk_generator_size; |
|---|
| 218 | uint8_t upk_generator_A[110]; |
|---|
| 219 | uint8_t upk_generator_B[110]; |
|---|
| 220 | } __attribute__((packed)); |
|---|
| 221 | |
|---|
| 222 | struct mpk_key_settings_t { |
|---|
| 223 | uint8_t mpk_even[16]; |
|---|
| 224 | uint8_t mpk_odd[16]; |
|---|
| 225 | } __attribute__((packed)); |
|---|
| 226 | |
|---|
| 227 | struct scc_amm_settings_t { |
|---|
| 228 | uint8_t cmac_a_key_select; |
|---|
| 229 | uint8_t cmac_a[8]; |
|---|
| 230 | uint8_t amm_data[74]; |
|---|
| 231 | } __attribute__((packed)); |
|---|
| 232 | |
|---|
| 233 | void bast_init(bapp_t *app); |
|---|
| 234 | void bast_channel_save(bapp_t *app); |
|---|
| 235 | void bast_misc_save(bapp_t *app); |
|---|
| 236 | void bast_eas_save(bapp_t *app); |
|---|
| 237 | void bast_phone_number_save(bapp_t *app); |
|---|
| 238 | void bast_channel_map_save(bapp_t *app); |
|---|
| 239 | int bast_channel_read(bapp_t *app); |
|---|
| 240 | int bast_misc_read(bapp_t *app); |
|---|
| 241 | int bast_eas_read(bapp_t *app); |
|---|
| 242 | int bast_phone_number_read(bapp_t *app); |
|---|
| 243 | int bast_channel_map_read(bapp_t *app); |
|---|
| 244 | |
|---|
| 245 | void bast_scc_amm_save(bapp_t *app); |
|---|
| 246 | int bast_scc_amm_read(bapp_t *app); |
|---|
| 247 | void bast_MPK_key_save(bapp_t *app); |
|---|
| 248 | int bast_MPK_key_read(bapp_t *app); |
|---|
| 249 | |
|---|
| 250 | void bast_shared_key_save(struct shared_key_settings_t * key); |
|---|
| 251 | int bast_shared_key_read(struct shared_key_settings_t * key); |
|---|
| 252 | void bast_upk_generator_save(struct upk_generator_settings_t * gen); |
|---|
| 253 | int bast_upk_generator_read(struct upk_generator_settings_t * gen); |
|---|
| 254 | |
|---|
| 255 | void bast_gp_nvm_save(uint8_t tag, uint8_t size, uint8_t *data); |
|---|
| 256 | int bast_gp_nvm_read(uint8_t tag, uint8_t *size, uint8_t *data); |
|---|
| 257 | |
|---|
| 258 | void bast_dcc_save(dcc_settings_t *settings); |
|---|
| 259 | int bast_dcc_read(dcc_settings_t *settings); |
|---|
| 260 | |
|---|
| 261 | void bast_ratings_save(ratings_settings_t *settings); |
|---|
| 262 | int bast_ratings_read(ratings_settings_t *settings); |
|---|
| 263 | |
|---|
| 264 | void bast_rrt_save(rrt_settings_t *settings); |
|---|
| 265 | int bast_rrt_read(rrt_settings_t *settings); |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | #endif |
|---|