| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2006-2012, 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: bape_mai_input.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/28 $ |
|---|
| 12 | * $brcm_Date: 3/22/12 2:59p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: MAI Audio Input Interface (used for HDMI) |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/ape/7422/bape_mai_input.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/28 3/22/12 2:59p gskerl |
|---|
| 21 | * SW7429-18: Moved preamble C parsing logic into |
|---|
| 22 | * BAPE_InputPort_P_BurstPreambleToCodec(). |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/27 3/16/12 6:15p gskerl |
|---|
| 25 | * SW7429-18: Corrected and enhanced codec detection based on preamble C |
|---|
| 26 | * burst info fields.. |
|---|
| 27 | * |
|---|
| 28 | * Hydra_Software_Devel/26 3/12/12 12:13p gskerl |
|---|
| 29 | * SW7429-18: Lots of cleanup, reorganization, and refactoring. |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/25 2/23/12 4:38p gskerl |
|---|
| 32 | * SW7429-18: Added some critical sections. Created |
|---|
| 33 | * BAPE_HdmiRx_P_SetReceiverOutputFormat_isr() to separate out receiver |
|---|
| 34 | * output format setting logic. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/24 2/9/12 11:21a jgarrett |
|---|
| 37 | * SW7425-2074: Enabling input halt and revising MAI shutown for |
|---|
| 38 | * multichannel PCM |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/23 1/17/12 3:07p gskerl |
|---|
| 41 | * SW7429-18: Removed references to obsolete fields in the |
|---|
| 42 | * BAPE_MaiInputFormatDetectionStatus struct. |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/22 1/16/12 2:50p gskerl |
|---|
| 45 | * SW7429-18: Merged changes from branch SW7429-18_20111212 to |
|---|
| 46 | * main/Hydra_Software_Devel/. |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/SW7429-18_20111212/5 1/13/12 5:48p gskerl |
|---|
| 49 | * SW7429-18: Added MAI/HDMI audio input support for 7429. |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/SW7429-18_20111212/4 1/10/12 10:52a gskerl |
|---|
| 52 | * SW7429-18: Merged from main to branch SW7429-18_20111212. |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/21 1/9/12 6:40p gskerl |
|---|
| 55 | * SW7429-18: Merged refactored code from branch SW7429-18_20111212 to |
|---|
| 56 | * main. |
|---|
| 57 | * |
|---|
| 58 | * Hydra_Software_Devel/SW7429-18_20111212/3 1/9/12 6:07p gskerl |
|---|
| 59 | * SW7429-18: Added hbr flag to BAPE_MaiInputFormatDetectionStatus struct. |
|---|
| 60 | * Fixed 7429 compile issues. Generalized calculation of numChannelPairs. |
|---|
| 61 | * |
|---|
| 62 | * Hydra_Software_Devel/SW7429-18_20111212/2 1/6/12 5:38p gskerl |
|---|
| 63 | * SW7429-18: Corrected misspelling: BAPE_NUM_ELEMS -> BAPE_P_NUM_ELEMS |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/SW7429-18_20111212/1 1/6/12 5:16p gskerl |
|---|
| 66 | * SW7429-18: Major refactoring to eliminate dependence on |
|---|
| 67 | * bape_input_port_priv.c |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/20 1/6/12 2:38p jgarrett |
|---|
| 70 | * SW7435-24: Merge to main branch |
|---|
| 71 | * |
|---|
| 72 | * Hydra_Software_Devel/SW7435-24/3 12/15/11 4:33p mward |
|---|
| 73 | * SW7435-24: Merge from main. |
|---|
| 74 | * |
|---|
| 75 | * Hydra_Software_Devel/SW7435-24/2 11/30/11 11:54a mward |
|---|
| 76 | * SW7435-24: Merge from main. |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/SW7435-24/1 11/3/11 4:34p mward |
|---|
| 79 | * SW7435-24: Add 7435. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/19 11/30/11 4:26p jgarrett |
|---|
| 82 | * SW7429-18: Adding stubs for SPDIF/MAI inputs on 7429 |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/18 11/14/11 3:38p gskerl |
|---|
| 85 | * SW7429-18: Merging 7429 changes back to main branch. |
|---|
| 86 | * |
|---|
| 87 | * Hydra_Software_Devel/SW7429-18/2 11/4/11 5:36p gskerl |
|---|
| 88 | * SW7429-18: Added conditional includes for bchp_int_id_aio_inth.h to fix |
|---|
| 89 | * compile errors on 7425 |
|---|
| 90 | * |
|---|
| 91 | * Hydra_Software_Devel/SW7429-18/1 10/26/11 12:44p jgarrett |
|---|
| 92 | * SW7429-18: Merging latest changes from main branch |
|---|
| 93 | * |
|---|
| 94 | * Hydra_Software_Devel/17 10/26/11 5:59p gskerl |
|---|
| 95 | * SW7231-129: Added stub version of BAPE_MaiInput_P_PrepareForStandby(). |
|---|
| 96 | * |
|---|
| 97 | * Hydra_Software_Devel/16 10/26/11 5:32p gskerl |
|---|
| 98 | * SW7231-129: Added BAPE_MaiInput_P_PrepareForStandby() to disable |
|---|
| 99 | * interrupts before entering standby. |
|---|
| 100 | * |
|---|
| 101 | * Hydra_Software_Devel/15 10/25/11 5:33p gskerl |
|---|
| 102 | * SW7231-129: Added code to invalidate the saved SPDIF receiver state |
|---|
| 103 | * before reinitializing the SPDIF receiver hardware. |
|---|
| 104 | * |
|---|
| 105 | * Hydra_Software_Devel/14 10/25/11 1:23p gskerl |
|---|
| 106 | * SW7231-129: Added stub version of BAPE_MaiInput_P_ResumeFromStandby() |
|---|
| 107 | * |
|---|
| 108 | * Hydra_Software_Devel/13 10/24/11 2:38p gskerl |
|---|
| 109 | * SW7231-129: Added support for recovering hardware state after power |
|---|
| 110 | * standby/resume. |
|---|
| 111 | * |
|---|
| 112 | * Hydra_Software_Devel/12 8/24/11 1:44p jgarrett |
|---|
| 113 | * SWDTV-8271: Reversing SPDIF/HDMI input ISRs on 352xx |
|---|
| 114 | * |
|---|
| 115 | * Hydra_Software_Devel/11 8/16/11 4:11p jgarrett |
|---|
| 116 | * SWDTV-8271: Correcting IOP Capture ID for DTV |
|---|
| 117 | * |
|---|
| 118 | * Hydra_Software_Devel/10 5/12/11 12:07p gskerl |
|---|
| 119 | * SW7422-354: Fixed to support APE compilation on 35230 |
|---|
| 120 | * |
|---|
| 121 | * Hydra_Software_Devel/9 5/2/11 5:28p gskerl |
|---|
| 122 | * SW7422-354: Removed explicit setting of handle->connector.type because |
|---|
| 123 | * it was already set by the BAPE_P_InitInputPort macro |
|---|
| 124 | * |
|---|
| 125 | * Hydra_Software_Devel/8 4/16/11 12:15p jgarrett |
|---|
| 126 | * SW7425-371: Removing tab characters |
|---|
| 127 | * |
|---|
| 128 | * Hydra_Software_Devel/7 3/27/11 12:32p piyushg |
|---|
| 129 | * SW7422-364: Rearrange Callback enable/disable calls and other |
|---|
| 130 | * bug fixes for HDMI input. |
|---|
| 131 | * |
|---|
| 132 | * Hydra_Software_Devel/6 3/24/11 12:11p piyushg |
|---|
| 133 | * SW7422-364: HDMI input support - fixing some initial bugs and |
|---|
| 134 | * compilation errors. |
|---|
| 135 | * |
|---|
| 136 | * Hydra_Software_Devel/5 3/24/11 10:28a jgarrett |
|---|
| 137 | * SW7422-364: Fixing compilation errors on systems without HDMI or SPDIF |
|---|
| 138 | * input |
|---|
| 139 | * |
|---|
| 140 | * Hydra_Software_Devel/4 3/23/11 11:07a piyushg |
|---|
| 141 | * SW7422-364: Initial checking for HDMI input support. |
|---|
| 142 | * |
|---|
| 143 | * Hydra_Software_Devel/3 2/22/11 5:43p jgarrett |
|---|
| 144 | * SW7422-146: Implemented type renaming based on filter graph review |
|---|
| 145 | * comments |
|---|
| 146 | * |
|---|
| 147 | * Hydra_Software_Devel/2 1/18/11 11:04a jgarrett |
|---|
| 148 | * SW7422-146: Adding handle to input open routines |
|---|
| 149 | * |
|---|
| 150 | * Hydra_Software_Devel/1 1/12/11 4:24p jgarrett |
|---|
| 151 | * SW7422-146: Adding additional APIs |
|---|
| 152 | * |
|---|
| 153 | ***************************************************************************/ |
|---|
| 154 | |
|---|
| 155 | #include "bape.h" |
|---|
| 156 | #include "bape_priv.h" |
|---|
| 157 | |
|---|
| 158 | #ifdef BCHP_AIO_INTH_REG_START |
|---|
| 159 | #include "bchp_int_id_aio_inth.h" |
|---|
| 160 | #endif |
|---|
| 161 | |
|---|
| 162 | #ifdef BCHP_AUD_INTH_REG_START |
|---|
| 163 | #include "bchp_int_id_aud_inth.h" |
|---|
| 164 | #endif |
|---|
| 165 | |
|---|
| 166 | BDBG_MODULE(bape_mai_input); |
|---|
| 167 | |
|---|
| 168 | BDBG_OBJECT_ID(BAPE_MaiInput); |
|---|
| 169 | |
|---|
| 170 | #if BAPE_CHIP_MAX_MAI_INPUTS > 0 |
|---|
| 171 | |
|---|
| 172 | typedef struct BAPE_MaiInput |
|---|
| 173 | { |
|---|
| 174 | BDBG_OBJECT(BAPE_MaiInput) |
|---|
| 175 | BAPE_Handle deviceHandle; |
|---|
| 176 | BAPE_MaiInputSettings settings; |
|---|
| 177 | unsigned index; |
|---|
| 178 | BAPE_InputPortObject inputPort; |
|---|
| 179 | uint32_t offset; |
|---|
| 180 | BAPE_MaiInputFormatDetectionSettings clientFormatDetectionSettings; |
|---|
| 181 | bool localFormatDetectionEnabled; |
|---|
| 182 | bool formatDetectionEnabled; |
|---|
| 183 | uint32_t outFormatEna; /* last value written to OUT_FORMAT_ENA field. */ |
|---|
| 184 | bool enable; |
|---|
| 185 | char name[12]; /* MAI IN %d */ |
|---|
| 186 | |
|---|
| 187 | BINT_CallbackHandle maiRxCallback; |
|---|
| 188 | |
|---|
| 189 | BAPE_MaiInputFormatDetectionStatus lastFormatDetectionStatus; |
|---|
| 190 | } BAPE_MaiInput; |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | #if BCHP_CHIP == 7425 || BCHP_CHIP == 7422 || BCHP_CHIP == 7435 |
|---|
| 194 | #define BAPE_MAI_INPUT_CAPTURE_ID(chPair) (5+(chPair)) |
|---|
| 195 | #elif BCHP_CHIP == 35230 || BCHP_CHIP == 35233 || BCHP_CHIP == 35125 || BCHP_CHIP == 35126 |
|---|
| 196 | #define BAPE_MAI_INPUT_CAPTURE_ID(chPair) (6+(chPair)) |
|---|
| 197 | #elif defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 198 | /* 7429-style chips do not need this hardcoded */ |
|---|
| 199 | #else |
|---|
| 200 | #error MAI Input Capture ID not defined |
|---|
| 201 | #endif |
|---|
| 202 | |
|---|
| 203 | /* Build some abstract register names and map them to the chip's real names. */ |
|---|
| 204 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 205 | #define BAPE_P_HDMI_RX_MAI_FORMAT_REGADDR BCHP_AUD_FMM_IOP_IN_HDMI_0_MAI_FORMAT |
|---|
| 206 | #define BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME AUD_FMM_IOP_IN_HDMI_0_MAI_FORMAT |
|---|
| 207 | #define BAPE_P_HDMI_RX_STATUS_REGADDR BCHP_AUD_FMM_IOP_IN_HDMI_0_STATUS |
|---|
| 208 | #define BAPE_P_HDMI_RX_STATUS_REGNAME AUD_FMM_IOP_IN_HDMI_0_STATUS |
|---|
| 209 | #define BAPE_P_HDMI_RX_CONFIG_REGADDR BCHP_AUD_FMM_IOP_IN_HDMI_0_CONFIG |
|---|
| 210 | #define BAPE_P_HDMI_RX_CONFIG_REGNAME AUD_FMM_IOP_IN_HDMI_0_CONFIG |
|---|
| 211 | #endif |
|---|
| 212 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 213 | #define BAPE_P_HDMI_RX_MAI_FORMAT_REGADDR BCHP_HDMI_RCVR_CTRL_MAI_FORMAT /* Use HDMI register */ |
|---|
| 214 | #define BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME SPDIF_RCVR_CTRL_MAI_FORMAT /* but use SPDIF field and enum definitions */ |
|---|
| 215 | #define BAPE_P_HDMI_RX_STATUS_REGADDR BCHP_HDMI_RCVR_CTRL_STATUS |
|---|
| 216 | #define BAPE_P_HDMI_RX_STATUS_REGNAME SPDIF_RCVR_CTRL_STATUS |
|---|
| 217 | #define BAPE_P_HDMI_RX_CONFIG_REGADDR BCHP_HDMI_RCVR_CTRL_CONFIG |
|---|
| 218 | #define BAPE_P_HDMI_RX_CONFIG_REGNAME SPDIF_RCVR_CTRL_CONFIG |
|---|
| 219 | #endif |
|---|
| 220 | |
|---|
| 221 | /* Static function prototypes */ |
|---|
| 222 | static BERR_Code BAPE_MaiInput_P_OpenHw(BAPE_MaiInputHandle hMaiInput); |
|---|
| 223 | static BERR_Code BAPE_MaiInput_P_ApplySettings(BAPE_MaiInputHandle hMaiInput); |
|---|
| 224 | static void BAPE_MaiInput_P_DetectInputChange_isr (BAPE_MaiInputHandle hMaiInput); |
|---|
| 225 | static BERR_Code BAPE_MaiInput_P_GetFormatDetectionStatus_isr(BAPE_MaiInputHandle hMaiInput, BAPE_MaiInputFormatDetectionStatus *pStatus ); |
|---|
| 226 | static void BAPE_P_MAI_RX_isr (void * pParm1, int iParm2); |
|---|
| 227 | static void BAPE_MaiInput_P_SetReceiverOutputFormat_isr (BAPE_MaiInputHandle hMaiInput, BAPE_MaiInputFormatDetectionStatus *pFormatDetectionStatus); |
|---|
| 228 | static BERR_Code BAPE_MaiInput_P_SetFormatDetection(BAPE_MaiInputHandle hMaiInput); |
|---|
| 229 | static void BAPE_MaiInput_P_UpdateInputPortFormatFields_isr (BAPE_MaiInputHandle hMaiInput, BAPE_MaiInputFormatDetectionStatus *pFormatDetectionStatus); |
|---|
| 230 | |
|---|
| 231 | /* Input port callbacks */ |
|---|
| 232 | static void BAPE_MaiInput_P_Enable(BAPE_InputPort inputPort); |
|---|
| 233 | static void BAPE_MaiInput_P_Disable(BAPE_InputPort inputPort); |
|---|
| 234 | static void BAPE_MaiInput_P_Halt_isr(BAPE_InputPort inputPort); |
|---|
| 235 | static BERR_Code BAPE_MaiInput_P_ConsumerAttached(BAPE_InputPort inputPort, BAPE_PathNode *pConsumer); |
|---|
| 236 | static void BAPE_MaiInput_P_ConsumerDetached(BAPE_InputPort inputPort, BAPE_PathNode *pConsumer); |
|---|
| 237 | |
|---|
| 238 | /*************************************************************************** |
|---|
| 239 | Public APIs: From bape_input.h |
|---|
| 240 | ***************************************************************************/ |
|---|
| 241 | void BAPE_MaiInput_GetDefaultSettings( |
|---|
| 242 | BAPE_MaiInputSettings *pSettings /* [out] */ |
|---|
| 243 | ) |
|---|
| 244 | { |
|---|
| 245 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 246 | BKNI_Memset(pSettings, 0, sizeof(*pSettings)); |
|---|
| 247 | |
|---|
| 248 | pSettings->errorInsertion = BAPE_SpdifInputErrorInsertion_eNone; |
|---|
| 249 | pSettings->ignoreCompressedParity = true; |
|---|
| 250 | pSettings->ignorePcmParity = true; |
|---|
| 251 | pSettings->ignoreValidity = true; |
|---|
| 252 | pSettings->timebase = BAVC_Timebase_e0; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | /**************************************************************************/ |
|---|
| 256 | |
|---|
| 257 | BERR_Code BAPE_MaiInput_Open( |
|---|
| 258 | BAPE_Handle hApe, |
|---|
| 259 | unsigned index, |
|---|
| 260 | const BAPE_MaiInputSettings *pSettings, |
|---|
| 261 | BAPE_MaiInputHandle *phMaiInput |
|---|
| 262 | ) |
|---|
| 263 | { |
|---|
| 264 | BERR_Code errCode; |
|---|
| 265 | BAPE_MaiInputHandle hMaiInput; |
|---|
| 266 | BAPE_MaiInputSettings defaultSettings; |
|---|
| 267 | |
|---|
| 268 | BDBG_OBJECT_ASSERT(hApe, BAPE_Device); |
|---|
| 269 | BDBG_ASSERT(NULL != phMaiInput); |
|---|
| 270 | |
|---|
| 271 | BDBG_MSG(("%s: Opening MAI Input: %u", __FUNCTION__, index)); |
|---|
| 272 | |
|---|
| 273 | *phMaiInput = NULL; |
|---|
| 274 | |
|---|
| 275 | if ( index >= BAPE_CHIP_MAX_MAI_INPUTS ) |
|---|
| 276 | { |
|---|
| 277 | BDBG_ERR(("Request to open MAI %d but chip only has %u MAI inputs", index, BAPE_CHIP_MAX_MAI_INPUTS )); |
|---|
| 278 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | if ( hApe->maiInputs[index] ) |
|---|
| 282 | { |
|---|
| 283 | BDBG_ERR(("MAI input %d already open", index)); |
|---|
| 284 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | /* Allocate the device structure, then fill in all the fields. */ |
|---|
| 288 | hMaiInput = BKNI_Malloc(sizeof(BAPE_MaiInput)); |
|---|
| 289 | if ( NULL == hMaiInput ) |
|---|
| 290 | { |
|---|
| 291 | return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | BKNI_Memset(hMaiInput, 0, sizeof(BAPE_MaiInput)); |
|---|
| 295 | BDBG_OBJECT_SET(hMaiInput, BAPE_MaiInput); |
|---|
| 296 | BAPE_P_InitInputPort(&hMaiInput->inputPort, BAPE_InputPortType_eMai, index, hMaiInput); |
|---|
| 297 | hMaiInput->maiRxCallback = NULL; |
|---|
| 298 | hMaiInput->deviceHandle = hApe; |
|---|
| 299 | hMaiInput->index = index; |
|---|
| 300 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 301 | { |
|---|
| 302 | uint32_t regVal = BAPE_Reg_P_Read(hApe, BCHP_AUD_FMM_IOP_IN_HDMI_0_CAPTURE_FCI_ID_TABLE); |
|---|
| 303 | regVal = BCHP_GET_FIELD_DATA(regVal, AUD_FMM_IOP_IN_HDMI_0_CAPTURE_FCI_ID_TABLE, START_FCI_ID); |
|---|
| 304 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eLeftRight] = regVal; |
|---|
| 305 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eLeftRightSurround] = regVal+1; |
|---|
| 306 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eCenterLfe] = regVal+2; |
|---|
| 307 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eLeftRightRear] = regVal+3; |
|---|
| 308 | } |
|---|
| 309 | #endif |
|---|
| 310 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 311 | |
|---|
| 312 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eLeftRight] = BAPE_MAI_INPUT_CAPTURE_ID(BAPE_ChannelPair_eLeftRight); |
|---|
| 313 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eLeftRightSurround] = BAPE_MAI_INPUT_CAPTURE_ID(BAPE_ChannelPair_eLeftRightSurround); |
|---|
| 314 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eCenterLfe] = BAPE_MAI_INPUT_CAPTURE_ID(BAPE_ChannelPair_eCenterLfe); |
|---|
| 315 | hMaiInput->inputPort.streamId[BAPE_ChannelPair_eLeftRightRear] = BAPE_MAI_INPUT_CAPTURE_ID(BAPE_ChannelPair_eLeftRightRear); |
|---|
| 316 | #endif |
|---|
| 317 | hMaiInput->inputPort.enable = BAPE_MaiInput_P_Enable; |
|---|
| 318 | hMaiInput->inputPort.disable = BAPE_MaiInput_P_Disable; |
|---|
| 319 | hMaiInput->inputPort.consumerAttached = BAPE_MaiInput_P_ConsumerAttached; |
|---|
| 320 | hMaiInput->inputPort.consumerDetached = BAPE_MaiInput_P_ConsumerDetached; |
|---|
| 321 | hMaiInput->inputPort.numChannelPairs = 1; |
|---|
| 322 | hMaiInput->inputPort.sampleRate = 48000; |
|---|
| 323 | BKNI_Snprintf(hMaiInput->name, sizeof(hMaiInput->name), "MAI IN %u", index); |
|---|
| 324 | hMaiInput->inputPort.pName = hMaiInput->name; |
|---|
| 325 | |
|---|
| 326 | /* Currently we only support one MAI input, this can be expanded later if we support more */ |
|---|
| 327 | #if BAPE_CHIP_MAX_MAI_INPUTS > 1 |
|---|
| 328 | #error "Need to support more MAI inputs" |
|---|
| 329 | #endif |
|---|
| 330 | hMaiInput->offset = 0; |
|---|
| 331 | |
|---|
| 332 | BDBG_ASSERT(hMaiInput->offset == 0); |
|---|
| 333 | |
|---|
| 334 | /* Init to specified settings */ |
|---|
| 335 | if ( NULL == pSettings ) |
|---|
| 336 | { |
|---|
| 337 | BAPE_MaiInput_GetDefaultSettings(&defaultSettings); |
|---|
| 338 | pSettings = &defaultSettings; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | errCode = BAPE_MaiInput_P_OpenHw(hMaiInput); |
|---|
| 342 | if ( errCode ) |
|---|
| 343 | { |
|---|
| 344 | BAPE_MaiInput_Close(hMaiInput); |
|---|
| 345 | return BERR_TRACE(errCode); |
|---|
| 346 | } |
|---|
| 347 | |
|---|
| 348 | errCode = BAPE_MaiInput_SetSettings(hMaiInput, pSettings); |
|---|
| 349 | if ( errCode ) |
|---|
| 350 | { |
|---|
| 351 | BAPE_MaiInput_Close(hMaiInput); |
|---|
| 352 | return BERR_TRACE(errCode); |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | *phMaiInput = hMaiInput; |
|---|
| 356 | hMaiInput->deviceHandle->maiInputs[index] = hMaiInput; |
|---|
| 357 | return BERR_SUCCESS; |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | /**************************************************************************/ |
|---|
| 361 | |
|---|
| 362 | void BAPE_MaiInput_Close( |
|---|
| 363 | BAPE_MaiInputHandle hMaiInput |
|---|
| 364 | ) |
|---|
| 365 | { |
|---|
| 366 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 367 | |
|---|
| 368 | /* Make sure we're not still connected to anything */ |
|---|
| 369 | if ( hMaiInput->inputPort.pConsumer ) |
|---|
| 370 | { |
|---|
| 371 | BDBG_ERR(("Cannot close MAI input %p (%d), still connected to %s", hMaiInput, hMaiInput->index, hMaiInput->inputPort.pConsumer->pName)); |
|---|
| 372 | BDBG_ASSERT(NULL == hMaiInput->inputPort.pConsumer); |
|---|
| 373 | return; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | if ( hMaiInput->maiRxCallback ) { |
|---|
| 377 | BINT_DestroyCallback(hMaiInput->maiRxCallback); |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | hMaiInput->deviceHandle->maiInputs[hMaiInput->index] = NULL; |
|---|
| 381 | BDBG_OBJECT_DESTROY(hMaiInput, BAPE_MaiInput); |
|---|
| 382 | BKNI_Free(hMaiInput); |
|---|
| 383 | } |
|---|
| 384 | |
|---|
| 385 | /**************************************************************************/ |
|---|
| 386 | |
|---|
| 387 | void BAPE_MaiInput_GetSettings( |
|---|
| 388 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 389 | BAPE_MaiInputSettings *pSettings /* [out] */ |
|---|
| 390 | ) |
|---|
| 391 | { |
|---|
| 392 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 393 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 394 | *pSettings = hMaiInput->settings; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | /**************************************************************************/ |
|---|
| 398 | |
|---|
| 399 | BERR_Code BAPE_MaiInput_SetSettings( |
|---|
| 400 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 401 | const BAPE_MaiInputSettings *pSettings |
|---|
| 402 | ) |
|---|
| 403 | { |
|---|
| 404 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 405 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 406 | hMaiInput->settings = *pSettings; |
|---|
| 407 | |
|---|
| 408 | return BAPE_MaiInput_P_ApplySettings(hMaiInput); |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | /**************************************************************************/ |
|---|
| 412 | |
|---|
| 413 | void BAPE_MaiInput_GetInputPort( |
|---|
| 414 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 415 | BAPE_InputPort *pPort |
|---|
| 416 | ) |
|---|
| 417 | { |
|---|
| 418 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 419 | BDBG_ASSERT(NULL != pPort); |
|---|
| 420 | *pPort = &hMaiInput->inputPort; |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | /**************************************************************************/ |
|---|
| 424 | |
|---|
| 425 | void BAPE_MaiInput_GetFormatDetectionSettings( |
|---|
| 426 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 427 | BAPE_MaiInputFormatDetectionSettings *pSettings /* [out] */ |
|---|
| 428 | ) |
|---|
| 429 | { |
|---|
| 430 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 431 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 432 | |
|---|
| 433 | { /* Start Critical Section */ |
|---|
| 434 | BKNI_EnterCriticalSection(); |
|---|
| 435 | *pSettings = hMaiInput->clientFormatDetectionSettings; |
|---|
| 436 | BKNI_LeaveCriticalSection(); |
|---|
| 437 | } /* End Critical Section */ |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | /**************************************************************************/ |
|---|
| 441 | |
|---|
| 442 | BERR_Code BAPE_MaiInput_SetFormatDetectionSettings( |
|---|
| 443 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 444 | const BAPE_MaiInputFormatDetectionSettings *pSettings |
|---|
| 445 | ) |
|---|
| 446 | { |
|---|
| 447 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 448 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 449 | |
|---|
| 450 | { /* Start Critical Section */ |
|---|
| 451 | BKNI_EnterCriticalSection(); |
|---|
| 452 | hMaiInput->clientFormatDetectionSettings = *pSettings; |
|---|
| 453 | BKNI_LeaveCriticalSection(); |
|---|
| 454 | } /* End Critical Section */ |
|---|
| 455 | |
|---|
| 456 | BAPE_MaiInput_P_SetFormatDetection(hMaiInput); |
|---|
| 457 | |
|---|
| 458 | return BERR_SUCCESS; |
|---|
| 459 | } |
|---|
| 460 | |
|---|
| 461 | /**************************************************************************/ |
|---|
| 462 | |
|---|
| 463 | BERR_Code BAPE_MaiInput_GetFormatDetectionStatus( |
|---|
| 464 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 465 | BAPE_MaiInputFormatDetectionStatus *pStatus |
|---|
| 466 | ) |
|---|
| 467 | { |
|---|
| 468 | BERR_Code ret = BERR_SUCCESS; |
|---|
| 469 | |
|---|
| 470 | BDBG_ENTER(BAPE_MaiInput_GetFormatDetectionStatus); |
|---|
| 471 | |
|---|
| 472 | BDBG_ASSERT(hMaiInput); |
|---|
| 473 | BDBG_ASSERT(pStatus); |
|---|
| 474 | |
|---|
| 475 | if ( hMaiInput->formatDetectionEnabled ) |
|---|
| 476 | { |
|---|
| 477 | /* If Format Detection is enabled, we can just return a copy of whats |
|---|
| 478 | * in the handle's lastFormatDectionStatus structure (since it's being |
|---|
| 479 | * kept up to date). */ |
|---|
| 480 | BDBG_CASSERT(sizeof (*pStatus) == sizeof (hMaiInput->lastFormatDetectionStatus)); |
|---|
| 481 | BKNI_Memcpy(pStatus, &hMaiInput->lastFormatDetectionStatus, sizeof (*pStatus)); |
|---|
| 482 | } |
|---|
| 483 | else |
|---|
| 484 | { |
|---|
| 485 | /* Format Detection is not enabled, so build a fresh format detection status |
|---|
| 486 | * structure by reading the hardware. */ |
|---|
| 487 | { /* Start Critical Section */ |
|---|
| 488 | BKNI_EnterCriticalSection(); |
|---|
| 489 | BAPE_MaiInput_P_GetFormatDetectionStatus_isr(hMaiInput, pStatus); |
|---|
| 490 | BKNI_LeaveCriticalSection(); |
|---|
| 491 | } /* End Critical Section */ |
|---|
| 492 | } |
|---|
| 493 | |
|---|
| 494 | BDBG_LEAVE(BAPE_MaiInput_GetFormatDetectionStatus); |
|---|
| 495 | return ret; |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | /*************************************************************************** |
|---|
| 499 | BAPE Internal APIs: From bape_fmm_priv.h |
|---|
| 500 | ***************************************************************************/ |
|---|
| 501 | |
|---|
| 502 | BERR_Code BAPE_MaiInput_P_PrepareForStandby(BAPE_Handle hApe) |
|---|
| 503 | { |
|---|
| 504 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 505 | unsigned maiInputIndex; |
|---|
| 506 | |
|---|
| 507 | BDBG_OBJECT_ASSERT(hApe, BAPE_Device); |
|---|
| 508 | |
|---|
| 509 | /* For each opened MaiInput... */ |
|---|
| 510 | for ( maiInputIndex=0 ; maiInputIndex<BAPE_CHIP_MAX_MAI_INPUTS ; maiInputIndex++ ) |
|---|
| 511 | { |
|---|
| 512 | if ( hApe->maiInputs[maiInputIndex] ) /* If this MaiInput is open... */ |
|---|
| 513 | { |
|---|
| 514 | BAPE_MaiInputHandle hMaiInput = hApe->maiInputs[maiInputIndex]; |
|---|
| 515 | |
|---|
| 516 | /* If we already have a callback (interrupt), make sure that it's disabled, then destroy it. */ |
|---|
| 517 | if( hMaiInput->maiRxCallback ) |
|---|
| 518 | { |
|---|
| 519 | errCode = BINT_DisableCallback(hMaiInput->maiRxCallback); |
|---|
| 520 | if (errCode != BERR_SUCCESS) |
|---|
| 521 | { |
|---|
| 522 | BDBG_ERR(("Unable to Disable MAI RX callback")); |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | BINT_DestroyCallback(hMaiInput->maiRxCallback); |
|---|
| 526 | hMaiInput->maiRxCallback = NULL; |
|---|
| 527 | } |
|---|
| 528 | } |
|---|
| 529 | } |
|---|
| 530 | return errCode; |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | /**************************************************************************/ |
|---|
| 534 | |
|---|
| 535 | BERR_Code BAPE_MaiInput_P_ResumeFromStandby(BAPE_Handle hApe) |
|---|
| 536 | { |
|---|
| 537 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 538 | unsigned maiInputIndex; |
|---|
| 539 | |
|---|
| 540 | BDBG_OBJECT_ASSERT(hApe, BAPE_Device); |
|---|
| 541 | |
|---|
| 542 | /* For each opened MaiInput, call the functions necessary to restore the hardware to it's appropriate state. */ |
|---|
| 543 | for ( maiInputIndex=0 ; maiInputIndex<BAPE_CHIP_MAX_MAI_INPUTS ; maiInputIndex++ ) |
|---|
| 544 | { |
|---|
| 545 | if ( hApe->maiInputs[maiInputIndex] ) /* If this MaiInput is open... */ |
|---|
| 546 | { |
|---|
| 547 | BAPE_MaiInputHandle hMaiInput = hApe->maiInputs[maiInputIndex]; |
|---|
| 548 | |
|---|
| 549 | /* Put the HW into the generic open state. */ |
|---|
| 550 | errCode = BAPE_MaiInput_P_OpenHw(hMaiInput); |
|---|
| 551 | if ( errCode ) return BERR_TRACE(errCode); |
|---|
| 552 | |
|---|
| 553 | /* Now apply changes for the settings struct. */ |
|---|
| 554 | errCode = BAPE_MaiInput_SetSettings(hMaiInput, &hMaiInput->settings); |
|---|
| 555 | if ( errCode ) return BERR_TRACE(errCode); |
|---|
| 556 | |
|---|
| 557 | /* Now restore the dynamic stuff from the values saved in the device struct. */ |
|---|
| 558 | errCode = BAPE_MaiInput_SetFormatDetectionSettings(hMaiInput, &hMaiInput->clientFormatDetectionSettings); |
|---|
| 559 | if ( errCode ) return BERR_TRACE(errCode); |
|---|
| 560 | } |
|---|
| 561 | } |
|---|
| 562 | return errCode; |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | /*************************************************************************** |
|---|
| 566 | Private callbacks: Protyped above |
|---|
| 567 | ***************************************************************************/ |
|---|
| 568 | static void BAPE_MaiInput_P_Enable(BAPE_InputPort inputPort) |
|---|
| 569 | { |
|---|
| 570 | BAPE_MaiInputHandle hMaiInput; |
|---|
| 571 | |
|---|
| 572 | BDBG_OBJECT_ASSERT(inputPort, BAPE_InputPort); |
|---|
| 573 | hMaiInput = inputPort->pHandle; |
|---|
| 574 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 575 | BDBG_ASSERT(false == hMaiInput->enable); |
|---|
| 576 | |
|---|
| 577 | BDBG_MSG(("Enabling %s", hMaiInput->name)); |
|---|
| 578 | |
|---|
| 579 | /* Group the input channel pairs, then enable capture */ |
|---|
| 580 | |
|---|
| 581 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN /* Local (HDMI-specific) STREAM_CFG register */ |
|---|
| 582 | { |
|---|
| 583 | unsigned i; |
|---|
| 584 | uint32_t regAddr; |
|---|
| 585 | |
|---|
| 586 | /* Set Capture Group ID's for the correct number of channel pairs */ |
|---|
| 587 | for ( i = 0; i < inputPort->numChannelPairs; i++ ) |
|---|
| 588 | { |
|---|
| 589 | regAddr = BAPE_Reg_P_GetArrayAddress( AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, i); |
|---|
| 590 | BAPE_Reg_P_UpdateField(hMaiInput->deviceHandle, regAddr, AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, CAP_GROUP_ID, 0); |
|---|
| 591 | } |
|---|
| 592 | for ( ; i <= BCHP_AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i_ARRAY_END; i++ ) |
|---|
| 593 | { |
|---|
| 594 | regAddr = BAPE_Reg_P_GetArrayAddress( AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, i); |
|---|
| 595 | BAPE_Reg_P_UpdateField(hMaiInput->deviceHandle, regAddr, AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, CAP_GROUP_ID, i); |
|---|
| 596 | } |
|---|
| 597 | |
|---|
| 598 | /* Enable capture */ |
|---|
| 599 | for ( i = 0; i < inputPort->numChannelPairs; i++ ) |
|---|
| 600 | { |
|---|
| 601 | regAddr = BAPE_Reg_P_GetArrayAddress( AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, i); |
|---|
| 602 | BAPE_Reg_P_UpdateField(hMaiInput->deviceHandle, regAddr, AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, CAP_ENA, 1); |
|---|
| 603 | } |
|---|
| 604 | } |
|---|
| 605 | #elif defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY /* Shared pool of STREAM_CFG registers in IOP */ |
|---|
| 606 | BAPE_Iop_P_EnableCapture( hMaiInput->deviceHandle, inputPort->streamId[0], inputPort->numChannelPairs ); |
|---|
| 607 | #else |
|---|
| 608 | #error "Unknown MAI register format" |
|---|
| 609 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN... BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY */ |
|---|
| 610 | |
|---|
| 611 | /* Enable output FIFO */ |
|---|
| 612 | { /* Start Critical Section */ |
|---|
| 613 | BKNI_EnterCriticalSection(); |
|---|
| 614 | BAPE_Reg_P_UpdateEnum_isr(hMaiInput->deviceHandle, BAPE_P_HDMI_RX_CONFIG_REGADDR, |
|---|
| 615 | BAPE_P_HDMI_RX_CONFIG_REGNAME, OUTFIFO_ENA, Enable); |
|---|
| 616 | hMaiInput->enable = true; |
|---|
| 617 | BKNI_LeaveCriticalSection(); |
|---|
| 618 | } /* End Critical Section */ |
|---|
| 619 | } |
|---|
| 620 | |
|---|
| 621 | /**************************************************************************/ |
|---|
| 622 | |
|---|
| 623 | static void BAPE_MaiInput_P_Disable(BAPE_InputPort inputPort) |
|---|
| 624 | { |
|---|
| 625 | BAPE_MaiInputHandle hMaiInput; |
|---|
| 626 | |
|---|
| 627 | BDBG_OBJECT_ASSERT(inputPort, BAPE_InputPort); |
|---|
| 628 | hMaiInput = inputPort->pHandle; |
|---|
| 629 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 630 | |
|---|
| 631 | BDBG_MSG(("Disabling %s", hMaiInput->name)); |
|---|
| 632 | |
|---|
| 633 | /* Disable the output FIFO. */ |
|---|
| 634 | { /* Start Critical Section */ |
|---|
| 635 | BKNI_EnterCriticalSection(); |
|---|
| 636 | BAPE_Reg_P_UpdateEnum_isr(hMaiInput->deviceHandle, BAPE_P_HDMI_RX_CONFIG_REGADDR, |
|---|
| 637 | BAPE_P_HDMI_RX_CONFIG_REGNAME, OUTFIFO_ENA, Disable); |
|---|
| 638 | hMaiInput->enable = false; |
|---|
| 639 | BKNI_LeaveCriticalSection(); |
|---|
| 640 | } /* End Critical Section */ |
|---|
| 641 | |
|---|
| 642 | /* Disable capture and ungroup the channel pairs */ |
|---|
| 643 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN /* Local (HDMI-specific) STREAM_CFG register */ |
|---|
| 644 | { |
|---|
| 645 | uint32_t regAddr; |
|---|
| 646 | unsigned i; |
|---|
| 647 | |
|---|
| 648 | /* Disable capture */ |
|---|
| 649 | for ( i = 0; i < BAPE_ChannelPair_eMax; i++ ) |
|---|
| 650 | { |
|---|
| 651 | regAddr = BAPE_Reg_P_GetArrayAddress( AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, i); |
|---|
| 652 | BAPE_Reg_P_UpdateField(hMaiInput->deviceHandle, regAddr, AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, CAP_ENA, 0); |
|---|
| 653 | } |
|---|
| 654 | |
|---|
| 655 | /* Ungroup */ |
|---|
| 656 | for ( i = 0; i < BAPE_ChannelPair_eMax; i++ ) |
|---|
| 657 | { |
|---|
| 658 | regAddr = BAPE_Reg_P_GetArrayAddress( AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, i); |
|---|
| 659 | BAPE_Reg_P_UpdateField(hMaiInput->deviceHandle, regAddr, AUD_FMM_IOP_IN_HDMI_0_CAP_STREAM_CFG_i, CAP_GROUP_ID, i); |
|---|
| 660 | } |
|---|
| 661 | } |
|---|
| 662 | #elif defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY /* Shared pool of STREAM_CFG registers in IOP */ |
|---|
| 663 | BAPE_Iop_P_DisableCapture( hMaiInput->deviceHandle, inputPort->streamId[0], BAPE_ChannelPair_eMax ); |
|---|
| 664 | #else |
|---|
| 665 | #error "Unknown MAI register format" |
|---|
| 666 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN, BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY */ |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | /**************************************************************************/ |
|---|
| 670 | |
|---|
| 671 | static void BAPE_MaiInput_P_Halt_isr(BAPE_InputPort inputPort) |
|---|
| 672 | { |
|---|
| 673 | BAPE_MaiInputHandle hMaiInput; |
|---|
| 674 | |
|---|
| 675 | BKNI_ASSERT_ISR_CONTEXT(); |
|---|
| 676 | BDBG_OBJECT_ASSERT(inputPort, BAPE_InputPort); |
|---|
| 677 | hMaiInput = inputPort->pHandle; |
|---|
| 678 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 679 | |
|---|
| 680 | BDBG_MSG(("Halting %s", hMaiInput->name)); |
|---|
| 681 | |
|---|
| 682 | /* Disable the output FIFO. */ |
|---|
| 683 | if ( hMaiInput->enable ) |
|---|
| 684 | { |
|---|
| 685 | BAPE_Reg_P_UpdateEnum_isr(hMaiInput->deviceHandle, BAPE_P_HDMI_RX_CONFIG_REGADDR, |
|---|
| 686 | BAPE_P_HDMI_RX_CONFIG_REGNAME, OUTFIFO_ENA, Disable); |
|---|
| 687 | } |
|---|
| 688 | } |
|---|
| 689 | |
|---|
| 690 | /**************************************************************************/ |
|---|
| 691 | |
|---|
| 692 | static BERR_Code BAPE_MaiInput_P_ConsumerAttached(BAPE_InputPort inputPort, BAPE_PathNode *pConsumer) |
|---|
| 693 | { |
|---|
| 694 | BAPE_MaiInputHandle hMaiInput; |
|---|
| 695 | |
|---|
| 696 | BDBG_OBJECT_ASSERT(inputPort, BAPE_InputPort); |
|---|
| 697 | hMaiInput = inputPort->pHandle; |
|---|
| 698 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 699 | |
|---|
| 700 | BDBG_MSG(("Attaching consumer %s", pConsumer->pName)); |
|---|
| 701 | |
|---|
| 702 | switch ( pConsumer->type ) |
|---|
| 703 | { |
|---|
| 704 | case BAPE_PathNodeType_eDecoder: |
|---|
| 705 | case BAPE_PathNodeType_eInputCapture: |
|---|
| 706 | break; |
|---|
| 707 | default: |
|---|
| 708 | BDBG_ERR(("Node %u is not a valid consumer for MAI Input", pConsumer->pName)); |
|---|
| 709 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 710 | } |
|---|
| 711 | |
|---|
| 712 | BDBG_ASSERT(inputPort->pConsumer == pConsumer); |
|---|
| 713 | |
|---|
| 714 | /* Enable format detection interupts. After this, the current input format |
|---|
| 715 | * will be maintained in the handle's lastFormatDetectionStatus struct. */ |
|---|
| 716 | hMaiInput->localFormatDetectionEnabled = true; |
|---|
| 717 | BAPE_MaiInput_P_SetFormatDetection(hMaiInput); |
|---|
| 718 | |
|---|
| 719 | { /* Start Critical Section */ |
|---|
| 720 | BKNI_EnterCriticalSection(); |
|---|
| 721 | |
|---|
| 722 | /* Update the InputPort's fields to match the current input format. */ |
|---|
| 723 | BAPE_MaiInput_P_UpdateInputPortFormatFields_isr (hMaiInput, &hMaiInput->lastFormatDetectionStatus); |
|---|
| 724 | BAPE_MaiInput_P_SetReceiverOutputFormat_isr (hMaiInput, &hMaiInput->lastFormatDetectionStatus); |
|---|
| 725 | |
|---|
| 726 | BKNI_LeaveCriticalSection(); |
|---|
| 727 | } /* End Critical Section */ |
|---|
| 728 | |
|---|
| 729 | return BERR_SUCCESS; |
|---|
| 730 | } |
|---|
| 731 | |
|---|
| 732 | /**************************************************************************/ |
|---|
| 733 | |
|---|
| 734 | static void BAPE_MaiInput_P_ConsumerDetached(BAPE_InputPort inputPort, BAPE_PathNode *pConsumer) |
|---|
| 735 | { |
|---|
| 736 | BAPE_MaiInputHandle hMaiInput; |
|---|
| 737 | |
|---|
| 738 | BSTD_UNUSED(pConsumer); |
|---|
| 739 | |
|---|
| 740 | BDBG_OBJECT_ASSERT(inputPort, BAPE_InputPort); |
|---|
| 741 | hMaiInput = inputPort->pHandle; |
|---|
| 742 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 743 | |
|---|
| 744 | /* Disable local format detection. */ |
|---|
| 745 | hMaiInput->localFormatDetectionEnabled = false; |
|---|
| 746 | BAPE_MaiInput_P_SetFormatDetection(hMaiInput); |
|---|
| 747 | |
|---|
| 748 | return; |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | /*************************************************************************** |
|---|
| 752 | Private functions: Protyped above |
|---|
| 753 | ***************************************************************************/ |
|---|
| 754 | |
|---|
| 755 | static BERR_Code BAPE_MaiInput_P_OpenHw(BAPE_MaiInputHandle hMaiInput) |
|---|
| 756 | { |
|---|
| 757 | uint32_t regAddr; |
|---|
| 758 | BAPE_Handle hApe; |
|---|
| 759 | BAPE_Reg_P_FieldList regFieldList; |
|---|
| 760 | BERR_Code errCode = BERR_SUCCESS; |
|---|
| 761 | |
|---|
| 762 | /* Currently we only support one MAI input, this can be expanded later if we support more */ |
|---|
| 763 | #if BAPE_CHIP_MAX_MAI_INPUTS > 1 |
|---|
| 764 | #error "Need to support more MAI inputs" |
|---|
| 765 | #endif |
|---|
| 766 | |
|---|
| 767 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 768 | |
|---|
| 769 | hApe = hMaiInput->deviceHandle; |
|---|
| 770 | BDBG_OBJECT_ASSERT(hApe, BAPE_Device); |
|---|
| 771 | |
|---|
| 772 | /* Taken from RAP PI (regarding ALLOW_NZ_STUFFING=Nonzero_Ok) --> |
|---|
| 773 | PR 35668: Some Blu Ray DVD Players send Non Zero values between compressed |
|---|
| 774 | frames. This was getting treated as PCM data and causing confusion in 3563 |
|---|
| 775 | and a workaround was put. In 3548 this has been fixed in hardware. |
|---|
| 776 | Enabling the bit here. |
|---|
| 777 | */ |
|---|
| 778 | |
|---|
| 779 | BAPE_Reg_P_InitFieldList(hApe, ®FieldList); |
|---|
| 780 | |
|---|
| 781 | regAddr = BAPE_P_HDMI_RX_CONFIG_REGADDR; |
|---|
| 782 | |
|---|
| 783 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, PCM); |
|---|
| 784 | hMaiInput->outFormatEna = BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, PCM); /* Remember OUT_FORMAT_ENA setting. */ |
|---|
| 785 | |
|---|
| 786 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, ALLOW_NZ_STUFFING, Nonzero_OK); |
|---|
| 787 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 788 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, SOURCE_SEL, MAI); |
|---|
| 789 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, HDMI_SEL, HDMI0); |
|---|
| 790 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY */ |
|---|
| 791 | |
|---|
| 792 | BAPE_Reg_P_ApplyFieldList(®FieldList, regAddr); |
|---|
| 793 | |
|---|
| 794 | /* Clear the interrupts before enabling any callbacks */ |
|---|
| 795 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 796 | /* Clear and unmask L3 interrupts. */ |
|---|
| 797 | BAPE_Reg_P_Write(hApe, BCHP_AUD_FMM_IOP_IN_HDMI_0_ESR_MASK_SET, 0xffffffff); |
|---|
| 798 | BAPE_Reg_P_Write(hApe, BCHP_AUD_FMM_IOP_IN_HDMI_0_ESR_STATUS_CLEAR, 0xffffffff); |
|---|
| 799 | BAPE_Reg_P_Write(hApe, BCHP_AUD_FMM_IOP_IN_HDMI_0_ESR_MASK_CLEAR, BCHP_MASK( AUD_FMM_IOP_IN_HDMI_0_ESR_MASK_CLEAR, HDMIRX_CHAN_STAT_MASK) | |
|---|
| 800 | BCHP_MASK( AUD_FMM_IOP_IN_HDMI_0_ESR_MASK_CLEAR, HDMIRX_PC_CHANGE_MASK) | |
|---|
| 801 | BCHP_MASK( AUD_FMM_IOP_IN_HDMI_0_ESR_MASK_CLEAR, HDMIRX_COMP_CHANGE_MASK) | |
|---|
| 802 | BCHP_MASK( AUD_FMM_IOP_IN_HDMI_0_ESR_MASK_CLEAR, HDMIRX_MAI_FMT_CHANGE_MASK) ); |
|---|
| 803 | |
|---|
| 804 | /* Clear and unmask L2 interrupt. */ |
|---|
| 805 | BAPE_Reg_P_Write(hApe, BCHP_AUD_FMM_IOP_MISC_ESR_MASK_SET, BCHP_MASK( AUD_FMM_IOP_MISC_ESR_MASK_SET, IOP_INTERRUPT_IN_HDMI_0)); |
|---|
| 806 | BAPE_Reg_P_Write(hApe, BCHP_AUD_FMM_IOP_MISC_ESR_STATUS_CLEAR, BCHP_MASK( AUD_FMM_IOP_MISC_ESR_STATUS_CLEAR, IOP_INTERRUPT_IN_HDMI_0)); |
|---|
| 807 | BAPE_Reg_P_Write(hApe, BCHP_AUD_FMM_IOP_MISC_ESR_MASK_CLEAR, BCHP_MASK( AUD_FMM_IOP_MISC_ESR_MASK_CLEAR, IOP_INTERRUPT_IN_HDMI_0)); |
|---|
| 808 | |
|---|
| 809 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN */ |
|---|
| 810 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 811 | /* Clear and unmask L2 interrupts. */ |
|---|
| 812 | BAPE_Reg_P_Write(hApe, BCHP_HDMI_RCVR_ESR_MASK_SET, 0xffffffff); |
|---|
| 813 | BAPE_Reg_P_Write(hApe, BCHP_HDMI_RCVR_ESR_STATUS_CLEAR, 0xffffffff); |
|---|
| 814 | BAPE_Reg_P_Write(hApe, BCHP_HDMI_RCVR_ESR_MASK_CLEAR, BCHP_MASK( SPDIF_RCVR_ESR_MASK_CLEAR, SPDIFRX_CHAN_STAT_MASK ) | |
|---|
| 815 | BCHP_MASK( SPDIF_RCVR_ESR_MASK_CLEAR, SPDIFRX_PC_CHANGE_MASK ) | |
|---|
| 816 | BCHP_MASK( SPDIF_RCVR_ESR_MASK_CLEAR, SPDIFRX_COMP_CHANGE_MASK ) | |
|---|
| 817 | BCHP_MASK( SPDIF_RCVR_ESR_MASK_CLEAR, SPDIFRX_MAI_FMT_CHANGE_MASK )); |
|---|
| 818 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY */ |
|---|
| 819 | |
|---|
| 820 | { |
|---|
| 821 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 822 | BINT_Id intId = BCHP_INT_ID_AUD_IOP; |
|---|
| 823 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN */ |
|---|
| 824 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 825 | BINT_Id intId = BCHP_INT_ID_HDMIRX; |
|---|
| 826 | #endif /* if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY */ |
|---|
| 827 | |
|---|
| 828 | errCode = BINT_CreateCallback( &hMaiInput->maiRxCallback, |
|---|
| 829 | hApe->intHandle, |
|---|
| 830 | intId, |
|---|
| 831 | BAPE_P_MAI_RX_isr, |
|---|
| 832 | (void*)hMaiInput, |
|---|
| 833 | 0 /* Not used*/ |
|---|
| 834 | ); |
|---|
| 835 | } |
|---|
| 836 | if (errCode != BERR_SUCCESS) |
|---|
| 837 | { |
|---|
| 838 | BDBG_ERR(("Unable to create MAI RX callback")); |
|---|
| 839 | return errCode; |
|---|
| 840 | } |
|---|
| 841 | |
|---|
| 842 | return errCode; |
|---|
| 843 | } |
|---|
| 844 | |
|---|
| 845 | /**************************************************************************/ |
|---|
| 846 | |
|---|
| 847 | static BERR_Code BAPE_MaiInput_P_ApplySettings(BAPE_MaiInputHandle hMaiInput) |
|---|
| 848 | { |
|---|
| 849 | BAPE_Reg_P_FieldList regFieldList; |
|---|
| 850 | const BAPE_MaiInputSettings *pSettings = &hMaiInput->settings; |
|---|
| 851 | |
|---|
| 852 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 853 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 854 | |
|---|
| 855 | BAPE_Reg_P_InitFieldList(hMaiInput->deviceHandle, ®FieldList); |
|---|
| 856 | BAPE_Reg_P_AddToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, IGNORE_VALID_PCM, pSettings->ignoreValidity); |
|---|
| 857 | BAPE_Reg_P_AddToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, IGNORE_PERR_PCM, pSettings->ignorePcmParity); |
|---|
| 858 | BAPE_Reg_P_AddToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, IGNORE_PERR_COMP, pSettings->ignoreCompressedParity); |
|---|
| 859 | BAPE_Reg_P_AddToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, TIMEBASE_SEL, pSettings->timebase); |
|---|
| 860 | |
|---|
| 861 | switch ( pSettings->errorInsertion ) |
|---|
| 862 | { |
|---|
| 863 | case BAPE_SpdifInputErrorInsertion_eNone: |
|---|
| 864 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, INSERT_MODE, No_insert); |
|---|
| 865 | break; |
|---|
| 866 | case BAPE_SpdifInputErrorInsertion_eZero: |
|---|
| 867 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, INSERT_MODE, Insert_zero); |
|---|
| 868 | break; |
|---|
| 869 | case BAPE_SpdifInputErrorInsertion_eRepeat: |
|---|
| 870 | BAPE_Reg_P_AddEnumToFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGNAME, INSERT_MODE, Insert_repeat); |
|---|
| 871 | break; |
|---|
| 872 | default: |
|---|
| 873 | BDBG_ERR(("Invalid Error Insertion Mode %d", pSettings->errorInsertion)); |
|---|
| 874 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 875 | } |
|---|
| 876 | |
|---|
| 877 | { /* Start Critical Section */ |
|---|
| 878 | BKNI_EnterCriticalSection(); |
|---|
| 879 | BAPE_Reg_P_ApplyFieldList(®FieldList, BAPE_P_HDMI_RX_CONFIG_REGADDR); |
|---|
| 880 | BKNI_LeaveCriticalSection(); |
|---|
| 881 | } /* End Critical Section */ |
|---|
| 882 | |
|---|
| 883 | return BERR_SUCCESS; |
|---|
| 884 | } |
|---|
| 885 | |
|---|
| 886 | /**************************************************************************/ |
|---|
| 887 | |
|---|
| 888 | static void BAPE_P_MAI_RX_isr ( |
|---|
| 889 | void * pParm1, /* [in] channel hMaiInput */ |
|---|
| 890 | int iParm2 /* [in] Not used */ |
|---|
| 891 | ) |
|---|
| 892 | { |
|---|
| 893 | BAPE_MaiInputHandle hMaiInput = NULL; |
|---|
| 894 | uint32_t ui32IntStatus=0; |
|---|
| 895 | uint32_t ui32MaskStatus=0; |
|---|
| 896 | |
|---|
| 897 | BDBG_ENTER (BAPE_P_MAI_RX_isr); |
|---|
| 898 | |
|---|
| 899 | BKNI_ASSERT_ISR_CONTEXT(); |
|---|
| 900 | BDBG_ASSERT (pParm1); |
|---|
| 901 | BSTD_UNUSED(iParm2); |
|---|
| 902 | |
|---|
| 903 | hMaiInput = (BAPE_MaiInputHandle) pParm1; |
|---|
| 904 | |
|---|
| 905 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 906 | ui32IntStatus = BAPE_Reg_P_Read_isr(hMaiInput->deviceHandle, BCHP_AUD_FMM_IOP_IN_HDMI_0_ESR_STATUS); |
|---|
| 907 | ui32MaskStatus = BAPE_Reg_P_Read_isr(hMaiInput->deviceHandle, BCHP_AUD_FMM_IOP_IN_HDMI_0_ESR_MASK); |
|---|
| 908 | #endif |
|---|
| 909 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 910 | ui32IntStatus = BAPE_Reg_P_Read_isr(hMaiInput->deviceHandle, BCHP_HDMI_RCVR_ESR_STATUS); |
|---|
| 911 | ui32MaskStatus = BAPE_Reg_P_Read_isr(hMaiInput->deviceHandle, BCHP_HDMI_RCVR_ESR_MASK); |
|---|
| 912 | #endif |
|---|
| 913 | |
|---|
| 914 | ui32IntStatus &= ~ui32MaskStatus; |
|---|
| 915 | |
|---|
| 916 | BDBG_MSG(("MAI_RX_ISR: ESR_STATUS (unmasked): 0x%x", ui32IntStatus)); |
|---|
| 917 | |
|---|
| 918 | if (ui32IntStatus) |
|---|
| 919 | { |
|---|
| 920 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 921 | BAPE_Reg_P_Write_isr(hMaiInput->deviceHandle, BCHP_AUD_FMM_IOP_MISC_ESR_STATUS_CLEAR, BCHP_MASK( AUD_FMM_IOP_MISC_ESR_STATUS_CLEAR, IOP_INTERRUPT_IN_HDMI_0)); |
|---|
| 922 | BAPE_Reg_P_Write_isr(hMaiInput->deviceHandle, BCHP_AUD_FMM_IOP_IN_HDMI_0_ESR_STATUS_CLEAR, ui32IntStatus); |
|---|
| 923 | #endif |
|---|
| 924 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 925 | BAPE_Reg_P_Write_isr(hMaiInput->deviceHandle, BCHP_HDMI_RCVR_ESR_STATUS_CLEAR, ui32IntStatus); |
|---|
| 926 | #endif |
|---|
| 927 | |
|---|
| 928 | BAPE_MaiInput_P_DetectInputChange_isr(hMaiInput); |
|---|
| 929 | } |
|---|
| 930 | BDBG_LEAVE (BAPE_P_MAI_RX_isr); |
|---|
| 931 | return; |
|---|
| 932 | } |
|---|
| 933 | |
|---|
| 934 | /**************************************************************************/ |
|---|
| 935 | |
|---|
| 936 | static BERR_Code BAPE_MaiInput_P_SetFormatDetection( |
|---|
| 937 | BAPE_MaiInputHandle hMaiInput |
|---|
| 938 | ) |
|---|
| 939 | { |
|---|
| 940 | BERR_Code ret = BERR_SUCCESS; |
|---|
| 941 | bool formatDetectionRequired = false; |
|---|
| 942 | |
|---|
| 943 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 944 | |
|---|
| 945 | |
|---|
| 946 | /* There are two reasons for enabling format detection. First, when the input is enabled, we need |
|---|
| 947 | * to use format detection for setting up the receiver's output format, and to halt the outfifo |
|---|
| 948 | * in the case of a format change that can't be handled on-the-fly. Secondly, the client (Nexus) |
|---|
| 949 | * can enable format detection to keep track of the current input format. |
|---|
| 950 | * So start by checking to see if anybody needs format detection on. */ |
|---|
| 951 | |
|---|
| 952 | /* Check to see if our client needs format detection. */ |
|---|
| 953 | if ( hMaiInput->clientFormatDetectionSettings.enabled == true && |
|---|
| 954 | hMaiInput->clientFormatDetectionSettings.formatChangeInterrupt.pCallback_isr) { |
|---|
| 955 | |
|---|
| 956 | formatDetectionRequired = true; |
|---|
| 957 | } |
|---|
| 958 | |
|---|
| 959 | /* Now see if we need it internally. */ |
|---|
| 960 | if ( hMaiInput->localFormatDetectionEnabled ) |
|---|
| 961 | { |
|---|
| 962 | formatDetectionRequired = true; |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | /* If it's not enabled and somebody needs it, then turn it on. */ |
|---|
| 966 | if (! hMaiInput->formatDetectionEnabled && formatDetectionRequired ) |
|---|
| 967 | { |
|---|
| 968 | { /* Start Critical Section */ |
|---|
| 969 | BKNI_EnterCriticalSection(); |
|---|
| 970 | |
|---|
| 971 | /* Make a call to BAPE_MaiInput_P_GetFormatDetectionStatus_isr() to get a |
|---|
| 972 | * fresh snapshot of the current state of things from the hardware |
|---|
| 973 | * (so that we can detect a change when interrupts occur later. */ |
|---|
| 974 | BAPE_MaiInput_P_GetFormatDetectionStatus_isr(hMaiInput, &hMaiInput->lastFormatDetectionStatus); |
|---|
| 975 | |
|---|
| 976 | BKNI_LeaveCriticalSection(); |
|---|
| 977 | } /* End Critical Section */ |
|---|
| 978 | |
|---|
| 979 | BINT_EnableCallback(hMaiInput->maiRxCallback); |
|---|
| 980 | hMaiInput->formatDetectionEnabled = true; |
|---|
| 981 | } |
|---|
| 982 | |
|---|
| 983 | /* If format detection is enabled, but nobody needs it, then turn if off. */ |
|---|
| 984 | if ( hMaiInput->formatDetectionEnabled && ! formatDetectionRequired ) |
|---|
| 985 | { |
|---|
| 986 | if( hMaiInput->maiRxCallback ) |
|---|
| 987 | { |
|---|
| 988 | hMaiInput->formatDetectionEnabled = false; |
|---|
| 989 | ret = BINT_DisableCallback(hMaiInput->maiRxCallback); |
|---|
| 990 | if (ret != BERR_SUCCESS) |
|---|
| 991 | { |
|---|
| 992 | BDBG_ERR(("Unable to Disable MAI RX callback")); |
|---|
| 993 | } |
|---|
| 994 | } |
|---|
| 995 | } |
|---|
| 996 | |
|---|
| 997 | return BERR_SUCCESS; |
|---|
| 998 | } |
|---|
| 999 | |
|---|
| 1000 | /**************************************************************************/ |
|---|
| 1001 | |
|---|
| 1002 | static BERR_Code BAPE_MaiInput_P_GetFormatDetectionStatus_isr(BAPE_MaiInputHandle hMaiInput, BAPE_MaiInputFormatDetectionStatus *pStatus) |
|---|
| 1003 | { |
|---|
| 1004 | uint32_t receiverStatusRegVal = 0; |
|---|
| 1005 | uint32_t maiFormatRegVal = 0; |
|---|
| 1006 | uint32_t maiFormatRegAudioFormat = 0; |
|---|
| 1007 | uint32_t maiFormatRegSampleRate = 0; |
|---|
| 1008 | uint32_t burstPreamble = 0; |
|---|
| 1009 | unsigned int i; |
|---|
| 1010 | |
|---|
| 1011 | BDBG_ENTER(BAPE_MaiInput_P_GetFormatDetectionStatus_isr); |
|---|
| 1012 | |
|---|
| 1013 | BKNI_ASSERT_ISR_CONTEXT(); |
|---|
| 1014 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 1015 | BDBG_ASSERT(pStatus); |
|---|
| 1016 | |
|---|
| 1017 | /* Clear out the destination buffer. */ |
|---|
| 1018 | BKNI_Memset(pStatus, 0, sizeof (*pStatus)); |
|---|
| 1019 | |
|---|
| 1020 | /* Set some default values in case we don't find a reason to change them. */ |
|---|
| 1021 | pStatus->codec = BAVC_AudioCompressionStd_eMax; |
|---|
| 1022 | pStatus->signalPresent = true; |
|---|
| 1023 | |
|---|
| 1024 | /* Let them know if the format change interrupts are enabled. */ |
|---|
| 1025 | pStatus->detectionEnabled = false; |
|---|
| 1026 | if (hMaiInput->clientFormatDetectionSettings.enabled == true && hMaiInput->clientFormatDetectionSettings.formatChangeInterrupt.pCallback_isr) { |
|---|
| 1027 | pStatus->detectionEnabled = true; |
|---|
| 1028 | } |
|---|
| 1029 | |
|---|
| 1030 | /* Read the HDMI Receiver's MAI_FORMAT and STATUS registers. */ |
|---|
| 1031 | maiFormatRegVal = BAPE_Reg_P_Read(hMaiInput->deviceHandle, BAPE_P_HDMI_RX_MAI_FORMAT_REGADDR); |
|---|
| 1032 | receiverStatusRegVal = BAPE_Reg_P_Read(hMaiInput->deviceHandle, BAPE_P_HDMI_RX_STATUS_REGADDR); |
|---|
| 1033 | |
|---|
| 1034 | /* Gather some of the fields from the MAI Format register. */ |
|---|
| 1035 | pStatus->sampleWidth = BCHP_GET_FIELD_DATA(maiFormatRegVal , BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_WIDTH); |
|---|
| 1036 | |
|---|
| 1037 | /* Get the sample rate from the MAI Format register and convert to an integer. */ |
|---|
| 1038 | maiFormatRegSampleRate = BCHP_GET_FIELD_DATA(maiFormatRegVal, BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE); |
|---|
| 1039 | |
|---|
| 1040 | switch (maiFormatRegSampleRate) |
|---|
| 1041 | { |
|---|
| 1042 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_8000Hz): pStatus->sampleRate = 8000; break; |
|---|
| 1043 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_11025Hz): pStatus->sampleRate = 11025; break; |
|---|
| 1044 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_12000Hz): pStatus->sampleRate = 12000; break; |
|---|
| 1045 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_16000Hz): pStatus->sampleRate = 16000; break; |
|---|
| 1046 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_22050Hz): pStatus->sampleRate = 22050; break; |
|---|
| 1047 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_24000Hz): pStatus->sampleRate = 24000; break; |
|---|
| 1048 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_32000Hz): pStatus->sampleRate = 32000; break; |
|---|
| 1049 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_44100Hz): pStatus->sampleRate = 44100; break; |
|---|
| 1050 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_48000Hz): pStatus->sampleRate = 48000; break; |
|---|
| 1051 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_64000Hz): pStatus->sampleRate = 64000; break; |
|---|
| 1052 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_88200Hz): pStatus->sampleRate = 88200; break; |
|---|
| 1053 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_96000Hz): pStatus->sampleRate = 96000; break; |
|---|
| 1054 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_12800Hz): pStatus->sampleRate = 128000; break; |
|---|
| 1055 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_17640Hz): pStatus->sampleRate = 176400; break; |
|---|
| 1056 | case BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, SAMPLE_RATE, Rate_19200Hz): pStatus->sampleRate = 192000; break; |
|---|
| 1057 | default: pStatus->sampleRate = 0; break; |
|---|
| 1058 | } |
|---|
| 1059 | |
|---|
| 1060 | if ( pStatus->sampleRate == 0 ) |
|---|
| 1061 | { |
|---|
| 1062 | BDBG_MSG (("MAI FORMAT : Sample Rate is Unknown")); |
|---|
| 1063 | } |
|---|
| 1064 | else |
|---|
| 1065 | { |
|---|
| 1066 | BDBG_MSG (("MAI FORMAT : Sample Rate is %u", pStatus->sampleRate )); |
|---|
| 1067 | } |
|---|
| 1068 | |
|---|
| 1069 | /* Get the audio format from the MAI Format register, then convert to the BAPE_MaiInputFormat enum. */ |
|---|
| 1070 | maiFormatRegAudioFormat = BCHP_GET_FIELD_DATA(maiFormatRegVal, BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT); |
|---|
| 1071 | { |
|---|
| 1072 | struct |
|---|
| 1073 | { |
|---|
| 1074 | uint32_t hwAudioFormat; |
|---|
| 1075 | BAPE_MaiInputFormat maiInputFormat; |
|---|
| 1076 | bool compressed; /* true => stream is compressed */ |
|---|
| 1077 | bool hbr; /* true => HBR stream */ |
|---|
| 1078 | unsigned numPcmChannels; /* Total number of PCM audio channels, 0 for comnpressed streams */ |
|---|
| 1079 | } maiInputFormatInfo[] = |
|---|
| 1080 | { /* hwAudioFormat maiInputFormat compressed hbr numPcmChannels */ |
|---|
| 1081 | |
|---|
| 1082 | |
|---|
| 1083 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, Idle), BAPE_MaiInputFormat_eIdle, false, false, 0 }, |
|---|
| 1084 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 1085 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, Linear_PCM_audio_stereo_mode), BAPE_MaiInputFormat_eSpdifLinearPcm, false, false, 2 }, |
|---|
| 1086 | #endif |
|---|
| 1087 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 1088 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, HDMI_linearPCM_stereo), BAPE_MaiInputFormat_eHdmiPcmStereo, false, false, 2 }, |
|---|
| 1089 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, SPDIF_linearPCM), BAPE_MaiInputFormat_eSpdifLinearPcm, false, false, 2 }, |
|---|
| 1090 | #endif |
|---|
| 1091 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, SPDIF_linearPCM_stereo), BAPE_MaiInputFormat_eSpdifPcmStereo, false, false, 2 }, |
|---|
| 1092 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, SPDIF_linearPCM_6_channel), BAPE_MaiInputFormat_eSpdifPcm6Channel, false, false, 6 }, |
|---|
| 1093 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, SPDIF_linearPCM_8_channel), BAPE_MaiInputFormat_eSpdifPcm8Channel, false, false, 8 }, |
|---|
| 1094 | |
|---|
| 1095 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, HBR_compressed_8_channel), BAPE_MaiInputFormat_eHbrCompressed, true, true, 0 }, |
|---|
| 1096 | |
|---|
| 1097 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_LEGACY |
|---|
| 1098 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, HDMI_nonlinearPCM), BAPE_MaiInputFormat_eHdmiNonLinearPcm, true, false, 0 }, |
|---|
| 1099 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, SPDIF_nonlinearPCM), BAPE_MaiInputFormat_eSpdifNonLinearPcm, true, false, 0 }, |
|---|
| 1100 | #endif |
|---|
| 1101 | #if defined BAPE_CHIP_MAI_INPUT_TYPE_IS_IOPIN |
|---|
| 1102 | {BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_MAI_FORMAT_REGNAME, AUDIO_FORMAT, Compressed_audio_2_channel), BAPE_MaiInputFormat_eSpdifNonLinearPcm, true, false, 0 }, |
|---|
| 1103 | #endif |
|---|
| 1104 | }; |
|---|
| 1105 | |
|---|
| 1106 | /* Loop through the table, looking for a match to the MAI Format audio format bits. */ |
|---|
| 1107 | for ( i=0 ; i<BAPE_P_NUM_ELEMS(maiInputFormatInfo) ; i++ ) |
|---|
| 1108 | { |
|---|
| 1109 | if ( maiInputFormatInfo[i].hwAudioFormat == maiFormatRegAudioFormat ) break; |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | if ( i < BAPE_P_NUM_ELEMS(maiInputFormatInfo) ) /* Found a match, use table entry. */ |
|---|
| 1113 | { |
|---|
| 1114 | pStatus->compressed = maiInputFormatInfo[i].compressed; |
|---|
| 1115 | pStatus->hbr = maiInputFormatInfo[i].hbr; |
|---|
| 1116 | pStatus->numPcmChannels = maiInputFormatInfo[i].numPcmChannels; |
|---|
| 1117 | } |
|---|
| 1118 | else /* MAI Format's audio format not listed in table. */ |
|---|
| 1119 | { |
|---|
| 1120 | BDBG_ERR (("MAI Format: 0x%08x not valid => BAVC_AudioCompressionStd_eMax!!!", maiFormatRegAudioFormat)); |
|---|
| 1121 | pStatus->compressed = false; |
|---|
| 1122 | pStatus->hbr = false; |
|---|
| 1123 | pStatus->numPcmChannels = 0; |
|---|
| 1124 | } |
|---|
| 1125 | } |
|---|
| 1126 | |
|---|
| 1127 | if ( ! pStatus->compressed ) |
|---|
| 1128 | { |
|---|
| 1129 | if ( pStatus->numPcmChannels > 0 ) |
|---|
| 1130 | { |
|---|
| 1131 | pStatus->codec = BAVC_AudioCompressionStd_ePcm; |
|---|
| 1132 | BDBG_MSG (("MAI_Format: Uncompressed => BAVC_AudioCompressionStd_ePcm")); |
|---|
| 1133 | } |
|---|
| 1134 | else |
|---|
| 1135 | { |
|---|
| 1136 | pStatus->signalPresent = false; |
|---|
| 1137 | pStatus->codec = BAVC_AudioCompressionStd_eMax; |
|---|
| 1138 | } |
|---|
| 1139 | } |
|---|
| 1140 | else /* must be compressed */ |
|---|
| 1141 | { |
|---|
| 1142 | BDBG_MSG (("MAI_Format: Compressed... Need to check Preamble C bits")); |
|---|
| 1143 | pStatus->pcValid = BCHP_GET_FIELD_DATA(receiverStatusRegVal, BAPE_P_HDMI_RX_STATUS_REGNAME, BPC_VALID); |
|---|
| 1144 | |
|---|
| 1145 | if (!pStatus->pcValid) /* If Preamble C is not valid */ |
|---|
| 1146 | { |
|---|
| 1147 | pStatus->codec = BAVC_AudioCompressionStd_eMax; |
|---|
| 1148 | BDBG_MSG (("Preamble C: Not yet valid: BAVC_AudioCompressionStd_eMax")); |
|---|
| 1149 | } |
|---|
| 1150 | else /* if preamble C is valid... */ |
|---|
| 1151 | { |
|---|
| 1152 | burstPreamble = BCHP_GET_FIELD_DATA(receiverStatusRegVal, BAPE_P_HDMI_RX_STATUS_REGNAME, BURST_PREAM_C); |
|---|
| 1153 | |
|---|
| 1154 | BAPE_InputPort_P_BurstPreambleToCodec(burstPreamble, &pStatus->codec ); |
|---|
| 1155 | |
|---|
| 1156 | } /* End if preambleC is valid */ |
|---|
| 1157 | } /* End if not linear PCM */ |
|---|
| 1158 | |
|---|
| 1159 | BDBG_LEAVE(BAPE_MaiInput_P_GetFormatDetectionStatus_isr); |
|---|
| 1160 | |
|---|
| 1161 | return BERR_SUCCESS; |
|---|
| 1162 | } |
|---|
| 1163 | |
|---|
| 1164 | /**************************************************************************/ |
|---|
| 1165 | |
|---|
| 1166 | static void BAPE_MaiInput_P_DetectInputChange_isr (BAPE_MaiInputHandle hMaiInput) |
|---|
| 1167 | { |
|---|
| 1168 | BAPE_MaiInputFormatDetectionStatus oldFormatDetectionStatus, *pOldFormatDetectionStatus, *pNewFormatDetectionStatus; |
|---|
| 1169 | BERR_Code errCode; |
|---|
| 1170 | |
|---|
| 1171 | BDBG_ENTER(BAPE_MaiInput_P_DetectInputChange_isr); |
|---|
| 1172 | |
|---|
| 1173 | BKNI_ASSERT_ISR_CONTEXT(); |
|---|
| 1174 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 1175 | |
|---|
| 1176 | pOldFormatDetectionStatus = &oldFormatDetectionStatus; |
|---|
| 1177 | pNewFormatDetectionStatus = &hMaiInput->lastFormatDetectionStatus; |
|---|
| 1178 | |
|---|
| 1179 | /* Make a copy of the current "old" format detection snapshot. */ |
|---|
| 1180 | BKNI_Memcpy_isr(pOldFormatDetectionStatus, pNewFormatDetectionStatus, sizeof hMaiInput->lastFormatDetectionStatus); |
|---|
| 1181 | |
|---|
| 1182 | /* Now build a "new" format detection snapshot by reading the hardware. */ |
|---|
| 1183 | BAPE_MaiInput_P_GetFormatDetectionStatus_isr(hMaiInput, pNewFormatDetectionStatus); |
|---|
| 1184 | |
|---|
| 1185 | BAPE_MaiInput_P_SetReceiverOutputFormat_isr (hMaiInput, pNewFormatDetectionStatus); |
|---|
| 1186 | |
|---|
| 1187 | if (BKNI_Memcmp_isr(pNewFormatDetectionStatus, pOldFormatDetectionStatus, sizeof (*pNewFormatDetectionStatus)) != 0) |
|---|
| 1188 | { |
|---|
| 1189 | BAPE_MaiInput_P_UpdateInputPortFormatFields_isr (hMaiInput, pNewFormatDetectionStatus); |
|---|
| 1190 | |
|---|
| 1191 | /* Let the consumer know about the format change. */ |
|---|
| 1192 | errCode = BAPE_InputPort_P_FormatChanged_isr(&hMaiInput->inputPort); |
|---|
| 1193 | if ( errCode ) |
|---|
| 1194 | { |
|---|
| 1195 | /* The format change can't be handled on-the-fly, so stop the capture. */ |
|---|
| 1196 | BAPE_MaiInput_P_Halt_isr(&hMaiInput->inputPort); |
|---|
| 1197 | } |
|---|
| 1198 | |
|---|
| 1199 | if (hMaiInput->clientFormatDetectionSettings.enabled == true && hMaiInput->clientFormatDetectionSettings.formatChangeInterrupt.pCallback_isr) |
|---|
| 1200 | { |
|---|
| 1201 | BDBG_MSG(("Calling format change callback ", __FUNCTION__, __LINE__ )); |
|---|
| 1202 | hMaiInput->clientFormatDetectionSettings.formatChangeInterrupt.pCallback_isr( |
|---|
| 1203 | hMaiInput->clientFormatDetectionSettings.formatChangeInterrupt.pParam1, |
|---|
| 1204 | hMaiInput->clientFormatDetectionSettings.formatChangeInterrupt.param2); |
|---|
| 1205 | } |
|---|
| 1206 | |
|---|
| 1207 | /* Done with the important stuff, now print out each of the fields and indicate whether they've changed. */ |
|---|
| 1208 | #define BAPE_PRINT_CHANGE(name, pfmt, old, new) \ |
|---|
| 1209 | ( (old) != (new) \ |
|---|
| 1210 | ? BDBG_MSG(("%s: " pfmt " -> " pfmt , name, (old), (new ))) \ |
|---|
| 1211 | : BDBG_MSG(("%s: " pfmt, name, (new) )) \ |
|---|
| 1212 | ) |
|---|
| 1213 | |
|---|
| 1214 | BDBG_MSG(("--------MAI Input Format Change Detection ---- begin ----")); |
|---|
| 1215 | |
|---|
| 1216 | BAPE_PRINT_CHANGE(" Codec from Preamble C", "%s", BAPE_P_GetCodecName(pOldFormatDetectionStatus->codec), BAPE_P_GetCodecName(pNewFormatDetectionStatus->codec) ); |
|---|
| 1217 | BAPE_PRINT_CHANGE(" Num Chans (PCM only) ", "%u", pOldFormatDetectionStatus->numPcmChannels, pNewFormatDetectionStatus->numPcmChannels ); |
|---|
| 1218 | BAPE_PRINT_CHANGE(" Sample Rate ", "%u", pOldFormatDetectionStatus->sampleRate, pNewFormatDetectionStatus->sampleRate ); |
|---|
| 1219 | BAPE_PRINT_CHANGE(" Sample Width ", "%u", pOldFormatDetectionStatus->sampleWidth, pNewFormatDetectionStatus->sampleWidth); |
|---|
| 1220 | BAPE_PRINT_CHANGE(" Signal Present ", "%s", pOldFormatDetectionStatus->signalPresent ? "TRUE" : "false", pNewFormatDetectionStatus->signalPresent ? "TRUE" : "false" ); |
|---|
| 1221 | BAPE_PRINT_CHANGE(" Compressed Flag ", "%s", pOldFormatDetectionStatus->compressed ? "TRUE" : "false", pNewFormatDetectionStatus->compressed ? "TRUE" : "false" ); |
|---|
| 1222 | BAPE_PRINT_CHANGE(" Hi-bitrate (HBR) Flag", "%s", pOldFormatDetectionStatus->hbr ? "TRUE" : "false", pNewFormatDetectionStatus->hbr ? "TRUE" : "false" ); |
|---|
| 1223 | BAPE_PRINT_CHANGE(" Preamble C Valid ", "%s", pOldFormatDetectionStatus->pcValid ? "TRUE" : "false", pNewFormatDetectionStatus->pcValid ? "TRUE" : "false" ); |
|---|
| 1224 | BAPE_PRINT_CHANGE(" Detection Enabled ", "%s", pOldFormatDetectionStatus->detectionEnabled ? "TRUE" : "false", pNewFormatDetectionStatus->detectionEnabled ? "TRUE" : "false" ); |
|---|
| 1225 | |
|---|
| 1226 | BDBG_MSG(("--------MAI Input Format Change Detection ---- end ----")); |
|---|
| 1227 | } |
|---|
| 1228 | |
|---|
| 1229 | BDBG_LEAVE (BAPE_MaiInput_P_DetectInputChange_isr); |
|---|
| 1230 | return; |
|---|
| 1231 | } |
|---|
| 1232 | |
|---|
| 1233 | |
|---|
| 1234 | /**************************************************************************/ |
|---|
| 1235 | |
|---|
| 1236 | static void BAPE_MaiInput_P_SetReceiverOutputFormat_isr (BAPE_MaiInputHandle hMaiInput, BAPE_MaiInputFormatDetectionStatus *pFormatDetectionStatus) |
|---|
| 1237 | { |
|---|
| 1238 | uint32_t outFormatEna; |
|---|
| 1239 | |
|---|
| 1240 | BDBG_ENTER(BAPE_MaiInput_P_SetReceiverOutputFormat_isr); |
|---|
| 1241 | |
|---|
| 1242 | BKNI_ASSERT_ISR_CONTEXT(); |
|---|
| 1243 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 1244 | |
|---|
| 1245 | |
|---|
| 1246 | if ( pFormatDetectionStatus->compressed) |
|---|
| 1247 | { |
|---|
| 1248 | if ( hMaiInput->inputPort.pConsumer && hMaiInput->inputPort.pConsumer->type == BAPE_PathNodeType_eInputCapture ) |
|---|
| 1249 | { |
|---|
| 1250 | outFormatEna = BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, COMP); |
|---|
| 1251 | } |
|---|
| 1252 | else |
|---|
| 1253 | { |
|---|
| 1254 | outFormatEna = BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, PES); |
|---|
| 1255 | } |
|---|
| 1256 | } |
|---|
| 1257 | else |
|---|
| 1258 | { |
|---|
| 1259 | outFormatEna = BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, PCM); |
|---|
| 1260 | } |
|---|
| 1261 | |
|---|
| 1262 | if ( outFormatEna != hMaiInput->outFormatEna ) |
|---|
| 1263 | { |
|---|
| 1264 | hMaiInput->outFormatEna = outFormatEna; /* Update the saved state in the handle. */ |
|---|
| 1265 | |
|---|
| 1266 | BDBG_MSG (("Switching HDMI Receiver output format to %s", |
|---|
| 1267 | (outFormatEna == BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, COMP) ) ? "COMP" : |
|---|
| 1268 | (outFormatEna == BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, PES) ) ? "PES" : |
|---|
| 1269 | (outFormatEna == BAPE_P_BCHP_ENUM(BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, PCM) ) ? "PCM" : |
|---|
| 1270 | "Unknown" )); |
|---|
| 1271 | |
|---|
| 1272 | BAPE_Reg_P_UpdateField_isr(hMaiInput->deviceHandle, |
|---|
| 1273 | BAPE_P_HDMI_RX_CONFIG_REGADDR, |
|---|
| 1274 | BAPE_P_HDMI_RX_CONFIG_REGNAME, OUT_FORMAT_ENA, outFormatEna); |
|---|
| 1275 | } |
|---|
| 1276 | BDBG_LEAVE (BAPE_MaiInput_P_SetReceiverOutputFormat_isr); |
|---|
| 1277 | return; |
|---|
| 1278 | } |
|---|
| 1279 | |
|---|
| 1280 | /**************************************************************************/ |
|---|
| 1281 | |
|---|
| 1282 | static void BAPE_MaiInput_P_UpdateInputPortFormatFields_isr (BAPE_MaiInputHandle hMaiInput, BAPE_MaiInputFormatDetectionStatus *pFormatDetectionStatus) |
|---|
| 1283 | { |
|---|
| 1284 | BAPE_InputPort inputPort; |
|---|
| 1285 | BDBG_ENTER(BAPE_MaiInput_P_UpdateInputPortFormatFields_isr); |
|---|
| 1286 | |
|---|
| 1287 | BKNI_ASSERT_ISR_CONTEXT(); |
|---|
| 1288 | BDBG_OBJECT_ASSERT(hMaiInput, BAPE_MaiInput); |
|---|
| 1289 | |
|---|
| 1290 | inputPort = &hMaiInput->inputPort; |
|---|
| 1291 | BDBG_OBJECT_ASSERT(inputPort, BAPE_InputPort); |
|---|
| 1292 | |
|---|
| 1293 | inputPort->sampleRate = pFormatDetectionStatus->sampleRate; |
|---|
| 1294 | inputPort->compressed = pFormatDetectionStatus->compressed; |
|---|
| 1295 | |
|---|
| 1296 | if ( pFormatDetectionStatus->compressed ) |
|---|
| 1297 | { |
|---|
| 1298 | inputPort->numChannelPairs = 1; |
|---|
| 1299 | } |
|---|
| 1300 | else if ( pFormatDetectionStatus->numPcmChannels > 0 ) |
|---|
| 1301 | { |
|---|
| 1302 | inputPort->numChannelPairs = (((pFormatDetectionStatus->numPcmChannels - 1) / 2) + 1); |
|---|
| 1303 | } |
|---|
| 1304 | else |
|---|
| 1305 | { |
|---|
| 1306 | inputPort->numChannelPairs = 1; /* Probably idle or unknown format... just default to 1 pair. */ |
|---|
| 1307 | } |
|---|
| 1308 | BDBG_MSG (("Updated InputPort format fields: sampleRate:%u, numChannelPairs:%u, compressed:%s", |
|---|
| 1309 | inputPort->sampleRate, |
|---|
| 1310 | inputPort->numChannelPairs, |
|---|
| 1311 | inputPort->compressed ? "TRUE" : "false" )); |
|---|
| 1312 | |
|---|
| 1313 | BDBG_LEAVE (BAPE_MaiInput_P_UpdateInputPortFormatFields_isr); |
|---|
| 1314 | return; |
|---|
| 1315 | } |
|---|
| 1316 | |
|---|
| 1317 | /*************************************************************************** |
|---|
| 1318 | Define stub functions for when there are no MAI inputs. |
|---|
| 1319 | ***************************************************************************/ |
|---|
| 1320 | #else /* BAPE_CHIP_MAX_MAI_INPUTS > 0 */ |
|---|
| 1321 | /* No MAI inputs, just use stubbed out functions. */ |
|---|
| 1322 | |
|---|
| 1323 | /**************************************************************************/ |
|---|
| 1324 | void BAPE_MaiInput_GetDefaultSettings( |
|---|
| 1325 | BAPE_MaiInputSettings *pSettings /* [out] */ |
|---|
| 1326 | ) |
|---|
| 1327 | { |
|---|
| 1328 | BSTD_UNUSED(pSettings); |
|---|
| 1329 | } |
|---|
| 1330 | |
|---|
| 1331 | /**************************************************************************/ |
|---|
| 1332 | |
|---|
| 1333 | BERR_Code BAPE_MaiInput_Open( |
|---|
| 1334 | BAPE_Handle hApe, |
|---|
| 1335 | unsigned index, |
|---|
| 1336 | const BAPE_MaiInputSettings *pSettings, |
|---|
| 1337 | BAPE_MaiInputHandle *phMaiInput /* [out] */ |
|---|
| 1338 | ) |
|---|
| 1339 | { |
|---|
| 1340 | BSTD_UNUSED(hApe); |
|---|
| 1341 | BSTD_UNUSED(index); |
|---|
| 1342 | BSTD_UNUSED(pSettings); |
|---|
| 1343 | BSTD_UNUSED(phMaiInput); |
|---|
| 1344 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 1345 | } |
|---|
| 1346 | |
|---|
| 1347 | /**************************************************************************/ |
|---|
| 1348 | |
|---|
| 1349 | void BAPE_MaiInput_Close( |
|---|
| 1350 | BAPE_MaiInputHandle hMaiInput |
|---|
| 1351 | ) |
|---|
| 1352 | { |
|---|
| 1353 | BSTD_UNUSED(hMaiInput); |
|---|
| 1354 | } |
|---|
| 1355 | |
|---|
| 1356 | /**************************************************************************/ |
|---|
| 1357 | |
|---|
| 1358 | void BAPE_MaiInput_GetSettings( |
|---|
| 1359 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 1360 | BAPE_MaiInputSettings *pSettings /* [out] */ |
|---|
| 1361 | ) |
|---|
| 1362 | { |
|---|
| 1363 | BSTD_UNUSED(hMaiInput); |
|---|
| 1364 | BSTD_UNUSED(pSettings); |
|---|
| 1365 | } |
|---|
| 1366 | |
|---|
| 1367 | /**************************************************************************/ |
|---|
| 1368 | |
|---|
| 1369 | BERR_Code BAPE_MaiInput_SetSettings( |
|---|
| 1370 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 1371 | const BAPE_MaiInputSettings *pSettings |
|---|
| 1372 | ) |
|---|
| 1373 | { |
|---|
| 1374 | BSTD_UNUSED(hMaiInput); |
|---|
| 1375 | BSTD_UNUSED(pSettings); |
|---|
| 1376 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 1377 | } |
|---|
| 1378 | |
|---|
| 1379 | /**************************************************************************/ |
|---|
| 1380 | |
|---|
| 1381 | void BAPE_MaiInput_GetInputPort( |
|---|
| 1382 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 1383 | BAPE_InputPort *pPort |
|---|
| 1384 | ) |
|---|
| 1385 | { |
|---|
| 1386 | BSTD_UNUSED(hMaiInput); |
|---|
| 1387 | BSTD_UNUSED(pPort); |
|---|
| 1388 | } |
|---|
| 1389 | |
|---|
| 1390 | /**************************************************************************/ |
|---|
| 1391 | |
|---|
| 1392 | void BAPE_MaiInput_GetFormatDetectionSettings( |
|---|
| 1393 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 1394 | BAPE_MaiInputFormatDetectionSettings *pSettings /* [out] */ |
|---|
| 1395 | ) |
|---|
| 1396 | { |
|---|
| 1397 | BSTD_UNUSED(hMaiInput); |
|---|
| 1398 | BSTD_UNUSED(pSettings); |
|---|
| 1399 | } |
|---|
| 1400 | |
|---|
| 1401 | /**************************************************************************/ |
|---|
| 1402 | |
|---|
| 1403 | BERR_Code BAPE_MaiInput_SetFormatDetectionSettings( |
|---|
| 1404 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 1405 | const BAPE_MaiInputFormatDetectionSettings *pSettings |
|---|
| 1406 | ) |
|---|
| 1407 | { |
|---|
| 1408 | BSTD_UNUSED(hMaiInput); |
|---|
| 1409 | BSTD_UNUSED(pSettings); |
|---|
| 1410 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 1411 | } |
|---|
| 1412 | |
|---|
| 1413 | /**************************************************************************/ |
|---|
| 1414 | |
|---|
| 1415 | BERR_Code BAPE_MaiInput_GetFormatDetectionStatus( |
|---|
| 1416 | BAPE_MaiInputHandle hMaiInput, |
|---|
| 1417 | BAPE_MaiInputFormatDetectionStatus *pStatus |
|---|
| 1418 | ) |
|---|
| 1419 | { |
|---|
| 1420 | BSTD_UNUSED(hMaiInput); |
|---|
| 1421 | BSTD_UNUSED(pStatus); |
|---|
| 1422 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 1423 | } |
|---|
| 1424 | |
|---|
| 1425 | /**************************************************************************/ |
|---|
| 1426 | |
|---|
| 1427 | BERR_Code BAPE_MaiInput_P_PrepareForStandby(BAPE_Handle hApe) |
|---|
| 1428 | { |
|---|
| 1429 | BSTD_UNUSED(hApe); |
|---|
| 1430 | return BERR_SUCCESS; |
|---|
| 1431 | } |
|---|
| 1432 | |
|---|
| 1433 | /**************************************************************************/ |
|---|
| 1434 | |
|---|
| 1435 | BERR_Code BAPE_MaiInput_P_ResumeFromStandby(BAPE_Handle hApe) |
|---|
| 1436 | { |
|---|
| 1437 | BSTD_UNUSED(hApe); |
|---|
| 1438 | return BERR_SUCCESS; |
|---|
| 1439 | } |
|---|
| 1440 | |
|---|
| 1441 | #endif |
|---|