| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2004-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_frontend_qam.c $ |
|---|
| 39 | * $brcm_Revision: 10 $ |
|---|
| 40 | * $brcm_Date: 10/12/11 12:04p $ |
|---|
| 41 | * |
|---|
| 42 | * API Description: |
|---|
| 43 | * API name: Frontend QAM |
|---|
| 44 | * Generic APIs for QAM tuning. |
|---|
| 45 | * |
|---|
| 46 | * Revision History: |
|---|
| 47 | * |
|---|
| 48 | * $brcm_Log: /nexus/modules/frontend/common/src/nexus_frontend_qam.c $ |
|---|
| 49 | * |
|---|
| 50 | * 10 10/12/11 12:04p erickson |
|---|
| 51 | * SW3461-50, SW3128-16: add qam scan |
|---|
| 52 | * |
|---|
| 53 | * 9 9/6/11 9:32p vishk |
|---|
| 54 | * SW3461-48: Fix 3461 frontend issues. |
|---|
| 55 | * |
|---|
| 56 | * 8 10/21/10 7:00p vishk |
|---|
| 57 | * SW7420-1020: Request for non-blocking call support in Nexus frontend |
|---|
| 58 | * |
|---|
| 59 | * 7 8/5/10 4:36p VISHK |
|---|
| 60 | * SW7405-4722: Add support for "Frequency offset" and "Null packets" for |
|---|
| 61 | * ADS and expose "auto acquire" in nexus for AOB |
|---|
| 62 | * |
|---|
| 63 | * 6 3/8/10 8:42p VISHK |
|---|
| 64 | * SW7405-3995: Support spectrum mode and spectrum inversion control from |
|---|
| 65 | * nexus. |
|---|
| 66 | * |
|---|
| 67 | * 5 12/31/09 4:36p VISHK |
|---|
| 68 | * SW7550-135: Support 7550 QAM/DVB-C support in Nexus |
|---|
| 69 | * |
|---|
| 70 | * 4 1/23/09 3:32p jgarrett |
|---|
| 71 | * PR 51457: Adding frontend extension hooks for tuners and |
|---|
| 72 | * frontends/demods |
|---|
| 73 | * |
|---|
| 74 | * 3 7/11/08 5:07p jtna |
|---|
| 75 | * PR42924: Add channel change measurements functionality |
|---|
| 76 | * |
|---|
| 77 | * 2 5/1/08 11:19a erickson |
|---|
| 78 | * PR42376: default the QAM symbolRate based on the mode and annex if 0 |
|---|
| 79 | * |
|---|
| 80 | * 1 1/18/08 2:19p jgarrett |
|---|
| 81 | * PR 38808: Merging to main branch |
|---|
| 82 | * |
|---|
| 83 | * Nexus_Devel/2 10/10/07 2:32p jgarrett |
|---|
| 84 | * PR 35551: Making annex b default |
|---|
| 85 | * |
|---|
| 86 | * Nexus_Devel/1 10/5/07 5:52p jgarrett |
|---|
| 87 | * PR 35551: Adding initial version |
|---|
| 88 | * |
|---|
| 89 | * Nexus_Devel/1 10/4/07 2:41p jgarrett |
|---|
| 90 | * PR 35551: Adding initial version |
|---|
| 91 | * |
|---|
| 92 | ***************************************************************************/ |
|---|
| 93 | |
|---|
| 94 | #include "nexus_frontend_module.h" |
|---|
| 95 | |
|---|
| 96 | BDBG_MODULE(nexus_frontend_qam); |
|---|
| 97 | |
|---|
| 98 | BTRC_MODULE_DECLARE(ChnChange_Tune); |
|---|
| 99 | |
|---|
| 100 | /*************************************************************************** |
|---|
| 101 | Summary: |
|---|
| 102 | Initialize a QAM settings structure to defaults |
|---|
| 103 | See Also: |
|---|
| 104 | NEXUS_Frontend_TuneQam |
|---|
| 105 | ***************************************************************************/ |
|---|
| 106 | void NEXUS_Frontend_GetDefaultQamSettings( |
|---|
| 107 | NEXUS_FrontendQamSettings *pSettings |
|---|
| 108 | ) |
|---|
| 109 | { |
|---|
| 110 | BKNI_Memset(pSettings, 0, sizeof(*pSettings)); |
|---|
| 111 | pSettings->mode = NEXUS_FrontendQamMode_e64; |
|---|
| 112 | pSettings->annex = NEXUS_FrontendQamAnnex_eB; |
|---|
| 113 | pSettings->bandwidth = NEXUS_FrontendQamBandwidth_e6Mhz; |
|---|
| 114 | pSettings->spectrumMode = NEXUS_FrontendQamSpectrumMode_eManual; |
|---|
| 115 | pSettings->frequencyOffset = NEXUS_FrontendQamFrequencyOffset_e180Khz; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | /*************************************************************************** |
|---|
| 119 | Summary: |
|---|
| 120 | Tune to a QAM channel |
|---|
| 121 | See Also: |
|---|
| 122 | NEXUS_Frontend_InitQamSettings |
|---|
| 123 | ***************************************************************************/ |
|---|
| 124 | NEXUS_Error NEXUS_Frontend_TuneQam( |
|---|
| 125 | NEXUS_FrontendHandle handle, |
|---|
| 126 | const NEXUS_FrontendQamSettings *pSettings |
|---|
| 127 | ) |
|---|
| 128 | { |
|---|
| 129 | BDBG_ASSERT(NULL != handle); |
|---|
| 130 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 131 | BTRC_TRACE(ChnChange_Tune, START); |
|---|
| 132 | |
|---|
| 133 | if ( NULL == handle->tuneQam ) |
|---|
| 134 | { |
|---|
| 135 | if ( handle->pParentFrontend ) |
|---|
| 136 | { |
|---|
| 137 | return NEXUS_Frontend_TuneQam(handle->pParentFrontend, pSettings); |
|---|
| 138 | } |
|---|
| 139 | else |
|---|
| 140 | { |
|---|
| 141 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 142 | } |
|---|
| 143 | } |
|---|
| 144 | else |
|---|
| 145 | { |
|---|
| 146 | return handle->tuneQam(handle->pDeviceHandle, pSettings); |
|---|
| 147 | } |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | /*************************************************************************** |
|---|
| 151 | Summary: |
|---|
| 152 | Get the status synchronously of a QAM tuner |
|---|
| 153 | See Also: |
|---|
| 154 | NEXUS_Frontend_TuneQam |
|---|
| 155 | ***************************************************************************/ |
|---|
| 156 | NEXUS_Error NEXUS_Frontend_GetQamStatus( |
|---|
| 157 | NEXUS_FrontendHandle handle, |
|---|
| 158 | NEXUS_FrontendQamStatus *pStatus /* [out] */ |
|---|
| 159 | ) |
|---|
| 160 | { |
|---|
| 161 | BDBG_ASSERT(NULL != handle); |
|---|
| 162 | BDBG_ASSERT(NULL != pStatus); |
|---|
| 163 | |
|---|
| 164 | if ( NULL == handle->getQamStatus ) |
|---|
| 165 | { |
|---|
| 166 | if ( handle->pParentFrontend ) |
|---|
| 167 | { |
|---|
| 168 | return NEXUS_Frontend_GetQamStatus(handle->pParentFrontend, pStatus); |
|---|
| 169 | } |
|---|
| 170 | else |
|---|
| 171 | { |
|---|
| 172 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 173 | } |
|---|
| 174 | } |
|---|
| 175 | else |
|---|
| 176 | { |
|---|
| 177 | return handle->getQamStatus(handle->pDeviceHandle, pStatus); |
|---|
| 178 | } |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | /*************************************************************************** |
|---|
| 182 | Summary: |
|---|
| 183 | Get the status asynchronously of a QAM tuner |
|---|
| 184 | See Also: |
|---|
| 185 | NEXUS_Frontend_TuneQam |
|---|
| 186 | NEXUS_Frontend_RequestQamStatus |
|---|
| 187 | ***************************************************************************/ |
|---|
| 188 | NEXUS_Error NEXUS_Frontend_GetQamAsyncStatus( |
|---|
| 189 | NEXUS_FrontendHandle handle, |
|---|
| 190 | NEXUS_FrontendQamStatus *pStatus /* [out] */ |
|---|
| 191 | ) |
|---|
| 192 | { |
|---|
| 193 | BDBG_ASSERT(NULL != handle); |
|---|
| 194 | BDBG_ASSERT(NULL != pStatus); |
|---|
| 195 | |
|---|
| 196 | if ( NULL == handle->getQamAsyncStatus ) |
|---|
| 197 | { |
|---|
| 198 | if ( handle->pParentFrontend ) |
|---|
| 199 | { |
|---|
| 200 | return NEXUS_Frontend_GetQamAsyncStatus(handle->pParentFrontend, pStatus); |
|---|
| 201 | } |
|---|
| 202 | else |
|---|
| 203 | { |
|---|
| 204 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 205 | } |
|---|
| 206 | } |
|---|
| 207 | else |
|---|
| 208 | { |
|---|
| 209 | return handle->getQamAsyncStatus(handle->pDeviceHandle, pStatus); |
|---|
| 210 | } |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | /*************************************************************************** |
|---|
| 214 | Summary: |
|---|
| 215 | Request the status asynchronously of a QAM tuner |
|---|
| 216 | See Also: |
|---|
| 217 | NEXUS_Frontend_GetQamAsyncStatus |
|---|
| 218 | ***************************************************************************/ |
|---|
| 219 | NEXUS_Error NEXUS_Frontend_RequestQamAsyncStatus( |
|---|
| 220 | NEXUS_FrontendHandle handle |
|---|
| 221 | ) |
|---|
| 222 | { |
|---|
| 223 | BDBG_ASSERT(NULL != handle); |
|---|
| 224 | |
|---|
| 225 | if ( NULL == handle->requestQamAsyncStatus ) |
|---|
| 226 | { |
|---|
| 227 | if ( handle->pParentFrontend ) |
|---|
| 228 | { |
|---|
| 229 | return NEXUS_Frontend_RequestQamAsyncStatus(handle->pParentFrontend); |
|---|
| 230 | } |
|---|
| 231 | else |
|---|
| 232 | { |
|---|
| 233 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 234 | } |
|---|
| 235 | } |
|---|
| 236 | else |
|---|
| 237 | { |
|---|
| 238 | return handle->requestQamAsyncStatus(handle->pDeviceHandle); |
|---|
| 239 | } |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | /*************************************************************************** |
|---|
| 243 | Summary: |
|---|
| 244 | Request the status asynchronously of a QAM tuner |
|---|
| 245 | See Also: |
|---|
| 246 | NEXUS_Frontend_GetQamAsyncStatus |
|---|
| 247 | ***************************************************************************/ |
|---|
| 248 | NEXUS_Error NEXUS_Frontend_GetQamScanStatus( |
|---|
| 249 | NEXUS_FrontendHandle handle, |
|---|
| 250 | NEXUS_FrontendQamScanStatus *pScanStatus /* [out] */ |
|---|
| 251 | ) |
|---|
| 252 | { |
|---|
| 253 | BDBG_ASSERT(NULL != handle); |
|---|
| 254 | |
|---|
| 255 | if ( NULL == handle->getQamScanStatus ) |
|---|
| 256 | { |
|---|
| 257 | if ( handle->pParentFrontend ) |
|---|
| 258 | { |
|---|
| 259 | return NEXUS_Frontend_GetQamScanStatus(handle->pParentFrontend, pScanStatus); |
|---|
| 260 | } |
|---|
| 261 | else |
|---|
| 262 | { |
|---|
| 263 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 264 | } |
|---|
| 265 | } |
|---|
| 266 | else |
|---|
| 267 | { |
|---|
| 268 | return handle->getQamScanStatus(handle->pDeviceHandle, pScanStatus); |
|---|
| 269 | } |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | unsigned NEXUS_Frontend_P_GetDefaultQamSymbolRate(NEXUS_FrontendQamMode mode, NEXUS_FrontendQamAnnex annex) |
|---|
| 273 | { |
|---|
| 274 | if (annex == NEXUS_FrontendQamAnnex_eA) { |
|---|
| 275 | switch (mode) { |
|---|
| 276 | case NEXUS_FrontendQamMode_e64: |
|---|
| 277 | case NEXUS_FrontendQamMode_e256: |
|---|
| 278 | return 6952000; |
|---|
| 279 | case NEXUS_FrontendQamMode_e16: |
|---|
| 280 | case NEXUS_FrontendQamMode_e32: |
|---|
| 281 | case NEXUS_FrontendQamMode_e128: |
|---|
| 282 | default: |
|---|
| 283 | return 6952000; /* TODO */ |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | } |
|---|
| 287 | else { |
|---|
| 288 | switch (mode) { |
|---|
| 289 | case NEXUS_FrontendQamMode_e64: |
|---|
| 290 | return 5056941; |
|---|
| 291 | case NEXUS_FrontendQamMode_e256: |
|---|
| 292 | return 5360537; |
|---|
| 293 | case NEXUS_FrontendQamMode_e16: |
|---|
| 294 | case NEXUS_FrontendQamMode_e32: |
|---|
| 295 | case NEXUS_FrontendQamMode_e128: |
|---|
| 296 | default: |
|---|
| 297 | return 5056941; /* TODO */ |
|---|
| 298 | } |
|---|
| 299 | } |
|---|
| 300 | } |
|---|