| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2002-2009, 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: bsettop_cablecard.c $ |
|---|
| 11 | * $brcm_Revision: 7 $ |
|---|
| 12 | * $brcm_Date: 1/16/09 10:19a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/api/src/nexus/bsettop_cablecard.c $ |
|---|
| 19 | * |
|---|
| 20 | * 7 1/16/09 10:19a haisongw |
|---|
| 21 | * PR51117: Transport stream routing for MCard Interface incorrect |
|---|
| 22 | * |
|---|
| 23 | * 6 1/15/09 3:47p haisongw |
|---|
| 24 | * PR51129: Remove SPOD support |
|---|
| 25 | * |
|---|
| 26 | * 5 1/14/09 3:47p anilmm |
|---|
| 27 | * PR51117: Incorrect transport stream routing for MCard interface |
|---|
| 28 | * |
|---|
| 29 | * 4 10/14/08 10:58p anilmm |
|---|
| 30 | * PR44830: Adjust naming convention |
|---|
| 31 | * |
|---|
| 32 | * 3 9/23/08 9:16a jgarrett |
|---|
| 33 | * PR 46513: Merging 97459 support to mainline |
|---|
| 34 | * |
|---|
| 35 | * PR44830/2 7/28/08 7:19p anilmm |
|---|
| 36 | * PR44830: Remove unnecessary handle passed into GetDefaultSettings |
|---|
| 37 | * |
|---|
| 38 | * PR44830/1 7/15/08 8:16p anilmm |
|---|
| 39 | * PR44830: add full cablecard support, fill in stubs |
|---|
| 40 | * |
|---|
| 41 | * 2 3/25/08 10:13a jgarrett |
|---|
| 42 | * PR 40857: Adding stubs for thunk layer |
|---|
| 43 | * |
|---|
| 44 | * 1 10/15/07 2:35p erickson |
|---|
| 45 | * PR36068: initial |
|---|
| 46 | * |
|---|
| 47 | * 2 1/3/07 11:30a vsilyaev |
|---|
| 48 | * PR26393: 7401C0/C1 SPOD XPT interface support |
|---|
| 49 | * |
|---|
| 50 | * PROD_TRINITY_REFSW_Devel/4 1/2/07 5:35p haisongw |
|---|
| 51 | * PR26393: 7401C0/C1 SPOD XPT interface support |
|---|
| 52 | * |
|---|
| 53 | * PROD_TRINITY_REFSW_Devel/3 12/29/06 4:05p haisongw |
|---|
| 54 | * PR26393: 7401C0/C1 SPOD XPT interface support |
|---|
| 55 | * |
|---|
| 56 | * PROD_TRINITY_REFSW_Devel/2 12/27/06 4:48p haisongw |
|---|
| 57 | * PR26258: add cablecard support in Settop API kernel mode |
|---|
| 58 | * |
|---|
| 59 | * PROD_TRINITY_REFSW_Devel/1 12/19/06 3:27p haisongw |
|---|
| 60 | * PR26258: add cablecard support in Settop API kernel mode |
|---|
| 61 | * |
|---|
| 62 | ****************************************************************************/ |
|---|
| 63 | #include "bsettop_impl.h" |
|---|
| 64 | #include "bsettop_cablecard.h" |
|---|
| 65 | #include "nexus_mpod.h" |
|---|
| 66 | |
|---|
| 67 | BDBG_MODULE(cablecard); |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | #define B_MAX_CABLECARDS 1 |
|---|
| 71 | #define MAX_CABLECARD_ROUTE 6 |
|---|
| 72 | |
|---|
| 73 | BDBG_OBJECT_ID(bcablecard); |
|---|
| 74 | |
|---|
| 75 | #if defined(MPOD_SUPPORT) |
|---|
| 76 | |
|---|
| 77 | extern bband_t b_get_inband(btuner_t tuner); |
|---|
| 78 | |
|---|
| 79 | struct bcablecard { |
|---|
| 80 | BDBG_OBJECT(bcablecard) |
|---|
| 81 | bcablecard_settings settings; |
|---|
| 82 | NEXUS_MpodHandle mpod; |
|---|
| 83 | NEXUS_MpodInputHandle mpod_input[MAX_CABLECARD_ROUTE]; |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | static void b_reset_mpod_route(NEXUS_MpodHandle mpod) |
|---|
| 88 | { |
|---|
| 89 | NEXUS_MpodInputSettings settings; |
|---|
| 90 | unsigned pr_band; |
|---|
| 91 | NEXUS_MpodInputHandle mpod_input; |
|---|
| 92 | |
|---|
| 93 | NEXUS_MpodInput_GetDefaultSettings(&settings); |
|---|
| 94 | settings.bandType = NEXUS_MpodBandType_eParserBand; |
|---|
| 95 | settings.allPass = false; |
|---|
| 96 | |
|---|
| 97 | for ( pr_band = 0; pr_band < MAX_CABLECARD_ROUTE; pr_band++) |
|---|
| 98 | { |
|---|
| 99 | settings.band.parserBand = (NEXUS_ParserBand)pr_band; |
|---|
| 100 | mpod_input = NEXUS_MpodInput_Open(mpod, &settings); |
|---|
| 101 | NEXUS_MpodInput_Close(mpod_input); |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | bcablecard_t bcablecard_open( |
|---|
| 106 | bobject_t cablecard_id /* cablecard object id */ |
|---|
| 107 | ) |
|---|
| 108 | { |
|---|
| 109 | bcablecard_t cablecard; |
|---|
| 110 | int index; |
|---|
| 111 | NEXUS_MpodOpenSettings setting; |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | BDBG_MSG(("bcablecard_open: %d", B_ID_GET_INDEX(cablecard_id))); |
|---|
| 115 | |
|---|
| 116 | index = B_ID_GET_INDEX(cablecard_id); |
|---|
| 117 | if (index>=B_MAX_CABLECARDS) { |
|---|
| 118 | BSETTOP_ERROR(berr_invalid_parameter); |
|---|
| 119 | goto error; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | cablecard = BKNI_Malloc(sizeof(struct bcablecard)); |
|---|
| 123 | BKNI_Memset(cablecard, 0, sizeof(struct bcablecard)); |
|---|
| 124 | BDBG_OBJECT_SET(cablecard, bcablecard); |
|---|
| 125 | |
|---|
| 126 | if (cablecard == NULL) goto error; |
|---|
| 127 | |
|---|
| 128 | NEXUS_Mpod_GetDefaultOpenSettings(&setting); |
|---|
| 129 | setting.mpodMode = NEXUS_MpodMode_eMpod; |
|---|
| 130 | setting.bandType = NEXUS_MpodBandType_eParserBand; |
|---|
| 131 | |
|---|
| 132 | /*TODO:: get platform specific setting from platform layer |
|---|
| 133 | harcoded for 7405 here for the time being*/ |
|---|
| 134 | setting.byteSync = 1; |
|---|
| 135 | setting.clockDelay = 1; |
|---|
| 136 | setting.invertClock = 0; |
|---|
| 137 | |
|---|
| 138 | cablecard->mpod = NEXUS_Mpod_Open(index, &setting); |
|---|
| 139 | if ( cablecard->mpod == NULL) |
|---|
| 140 | { |
|---|
| 141 | BKNI_Free(cablecard); |
|---|
| 142 | goto error; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | b_reset_mpod_route(cablecard->mpod ); |
|---|
| 146 | |
|---|
| 147 | return cablecard; |
|---|
| 148 | error: |
|---|
| 149 | return NULL; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | /* |
|---|
| 154 | Summary: |
|---|
| 155 | Close a CableCARD resource. |
|---|
| 156 | Description: |
|---|
| 157 | It de-initializes transport interface for cablecard. |
|---|
| 158 | */ |
|---|
| 159 | void bcablecard_close( |
|---|
| 160 | bcablecard_t cablecard /* handle returned by bcablecard_open */ |
|---|
| 161 | ) |
|---|
| 162 | { |
|---|
| 163 | int i; |
|---|
| 164 | |
|---|
| 165 | if (NULL != cablecard) |
|---|
| 166 | { |
|---|
| 167 | for (i=0; i<MAX_CABLECARD_ROUTE; i++) |
|---|
| 168 | { |
|---|
| 169 | if ( NULL != cablecard->mpod_input[i]) |
|---|
| 170 | NEXUS_MpodInput_Close(cablecard->mpod_input[i]); |
|---|
| 171 | } |
|---|
| 172 | NEXUS_Mpod_Close(cablecard->mpod); |
|---|
| 173 | BDBG_OBJECT_UNSET(cablecard, bcablecard); |
|---|
| 174 | BKNI_Free(cablecard); |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | /** |
|---|
| 180 | Summary: |
|---|
| 181 | Get current CableCARD settings |
|---|
| 182 | **/ |
|---|
| 183 | void bcablecard_get( |
|---|
| 184 | bcablecard_t cablecard, |
|---|
| 185 | bcablecard_settings *settings /* [out] */ |
|---|
| 186 | ) |
|---|
| 187 | { |
|---|
| 188 | if ( NULL != cablecard) |
|---|
| 189 | { |
|---|
| 190 | cablecard->settings.ctrl = bcablecard_physical_control_none; |
|---|
| 191 | *settings = cablecard->settings; |
|---|
| 192 | } |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | /** |
|---|
| 196 | Summary: |
|---|
| 197 | Set new CableCARD settings |
|---|
| 198 | **/ |
|---|
| 199 | bresult bcablecard_set( |
|---|
| 200 | bcablecard_t cablecard, |
|---|
| 201 | const bcablecard_settings *settings |
|---|
| 202 | ) |
|---|
| 203 | { |
|---|
| 204 | if ( NULL != cablecard) |
|---|
| 205 | { |
|---|
| 206 | cablecard->settings = *settings; |
|---|
| 207 | #if 0 |
|---|
| 208 | /*TODO:: add OOB pin tristate control here*/ |
|---|
| 209 | switch (cablecard->settings.ctrl) { |
|---|
| 210 | case bcablecard_physical_control_disable_OOB_pins: |
|---|
| 211 | case bcablecard_physical_control_enable_OOB_pins: |
|---|
| 212 | { |
|---|
| 213 | BRPC_Handle rpc_handle = b_root.tuner.rpc_handle; |
|---|
| 214 | BERR_Code retVal; |
|---|
| 215 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 216 | BRPC_Param_POD_CardApplyPower Param; |
|---|
| 217 | Param.devId = BRPC_DevId_3255_POD; |
|---|
| 218 | if (cablecard->settings.ctrl == bcablecard_physical_control_disable_OOB_pins) |
|---|
| 219 | Param.powerMode = DISABLE_POD_OUTPINS; |
|---|
| 220 | else |
|---|
| 221 | Param.powerMode = ENABLE_POD_OUTPINS; |
|---|
| 222 | CHK_RETCODE( retCode, BRPC_CallProc(rpc_handle, BRPC_ProcId_POD_CardApplyPower, |
|---|
| 223 | (const uint32_t *)&Param, sizeInLong(Param), NULL, 0, &retVal)); |
|---|
| 224 | CHK_RETCODE( retCode, retVal ); |
|---|
| 225 | } |
|---|
| 226 | break; |
|---|
| 227 | case bcablecard_physical_control_init: |
|---|
| 228 | case bcablecard_physical_control_cardout: |
|---|
| 229 | case bcablecard_physical_control_shutdown: |
|---|
| 230 | case bcablecard_physical_control_applypower: |
|---|
| 231 | case bcablecard_physical_control_applypower_3V: |
|---|
| 232 | case bcablecard_physical_control_applypower_5V: |
|---|
| 233 | case bcablecard_physical_control_resetdone: |
|---|
| 234 | BDBG_ERR((" unsupported CableCARD Rmagnum %d", cablecard->settings.ctrl)); |
|---|
| 235 | break; |
|---|
| 236 | default: |
|---|
| 237 | break; |
|---|
| 238 | } |
|---|
| 239 | #endif |
|---|
| 240 | return b_ok; |
|---|
| 241 | } |
|---|
| 242 | else |
|---|
| 243 | { |
|---|
| 244 | return berr_invalid_parameter; |
|---|
| 245 | } |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | /* |
|---|
| 249 | Summary: |
|---|
| 250 | Enable routing tuner's transport output to CableCARD. |
|---|
| 251 | Description: |
|---|
| 252 | */ |
|---|
| 253 | bresult bcablecard_route_add_tuner( |
|---|
| 254 | bcablecard_t cablecard, |
|---|
| 255 | btuner_t tuner /* which btuner's output to be routed to CableCARD */ |
|---|
| 256 | ) |
|---|
| 257 | { |
|---|
| 258 | |
|---|
| 259 | NEXUS_MpodInputSettings settings; |
|---|
| 260 | unsigned pr_band; |
|---|
| 261 | |
|---|
| 262 | if (cablecard == NULL || tuner == NULL) return berr_invalid_parameter; |
|---|
| 263 | |
|---|
| 264 | NEXUS_MpodInput_GetDefaultSettings(&settings); |
|---|
| 265 | settings.bandType = NEXUS_MpodBandType_eParserBand; |
|---|
| 266 | settings.allPass = false; |
|---|
| 267 | |
|---|
| 268 | pr_band = b_get_parser_band(b_get_inband(tuner)); |
|---|
| 269 | settings.band.parserBand = (NEXUS_ParserBand)pr_band; |
|---|
| 270 | |
|---|
| 271 | if (pr_band >= B_MAX_PARSERS) |
|---|
| 272 | { |
|---|
| 273 | BDBG_WRN((" haven't allocate parseband yet")); |
|---|
| 274 | return b_ok; |
|---|
| 275 | } |
|---|
| 276 | |
|---|
| 277 | if ( NULL == cablecard->mpod_input[pr_band]) |
|---|
| 278 | { |
|---|
| 279 | cablecard->mpod_input[pr_band] = NEXUS_MpodInput_Open(cablecard->mpod, &settings); |
|---|
| 280 | if (cablecard->mpod_input[pr_band] == NULL) return berr_not_available; |
|---|
| 281 | } |
|---|
| 282 | else |
|---|
| 283 | { |
|---|
| 284 | BDBG_WRN((" tuner has already been routed to MPOD")); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | return b_ok; |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | /* |
|---|
| 291 | Summary: |
|---|
| 292 | Disable routing tuner's transport output to CableCARD. |
|---|
| 293 | Description: |
|---|
| 294 | */ |
|---|
| 295 | bresult bcablecard_route_remove_tuner( |
|---|
| 296 | bcablecard_t cablecard, |
|---|
| 297 | btuner_t tuner /* which btuner's output NOT to be routed to cablecard */ |
|---|
| 298 | ) |
|---|
| 299 | { |
|---|
| 300 | unsigned pr_band; |
|---|
| 301 | |
|---|
| 302 | if (cablecard == NULL || tuner == NULL) return berr_invalid_parameter; |
|---|
| 303 | pr_band = b_get_parser_band(b_get_inband(tuner)); |
|---|
| 304 | if (pr_band >= B_MAX_PARSERS) |
|---|
| 305 | { |
|---|
| 306 | BDBG_WRN((" haven't allocate parseband yet")); |
|---|
| 307 | return b_ok; |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | if ( NULL != cablecard->mpod_input[pr_band]) |
|---|
| 311 | { |
|---|
| 312 | NEXUS_MpodInput_Close(cablecard->mpod_input[pr_band]); |
|---|
| 313 | cablecard->mpod_input[pr_band] = NULL; |
|---|
| 314 | } |
|---|
| 315 | else |
|---|
| 316 | { |
|---|
| 317 | BDBG_MSG((" tuner has already been disconnected from MPOD")); |
|---|
| 318 | } |
|---|
| 319 | return b_ok; |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | /* |
|---|
| 323 | Summary: |
|---|
| 324 | get settings for the transport route input from tuner to CableCARD |
|---|
| 325 | Description: |
|---|
| 326 | */ |
|---|
| 327 | bresult bcablecard_route_get( |
|---|
| 328 | bcablecard_t cablecard, |
|---|
| 329 | btuner_t tuner, /* tuner's output routed to POD */ |
|---|
| 330 | bcablecard_route_settings *settings /*CableCARD route settings*/ |
|---|
| 331 | ) |
|---|
| 332 | { |
|---|
| 333 | unsigned int pr_band; |
|---|
| 334 | |
|---|
| 335 | if (cablecard == NULL || tuner == NULL) return berr_invalid_parameter; |
|---|
| 336 | pr_band = b_get_parser_band(b_get_inband(tuner)); |
|---|
| 337 | settings->band = b_get_inband(tuner); |
|---|
| 338 | settings->ltsid = (pr_band&0x1f); |
|---|
| 339 | return b_ok; |
|---|
| 340 | } |
|---|
| 341 | |
|---|
| 342 | #else |
|---|
| 343 | |
|---|
| 344 | bcablecard_t |
|---|
| 345 | bcablecard_open(bobject_t cablecard_id) |
|---|
| 346 | { |
|---|
| 347 | BSTD_UNUSED(cablecard_id); |
|---|
| 348 | return NULL; |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | void |
|---|
| 352 | bcablecard_close(bcablecard_t cablecard) |
|---|
| 353 | { |
|---|
| 354 | BSTD_UNUSED(cablecard); |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | |
|---|
| 358 | void bcablecard_get(bcablecard_t cablecard, bcablecard_settings *settings) |
|---|
| 359 | { |
|---|
| 360 | BSTD_UNUSED(cablecard); |
|---|
| 361 | BSTD_UNUSED(settings); |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | |
|---|
| 365 | bresult bcablecard_set(bcablecard_t cablecard, const bcablecard_settings *settings) |
|---|
| 366 | { |
|---|
| 367 | BSTD_UNUSED(cablecard); |
|---|
| 368 | BSTD_UNUSED(settings); |
|---|
| 369 | return berr_not_supported; |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | bresult bcablecard_route_add_tuner(bcablecard_t cablecard,btuner_t tuner) |
|---|
| 373 | { |
|---|
| 374 | BSTD_UNUSED(tuner); |
|---|
| 375 | BSTD_UNUSED(cablecard); |
|---|
| 376 | return berr_not_supported; |
|---|
| 377 | } |
|---|
| 378 | |
|---|
| 379 | bresult bcablecard_route_remove_tuner(bcablecard_t cablecard,btuner_t tuner) |
|---|
| 380 | { |
|---|
| 381 | BSTD_UNUSED(tuner); |
|---|
| 382 | BSTD_UNUSED(cablecard); |
|---|
| 383 | return berr_not_supported; |
|---|
| 384 | } |
|---|
| 385 | bresult bcablecard_route_get(bcablecard_t cablecard,btuner_t tuner, bcablecard_route_settings *settings) |
|---|
| 386 | { |
|---|
| 387 | BSTD_UNUSED(tuner); |
|---|
| 388 | BSTD_UNUSED(cablecard); |
|---|
| 389 | BSTD_UNUSED(settings); |
|---|
| 390 | return berr_not_supported; |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | #endif |
|---|