| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2003-2011 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: nexus_tsmf.c $ |
|---|
| 39 | * $brcm_Revision: 5 $ |
|---|
| 40 | * $brcm_Date: 11/2/11 11:57a $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/modules/transport/7425/src/nexus_tsmf.c $ |
|---|
| 47 | * |
|---|
| 48 | * 5 11/2/11 11:57a jtna |
|---|
| 49 | * SW7231-391: fix compiler warning |
|---|
| 50 | * |
|---|
| 51 | * 4 10/31/11 7:49p bandrews |
|---|
| 52 | * SW7231-391: merge to main |
|---|
| 53 | * |
|---|
| 54 | * SW7420-2078/1 10/25/11 5:22p bandrews |
|---|
| 55 | * SW7231-391: update parser band and timebase implementations to use |
|---|
| 56 | * handles everywhere, even for legacy enum usage |
|---|
| 57 | * |
|---|
| 58 | * 3 10/14/11 2:53p jtna |
|---|
| 59 | * SW7425-1189: added NEXUS_TsmfSettings.frontendTsmfIndex. allow change |
|---|
| 60 | * between auto and semi-auto mode without enable/disable. |
|---|
| 61 | * |
|---|
| 62 | * 2 10/5/11 1:32p jtna |
|---|
| 63 | * SW7425-1189: fix non-7425 platforms |
|---|
| 64 | * |
|---|
| 65 | * 1 10/5/11 12:27p jtna |
|---|
| 66 | * SW7425-1189: add transport and frontend TSMF support |
|---|
| 67 | * |
|---|
| 68 | ***************************************************************************/ |
|---|
| 69 | #include "nexus_transport_module.h" |
|---|
| 70 | #include "nexus_playpump_impl.h" |
|---|
| 71 | #if NEXUS_HAS_TSMF |
|---|
| 72 | #include "bxpt_tsmf.h" |
|---|
| 73 | #endif |
|---|
| 74 | |
|---|
| 75 | BDBG_MODULE(nexus_tsmf); |
|---|
| 76 | |
|---|
| 77 | BDBG_OBJECT_ID(NEXUS_Tsmf); |
|---|
| 78 | |
|---|
| 79 | #if NEXUS_HAS_TSMF |
|---|
| 80 | struct NEXUS_Tsmf |
|---|
| 81 | { |
|---|
| 82 | BDBG_OBJECT(NEXUS_Tsmf) |
|---|
| 83 | unsigned index; |
|---|
| 84 | NEXUS_TsmfOpenSettings openSettings; |
|---|
| 85 | NEXUS_TsmfSettings settings; |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | void NEXUS_Tsmf_GetDefaultOpenSettings(NEXUS_TsmfOpenSettings *pOpenSettings) |
|---|
| 89 | { |
|---|
| 90 | BKNI_Memset(pOpenSettings, 0, sizeof(*pOpenSettings)); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | NEXUS_TsmfHandle NEXUS_Tsmf_Open(unsigned index, const NEXUS_TsmfOpenSettings* pOpenSettings) |
|---|
| 94 | { |
|---|
| 95 | NEXUS_Error rc; |
|---|
| 96 | NEXUS_TsmfHandle handle; |
|---|
| 97 | |
|---|
| 98 | handle = BKNI_Malloc(sizeof(*handle)); |
|---|
| 99 | if (!handle) { |
|---|
| 100 | rc = BERR_TRACE(NEXUS_OUT_OF_SYSTEM_MEMORY); |
|---|
| 101 | return NULL; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | BKNI_Memset(handle, 0, sizeof(*handle)); |
|---|
| 105 | BDBG_OBJECT_SET(handle, NEXUS_Tsmf); |
|---|
| 106 | |
|---|
| 107 | handle->index = index; |
|---|
| 108 | handle->openSettings = *pOpenSettings; |
|---|
| 109 | |
|---|
| 110 | return handle; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | void NEXUS_Tsmf_Close(NEXUS_TsmfHandle handle) |
|---|
| 114 | { |
|---|
| 115 | BDBG_OBJECT_ASSERT(handle, NEXUS_Tsmf); |
|---|
| 116 | BDBG_OBJECT_DESTROY(handle, NEXUS_Tsmf); |
|---|
| 117 | BKNI_Free(handle); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | void NEXUS_Tsmf_GetSettings(NEXUS_TsmfHandle handle, NEXUS_TsmfSettings *pSettings) |
|---|
| 121 | { |
|---|
| 122 | NEXUS_Error rc; |
|---|
| 123 | unsigned tsmfIndex = handle->index; |
|---|
| 124 | |
|---|
| 125 | BDBG_OBJECT_ASSERT(handle, NEXUS_Tsmf); |
|---|
| 126 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 127 | |
|---|
| 128 | rc = BXPT_TSMF_GetFldVerifyConfig(pTransport->xpt, tsmfIndex, (BXPT_TSMFFldVerifyConfig *)(&(handle->settings.fieldVerifyConfig))); |
|---|
| 129 | if (rc) {rc = BERR_TRACE(rc);} /* keep going */ |
|---|
| 130 | *pSettings = handle->settings; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | NEXUS_Error NEXUS_Tsmf_SetSettings(NEXUS_TsmfHandle handle, const NEXUS_TsmfSettings *pSettings) |
|---|
| 134 | { |
|---|
| 135 | NEXUS_Error rc; |
|---|
| 136 | unsigned tsmfIndex = handle->index; |
|---|
| 137 | |
|---|
| 138 | BDBG_OBJECT_ASSERT(handle, NEXUS_Tsmf); |
|---|
| 139 | BDBG_ASSERT(pSettings); |
|---|
| 140 | |
|---|
| 141 | BDBG_CASSERT(sizeof(NEXUS_TsmfFieldVerifyConfig) == sizeof(BXPT_TSMFFldVerifyConfig)); |
|---|
| 142 | BDBG_CASSERT(NEXUS_TsmfVersionChangeMode_eFrameChangeVer == (NEXUS_TsmfVersionChangeMode)BXPT_TSMFVersionChgMode_eFrameChgVer); |
|---|
| 143 | |
|---|
| 144 | rc = BXPT_TSMF_SetFldVerifyConfig(pTransport->xpt, tsmfIndex, (const BXPT_TSMFFldVerifyConfig *)&(pSettings->fieldVerifyConfig)); |
|---|
| 145 | if (rc) {rc = BERR_TRACE(rc);} /* keep going */ |
|---|
| 146 | |
|---|
| 147 | if ((pSettings->enabled!=handle->settings.enabled) || (pSettings->semiAutomaticMode!=handle->settings.semiAutomaticMode)) { |
|---|
| 148 | NEXUS_TsmfOpenSettings *pOpenSettings = &handle->openSettings; |
|---|
| 149 | |
|---|
| 150 | if (pSettings->enabled) { |
|---|
| 151 | BXPT_TSMF_InputSel inputSelect; |
|---|
| 152 | |
|---|
| 153 | /* convert to XPT enum */ |
|---|
| 154 | if (pOpenSettings->tsmfSource.playpump) { |
|---|
| 155 | inputSelect = BXPT_TSMF_InputSel_ePB0 + pOpenSettings->tsmfSource.playpump->index; |
|---|
| 156 | } |
|---|
| 157 | else if (pOpenSettings->tsmfSource.remux) { |
|---|
| 158 | if (pOpenSettings->tsmfSource.remux->index > 0) { |
|---|
| 159 | return BERR_TRACE(NEXUS_NOT_SUPPORTED); /* if HW supports, must extend enum */ |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | inputSelect = BXPT_TSMF_InputSel_eRMX; |
|---|
| 163 | } |
|---|
| 164 | else { |
|---|
| 165 | NEXUS_ParserBandHandle handle = NULL; |
|---|
| 166 | |
|---|
| 167 | handle = NEXUS_ParserBand_Resolve_priv(pOpenSettings->tsmfSource.parserBand); |
|---|
| 168 | if (handle) |
|---|
| 169 | { |
|---|
| 170 | unsigned parserBand = handle->hwIndex; |
|---|
| 171 | |
|---|
| 172 | const NEXUS_ParserBandSettings *pParserBandSettings = &pTransport->parserBand[parserBand].settings; |
|---|
| 173 | /* look up the input band connected to this parser band */ |
|---|
| 174 | if (pParserBandSettings->sourceType != NEXUS_ParserBandSourceType_eInputBand) { |
|---|
| 175 | BDBG_ERR(("You must connect the parser band to the input band before calling NEXUS_Tsmf_SetSettings")); |
|---|
| 176 | return BERR_TRACE(NEXUS_INVALID_PARAMETER); |
|---|
| 177 | } |
|---|
| 178 | inputSelect = BXPT_TSMF_InputSel_eIB0 + (pParserBandSettings->sourceTypeSettings.inputBand - NEXUS_InputBand_e0); |
|---|
| 179 | |
|---|
| 180 | /* specify which TSMF to enable for this parser */ |
|---|
| 181 | rc = BXPT_TSMF_SetParserConfig(pTransport->xpt, parserBand, tsmfIndex, true); |
|---|
| 182 | if (rc) return BERR_TRACE(rc); |
|---|
| 183 | } |
|---|
| 184 | else { |
|---|
| 185 | return BERR_TRACE(NEXUS_UNKNOWN); |
|---|
| 186 | } |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | /* specify the input source (and other params) to the TSMF */ |
|---|
| 190 | if (pSettings->semiAutomaticMode) { |
|---|
| 191 | rc = BXPT_TSMF_EnableSemiAutoMode(pTransport->xpt, inputSelect, tsmfIndex, pSettings->slotMapLo, pSettings->slotMapHi, pSettings->relativeTsNum); |
|---|
| 192 | if (rc) return BERR_TRACE(rc); |
|---|
| 193 | } |
|---|
| 194 | else { |
|---|
| 195 | rc = BXPT_TSMF_EnableAutoMode(pTransport->xpt, inputSelect, tsmfIndex, pSettings->relativeTsNum); |
|---|
| 196 | if (rc) return BERR_TRACE(rc); |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | else { /* (pSettings->enabled==false) */ |
|---|
| 201 | rc = BXPT_TSMF_DisableTsmf(pTransport->xpt, tsmfIndex); |
|---|
| 202 | if (rc) return BERR_TRACE(rc); |
|---|
| 203 | |
|---|
| 204 | if (!pOpenSettings->tsmfSource.playpump && !pOpenSettings->tsmfSource.remux) { |
|---|
| 205 | NEXUS_ParserBandHandle handle = NULL; |
|---|
| 206 | |
|---|
| 207 | handle = NEXUS_ParserBand_Resolve_priv(pOpenSettings->tsmfSource.parserBand); |
|---|
| 208 | if (handle) |
|---|
| 209 | { |
|---|
| 210 | unsigned parserBand = handle->hwIndex; |
|---|
| 211 | |
|---|
| 212 | rc = BXPT_TSMF_SetParserConfig(pTransport->xpt, parserBand, tsmfIndex, false); |
|---|
| 213 | if (rc) return BERR_TRACE(rc); |
|---|
| 214 | } |
|---|
| 215 | } |
|---|
| 216 | } |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | handle->settings = *pSettings; |
|---|
| 220 | |
|---|
| 221 | return rc; |
|---|
| 222 | } |
|---|
| 223 | #else /* NEXUS_HAS_TSMF */ |
|---|
| 224 | |
|---|
| 225 | void NEXUS_Tsmf_GetDefaultOpenSettings(NEXUS_TsmfOpenSettings *pOpenSettings) |
|---|
| 226 | { |
|---|
| 227 | BSTD_UNUSED(pOpenSettings); |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | NEXUS_TsmfHandle NEXUS_Tsmf_Open(unsigned index, const NEXUS_TsmfOpenSettings* pOpenSettings) |
|---|
| 231 | { |
|---|
| 232 | BSTD_UNUSED(index); |
|---|
| 233 | BSTD_UNUSED(pOpenSettings); |
|---|
| 234 | return NULL; |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | void NEXUS_Tsmf_Close(NEXUS_TsmfHandle handle) |
|---|
| 238 | { |
|---|
| 239 | BSTD_UNUSED(handle); |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | void NEXUS_Tsmf_GetSettings(NEXUS_TsmfHandle handle, NEXUS_TsmfSettings *pSettings) |
|---|
| 243 | { |
|---|
| 244 | BSTD_UNUSED(handle); |
|---|
| 245 | BSTD_UNUSED(pSettings); |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | NEXUS_Error NEXUS_Tsmf_SetSettings(NEXUS_TsmfHandle handle, const NEXUS_TsmfSettings *pSettings) |
|---|
| 249 | { |
|---|
| 250 | BSTD_UNUSED(handle); |
|---|
| 251 | BSTD_UNUSED(pSettings); |
|---|
| 252 | return 0; |
|---|
| 253 | } |
|---|
| 254 | #endif |
|---|