source: svn/trunk/newcon3bcm2_21bu/magnum/syslib/pcrlib/7552/bpcrlib_xvd.c

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 6.4 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2007, 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_xvd.c $
11 * $brcm_Revision: Hydra_Software_Devel/23 $
12 * $brcm_Date: 10/5/07 9:47a $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/syslib/pcrlib/7118/bpcrlib_xvd.c $
19 *
20 * Hydra_Software_Devel/23   10/5/07 9:47a mward
21 * PR25109 : use _isr function, as for
22 * BPCRlib_Audio_GetCdbLevel_Rap_isr().
23 *
24 * Hydra_Software_Devel/22   6/7/07 7:05p bandrews
25 * PR31945: fixed
26 *
27 * Hydra_Software_Devel/21   12/4/06 1:39p erickson
28 * PR26295: only call BXPT_PcrOffset_RegenOffset_isr on request_stc, not
29 * pts_error. this requires a new param to UpdateStc.
30 *
31 * Hydra_Software_Devel/20   11/22/06 11:33a erickson
32 * PR26126: call BXPT_PcrOffset_RegenOffset_isr when live-mode PTS
33 * interrupts are received. this ensures the decoders will see a valid
34 * PCR OFFSET when system is configured with non-zero
35 * PCR_OFFSET.OFFSET_THRESHOLD.
36 *
37 * Hydra_Software_Devel/19   10/2/06 4:13p vsilyaev
38 * PR 23826: Fixed comparison on module arithmetic
39 *
40 * Hydra_Software_Devel/18   9/14/06 3:36p jgarrett
41 * PR 23982: Removing release mode compiler warning.
42 *
43 * Hydra_Software_Devel/17   8/9/06 1:12p erickson
44 * PR20199: don't reset the STC if already very close. small adjustments
45 * cause raptor glitches because it's trying to maintain a tight TSM
46 * threshold window.
47 *
48 * Hydra_Software_Devel/16   7/21/06 9:08a dlwin
49 * PR 14429: Fix compiler warning.
50 *
51 * Hydra_Software_Devel/15   5/10/06 4:47p davidp
52 * PR20566: BXVD_SetSTCInvalidFlag changed to BXVD_SetSTCInvalidFlag_isr
53 *
54 * Hydra_Software_Devel/14   4/11/06 2:32p erickson
55 * PR20399: moved TODO
56 *
57 * Hydra_Software_Devel/13   4/4/06 10:07p erickson
58 * PR20566: BXVD_SetSTCInvalidFlag is now called after pcrlib sets STC
59 *
60 * Hydra_Software_Devel/12   2/9/06 12:30p erickson
61 * PR19445: convert BXPT_PcrOffset calls to _isr flavors
62 *
63 * Hydra_Software_Devel/11   2/3/06 3:50p vsilyaev
64 * PR 18642: Update PCRlibrary to support playback of constant bitrate
65 * streams
66 *
67 * Hydra_Software_Devel/10   11/11/05 3:28p erickson
68 * PR17108: fix for 97398
69 *
70 * Hydra_Software_Devel/9   11/11/05 12:57p erickson
71 * PR17108: calculate correct STC for 7401
72 *
73 * Hydra_Software_Devel/8   10/4/05 9:11a erickson
74 * PR17108: modified for XPT api changes
75 *
76 * Hydra_Software_Devel/7   9/28/05 5:37p erickson
77 * PR17108: don't call BXVD_GetSTC yet
78 *
79 * Hydra_Software_Devel/6   9/23/05 12:51p erickson
80 * PR17108: initial 97401 checkin
81 *
82 * Hydra_Software_Devel/5   8/29/05 6:24p vsilyaev
83 * PR 16685,PR15967: Added use of UpdateStc function.
84 *
85 * Hydra_Software_Devel/4   8/16/05 3:53p vsilyaev
86 * PR 15967: Added debug traces.
87 *
88 * Hydra_Software_Devel/3   8/9/05 2:32p vsilyaev
89 * PR 15967: Use both aux transport and decoder to access STC.
90 *
91 * Hydra_Software_Devel/2   8/5/05 3:08p vsilyaev
92 * PR 15967: Use _isr versions of appropriate functions
93 *
94 * Hydra_Software_Devel/1   6/24/05 3:50p vsilyaev
95 * PR 15967: 7038 implementation of the audio/video interface.
96 *
97 ***************************************************************************/
98
99#include "bstd.h"
100#include "bpcrlib.h"
101#include "bpcrlib_xvd.h"
102#include "bxvd.h"
103#ifndef BCHP_7411_VER
104#include "bxpt_pcr_offset.h"
105#endif
106
107BDBG_MODULE(pcrlib);
108
109static BERR_Code
110BPCRlib_Video_GetStc_XVD_isr(void *trp, void *dec, uint32_t *stc)
111{
112        BSTD_UNUSED(dec);
113        BDBG_MSG(("VID_XVD:GetStc %#x %#x", (unsigned)trp, (unsigned)dec));
114#ifdef BCHP_7411_VER
115        return BARC_GetSTC_isr(trp, stc);
116#else
117        *stc = BXPT_PcrOffset_GetStc_isr(trp) + BXPT_PcrOffset_GetOffset_isr(trp);
118        return BERR_SUCCESS;
119#endif
120}
121
122static BERR_Code
123BPCRlib_Video_GetPts_XVD_isr(void *dec, BAVC_PTSInfo *pts)
124{
125        BXVD_PTSInfo                    PTSInfo;
126        BERR_Code rc;
127        const BPCRlib_Xvd_Decoder *xvd=dec;
128
129        BDBG_MSG(("VID_XVD:GetPts %#x", (unsigned)dec));
130        rc = BXVD_GetPTS_isr(xvd->dec, &PTSInfo);
131#ifdef BCHP_7411_VER
132        pts->ui32CurrentPTS = PTSInfo.ulCurrentPTS;
133#else
134        pts->ui32CurrentPTS = PTSInfo.ui32RunningPTS;
135#endif
136        pts->ePTSType = PTSInfo.ePTSType;
137       
138        return rc;
139}
140
141BERR_Code
142BPCRlib_Video_GetCdbLevel_XVD_isr(void *dec, unsigned *level)
143{
144        const BPCRlib_Xvd_Decoder *xvd=dec;
145#ifdef BCHP_7411_VER
146        unsigned size;
147        return BXVD_GetCPBInfo_isr(xvd->dec, &size, level);
148#else
149        BXPT_Rave_BufferInfo buffer_info;
150        BERR_Code rc;
151
152        BDBG_ASSERT(xvd->rave);
153        rc = BXPT_Rave_GetBufferInfo_isr(xvd->rave, &buffer_info);
154        if (rc==BERR_SUCCESS) {
155                *level = buffer_info.CdbDepth;
156        }
157        return rc;
158#endif
159}
160
161static BERR_Code
162BPCRlib_Video_SetStc_XVD_isr(void *trp, void *dec, bool dss,uint32_t stc)
163{
164        const BPCRlib_Xvd_Decoder *xvd=dec;
165        BERR_Code rc = BERR_SUCCESS;
166        BSTD_UNUSED(dss);
167        BSTD_UNUSED(xvd);
168
169        BDBG_MSG(("VID_XVD:SetStc %#x %#x", (unsigned)trp, (unsigned)dec));
170#ifdef BCHP_7411_VER
171        BSTD_UNUSED(dec);
172        BSTD_UNUSED(xvd);
173        rc = BARC_SetSTC_isr(trp, stc);
174#else
175        {
176                uint32_t current_stc;
177                int32_t diff;
178       
179                current_stc = BXPT_PcrOffset_GetStc_isr(trp);
180                diff = (int32_t)current_stc - (int32_t)stc;
181                /* If the STC is already very close, there's no point in resetting it. This     
182                prevents PTS Errors from raptor which tries to follow a tight TSM threshold. */
183                if (diff > 100 || diff < -100) {
184                        /* assume that PCR_OFFSET offset was set to 0 by host before starting PVR. */
185                        rc = BXPT_PcrOffset_SetStc_isr(trp, stc);
186                }
187        }
188       
189        /* notify decoders that STC is now valid */
190        if (rc==BERR_SUCCESS) {
191                rc = BXVD_SetSTCInvalidFlag_isr(xvd->dec, false);
192        }
193#endif
194
195        return rc;
196}
197
198static BERR_Code
199BPCRlib_Video_UpdateStc_XVD_isr(void *trp, bool is_request_stc)
200{
201        BDBG_MSG(("XVD::UpdateStc %#x", (unsigned)trp));
202#ifdef BCHP_7411_VER
203        BSTD_UNUSED(is_request_stc);
204        return BARC_UpdateSTC_isr(trp);
205#else
206        if (is_request_stc) {
207                /* If PCR_OFFSET block has non-zero OFFSET_THRESHOLD, then it needs
208                to be forced to regenerate an offset message to RAVE. Otherwise the decoder
209                may lose a pcr_offset_valid message. */
210                BXPT_PcrOffset_RegenOffset_isr(trp);
211        }
212        return 0;
213#endif
214}
215
216
217const BPCRlib_StcDecIface BPCRlib_Video_Xvd = {
218        BPCRlib_Video_GetPts_XVD_isr,
219        BPCRlib_Video_GetStc_XVD_isr,
220        BPCRlib_Video_GetCdbLevel_XVD_isr,
221        BPCRlib_Video_SetStc_XVD_isr, 
222        BPCRlib_Video_UpdateStc_XVD_isr, 
223        true
224};
225
Note: See TracBrowser for help on using the repository browser.