source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/vdc/7552/bvdc_test.c

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

first commit

  • Property svn:executable set to *
File size: 20.5 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-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: bvdc_test.c $
11 * $brcm_Revision: Hydra_Software_Devel/58 $
12 * $brcm_Date: 2/16/12 1:16p $
13 *
14 * Module Description:
15 *      Header file for Test functions.
16 *
17 * Revision History:
18 *
19 * $brcm_Log: /magnum/portinginterface/vdc/7038/bvdc_test.c $
20 *
21 * Hydra_Software_Devel/58   2/16/12 1:16p pntruong
22 * SW7231-587: Correctly propagate the original pts value to get buffer.
23 *
24 * Hydra_Software_Devel/57   1/27/12 3:53p pntruong
25 * SW7231-587: Allow Original PTS to be passed-through VDC and come out of
26 * GetBuffer() to Nexus to Raaga encode.
27 *
28 * Hydra_Software_Devel/56   1/17/12 5:09p tdo
29 * SW7231-479: Fix GetBuffer_isr function to work with Psf case
30 *
31 * Hydra_Software_Devel/55   12/6/11 4:52p syang
32 * SW7425-1429: quiet error print when no buf available
33 *
34 * Hydra_Software_Devel/54   11/30/11 6:16p syang
35 * SW7425-1429: filter out fixed color buf
36 *
37 * Hydra_Software_Devel/53   11/9/11 6:45p syang
38 * SW7425-1429: fix NULL pHeapNode issue with GetBuffer_isr /
39 * ReturnBuffer_isr  during vnet reconfigure
40 *
41 * Hydra_Software_Devel/52   10/27/11 4:29p syang
42 * SW7425-1429: move per vsync call back from window to display
43 *
44 * Hydra_Software_Devel/51   10/24/11 4:27p syang
45 * SW7425-1429: check in after debug
46 *
47 * Hydra_Software_Devel/50   10/21/11 4:53p syang
48 * SW7425-1429: refined some name sof the data in
49 * BVDC_Test_Window_CapturedImage
50 *
51 * Hydra_Software_Devel/49   10/21/11 11:16a syang
52 * SW7425-1429: added GetBuff_isr and ReturnBuff_isr and per vsync window
53 * call back
54 *
55 * Hydra_Software_Devel/48   4/18/11 8:50a vanessah
56 * SW7425-374: turn on osd for Mcdi debug
57 *
58 * Hydra_Software_Devel/47   11/11/10 7:31p albertl
59 * SW7125-364: Fixed BVDC_P_CbIsDirty and added assert to check bitfields
60 * in dirty bits fit within union integer representation.  Fixed naming
61 * of dirty bits.
62 *
63 * Hydra_Software_Devel/46   6/18/10 4:24p rpan
64 * SW7400-2763: New BVN resource management.
65 *
66 * Hydra_Software_Devel/45   5/7/10 7:20p albertl
67 * SW7125-364: Changed dirty bits to use union structure to avoid type-pun
68 * warnings
69 *
70 * Hydra_Software_Devel/44   4/19/10 10:22p tdo
71 * SW3548-2814: Improvements to VDC ulBlackMagic. Move
72 * BDBG_OBJECT_ID_DECLARE private header files instead of .c.
73 *
74 * Hydra_Software_Devel/43   4/7/10 11:35a tdo
75 * SW3548-2814: Improvements to VDC ulBlackMagic.  Rename TLA
76 *
77 * Hydra_Software_Devel/42   4/5/10 4:14p tdo
78 * SW3548-2814: Improvements to VDC ulBlackMagic
79 *
80 * Hydra_Software_Devel/41   5/31/07 5:39p tdo
81 * PR27216: clean up warnings on VxWorks build
82 *
83 * Hydra_Software_Devel/40   4/12/07 5:37p tdo
84 * PR28837: Provide API to customize LAB LUT
85 *
86 * Hydra_Software_Devel/39   3/28/07 11:15p pntruong
87 * PR28395: Provide API to customize VDEC video quality.  Cleanup dirty
88 * meanings.
89 *
90 * Hydra_Software_Devel/38   3/26/07 3:28p tdo
91 * PR 28401: Provide API to customize CAB LUT and enable/disable CAB
92 *
93 * Hydra_Software_Devel/37   2/12/07 1:51p pntruong
94 * PR27821:  Remove unused lagacy and work-around code (7038) from
95 * mainline.
96 *
97 * Hydra_Software_Devel/36   12/18/06 11:31p pntruong
98 * PR22577: Merged back to mainline.
99 *
100 * Hydra_Software_Devel/Refsw_Devel_3563/2   11/20/06 3:20p tdo
101 * PR 23174:  Add VDC function to overwrite HD_DVI color matrix to output
102 * fix color
103 *
104 * Hydra_Software_Devel/35   8/30/06 11:25p tdo
105 * PR 17994, PR 23383:  Add support for DNR demo mode
106 *
107 * Hydra_Software_Devel/34   8/30/06 6:02p tdo
108 * PR 23212: Remove API for color clip and contrast stretch from test.
109 * They are now in bvdc.h
110 *
111 * Hydra_Software_Devel/33   8/21/06 3:24p yuxiaz
112 * PR20875: Remove unused test API BVDC_Test_Source_SetFeederImageFormat.
113 * Use BVDC_Test_Source_SetFeederImageFormat instead.
114 *
115 * Hydra_Software_Devel/32   5/23/06 5:41p hongtaoz
116 * PR17514: support correct usage mode of DNR; now DNR is available for
117 * any video window and shared between mpeg sources; only one mpeg source
118 * can acquire the DNR at a time;
119 *
120 * Hydra_Software_Devel/31   5/19/06 2:29p hongtaoz
121 * PR17514: added bypass filter enum for DNR setting; disable extreme
122 * filter for 7401a0 due to PR16299; fixed range clamping for DNR
123 * settings; added DNR demo mode setting in test api;
124 *
125 * Hydra_Software_Devel/30   5/19/06 1:49p pntruong
126 * PR21560: Global symbols without BVDC prefix in the BVDC module.  Reduce
127 * unnecessary global exported symbols.  Tighten const params.
128 *
129 * Hydra_Software_Devel/28   3/7/06 4:18p syang
130 * PR 19670: added 7438 support
131 *
132 * Hydra_Software_Devel/27   2/23/06 2:32p tdo
133 * PR 16061: Add filter for max, mid, and min.  Change some variable names
134 * to be more meaningful.  Change the max point to 94 and 95 to reduce
135 * the affect of some white letters suddenly appear on screen.  Increase
136 * precision of some incremental variables
137 *
138 * Hydra_Software_Devel/24   1/31/06 5:20p pntruong
139 * PR17778: Take in changes for new hddvi.
140 *
141 * Hydra_Software_Devel/20   1/12/06 9:58a tdo
142 * PR 16061: Implementing dynamic contrast stretch in the PEP
143 *
144 * Hydra_Software_Devel/19   10/13/05 11:52a hongtaoz
145 * PR17532: added a test API to turn on OSD for deinterlacer;
146 *
147 * Hydra_Software_Devel/18   6/28/05 11:04a jasonh
148 * PR 16012: Adding support for 7401
149 *
150 * Hydra_Software_Devel/17   5/20/05 9:44a tdo
151 * PR 15183: Add sharpness control to the PEP and remove the old TAB
152 * setting
153 *
154 * Hydra_Software_Devel/16   3/17/05 6:41p pntruong
155 * PR14494: Add preliminary software support to 3560 A0.
156 *
157 * Hydra_Software_Devel/15   12/8/04 6:29p hongtaoz
158 * PR9518: each display only has two associated rdc slots;
159 *
160 * Hydra_Software_Devel/14   7/30/04 12:47p tdo
161 * PR11971: Use host write to load CAB and LAB table
162 *
163 * Hydra_Software_Devel/13   7/28/04 11:55a tdo
164 * PR11971: Add CAB and LAB support
165 *
166 ***************************************************************************/
167#include "bvdc_test.h"
168#include "bvdc_display_priv.h"
169#include "bvdc_source_priv.h"
170#include "bvdc_feeder_priv.h"
171#include "bvdc_compositor_priv.h"
172#include "bvdc_pep_priv.h"
173#include "bvdc_mad_priv.h"
174#include "bvdc_mcvp_priv.h"
175#include "bvdc_mcdi_priv.h"
176
177
178BDBG_MODULE(BVDC_TEST);
179
180/*************************************************************************
181 *      BVDC_Test_Display_GetInterruptName
182 *************************************************************************/
183BERR_Code BVDC_Test_Display_GetInterruptName
184        ( BVDC_Display_Handle             hDisplay,
185          const BAVC_Polarity             eFieldId,
186          BINT_Id                        *pInterruptName )
187{
188        BDBG_ENTER(BVDC_Test_Display_GetInterruptName);
189
190        if (!hDisplay)
191        {
192                BDBG_ERR(("Invalid parameter"));
193                return BERR_TRACE(BERR_INVALID_PARAMETER);
194        }
195
196        BDBG_OBJECT_ASSERT(hDisplay->hCompositor, BVDC_CMP);
197
198        if(pInterruptName)
199        {
200                *pInterruptName = BRDC_Slot_GetIntId(
201                        hDisplay->hCompositor->ahSlot[eFieldId == BAVC_Polarity_eBotField]);
202        }
203
204        BDBG_LEAVE(BVDC_Test_Display_GetInterruptName);
205        return BERR_SUCCESS;
206}
207
208/*************************************************************************
209 *      BVDC_Test_Window_SetMadOsd
210 *************************************************************************/
211BERR_Code BVDC_Test_Window_SetMadOsd
212        ( BVDC_Window_Handle               hWindow,
213          bool                             bEnable,
214          uint32_t                         ulHpos,
215          uint32_t                         ulVpos)
216{
217        BVDC_P_Mad_Handle  hMad32 = NULL;
218        BVDC_P_Mcdi_Handle  hMcdi  = NULL;
219        BDBG_ENTER(BVDC_Test_Window_SetMadOsd);
220        BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN);
221
222        hMad32 = hWindow->stCurResource.hMad32;
223
224        hMcdi = hWindow->stCurResource.hMcvp->hMcdi;
225
226        if(!(hMad32 || hMcdi))
227        {
228                BDBG_ERR(("Window %d doesn't support deinterlacing Mad %8x Mcdi%8x", hWindow->eId, hMad32, hMcdi));
229                return BERR_TRACE(BERR_INVALID_PARAMETER);
230        }
231
232        if(hMad32)
233        {
234                /* set new value */
235                hMad32->bEnableOsd = bEnable;
236                /* Note: ulHPos must be an even number due to YUV422 format */
237                hMad32->ulOsdHpos  = ulHpos & (~1);
238                hMad32->ulOsdVpos  = ulVpos;
239        }
240
241        if(hMcdi)
242        {
243                /* set new value */
244                hMcdi->bEnableOsd = bEnable;
245                /* Note: ulHPos must be an even number due to YUV422 format */
246                hMcdi->ulOsdHpos  = ulHpos & (~1);
247                hMcdi->ulOsdVpos  = ulVpos;
248
249        }
250
251        BDBG_LEAVE(BVDC_Test_Window_SetMadOsd);
252        return BERR_SUCCESS;
253}
254
255/*************************************************************************
256 *      BVDC_Test_Window_GetMadOsd
257 *************************************************************************/
258BERR_Code BVDC_Test_Window_GetMadOsd
259        ( BVDC_Window_Handle               hWindow,
260          bool                            *pbEnable,
261          uint32_t                        *pulHpos,
262          uint32_t                        *pulVpos)
263{
264        BVDC_P_Mad_Handle hMad32;
265        BVDC_P_Mcdi_Handle hMcdi = NULL;
266        BDBG_ENTER(BVDC_Test_Window_GetMadOsd);
267        BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN);
268
269        hMad32 = hWindow->stCurResource.hMad32;
270        hMcdi = hWindow->stCurResource.hMcvp->hMcdi;
271        if((!(hMad32 || hMcdi)) ||
272                (!(pbEnable && pulHpos && pulVpos)))
273        {
274                BDBG_ERR(("Mad %8x Mcdi %8x", hMad32, hMcdi));
275                return BERR_TRACE(BERR_INVALID_PARAMETER);
276        }
277        /* Use BREG_Write32 to load table first */
278
279        if(hMad32)
280        {
281                *pbEnable = hMad32->bEnableOsd;
282                *pulHpos  = hMad32->ulOsdHpos;
283                *pulVpos  = hMad32->ulOsdVpos;
284        }
285
286        if(hMcdi)
287        {
288                *pbEnable = hMcdi->bEnableOsd;
289                *pulHpos  = hMcdi->ulOsdHpos;
290                *pulVpos  = hMcdi->ulOsdVpos;
291        }
292
293        BDBG_LEAVE(BVDC_Test_Window_GetMadOsd);
294        return BERR_SUCCESS;
295}
296
297/*************************************************************************
298 *      BVDC_Test_Source_SetFixColor
299 *************************************************************************/
300BERR_Code BVDC_Test_Source_SetFixColor
301        ( BVDC_Source_Handle               hSource,
302          BAVC_Polarity                    eFieldId,
303          bool                             bEnable,
304          uint32_t                         ulRed,
305          uint32_t                         ulGreen,
306          uint32_t                         ulBlue )
307{
308        BVDC_P_Source_Info *pNewInfo;
309        uint32_t ulColorARGB;
310        unsigned int ulFixColorYCrCb;
311
312        BDBG_ENTER(BVDC_Test_Source_SetFixColor);
313        BDBG_OBJECT_ASSERT(hSource, BVDC_SRC);
314        pNewInfo = &hSource->stNewInfo;
315
316        ulColorARGB = BPXL_MAKE_PIXEL(BPXL_eA8_R8_G8_B8, 0x00,
317                ulRed, ulGreen, ulBlue);
318        BPXL_ConvertPixel_RGBtoYCbCr(BPXL_eA8_Y8_Cb8_Cr8, BPXL_eA8_R8_G8_B8,
319                ulColorARGB, &ulFixColorYCrCb);
320
321        BDBG_ERR(("ulFixColorYCrCb[%d] = 0x%x", eFieldId, ulFixColorYCrCb));
322
323        if((hSource->stCurInfo.bFixColorEnable != bEnable) ||
324           (hSource->stCurInfo.aulFixColorYCrCb[eFieldId] != ulFixColorYCrCb) ||
325           (hSource->stNewInfo.bErrorLastSetting))
326        {
327                BVDC_P_Source_DirtyBits *pNewDirty = &pNewInfo->stDirty;
328
329                pNewInfo->bFixColorEnable = bEnable;
330                pNewInfo->aulFixColorYCrCb[eFieldId] = ulFixColorYCrCb;
331
332                /* Dirty bit set */
333                pNewDirty->stBits.bColorspace = BVDC_P_DIRTY;
334        }
335
336        BDBG_LEAVE(BVDC_Test_Source_SetFixColor);
337        return BERR_SUCCESS;
338}
339
340/*************************************************************************
341 *      BVDC_Test_Source_GetFixColor
342 *************************************************************************/
343BERR_Code BVDC_Test_Source_GetFixColor
344        ( BVDC_Source_Handle               hSource,
345          BAVC_Polarity                    eFieldId,
346          bool                            *pbEnable,
347          uint32_t                        *pulRed,
348          uint32_t                        *pulGreen,
349          uint32_t                        *pulBlue )
350{
351        unsigned int ulColorARGB;
352
353        BDBG_ENTER(BVDC_Test_Source_GetFixColor);
354        BDBG_OBJECT_ASSERT(hSource, BVDC_SRC);
355
356        BPXL_ConvertPixel_YCbCrtoRGB(BPXL_eA8_R8_G8_B8, BPXL_eA8_Y8_Cb8_Cr8,
357                hSource->stCurInfo.aulFixColorYCrCb[eFieldId], 0, 0xFF, &ulColorARGB);
358
359        BDBG_ERR(("aulFixColorYCrCb[%d] = 0x%x", eFieldId, hSource->stCurInfo.aulFixColorYCrCb[eFieldId]));
360
361        if(pbEnable)
362        {
363                *pbEnable = hSource->stCurInfo.bFixColorEnable;
364        }
365
366        if(pulRed)
367        {
368                *pulRed   = (uint32_t)BPXL_GET_COMPONENT(BPXL_eA8_R8_G8_B8, ulColorARGB, 2);
369        }
370
371        if(pulGreen)
372        {
373                *pulGreen = (uint32_t)BPXL_GET_COMPONENT(BPXL_eA8_R8_G8_B8, ulColorARGB, 1);
374        }
375
376        if(pulBlue)
377        {
378                *pulBlue  = (uint32_t)BPXL_GET_COMPONENT(BPXL_eA8_R8_G8_B8, ulColorARGB, 0);
379        }
380
381        BDBG_LEAVE(BVDC_Test_Source_GetFixColor);
382        return BERR_SUCCESS;
383}
384
385/***************************************************************************
386 *
387 */
388BERR_Code  BVDC_Test_P_Buffer_ExtractBuffer_isr
389        ( BVDC_P_Buffer_Handle            hBuffer,
390          BVDC_P_PictureNode            **ppPicture )
391{
392        BVDC_P_PictureNode *pPrevReaderNode = NULL, *pTempNode = NULL, *pNextTempNode = NULL;
393
394        /* user will call GetBuffer_isr in the callback function called at the end of reader_isr
395         * at this time, the PrevActiveAndNotUsedByUserNode of hBuffer->pCurReaderBuf is used
396         * by VFD right now, and we give it to user. This leads to correct lypsync. This buffer
397         * will then not be used by VDC PI software until it it returned.  Note: it is OK to have
398         * both user and VFD to read the same buffer. Note: if vnet reconfigure happens, we would
399         * have hBuffer->ulActiveBufCnt as 0, and pPrevReaderNode->pHeapNode might be NULL!!!
400         */
401        BVDC_P_Buffer_GetPrevActiveAndNotUsedByUserNode(pPrevReaderNode, hBuffer->pCurReaderBuf);
402        if ((pPrevReaderNode != hBuffer->pCurWriterBuf) && (pPrevReaderNode->pHeapNode) &&
403                (!pPrevReaderNode->stFlags.bMute) && (!pPrevReaderNode->stFlags.bMuteFixedColor) &&
404                (!pPrevReaderNode->stFlags.bMuteMad))
405        {
406                /* Mark picture node as currently used by user */
407                pPrevReaderNode->stFlags.bUsedByUser = true;
408                pPrevReaderNode->stFlags.bActiveNode = false;
409
410                *ppPicture =pPrevReaderNode;
411
412                /* XXX hSurface should NOT be needed !!!*/
413                /*pTempNode->hSurface = NULL;*/
414
415                /* Decrement active buffer count. */
416                hBuffer->ulActiveBufCnt--;
417                BDBG_MSG(("Extract bufferId %d", pPrevReaderNode->ulBufferId));
418
419                /* Toggle the picture node destination polarity pointed
420                 * to by the next writer and the nodes after it but before the reader. This
421                 * is necessary to keep the field prediction correct.
422                 */
423                BVDC_P_Buffer_GetPrevActiveAndNotUsedByUserNode(pTempNode, hBuffer->pCurReaderBuf);
424
425                while (pTempNode != hBuffer->pCurWriterBuf)
426                {
427                        pTempNode->eDstPolarity = BVDC_P_NEXT_POLARITY(pTempNode->eDstPolarity);
428                        BVDC_P_Buffer_GetPrevActiveAndNotUsedByUserNode(pNextTempNode, pTempNode);
429                        pTempNode = pNextTempNode;
430                } ;
431
432                return BERR_SUCCESS;
433        }
434        else
435        {
436                BDBG_MSG(("Extract bufferId %d, node=0x%x???",
437                                  pPrevReaderNode->ulBufferId, pPrevReaderNode->pHeapNode));
438                return BVDC_ERR_NO_AVAIL_CAPTURE_BUFFER;
439        }
440}
441
442/***************************************************************************
443 * {private}
444 *
445 */
446BERR_Code BVDC_Test_P_Window_CapturePicture_isr
447        ( BVDC_Window_Handle               hWindow,
448          BVDC_P_Window_CapturedPicture   *pCapturedPic )
449{
450        BERR_Code eRet = BERR_SUCCESS;
451        unsigned int          uiPitch;
452
453        BDBG_ENTER(BVDC_Test_P_Window_CapturePicture_isr);
454        BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN);
455        BDBG_ASSERT(pCapturedPic);
456
457        /* Clear content */
458        BKNI_Memset((void*)pCapturedPic, 0x0, sizeof(BVDC_P_Window_CapturedPicture));
459
460        if(hWindow->uiAvailCaptureBuffers)
461        {
462                /* Mark the buffer as used by user */
463                if((eRet = BVDC_Test_P_Buffer_ExtractBuffer_isr(hWindow->hBuffer, &pCapturedPic->pPicture)))
464                {
465                        pCapturedPic->pvBufAddr   = NULL;
466                        pCapturedPic->pvBufAddr_R = NULL;
467                        return eRet;
468                }
469
470                /* Decrement number of capture buffers used */
471                hWindow->uiAvailCaptureBuffers--;
472
473                /* Give the virtual address to convert a picture to a surface. */
474                pCapturedPic->pvBufAddr = pCapturedPic->pPicture->pHeapNode->pvBufAddr;
475
476#if (BVDC_P_SUPPORT_3D_VIDEO)
477                if(pCapturedPic->pPicture->pHeapNode_R != NULL)
478                        pCapturedPic->pvBufAddr_R  = pCapturedPic->pPicture->pHeapNode_R->pvBufAddr;
479                pCapturedPic->eDispOrientation = pCapturedPic->pPicture->eDispOrientation;
480#endif
481
482                /* Get polarity */
483                pCapturedPic->ePolarity = (BVDC_P_VNET_USED_SCALER_AT_WRITER(pCapturedPic->pPicture->stVnetMode)
484                                ? pCapturedPic->pPicture->eDstPolarity : pCapturedPic->pPicture->eSrcPolarity);
485
486                /* Get Pixel Format */
487                pCapturedPic->ePxlFmt = pCapturedPic->pPicture->ePixelFormat;
488
489                /* Get Height */
490                if(pCapturedPic->ePolarity != BAVC_Polarity_eFrame)
491                {
492                        pCapturedPic->ulHeight = pCapturedPic->pPicture->pVfdIn->ulHeight/2;
493                }
494                else
495                {
496                        pCapturedPic->ulHeight = pCapturedPic->pPicture->pVfdIn->ulHeight;
497                }
498
499                /* Get width */
500                pCapturedPic->ulWidth = pCapturedPic->pPicture->pVfdIn->ulWidth;
501
502                /* Get pitch. See ulPitch in BVDC_P_Capture_SetEnable_isr and ulStride in
503                   BVDC_P_Feeder_SetPlaybackInfo_isr */
504                BPXL_GetBytesPerNPixels(pCapturedPic->ePxlFmt,
505                        pCapturedPic->pPicture->pVfdIn->ulWidth, &uiPitch);
506                pCapturedPic->ulPitch = BVDC_P_ALIGN_UP(uiPitch, BVDC_P_PITCH_ALIGN);
507
508                /* Get Original PTS */
509                pCapturedPic->ulOrigPTS = pCapturedPic->pPicture->ulOrigPTS;
510        }
511        else
512        {
513                pCapturedPic->pvBufAddr   = NULL;
514                pCapturedPic->pvBufAddr_R = NULL;
515                eRet = BVDC_ERR_NO_AVAIL_CAPTURE_BUFFER;
516        }
517
518        BDBG_LEAVE(BVDC_Test_P_Window_CapturePicture_isr);
519        return eRet;
520}
521
522/***************************************************************************
523 *
524 */
525BERR_Code BVDC_Test_Window_GetBuffer_isr
526        ( BVDC_Window_Handle              hWindow,
527          BVDC_Test_Window_CapturedImage *pCapturedImage )
528{
529        BERR_Code eRet = BERR_SUCCESS;
530        BVDC_P_Window_CapturedPicture stCaptPic;
531
532        BDBG_ENTER(BVDC_Test_Window_GetBuffer_isr);
533        BDBG_ASSERT(pCapturedImage);
534        BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN);
535
536        eRet = BVDC_Test_P_Window_CapturePicture_isr(hWindow, &stCaptPic);
537        if (eRet == BERR_SUCCESS)
538        {
539                pCapturedImage->pvBufAddr = stCaptPic.pvBufAddr;
540                pCapturedImage->ulWidth = stCaptPic.ulWidth;
541                pCapturedImage->ulHeight = stCaptPic.ulHeight;
542                pCapturedImage->ulPitch = stCaptPic.ulPitch;
543                pCapturedImage->ePxlFmt = stCaptPic.ePxlFmt;
544                pCapturedImage->eCapturePolarity = stCaptPic.ePolarity;
545                pCapturedImage->ulCaptureNumVbiLines = stCaptPic.ulNumVbiLines;
546#if (BVDC_P_SUPPORT_3D_VIDEO)
547                pCapturedImage->pvBufAddrR = stCaptPic.pvBufAddr_R;
548                pCapturedImage->eDispOrientation = stCaptPic.eDispOrientation;
549#else
550                pCapturedImage->pvBufAddrR = NULL;
551#endif
552                pCapturedImage->ulOrigPTS = stCaptPic.ulOrigPTS;
553        }
554        else
555        {
556                pCapturedImage->pvBufAddr  = NULL;
557                pCapturedImage->pvBufAddrR = NULL;
558        }
559
560        BDBG_LEAVE(BVDC_Test_Window_GetBuffer_isr);
561        return eRet;
562        /*return BERR_TRACE(eRet); turn off error print per app request*/
563}
564
565
566/***************************************************************************
567 * {private}
568 *
569 */
570BERR_Code BVDC_Test_P_Window_ReleasePicture_isr
571        ( BVDC_Window_Handle               hWindow,
572          void                            *pvBufAddr )
573{
574        BVDC_P_PictureNode *pPicture;
575        uint32_t cnt = 0;
576
577        BDBG_ENTER(BVDC_Test_P_Window_ReleasePicture_isr);
578        BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN);
579
580        pPicture = hWindow->hBuffer->pCurReaderBuf;
581        /* during vnet reconfigure, we might have pPicture->pHeapNode as NULL */
582        while ((!pPicture->pHeapNode || (pvBufAddr != pPicture->pHeapNode->pvBufAddr)) &&
583                   (cnt < BVDC_P_MAX_USER_CAPTURE_BUFFER_COUNT))
584        {
585                BVDC_P_Buffer_GetNextUsedByUserNode(pPicture, pPicture);
586                cnt++;
587        }
588
589        if(cnt >= BVDC_P_MAX_USER_CAPTURE_BUFFER_COUNT)
590        {
591                /* likely it is during vnet reconfigure, what we should do with this
592                 * return? does vnet reconfigure free and reset flag for all active and
593                 * usedByUser buffers? */
594                BDBG_MSG(("return mistached buffer, 0x%x???", pvBufAddr));
595                return BERR_TRACE(BVDC_ERR_CAPTURED_BUFFER_NOT_FOUND);
596        }
597        else
598        {
599                BDBG_MSG(("return bufferId %d, addr 0x%x; Is Used? %d",
600                                  pPicture->ulBufferId, pPicture->pHeapNode->pvBufAddr,
601                                  pPicture->stFlags.bUsedByUser));
602                BVDC_P_Buffer_ReturnBuffer_isr(hWindow->hBuffer, pPicture);
603                hWindow->uiAvailCaptureBuffers++;
604        }
605
606        BDBG_LEAVE(BVDC_Test_P_Window_ReleasePicture_isr);
607        return BERR_SUCCESS;
608}
609
610/***************************************************************************
611 *
612 */
613BERR_Code BVDC_Test_Window_ReturnBuffer_isr
614        ( BVDC_Window_Handle               hWindow,
615          BVDC_Test_Window_CapturedImage  *pCapturedImage )
616{
617        BERR_Code eRet = BERR_SUCCESS;
618
619        BDBG_ENTER(BVDC_Test_Window_ReturnBuffer_isr);
620        BDBG_ASSERT(pCapturedImage);
621        BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN);
622
623        if (pCapturedImage->pvBufAddr)
624        {
625                eRet = BVDC_Test_P_Window_ReleasePicture_isr(hWindow, pCapturedImage->pvBufAddr);
626                if (eRet != BERR_SUCCESS)
627                {
628                        return BERR_TRACE(eRet);
629                }
630        }
631
632        /* syang: the following is copied from BVDC_Winow_ReturnBuffer,
633           but looks wrong to me
634#if (BVDC_P_SUPPORT_3D_VIDEO)
635        if (pCapturedImage->pvBufAddrR)
636        {
637                eRet = BVDC_Test_P_Window_ReleasePicture_isr(hWindow, pCapturedImage->pvBufAddrR);
638                if (eRet != BERR_SUCCESS)
639                {
640                        return BERR_TRACE(eRet);
641                }
642        }
643#endif
644        */
645
646        BDBG_LEAVE(BVDC_Test_Window_ReturnBuffer_isr);
647        return BERR_SUCCESS;
648}
649
650/* End of File */
Note: See TracBrowser for help on using the repository browser.