| 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 CH_MAP_H__ |
|---|
| 22 | #define CH_MAP_H__ |
|---|
| 23 | |
|---|
| 24 | #include "bapp_task.h" |
|---|
| 25 | |
|---|
| 26 | #define MAX_FREQ_MAP 0xFF |
|---|
| 27 | #define MAX_VCH_LEN 16 |
|---|
| 28 | #define MAX_VCH 512 |
|---|
| 29 | #define MAX_AUDIO_PIDS 4 |
|---|
| 30 | |
|---|
| 31 | /* |
|---|
| 32 | * Entry in modulation table built from MMS records in NIT |
|---|
| 33 | */ |
|---|
| 34 | |
|---|
| 35 | typedef struct mms_t |
|---|
| 36 | { |
|---|
| 37 | unsigned char idx; /* Frequency Index */ |
|---|
| 38 | unsigned char code_rate; /* Inner Coding Rate */ |
|---|
| 39 | unsigned char modulation; /* Modulation Format */ |
|---|
| 40 | unsigned int symbol_rate; /* Symbol rate */ |
|---|
| 41 | }mms_t; |
|---|
| 42 | |
|---|
| 43 | /* |
|---|
| 44 | * MMS table built from MMS records in NIT |
|---|
| 45 | */ |
|---|
| 46 | |
|---|
| 47 | typedef struct mms_map_t |
|---|
| 48 | { |
|---|
| 49 | unsigned char num_mms; /* Number of mms structures in table */ |
|---|
| 50 | mms_t mms[MAX_FREQ_MAP]; |
|---|
| 51 | }mms_map_t; |
|---|
| 52 | |
|---|
| 53 | /* |
|---|
| 54 | * Entry in frequency table built from CDS records in NIT |
|---|
| 55 | */ |
|---|
| 56 | |
|---|
| 57 | typedef struct freq_t |
|---|
| 58 | { |
|---|
| 59 | unsigned char idx; /* Frequency Index */ |
|---|
| 60 | unsigned int freq_khz; /* Frequency in KHz */ |
|---|
| 61 | }freq_t; |
|---|
| 62 | |
|---|
| 63 | /* |
|---|
| 64 | * Frequency table built from CDS records in NIT |
|---|
| 65 | */ |
|---|
| 66 | |
|---|
| 67 | typedef struct freq_map_t |
|---|
| 68 | { |
|---|
| 69 | unsigned char num_freq; /* Number of frequencies in table */ |
|---|
| 70 | freq_t freq[MAX_FREQ_MAP]; |
|---|
| 71 | }freq_map_t; |
|---|
| 72 | |
|---|
| 73 | /* |
|---|
| 74 | * Source text entry build from NTT |
|---|
| 75 | */ |
|---|
| 76 | |
|---|
| 77 | typedef struct st_t |
|---|
| 78 | { |
|---|
| 79 | unsigned short source_id; /* Source ID identifying program source */ |
|---|
| 80 | unsigned char name[MAX_VCH_LEN + 1];/* NULL terminated source name */ |
|---|
| 81 | }st_t; |
|---|
| 82 | |
|---|
| 83 | /* |
|---|
| 84 | * Frequency table built from CDS records in NIT |
|---|
| 85 | */ |
|---|
| 86 | |
|---|
| 87 | typedef struct st_map_t |
|---|
| 88 | { |
|---|
| 89 | unsigned short num_st; /* Number of source text entries in table */ |
|---|
| 90 | st_t st[MAX_VCH]; |
|---|
| 91 | }st_map_t; |
|---|
| 92 | |
|---|
| 93 | /* |
|---|
| 94 | * Entry in virtual channel table built from VCM records in SVCT |
|---|
| 95 | */ |
|---|
| 96 | |
|---|
| 97 | typedef struct vch_t |
|---|
| 98 | { |
|---|
| 99 | unsigned short ch_num; /* Virtual channel number */ |
|---|
| 100 | unsigned short source_id; /* Source ID identifying program source */ |
|---|
| 101 | unsigned short program_num; /* program number in PMT */ |
|---|
| 102 | unsigned char freq_idx; /* frequency index in frequency */ |
|---|
| 103 | unsigned char mms_idx; /* mms index */ |
|---|
| 104 | unsigned char vchflags; /* non-zero indicates hidden channel */ |
|---|
| 105 | unsigned char num_audio; |
|---|
| 106 | unsigned char cur_audio; |
|---|
| 107 | unsigned short pcr_pid; |
|---|
| 108 | unsigned short scte127_pid; |
|---|
| 109 | unsigned short video_pid; |
|---|
| 110 | unsigned char video_type; |
|---|
| 111 | unsigned short ca_pid; |
|---|
| 112 | unsigned short audio_pid[MAX_AUDIO_PIDS]; |
|---|
| 113 | unsigned char audio_type[MAX_AUDIO_PIDS]; |
|---|
| 114 | char audio_lang[MAX_AUDIO_PIDS][3]; |
|---|
| 115 | }vch_t; |
|---|
| 116 | |
|---|
| 117 | /* |
|---|
| 118 | * virtual channel table built from VCM records in SVCT |
|---|
| 119 | */ |
|---|
| 120 | |
|---|
| 121 | typedef struct vch_map_t |
|---|
| 122 | { |
|---|
| 123 | unsigned short num_vch; /* Number of virtual channels in table */ |
|---|
| 124 | vch_t vch[MAX_VCH]; /* table of virtual channels */ |
|---|
| 125 | }vch_map_t; |
|---|
| 126 | |
|---|
| 127 | /* |
|---|
| 128 | * Structure for managing and maintaining the frequency and channel maps |
|---|
| 129 | */ |
|---|
| 130 | |
|---|
| 131 | typedef struct ch_map_t |
|---|
| 132 | { |
|---|
| 133 | bapp_task_mutex_t p_mutex; |
|---|
| 134 | unsigned short cur_ch; /* current channel */ |
|---|
| 135 | mms_map_t mms_map; /* MMS map structure */ |
|---|
| 136 | freq_map_t freq_map; /* frequency map structure */ |
|---|
| 137 | st_map_t st_map; /* source text map structure */ |
|---|
| 138 | vch_map_t vch_map; /* virtual channel map */ |
|---|
| 139 | }ch_map_t; |
|---|
| 140 | |
|---|
| 141 | #ifdef __cplusplus |
|---|
| 142 | extern "C" { |
|---|
| 143 | #endif |
|---|
| 144 | |
|---|
| 145 | /* |
|---|
| 146 | Summary: |
|---|
| 147 | Initialize channel map mgmt internals (structure may already be initialized). |
|---|
| 148 | */ |
|---|
| 149 | void ch_map_init(ch_map_t *p_ch_map,bapp_task_mutex_t handle); |
|---|
| 150 | |
|---|
| 151 | /* |
|---|
| 152 | Summary: |
|---|
| 153 | reset channel map mgmt internals. |
|---|
| 154 | */ |
|---|
| 155 | void ch_map_reset(ch_map_t *p_ch_map); |
|---|
| 156 | /* |
|---|
| 157 | Summary: |
|---|
| 158 | copy channel map. |
|---|
| 159 | */ |
|---|
| 160 | void ch_map_copy(ch_map_t *p_ch_map_to,ch_map_t *p_ch_map_from,unsigned int flags); |
|---|
| 161 | /* |
|---|
| 162 | Summary: |
|---|
| 163 | compare channel map settings. |
|---|
| 164 | */ |
|---|
| 165 | unsigned int ch_map_cmp(ch_map_t *p_ch_map_to,ch_map_t *p_ch_map_from); |
|---|
| 166 | int ch_map_cmp_st(st_map_t *p_map_to, st_map_t *p_map_from); |
|---|
| 167 | int ch_map_cmp_vch(vch_map_t *p_map_to, vch_map_t *p_map_from); |
|---|
| 168 | int ch_map_cmp_freq(freq_map_t *p_freq_map_to, freq_map_t *p_freq_map_from); |
|---|
| 169 | int ch_map_cmp_mms(mms_map_t *p_mms_map_to, mms_map_t *p_mms_map_from); |
|---|
| 170 | |
|---|
| 171 | /* |
|---|
| 172 | Summary: |
|---|
| 173 | Add a frequency entry. |
|---|
| 174 | */ |
|---|
| 175 | void ch_map_add_freq(ch_map_t *p_ch_map, freq_t *p_freq); |
|---|
| 176 | |
|---|
| 177 | /* |
|---|
| 178 | Summary: |
|---|
| 179 | Add an mms entry. |
|---|
| 180 | */ |
|---|
| 181 | void ch_map_add_mms(ch_map_t *p_ch_map, mms_t *p_mms); |
|---|
| 182 | |
|---|
| 183 | /* |
|---|
| 184 | Summary: |
|---|
| 185 | Find the matching freqency info for the given the vch reference. |
|---|
| 186 | */ |
|---|
| 187 | bool ch_map_find_freq(ch_map_t *p_ch_map, vch_t *p_vch, freq_t *p_freq); |
|---|
| 188 | |
|---|
| 189 | /* |
|---|
| 190 | Summary: |
|---|
| 191 | Add a virtual channel entry. |
|---|
| 192 | */ |
|---|
| 193 | void ch_map_add_vch(ch_map_t *p_ch_map, vch_t *p_vch); |
|---|
| 194 | |
|---|
| 195 | /* |
|---|
| 196 | Summary: |
|---|
| 197 | Add a source text entry. |
|---|
| 198 | */ |
|---|
| 199 | void ch_map_add_st(ch_map_t *p_ch_map, st_t *p_st); |
|---|
| 200 | /* |
|---|
| 201 | Summary: |
|---|
| 202 | Get number of map entries. |
|---|
| 203 | */ |
|---|
| 204 | void ch_map_get_counts(ch_map_t *p_ch_map, |
|---|
| 205 | unsigned short *num_vch, |
|---|
| 206 | unsigned short *num_st, |
|---|
| 207 | unsigned char *num_freq |
|---|
| 208 | ); |
|---|
| 209 | /* |
|---|
| 210 | Summary: |
|---|
| 211 | Get number of vch entries. |
|---|
| 212 | */ |
|---|
| 213 | void ch_map_get_vch_num(ch_map_t *p_ch_map, |
|---|
| 214 | unsigned short *num_vch |
|---|
| 215 | ); |
|---|
| 216 | /* |
|---|
| 217 | Summary: |
|---|
| 218 | Get mms for frequency idx. |
|---|
| 219 | */ |
|---|
| 220 | bool ch_map_get_mms(ch_map_t *p_ch_map, |
|---|
| 221 | unsigned char mms_idx, |
|---|
| 222 | mms_t *p_mms |
|---|
| 223 | ); |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | /* |
|---|
| 228 | Summary: |
|---|
| 229 | Get current channel information. |
|---|
| 230 | */ |
|---|
| 231 | bool ch_map_get_current(ch_map_t *p_ch_map, vch_t *p_vch, st_t *p_st, freq_t *p_freq); |
|---|
| 232 | |
|---|
| 233 | /* |
|---|
| 234 | Summary: |
|---|
| 235 | Get next channel information. |
|---|
| 236 | */ |
|---|
| 237 | bool ch_map_set_next(ch_map_t *p_ch_map); |
|---|
| 238 | |
|---|
| 239 | /* |
|---|
| 240 | Summary: |
|---|
| 241 | Get prev channel information. |
|---|
| 242 | */ |
|---|
| 243 | bool ch_map_set_prev(ch_map_t *p_ch_map); |
|---|
| 244 | |
|---|
| 245 | /* |
|---|
| 246 | Summary: |
|---|
| 247 | Return true if the channel is not a hidden channel. |
|---|
| 248 | */ |
|---|
| 249 | bool ch_map_is_channel_visible(ch_map_t *p_ch_map, unsigned short ch_num); |
|---|
| 250 | |
|---|
| 251 | /* |
|---|
| 252 | Summary: |
|---|
| 253 | Get channel information by number. |
|---|
| 254 | */ |
|---|
| 255 | bool ch_map_set_ch(ch_map_t *p_ch_map, unsigned short ch_num); |
|---|
| 256 | /* |
|---|
| 257 | Summary: |
|---|
| 258 | Set current channel given source ID. |
|---|
| 259 | */ |
|---|
| 260 | bool ch_map_set(ch_map_t *p_ch_map,unsigned short source_id); |
|---|
| 261 | /* |
|---|
| 262 | Summary: |
|---|
| 263 | Update the channel current channel info. |
|---|
| 264 | */ |
|---|
| 265 | |
|---|
| 266 | bool ch_map_vch_update(ch_map_t *p_ch_map, vch_t *p_vch); |
|---|
| 267 | |
|---|
| 268 | /* |
|---|
| 269 | Summary: |
|---|
| 270 | try to find a source ID from the frequency vector and program number (for EAS major/minor ch#). |
|---|
| 271 | */ |
|---|
| 272 | bool ch_map_find_soure_id(ch_map_t *p_ch_map, |
|---|
| 273 | unsigned char freq_vec, |
|---|
| 274 | unsigned short prog_num, |
|---|
| 275 | unsigned short *p_source_id |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | /* |
|---|
| 279 | Summary: |
|---|
| 280 | Output details to console. |
|---|
| 281 | */ |
|---|
| 282 | void ch_output(ch_map_t *p_ch_map); |
|---|
| 283 | |
|---|
| 284 | #ifdef __cplusplus |
|---|
| 285 | } |
|---|
| 286 | #endif |
|---|
| 287 | |
|---|
| 288 | #endif /* CH_MAP_H__ */ |
|---|
| 289 | |
|---|
| 290 | |
|---|