| 1 | /****************************************************************************** |
|---|
| 2 | * (c)2008-2009 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: $ |
|---|
| 39 | * $brcm_Revision: $ |
|---|
| 40 | * $brcm_Date: $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Manage application settings like volume, channel map, etc. |
|---|
| 45 | * |
|---|
| 46 | * Revision History: |
|---|
| 47 | * |
|---|
| 48 | * Created: 09/28/2009 by Jeff Fisher |
|---|
| 49 | * |
|---|
| 50 | * $brcm_Log: $ |
|---|
| 51 | * |
|---|
| 52 | * |
|---|
| 53 | *****************************************************************************/ |
|---|
| 54 | #ifndef BAPP_SETTINGS_H__ |
|---|
| 55 | #define BAPP_SETTINGS_H__ |
|---|
| 56 | |
|---|
| 57 | #include "bsettop.h" |
|---|
| 58 | #include "ch_map.h" |
|---|
| 59 | #include "psip_descriptor.h" |
|---|
| 60 | #include "bapp.h" |
|---|
| 61 | |
|---|
| 62 | /* definitions for the various settings ids */ |
|---|
| 63 | #define BAST_BASE_ID (1) |
|---|
| 64 | #define BAST_EAS_ID (BAST_BASE_ID) |
|---|
| 65 | #define BAST_MISC_ID (BAST_EAS_ID+1) |
|---|
| 66 | #define BAST_PHONE_NUMBER_ID (BAST_MISC_ID+1) |
|---|
| 67 | #define BAST_CHANNEL_MAP_HEADER_ID (BAST_PHONE_NUMBER_ID+1) |
|---|
| 68 | #define BAST_MMS_ENTRY_ID (BAST_CHANNEL_MAP_HEADER_ID+1) |
|---|
| 69 | #define BAST_FREQ_ENTRY_ID (BAST_MMS_ENTRY_ID+1) |
|---|
| 70 | #define BAST_ST_ENTRY_ID (BAST_FREQ_ENTRY_ID+1) |
|---|
| 71 | #define BAST_VCH_ENTRY_ID (BAST_ST_ENTRY_ID+1) |
|---|
| 72 | #define BAST_CHANNEL_ID (BAST_VCH_ENTRY_ID+1) |
|---|
| 73 | #define BAST_SHARED_KEY_ID (BAST_CHANNEL_ID+1) |
|---|
| 74 | #define BAST_UPK_GENERATOR_ID (BAST_SHARED_KEY_ID+1) |
|---|
| 75 | #define BAST_GP_NVM_VERSION_ID (BAST_UPK_GENERATOR_ID+1) |
|---|
| 76 | #define BAST_GP_TARGET_INFO_ID (BAST_GP_NVM_VERSION_ID+1) |
|---|
| 77 | #define BAST_GP_NIB_FRAME_CNT_ID (BAST_GP_TARGET_INFO_ID+1) |
|---|
| 78 | #define BAST_GP_NIB_BASE_CH_ID (BAST_GP_NIB_FRAME_CNT_ID+1) |
|---|
| 79 | #define BAST_GP_NIB_POWER_SAVE_ID (BAST_GP_NIB_BASE_CH_ID+1) |
|---|
| 80 | #define BAST_GP_NIB_GENERAL_ID (BAST_GP_NIB_POWER_SAVE_ID+1) |
|---|
| 81 | #define BAST_GP_PAIRING_ID_0 (BAST_GP_NIB_GENERAL_ID+1) |
|---|
| 82 | #define BAST_GP_PAIRING_ID_1 (BAST_GP_PAIRING_ID_0+1) |
|---|
| 83 | #define BAST_GP_PAIRING_ID_2 (BAST_GP_PAIRING_ID_1+1) |
|---|
| 84 | #define BAST_GP_PAIRING_ID_3 (BAST_GP_PAIRING_ID_2+1) |
|---|
| 85 | #define BAST_GP_PAIRING_ID_4 (BAST_GP_PAIRING_ID_3+1) |
|---|
| 86 | #define BAST_GP_PAIRING_ID_5 (BAST_GP_PAIRING_ID_4+1) |
|---|
| 87 | #define BAST_GP_VAL_ID (BAST_GP_PAIRING_ID_5+1) |
|---|
| 88 | #define BAST_GP_KICK_ID (BAST_GP_VAL_ID+1) |
|---|
| 89 | #define BAST_GP_RIB_ID_0 (BAST_GP_KICK_ID+1) |
|---|
| 90 | #define BAST_GP_RIB_ID_1 (BAST_GP_RIB_ID_0+1) |
|---|
| 91 | #define BAST_DCC_ID (BAST_GP_RIB_ID_1+1) |
|---|
| 92 | #define BAST_RRT_SETTINGS_ID (BAST_DCC_ID+1) |
|---|
| 93 | #define BAST_RRT_DIM_0 (BAST_RRT_SETTINGS_ID+1) |
|---|
| 94 | #define BAST_RRT_DIM_1 (BAST_RRT_DIM_0+1) |
|---|
| 95 | #define BAST_RRT_DIM_2 (BAST_RRT_DIM_1+1) |
|---|
| 96 | #define BAST_RRT_TBL_0 (BAST_RRT_DIM_2+1) |
|---|
| 97 | #define BAST_RRT_TBL_1 (BAST_RRT_TBL_0+1) |
|---|
| 98 | #define BAST_RRT_TBL_2 (BAST_RRT_TBL_1+1) |
|---|
| 99 | #define BAST_RRT_TBL_3 (BAST_RRT_TBL_2+1) |
|---|
| 100 | #define BAST_RRT_TBL_4 (BAST_RRT_TBL_3+1) |
|---|
| 101 | #define BAST_RATINGS_ID (BAST_RRT_TBL_4+1) |
|---|
| 102 | |
|---|
| 103 | #define BAST_SCREEN_ID (BAST_RATINGS_ID+1) |
|---|
| 104 | |
|---|
| 105 | struct eas_settings_t { |
|---|
| 106 | uint8_t eas_filter_control; |
|---|
| 107 | uint8_t eas_state_code; |
|---|
| 108 | uint8_t eas_county_subdivision; |
|---|
| 109 | uint16_t eas_county_code; |
|---|
| 110 | } __attribute__((packed)); |
|---|
| 111 | |
|---|
| 112 | struct bit_item_t { |
|---|
| 113 | unsigned int activated : 1; |
|---|
| 114 | unsigned int deactivated : 1; |
|---|
| 115 | unsigned int standby : 1; |
|---|
| 116 | unsigned int has_CAT : 1; |
|---|
| 117 | unsigned int av_mute : 1; |
|---|
| 118 | unsigned int psi_scan : 1; |
|---|
| 119 | unsigned int state : 4; |
|---|
| 120 | unsigned int dummy : 22; |
|---|
| 121 | }; |
|---|
| 122 | |
|---|
| 123 | struct misc_settings_t { |
|---|
| 124 | struct bit_item_t bits; |
|---|
| 125 | uint8_t dst_delta; |
|---|
| 126 | uint8_t timeout_policy; |
|---|
| 127 | uint8_t SCP_operating_mode; |
|---|
| 128 | uint8_t dummy0; |
|---|
| 129 | uint16_t CA_System_ID; |
|---|
| 130 | uint16_t EMM_Provider_ID; |
|---|
| 131 | uint16_t EMM_PID; |
|---|
| 132 | uint16_t VCT_ID; |
|---|
| 133 | uint16_t network_PID; |
|---|
| 134 | uint16_t hunt_cnt; |
|---|
| 135 | uint16_t download_failed_cnt; |
|---|
| 136 | uint16_t download_invalid_cnt; |
|---|
| 137 | uint16_t timeout; |
|---|
| 138 | uint16_t max_location_errors; |
|---|
| 139 | uint16_t location_errors; |
|---|
| 140 | uint32_t message_time; |
|---|
| 141 | uint32_t turn_on_freq_khz; |
|---|
| 142 | uint32_t addressable_time; |
|---|
| 143 | uint32_t timeout_cnt; |
|---|
| 144 | uint32_t location; |
|---|
| 145 | int32_t utc_offset; |
|---|
| 146 | uint32_t dst_entry; |
|---|
| 147 | uint32_t dst_exit; |
|---|
| 148 | |
|---|
| 149 | uint16_t aspect_ratio; |
|---|
| 150 | uint16_t hd_options; |
|---|
| 151 | uint16_t output_format; |
|---|
| 152 | uint16_t sharpness; |
|---|
| 153 | uint16_t sd_options; |
|---|
| 154 | } __attribute__((packed)); |
|---|
| 155 | |
|---|
| 156 | struct phone_number_settings_t { |
|---|
| 157 | uint8_t size; |
|---|
| 158 | uint8_t data[MAX_PHONE_LEN-2]; |
|---|
| 159 | } __attribute__((packed)); |
|---|
| 160 | |
|---|
| 161 | /* header information about stored channel map */ |
|---|
| 162 | struct channel_map_header_settings_t { |
|---|
| 163 | uint8_t mms_count; |
|---|
| 164 | uint8_t freq_count; |
|---|
| 165 | uint16_t st_count; |
|---|
| 166 | uint16_t vch_count; |
|---|
| 167 | } __attribute__((packed)); |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | struct mms_item_t { |
|---|
| 171 | uint8_t idx; |
|---|
| 172 | uint8_t code_rate; |
|---|
| 173 | uint8_t modulation; |
|---|
| 174 | uint32_t symbol_rate; |
|---|
| 175 | } __attribute__((packed)); |
|---|
| 176 | |
|---|
| 177 | /* we pack 8 mms structures in to one tuple to reduce overhead 56 bytes*/ |
|---|
| 178 | struct mms_entry_settings_t { |
|---|
| 179 | struct mms_item_t mms[8]; |
|---|
| 180 | } __attribute__((packed)); |
|---|
| 181 | |
|---|
| 182 | struct freq_item_t { |
|---|
| 183 | uint8_t idx; |
|---|
| 184 | uint32_t freq_khz; |
|---|
| 185 | } __attribute__((packed)); |
|---|
| 186 | |
|---|
| 187 | /* pack 8 freq structures in to one tuple */ |
|---|
| 188 | struct freq_entry_settings_t { |
|---|
| 189 | struct freq_item_t freq[8]; |
|---|
| 190 | } __attribute__((packed)); |
|---|
| 191 | |
|---|
| 192 | /* 19 bytes */ |
|---|
| 193 | struct st_entry_settings_t { |
|---|
| 194 | uint16_t source_id; |
|---|
| 195 | uint8_t name[17]; |
|---|
| 196 | } __attribute__((packed)); |
|---|
| 197 | |
|---|
| 198 | struct screen_settings_t { |
|---|
| 199 | unsigned int sound : 2; |
|---|
| 200 | unsigned int picture : 1; |
|---|
| 201 | unsigned int language : 2; |
|---|
| 202 | unsigned int wiz_completed : 1; |
|---|
| 203 | unsigned int ratings_lock : 2; |
|---|
| 204 | unsigned int ratings_tv : 18; |
|---|
| 205 | unsigned int ratings_movies : 7; |
|---|
| 206 | unsigned int content_d : 1; |
|---|
| 207 | unsigned int content_l : 1; |
|---|
| 208 | unsigned int content_s : 1; |
|---|
| 209 | unsigned int content_v : 1; |
|---|
| 210 | unsigned int captions_basic : 4; |
|---|
| 211 | unsigned int captions_font : 3; |
|---|
| 212 | unsigned int captions_font_size : 2; |
|---|
| 213 | unsigned int captions_font_style : 2; |
|---|
| 214 | unsigned int captions_font_color : 4; |
|---|
| 215 | unsigned int captions_font_opacity : 3; |
|---|
| 216 | unsigned int captions_back_color : 4; |
|---|
| 217 | unsigned int captions_back_opacity : 3; |
|---|
| 218 | unsigned int captions_edge_color : 4; |
|---|
| 219 | unsigned int captions_edge_type : 3; |
|---|
| 220 | unsigned int auto_power_off : 1; |
|---|
| 221 | unsigned int rrt_status : 2; |
|---|
| 222 | unsigned int time_zone : 4; |
|---|
| 223 | unsigned int dst : 1; |
|---|
| 224 | unsigned int last_rrt_id : 16; |
|---|
| 225 | unsigned int pin : 32; |
|---|
| 226 | unsigned int auto_power : 32; |
|---|
| 227 | } __attribute__((packed)); |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | #define VCH_MAX_AUDIO 4 |
|---|
| 231 | #define VCH_MAX_DSUB 4 |
|---|
| 232 | /* 43 bytes long */ |
|---|
| 233 | struct vch_entry_settings_t { |
|---|
| 234 | uint16_t ch_num; |
|---|
| 235 | uint16_t source_id; |
|---|
| 236 | uint16_t program_num; |
|---|
| 237 | uint16_t pcr_pid; |
|---|
| 238 | uint16_t scte127_pid; |
|---|
| 239 | uint16_t video_pid; |
|---|
| 240 | uint16_t ca_pid; |
|---|
| 241 | uint16_t audio_pid[VCH_MAX_AUDIO]; |
|---|
| 242 | uint8_t audio_type[VCH_MAX_AUDIO]; |
|---|
| 243 | int8_t audio_lang[VCH_MAX_AUDIO][3]; |
|---|
| 244 | uint8_t freq_idx; |
|---|
| 245 | uint8_t mms_idx; |
|---|
| 246 | uint8_t video_type; |
|---|
| 247 | uint8_t vchflags; |
|---|
| 248 | uint8_t audio_count; |
|---|
| 249 | uint8_t audio_current; |
|---|
| 250 | #ifdef CONFIG_DVB_SUBTITLE |
|---|
| 251 | uint8_t dsub_count; |
|---|
| 252 | uint8_t dsub_current; |
|---|
| 253 | uint16_t dsub_pid[VCH_MAX_DSUB]; |
|---|
| 254 | uint8_t dsub_lang[VCH_MAX_DSUB][3]; |
|---|
| 255 | uint16_t dsub_page[VCH_MAX_DSUB]; |
|---|
| 256 | #endif |
|---|
| 257 | } __attribute__((packed)); |
|---|
| 258 | |
|---|
| 259 | /* 3 bytes */ |
|---|
| 260 | struct channel_settings_t { |
|---|
| 261 | uint16_t channel; |
|---|
| 262 | uint8_t volume; |
|---|
| 263 | } __attribute__((packed)); |
|---|
| 264 | |
|---|
| 265 | struct shared_key_settings_t { |
|---|
| 266 | uint8_t decryption_key_type; |
|---|
| 267 | uint8_t shared_key_A [16]; |
|---|
| 268 | uint8_t shared_key_B [16]; |
|---|
| 269 | } __attribute__((packed)); |
|---|
| 270 | |
|---|
| 271 | struct upk_generator_settings_t { |
|---|
| 272 | uint8_t upk_generator_size; |
|---|
| 273 | uint8_t upk_generator_A[110]; |
|---|
| 274 | uint8_t upk_generator_B[110]; |
|---|
| 275 | } __attribute__((packed)); |
|---|
| 276 | |
|---|
| 277 | #ifdef __cplusplus |
|---|
| 278 | extern "C" { |
|---|
| 279 | #endif |
|---|
| 280 | |
|---|
| 281 | void bast_init(bapp_t *app); |
|---|
| 282 | void bast_channel_save(bapp_t *app); |
|---|
| 283 | void bast_misc_save(bapp_t *app); |
|---|
| 284 | void bast_eas_save(bapp_t *app); |
|---|
| 285 | void bast_phone_number_save(bapp_t *app); |
|---|
| 286 | void bast_channel_map_save(bapp_t *app); |
|---|
| 287 | int bast_channel_read(bapp_t *app); |
|---|
| 288 | int bast_misc_read(bapp_t *app); |
|---|
| 289 | int bast_eas_read(bapp_t *app); |
|---|
| 290 | int bast_phone_number_read(bapp_t *app); |
|---|
| 291 | int bast_channel_map_read(bapp_t *app); |
|---|
| 292 | |
|---|
| 293 | void bast_shared_key_save(struct shared_key_settings_t * key); |
|---|
| 294 | int bast_shared_key_read(struct shared_key_settings_t * key); |
|---|
| 295 | void bast_upk_generator_save(struct upk_generator_settings_t * gen); |
|---|
| 296 | int bast_upk_generator_read(struct upk_generator_settings_t * gen); |
|---|
| 297 | |
|---|
| 298 | void bast_gp_nvm_save(uint8_t tag, uint8_t size, uint8_t *data); |
|---|
| 299 | int bast_gp_nvm_read(uint8_t tag, uint8_t *size, uint8_t *data); |
|---|
| 300 | |
|---|
| 301 | void bast_dcc_save(dcc_settings_t *settings); |
|---|
| 302 | int bast_dcc_read(dcc_settings_t *settings); |
|---|
| 303 | |
|---|
| 304 | void bast_ratings_save(ratings_settings_t *settings); |
|---|
| 305 | int bast_ratings_read(ratings_settings_t *settings); |
|---|
| 306 | |
|---|
| 307 | void bast_rrt_save(rrt_settings_t *settings); |
|---|
| 308 | int bast_rrt_read(rrt_settings_t *settings); |
|---|
| 309 | |
|---|
| 310 | void bast_screen_save(bapp_t *app); |
|---|
| 311 | int bast_screen_read(bapp_t *app); |
|---|
| 312 | |
|---|
| 313 | #ifdef __cplusplus |
|---|
| 314 | } |
|---|
| 315 | #endif |
|---|
| 316 | |
|---|
| 317 | #endif /* BAPP_SETTINGS_H__ */ |
|---|