| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2005-2008, 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: bpcrlib_rap.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/20 $ |
|---|
| 12 | * $brcm_Date: 3/21/08 11:25a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/syslib/pcrlib/7038/bpcrlib_rap.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/20 3/21/08 11:25a katrep |
|---|
| 21 | * PR40812:Add support for RAP PI 3.0 new FW arch |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/19 10/4/07 11:59a gmohile |
|---|
| 24 | * PR 25109 : use _isr function |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/18 8/23/07 11:28a katrep |
|---|
| 27 | * PR27643: Use BRAP_SetStcValidFlag_isr now available wit phase 0.5 |
|---|
| 28 | * raptor |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/17 7/20/07 12:30p katrep |
|---|
| 31 | * PR27643: Added support for RAP PI 2.0 required for 7405 |
|---|
| 32 | * |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/16 2/28/07 9:02p jgarrett |
|---|
| 35 | * PR 25900: Updating call to BXPT_PcrOffset_GetStc_isr |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/15 12/5/06 1:57p ahulse |
|---|
| 38 | * PR26295: Suppress warning for unused bool when building for 7411 |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/14 12/4/06 1:39p erickson |
|---|
| 41 | * PR26295: only call BXPT_PcrOffset_RegenOffset_isr on request_stc, not |
|---|
| 42 | * pts_error. this requires a new param to UpdateStc. |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/13 11/22/06 11:33a erickson |
|---|
| 45 | * PR26126: call BXPT_PcrOffset_RegenOffset_isr when live-mode PTS |
|---|
| 46 | * interrupts are received. this ensures the decoders will see a valid |
|---|
| 47 | * PCR OFFSET when system is configured with non-zero |
|---|
| 48 | * PCR_OFFSET.OFFSET_THRESHOLD. |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/12 10/2/06 4:13p vsilyaev |
|---|
| 51 | * PR 23826: Fixed comparison on module arithmetic |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/11 9/14/06 3:36p jgarrett |
|---|
| 54 | * PR 23982: Removing release mode compiler warning. |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/10 8/9/06 1:12p erickson |
|---|
| 57 | * PR20199: don't reset the STC if already very close. small adjustments |
|---|
| 58 | * cause raptor glitches because it's trying to maintain a tight TSM |
|---|
| 59 | * threshold window. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/9 2/3/06 3:50p vsilyaev |
|---|
| 62 | * PR 18642: Update PCRlibrary to support playback of constant bitrate |
|---|
| 63 | * streams |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/PR18642/1 1/19/06 6:16p vsilyaev |
|---|
| 66 | * PR18642: Use PTS offset to control buffer depth in the decoders |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/8 11/11/05 12:57p erickson |
|---|
| 69 | * PR17108: calculate correct STC for 7401 |
|---|
| 70 | * |
|---|
| 71 | * Hydra_Software_Devel/7 10/4/05 9:11a erickson |
|---|
| 72 | * PR17108: modified for XPT api changes |
|---|
| 73 | * |
|---|
| 74 | * Hydra_Software_Devel/6 9/23/05 12:51p erickson |
|---|
| 75 | * PR17108: initial 97401 checkin |
|---|
| 76 | * |
|---|
| 77 | * Hydra_Software_Devel/5 8/29/05 6:24p vsilyaev |
|---|
| 78 | * PR 16685,PR15967: Added use of UpdateStc function. |
|---|
| 79 | * |
|---|
| 80 | * Hydra_Software_Devel/4 8/16/05 3:53p vsilyaev |
|---|
| 81 | * PR 15967: Added debug traces. |
|---|
| 82 | * |
|---|
| 83 | * Hydra_Software_Devel/3 8/9/05 2:32p vsilyaev |
|---|
| 84 | * PR 15967: Use both aux transport and decoder to access STC. |
|---|
| 85 | * |
|---|
| 86 | * Hydra_Software_Devel/2 8/5/05 3:08p vsilyaev |
|---|
| 87 | * PR 15967: Use _isr versions of appropriate functions |
|---|
| 88 | * |
|---|
| 89 | * Hydra_Software_Devel/1 7/21/05 12:36p vsilyaev |
|---|
| 90 | * PR 15967: Added raptor STC interface |
|---|
| 91 | * |
|---|
| 92 | ***************************************************************************/ |
|---|
| 93 | |
|---|
| 94 | #include "bstd.h" |
|---|
| 95 | #include "bpcrlib.h" |
|---|
| 96 | #include "bpcrlib_rap.h" |
|---|
| 97 | #ifndef BCHP_7411_VER |
|---|
| 98 | #include "bxpt_pcr_offset.h" |
|---|
| 99 | #endif |
|---|
| 100 | |
|---|
| 101 | #if BRAP_VER >= 2 |
|---|
| 102 | #define BRAP_DSPCHN_GetCurrentPTS_isr(x,Y) BRAP_GetCurrentPTS_isr(x,Y) |
|---|
| 103 | #define BRAP_DSPCHN_SetStcValidFlag_isr(x) BRAP_SetStcValidFlag_isr(x) |
|---|
| 104 | #endif |
|---|
| 105 | |
|---|
| 106 | BDBG_MODULE(pcrlib); |
|---|
| 107 | |
|---|
| 108 | static BERR_Code |
|---|
| 109 | BPCRlib_Audio_GetStc_Rap_isr(void *trp, void *dec, uint32_t *stc) |
|---|
| 110 | { |
|---|
| 111 | BSTD_UNUSED(dec); |
|---|
| 112 | BDBG_MSG(("RAP:GetStc %#x %#x", (unsigned)trp, (unsigned)dec)); |
|---|
| 113 | #ifdef BCHP_7411_VER |
|---|
| 114 | return BARC_GetSTC_isr(trp, stc); |
|---|
| 115 | #else |
|---|
| 116 | *stc = BXPT_PcrOffset_GetStc_isr(trp) + BXPT_PcrOffset_GetOffset_isr(trp); |
|---|
| 117 | return BERR_SUCCESS; |
|---|
| 118 | #endif |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | static BERR_Code |
|---|
| 122 | BPCRlib_Audio_GetPts_Rap_isr(void *dec, BAVC_PTSInfo *pts) |
|---|
| 123 | { |
|---|
| 124 | BRAP_DSPCHN_PtsInfo PTSInfo; |
|---|
| 125 | BERR_Code rc; |
|---|
| 126 | const BPCRlib_Rap_Decoder *rap=dec; |
|---|
| 127 | |
|---|
| 128 | BDBG_MSG(("RAP:GetPts %#x", (unsigned)dec)); |
|---|
| 129 | rc = BRAP_DSPCHN_GetCurrentPTS_isr(rap->dec, &PTSInfo); |
|---|
| 130 | pts->ui32CurrentPTS = PTSInfo.ui32RunningPts; |
|---|
| 131 | pts->ePTSType = PTSInfo.ePtsType; |
|---|
| 132 | |
|---|
| 133 | return rc; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | static BERR_Code |
|---|
| 137 | BPCRlib_Audio_GetCdbLevel_Rap_isr(void *dec, unsigned *level) |
|---|
| 138 | { |
|---|
| 139 | const BPCRlib_Rap_Decoder *rap=dec; |
|---|
| 140 | #ifdef BCHP_7411_VER |
|---|
| 141 | return BRAP_TRANS_GetCdbOccupancy_isr(rap->trans, level); |
|---|
| 142 | #else |
|---|
| 143 | BXPT_Rave_BufferInfo buffer_info; |
|---|
| 144 | BERR_Code rc; |
|---|
| 145 | |
|---|
| 146 | BDBG_ASSERT(rap->rave); |
|---|
| 147 | rc = BXPT_Rave_GetBufferInfo_isr(rap->rave, &buffer_info); |
|---|
| 148 | if (rc==BERR_SUCCESS) { |
|---|
| 149 | *level = buffer_info.CdbDepth; |
|---|
| 150 | } |
|---|
| 151 | return rc; |
|---|
| 152 | #endif |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | static BERR_Code |
|---|
| 157 | BPCRlib_Audio_SetStc_Rap_isr(void *trp, void *dec, bool dss, uint32_t stc) |
|---|
| 158 | { |
|---|
| 159 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 160 | const BPCRlib_Rap_Decoder *rap=dec; |
|---|
| 161 | BSTD_UNUSED(dss); |
|---|
| 162 | |
|---|
| 163 | BDBG_MSG(("RAP:SetStc %#x %#x", (unsigned)trp, (unsigned)dec)); |
|---|
| 164 | |
|---|
| 165 | #ifdef BCHP_7411_VER |
|---|
| 166 | rc = BARC_SetSTC_isr(trp, stc); |
|---|
| 167 | #else |
|---|
| 168 | { |
|---|
| 169 | uint32_t current_stc; |
|---|
| 170 | int32_t diff; |
|---|
| 171 | |
|---|
| 172 | current_stc = BXPT_PcrOffset_GetStc_isr(trp); |
|---|
| 173 | diff = (int32_t)current_stc - (int32_t)stc; |
|---|
| 174 | /* If the STC is already very close, there's no point in resetting it. This |
|---|
| 175 | prevents PTS Errors from raptor which tries to follow a tight TSM threshold. */ |
|---|
| 176 | if (diff > 100 || diff < -100) { |
|---|
| 177 | /* assume that PCR_OFFSET offset was set to 0 by host before starting PVR. */ |
|---|
| 178 | rc = BXPT_PcrOffset_SetStc_isr(trp, stc); |
|---|
| 179 | } |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | #endif |
|---|
| 183 | if (rc==BERR_SUCCESS) { |
|---|
| 184 | rc = BRAP_DSPCHN_SetStcValidFlag_isr(rap->dec); |
|---|
| 185 | } |
|---|
| 186 | return rc; |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | static BERR_Code |
|---|
| 190 | BPCRlib_Audio_UpdateStc_Rap_isr(void *trp, bool is_request_stc) |
|---|
| 191 | { |
|---|
| 192 | BDBG_MSG(("RAP::UpdateStc %#x", (unsigned)trp)); |
|---|
| 193 | #ifdef BCHP_7411_VER |
|---|
| 194 | BSTD_UNUSED(is_request_stc); |
|---|
| 195 | return BARC_UpdateSTC_isr(trp); |
|---|
| 196 | #else |
|---|
| 197 | if (is_request_stc) { |
|---|
| 198 | /* If PCR_OFFSET block has non-zero OFFSET_THRESHOLD, then it needs |
|---|
| 199 | to be forced to regenerate an offset message to RAVE. Otherwise the decoder |
|---|
| 200 | may lose a pcr_offset_valid message. */ |
|---|
| 201 | BXPT_PcrOffset_RegenOffset_isr(trp); |
|---|
| 202 | } |
|---|
| 203 | return 0; |
|---|
| 204 | #endif |
|---|
| 205 | } |
|---|
| 206 | |
|---|
| 207 | const BPCRlib_StcDecIface BPCRlib_Audio_Rap = { |
|---|
| 208 | BPCRlib_Audio_GetPts_Rap_isr, |
|---|
| 209 | BPCRlib_Audio_GetStc_Rap_isr, |
|---|
| 210 | BPCRlib_Audio_GetCdbLevel_Rap_isr, |
|---|
| 211 | BPCRlib_Audio_SetStc_Rap_isr, |
|---|
| 212 | BPCRlib_Audio_UpdateStc_Rap_isr, /* no update STC */ |
|---|
| 213 | true |
|---|
| 214 | }; |
|---|
| 215 | |
|---|