| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2004-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: nexus_frontend_analog.c $ |
|---|
| 39 | * $brcm_Revision: 4 $ |
|---|
| 40 | * $brcm_Date: 1/23/09 3:32p $ |
|---|
| 41 | * |
|---|
| 42 | * API Description: |
|---|
| 43 | * API name: Frontend Analog |
|---|
| 44 | * Generic APIs for Analog tuning. |
|---|
| 45 | * |
|---|
| 46 | * Revision History: |
|---|
| 47 | * |
|---|
| 48 | * $brcm_Log: /nexus/modules/frontend/common/src/nexus_frontend_analog.c $ |
|---|
| 49 | * |
|---|
| 50 | * 4 1/23/09 3:32p jgarrett |
|---|
| 51 | * PR 51457: Adding frontend extension hooks for tuners and |
|---|
| 52 | * frontends/demods |
|---|
| 53 | * |
|---|
| 54 | * 3 8/8/08 6:59p jgarrett |
|---|
| 55 | * PR 45171: Adding AASD hooks |
|---|
| 56 | * |
|---|
| 57 | * 2 3/14/08 1:31p jgarrett |
|---|
| 58 | * PR 40111: Adding Analog AGC Settings |
|---|
| 59 | * |
|---|
| 60 | * 1 1/18/08 2:19p jgarrett |
|---|
| 61 | * PR 38808: Merging to main branch |
|---|
| 62 | * |
|---|
| 63 | * Nexus_Devel/2 12/20/07 2:30p jgarrett |
|---|
| 64 | * PR 38019: Adding GetAnalogAudioConnector |
|---|
| 65 | * |
|---|
| 66 | * Nexus_Devel/1 10/5/07 5:52p jgarrett |
|---|
| 67 | * PR 35551: Adding initial version |
|---|
| 68 | * |
|---|
| 69 | ***************************************************************************/ |
|---|
| 70 | |
|---|
| 71 | #include "nexus_frontend_module.h" |
|---|
| 72 | |
|---|
| 73 | BDBG_MODULE(nexus_frontend_analog); |
|---|
| 74 | |
|---|
| 75 | /*************************************************************************** |
|---|
| 76 | Summary: |
|---|
| 77 | Initialize an analog settings structure to defaults |
|---|
| 78 | See Also: |
|---|
| 79 | NEXUS_Frontend_TuneAnalog |
|---|
| 80 | ***************************************************************************/ |
|---|
| 81 | void NEXUS_Frontend_GetDefaultAnalogSettings( |
|---|
| 82 | NEXUS_FrontendAnalogSettings *pSettings |
|---|
| 83 | ) |
|---|
| 84 | { |
|---|
| 85 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 86 | BKNI_Memset(pSettings, 0, sizeof(*pSettings)); |
|---|
| 87 | NEXUS_Ifd_P_GetDefaultSettings(&pSettings->ifdSettings); |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | /*************************************************************************** |
|---|
| 91 | Summary: |
|---|
| 92 | Tune a frontend to an analog channel |
|---|
| 93 | See Also: |
|---|
| 94 | NEXUS_Frontend_GetAnalogStatus |
|---|
| 95 | ***************************************************************************/ |
|---|
| 96 | NEXUS_Error NEXUS_Frontend_TuneAnalog( |
|---|
| 97 | NEXUS_FrontendHandle handle, |
|---|
| 98 | const NEXUS_FrontendAnalogSettings *pSettings |
|---|
| 99 | ) |
|---|
| 100 | { |
|---|
| 101 | BDBG_ASSERT(NULL != handle); |
|---|
| 102 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 103 | |
|---|
| 104 | if ( NULL == handle->tuneAnalog ) |
|---|
| 105 | { |
|---|
| 106 | if ( handle->pParentFrontend ) |
|---|
| 107 | { |
|---|
| 108 | return NEXUS_Frontend_TuneAnalog(handle->pParentFrontend, pSettings); |
|---|
| 109 | } |
|---|
| 110 | else |
|---|
| 111 | { |
|---|
| 112 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | else |
|---|
| 116 | { |
|---|
| 117 | return handle->tuneAnalog(handle->pDeviceHandle, pSettings); |
|---|
| 118 | } |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | /*************************************************************************** |
|---|
| 122 | Summary: |
|---|
| 123 | Get the analog status of a frontend |
|---|
| 124 | See Also: |
|---|
| 125 | NEXUS_Frontend_TuneAnalog |
|---|
| 126 | ***************************************************************************/ |
|---|
| 127 | NEXUS_Error NEXUS_Frontend_GetAnalogStatus( |
|---|
| 128 | NEXUS_FrontendHandle handle, |
|---|
| 129 | NEXUS_FrontendAnalogStatus *pStatus /* [out] */ |
|---|
| 130 | ) |
|---|
| 131 | { |
|---|
| 132 | BDBG_ASSERT(NULL != handle); |
|---|
| 133 | BDBG_ASSERT(NULL != pStatus); |
|---|
| 134 | |
|---|
| 135 | if ( NULL == handle->getAnalogStatus ) |
|---|
| 136 | { |
|---|
| 137 | if ( handle->pParentFrontend ) |
|---|
| 138 | { |
|---|
| 139 | return NEXUS_Frontend_GetAnalogStatus(handle->pParentFrontend, pStatus); |
|---|
| 140 | } |
|---|
| 141 | else |
|---|
| 142 | { |
|---|
| 143 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 144 | } |
|---|
| 145 | } |
|---|
| 146 | else |
|---|
| 147 | { |
|---|
| 148 | return handle->getAnalogStatus(handle->pDeviceHandle, pStatus); |
|---|
| 149 | } |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | /*************************************************************************** |
|---|
| 153 | Summary: |
|---|
| 154 | Get the analog video connector from a frontend |
|---|
| 155 | Description: |
|---|
| 156 | This function is valid only for internal IF demodulators, and allows |
|---|
| 157 | the decoded video output to be routed directly to the VDEC. |
|---|
| 158 | This routine will return NULL if no direct connection exists between |
|---|
| 159 | the IFD and the audio hardware, in which case an external connection |
|---|
| 160 | such as Ccir656Input will be needed. |
|---|
| 161 | See Also: |
|---|
| 162 | NEXUS_AudioInput_Shutdown |
|---|
| 163 | ***************************************************************************/ |
|---|
| 164 | NEXUS_VideoInput NEXUS_Frontend_GetAnalogVideoConnector( |
|---|
| 165 | NEXUS_FrontendHandle handle |
|---|
| 166 | ) |
|---|
| 167 | { |
|---|
| 168 | BDBG_ASSERT(NULL != handle); |
|---|
| 169 | if ( NULL == handle->getAnalogVideoConnector ) |
|---|
| 170 | { |
|---|
| 171 | if ( handle->pParentFrontend ) |
|---|
| 172 | { |
|---|
| 173 | return NEXUS_Frontend_GetAnalogVideoConnector(handle->pParentFrontend); |
|---|
| 174 | } |
|---|
| 175 | else |
|---|
| 176 | { |
|---|
| 177 | (void)BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 178 | return NULL; |
|---|
| 179 | } |
|---|
| 180 | } |
|---|
| 181 | else |
|---|
| 182 | { |
|---|
| 183 | return handle->getAnalogVideoConnector(handle->pDeviceHandle); |
|---|
| 184 | } |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | /*************************************************************************** |
|---|
| 189 | Summary: |
|---|
| 190 | Get the analog audio connector from a frontend |
|---|
| 191 | Description: |
|---|
| 192 | This function is valid only for internal IF demodulators, and allows |
|---|
| 193 | the decoded audio output to be routed directly to the audio module. |
|---|
| 194 | This routine will return NULL if no direct connection exists between |
|---|
| 195 | the IFD and the audio hardware, in which case an external connection |
|---|
| 196 | such as I2sInput will be needed. |
|---|
| 197 | See Also: |
|---|
| 198 | NEXUS_AudioInput_Shutdown |
|---|
| 199 | ***************************************************************************/ |
|---|
| 200 | NEXUS_AudioInput NEXUS_Frontend_GetAnalogAudioConnector( |
|---|
| 201 | NEXUS_FrontendHandle handle |
|---|
| 202 | ) |
|---|
| 203 | { |
|---|
| 204 | BDBG_ASSERT(NULL != handle); |
|---|
| 205 | if ( NULL == handle->getAnalogAudioConnector ) |
|---|
| 206 | { |
|---|
| 207 | if ( handle->pParentFrontend ) |
|---|
| 208 | { |
|---|
| 209 | return NEXUS_Frontend_GetAnalogAudioConnector(handle->pParentFrontend); |
|---|
| 210 | } |
|---|
| 211 | else |
|---|
| 212 | { |
|---|
| 213 | (void)BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 214 | return NULL; |
|---|
| 215 | } |
|---|
| 216 | } |
|---|
| 217 | else |
|---|
| 218 | { |
|---|
| 219 | return handle->getAnalogAudioConnector(handle->pDeviceHandle); |
|---|
| 220 | } |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | /*************************************************************************** |
|---|
| 224 | Summary: |
|---|
| 225 | Get Analog AGC Settings |
|---|
| 226 | ***************************************************************************/ |
|---|
| 227 | void NEXUS_Frontend_GetAnalogAgcSettings( |
|---|
| 228 | NEXUS_FrontendHandle handle, |
|---|
| 229 | NEXUS_FrontendAnalogAgcSettings *pSettings /* [out] */ |
|---|
| 230 | ) |
|---|
| 231 | { |
|---|
| 232 | BDBG_ASSERT(NULL != handle); |
|---|
| 233 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 234 | if ( handle->getAnalogAgcSettings ) |
|---|
| 235 | { |
|---|
| 236 | handle->getAnalogAgcSettings(handle->pDeviceHandle, pSettings); |
|---|
| 237 | } |
|---|
| 238 | else if ( handle->pParentFrontend ) |
|---|
| 239 | { |
|---|
| 240 | NEXUS_Frontend_GetAnalogAgcSettings(handle->pParentFrontend, pSettings); |
|---|
| 241 | } |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | /*************************************************************************** |
|---|
| 245 | Summary: |
|---|
| 246 | Set Analog AGC Settings |
|---|
| 247 | ***************************************************************************/ |
|---|
| 248 | NEXUS_Error NEXUS_Frontend_SetAnalogAgcSettings( |
|---|
| 249 | NEXUS_FrontendHandle handle, |
|---|
| 250 | const NEXUS_FrontendAnalogAgcSettings *pSettings |
|---|
| 251 | ) |
|---|
| 252 | { |
|---|
| 253 | BDBG_ASSERT(NULL != handle); |
|---|
| 254 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 255 | if ( NULL == handle->setAnalogAgcSettings ) |
|---|
| 256 | { |
|---|
| 257 | if ( handle->pParentFrontend ) |
|---|
| 258 | { |
|---|
| 259 | return NEXUS_Frontend_SetAnalogAgcSettings(handle->pParentFrontend, pSettings); |
|---|
| 260 | } |
|---|
| 261 | else |
|---|
| 262 | { |
|---|
| 263 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 264 | } |
|---|
| 265 | } |
|---|
| 266 | else |
|---|
| 267 | { |
|---|
| 268 | return handle->setAnalogAgcSettings(handle->pDeviceHandle, pSettings); |
|---|
| 269 | } |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | /* Hook for VDEC to inform IFD of current video format */ |
|---|
| 273 | void NEXUS_Frontend_NotifyAnalogVideoFormat_priv( |
|---|
| 274 | NEXUS_FrontendHandle handle, |
|---|
| 275 | NEXUS_VideoFormat format) |
|---|
| 276 | { |
|---|
| 277 | BDBG_ASSERT(NULL != handle); |
|---|
| 278 | NEXUS_ASSERT_MODULE(); |
|---|
| 279 | if ( handle->notifyAnalogVideoFormat ) |
|---|
| 280 | { |
|---|
| 281 | handle->notifyAnalogVideoFormat(handle->pDeviceHandle, format); |
|---|
| 282 | } |
|---|
| 283 | else if ( handle->pParentFrontend ) |
|---|
| 284 | { |
|---|
| 285 | NEXUS_Frontend_NotifyAnalogVideoFormat_priv(handle->pParentFrontend, format); |
|---|
| 286 | } |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | /* Hook for AASD to retrieve current video format */ |
|---|
| 290 | void NEXUS_Frontend_GetAnalogVideoFormat_priv( |
|---|
| 291 | NEXUS_FrontendHandle handle, |
|---|
| 292 | NEXUS_VideoFormat *pFormat) |
|---|
| 293 | { |
|---|
| 294 | BDBG_ASSERT(NULL != handle); |
|---|
| 295 | NEXUS_ASSERT_MODULE(); |
|---|
| 296 | if ( handle->getAnalogVideoFormat ) |
|---|
| 297 | { |
|---|
| 298 | handle->getAnalogVideoFormat(handle->pDeviceHandle, pFormat); |
|---|
| 299 | } |
|---|
| 300 | else if ( handle->pParentFrontend ) |
|---|
| 301 | { |
|---|
| 302 | NEXUS_Frontend_GetAnalogVideoFormat_priv(handle->pParentFrontend, pFormat); |
|---|
| 303 | } |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | /* Hook for AASD to drive format switches */ |
|---|
| 307 | NEXUS_Error NEXUS_Frontend_SetAnalogAVFormat_priv( |
|---|
| 308 | NEXUS_FrontendHandle handle, |
|---|
| 309 | NEXUS_VideoFormat videoFormat, |
|---|
| 310 | NEXUS_IfdAudioMode audioMode, |
|---|
| 311 | bool carriersOnly) |
|---|
| 312 | { |
|---|
| 313 | BDBG_ASSERT(NULL != handle); |
|---|
| 314 | NEXUS_ASSERT_MODULE(); |
|---|
| 315 | |
|---|
| 316 | if ( handle->setAnalogAVFormat ) |
|---|
| 317 | { |
|---|
| 318 | return handle->setAnalogAVFormat(handle->pDeviceHandle, videoFormat, audioMode, carriersOnly); |
|---|
| 319 | } |
|---|
| 320 | else if ( handle->pParentFrontend ) |
|---|
| 321 | { |
|---|
| 322 | NEXUS_Frontend_SetAnalogAVFormat_priv(handle->pParentFrontend, videoFormat, audioMode, carriersOnly); |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | void NEXUS_Frontend_SetAnalogAudioInterrupt_priv( |
|---|
| 329 | NEXUS_FrontendHandle handle, |
|---|
| 330 | NEXUS_FrontendAnalogAudioInterruptFunc interruptFunc_isr, |
|---|
| 331 | void *pFuncParam) |
|---|
| 332 | { |
|---|
| 333 | BDBG_ASSERT(NULL != handle); |
|---|
| 334 | NEXUS_ASSERT_MODULE(); |
|---|
| 335 | |
|---|
| 336 | if ( handle->setAnalogAudioInterrupt ) |
|---|
| 337 | { |
|---|
| 338 | handle->setAnalogAudioInterrupt(handle->pDeviceHandle, interruptFunc_isr, pFuncParam); |
|---|
| 339 | } |
|---|
| 340 | else if ( handle->pParentFrontend ) |
|---|
| 341 | { |
|---|
| 342 | NEXUS_Frontend_SetAnalogAudioInterrupt_priv(handle->pParentFrontend, interruptFunc_isr, pFuncParam); |
|---|
| 343 | } |
|---|
| 344 | } |
|---|
| 345 | |
|---|