blit.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:9k
源码类别:

DVD

开发平台:

C/C++

  1. /*****************************************************************************
  2. File name: blit.c
  3. Description: blit setup
  4. COPYRIGHT (C) 2004 STMicroelectronics
  5. *****************************************************************************/
  6. /* Includes --------------------------------------------------------------- */
  7. #include <string.h>
  8. #include "stddefs.h"
  9. #include "stdevice.h"
  10. #include "sttbx.h"
  11. #include "gendef.h"
  12. #include "section.h"
  13. #include "errors.h"
  14. #include "evt.h" /* for KB_EVT_OSD */
  15. #include "avmem.h"
  16. #include "blit.h"
  17. #include "osd.h"
  18. #include "osp.h"
  19. /* Private Macros --------------------------------------------------------- */
  20. #define NODE_MAX_NUMBER             1024
  21. #define WORK_BUFFER_SIZE            1024
  22. /* Private Types ---------------------------------------------------------- */
  23. /* Private Constants ------------------------------------------------------ */
  24. /* Private Variables ------------------------------------------------------ */
  25. /* Private Function prototypes -------------------------------------------- */
  26. static ST_ErrorCode_t BLIT_InitContext(STBLIT_BlitContext_t * BlitContext_p);
  27. /* Constants -------------------------------------------------------------- */
  28. /* Global Variables ------------------------------------------------------- */
  29. ST_DeviceName_t BLIT_DeviceName = "BLIT";
  30. STBLIT_Handle_t BLIT_Handle;
  31. STBLIT_BlitContext_t GtBlitContext;
  32. /* Functions -------------------------------------------------------------- */
  33. /*-----------------------------------------------------------------------------
  34.  * Function : BLIT_Init
  35.  *
  36.  * Input    :
  37.  * Output   :
  38.  * --------------------------------------------------------------------------*/
  39. ST_ErrorCode_t BLIT_Setup(void)
  40. {
  41.     ST_ErrorCode_t          ErrCode;
  42.     STBLIT_InitParams_t     InitParams;
  43.     STBLIT_OpenParams_t     OpenParams;
  44.     #if 1
  45.     InitParams.DeviceType                 = STBLIT_DEVICE_TYPE_BDISP_5105;
  46.     InitParams.BaseAddress_p              = (void*)BLITTER_BASE_ADDRESS;
  47.     InitParams.SharedMemoryBaseAddress_p  = (void*)SDRAM_BASE_ADDRESS;
  48.     InitParams.BlitInterruptEvent         = STBLIT_BLIT_COMPLETED_EVT;
  49.     InitParams.CPUPartition_p             = SystemPartition;
  50.     InitParams.AVMEMPartition             = g_KBAvmemPartitionHandle[0];
  51.     strcpy(InitParams.EventHandlerName, g_KB_EVTDeviceName[KB_EVT_OSD]);
  52.     InitParams.MaxHandles                 = 2;
  53.     InitParams.SingleBlitNodeBufferUserAllocated = FALSE;
  54.     InitParams.SingleBlitNodeMaxNumber    = NODE_MAX_NUMBER;
  55.     InitParams.SingleBlitNodeBuffer_p     = NULL;
  56.     InitParams.JobBlitNodeBufferUserAllocated    = FALSE;
  57.     InitParams.JobBlitNodeMaxNumber       = 1;
  58.     InitParams.JobBlitNodeBuffer_p        = NULL;
  59.     InitParams.JobBlitBufferUserAllocated = FALSE;
  60.     InitParams.JobBlitMaxNumber           = 1;
  61.     InitParams.JobBlitBuffer_p            = NULL;
  62.     InitParams.JobBufferUserAllocated     = FALSE;
  63.     InitParams.JobMaxNumber               = 1;
  64.     InitParams.JobBuffer_p                = NULL;
  65.     InitParams.WorkBufferUserAllocated    = FALSE;
  66.     InitParams.WorkBufferSize             = WORK_BUFFER_SIZE;
  67.     InitParams.WorkBuffer_p               = NULL;
  68.     InitParams.BigNotLittle               = FALSE;
  69.     InitParams.BlitInterruptNumber        = BLIT_INTERRUPT;
  70.     InitParams.BlitInterruptLevel         = BLIT_INTERRUPT_LEVEL;
  71.     #else
  72.     
  73.         InitParams.SingleBlitNodeMaxNumber = 100; //500; //TTM 4000;
  74.         
  75.         InitParams.JobBlitNodeMaxNumber    = 1;
  76.         InitParams.JobBlitMaxNumber        = 1;
  77.         InitParams.JobMaxNumber            = 1;
  78.         InitParams.WorkBufferSize          = WORK_BUFFER_SIZE;
  79.         /*TMTM note: MinWorkBufferSize             = STBLIT_DEFAULT_FILTER_BUFFER_SIZE + STBLIT_ALPHA4TO8_CONVERSION_PALETTE_SIZE;
  80.         //size to store the 5-TAP filter coefficients + Alpha4 to Alpha8 conversion palette */
  81.         InitParams.CPUPartition_p = SystemPartition;
  82.         
  83.         InitParams.DeviceType    = STBLIT_DEVICE_TYPE_BDISP_5105;
  84.         
  85.         InitParams.BaseAddress_p = (void*)BLITTER_BASE_ADDRESS;
  86.      /* (STBLIT_EMULATOR == TRUE) */
  87.         InitParams.AVMEMPartition = g_KBAvmemPartitionHandle[0];
  88.         InitParams.SharedMemoryBaseAddress_p = (void *)SDRAM_BASE_ADDRESS;
  89.         strcpy( InitParams.EventHandlerName, g_KB_EVTDeviceName[KB_EVT_OSD]);
  90.         InitParams.BlitInterruptEvent           = STBLIT_BLIT_COMPLETED_EVT;
  91.         InitParams.BlitInterruptNumber          = BLIT_INTERRUPT;
  92.         InitParams.BlitInterruptLevel           = BLIT_INTERRUPT_LEVEL;
  93.         InitParams.MaxHandles                   = 5;
  94.         InitParams.SingleBlitNodeBufferUserAllocated = FALSE;
  95.         InitParams.SingleBlitNodeBuffer_p            = NULL;
  96.         InitParams.JobBlitNodeBufferUserAllocated    = FALSE;
  97.         //InitParams.JobBlitNodeMaxNumber       = 400;
  98.         InitParams.JobBlitNodeBuffer_p               = NULL;
  99.         InitParams.JobBlitBufferUserAllocated        = FALSE;
  100.         InitParams.JobBlitBuffer_p                   = NULL;
  101.         InitParams.JobBufferUserAllocated            = FALSE;
  102.         InitParams.JobBuffer_p                       = NULL;
  103.         InitParams.WorkBufferUserAllocated           = FALSE;
  104.         InitParams.WorkBuffer_p                      = NULL;
  105.         InitParams.BigNotLittle                      = FALSE;
  106.         
  107.     #endif
  108.     STTBX_Print(("BLIT_Setup(%s)=",BLIT_DeviceName));
  109.     ErrCode = STBLIT_Init(BLIT_DeviceName, &InitParams);
  110.     if (ErrCode != ST_NO_ERROR)
  111.     {
  112.         STTBX_Print(("%sn", DBGError(ErrCode)));
  113.         return( ErrCode );
  114.     }
  115.     ErrCode = STBLIT_Open(BLIT_DeviceName, &OpenParams, &BLIT_Handle);
  116.     if (ErrCode != ST_NO_ERROR)
  117.     {
  118.         STTBX_Print(("%sn", DBGError(ErrCode)));
  119.         return( ErrCode );
  120.     }
  121.     
  122.     STTBX_Print(("%sn", STBLIT_GetRevision()));
  123.     memset(&GtBlitContext, 0, sizeof(STBLIT_BlitContext_t));
  124.     BLIT_InitContext(&GtBlitContext);
  125.     return (ErrCode);
  126. } /* end BLIT_Init */
  127. static ST_ErrorCode_t BLIT_InitContext(STBLIT_BlitContext_t * BlitContext_p)
  128. {
  129.     STEVT_DeviceSubscribeParams_t EvtSubscribeParams;
  130.     ST_ErrorCode_t          Err;
  131.     STEVT_SubscriberID_t    SubscriberID;
  132.     
  133.     BlitContext_p->ColorKeyCopyMode          = STBLIT_COLOR_KEY_MODE_NONE;
  134.     /* BlitContext_p->ColorKey                  = 0; undefined */
  135.     BlitContext_p->AluMode                   = STBLIT_ALU_COPY;
  136.     BlitContext_p->EnableMaskWord            = FALSE;
  137.     /* BlitContext_p->MaskWord */
  138.     BlitContext_p->EnableMaskBitmap          = FALSE;
  139.     /* BlitContext_p->MaskBitmap_p */
  140.     /* BlitContext_p->MaskRectangle */
  141.     /* BlitContext_p->WorkBuffer_p = ((stgfx_Unit_t*)Handle)->BdfFgndWB_p; */
  142.     /* BlitContext_p->WorkBuffer_p = KB_OSDAllocate(200, 200); */
  143.     BlitContext_p->EnableColorCorrection     = FALSE;
  144.     /* BlitContext_p->ColorCorrectionTable_p */
  145.     #if 1
  146.     BlitContext_p->Trigger.EnableTrigger     = FALSE;
  147.     #else
  148.     BlitContext_p->Trigger.EnableTrigger     = TRUE;    
  149.     BlitContext_p->Trigger.Type              = STBLIT_TRIGGER_TYPE_PROGRESSIVE_VSYNC;
  150.     #endif
  151.     BlitContext_p->GlobalAlpha               = 255;
  152.     /* previously 255, ignored except for STBLIT_ALU_ALPHA_BLEND */
  153.     
  154.     BlitContext_p->EnableClipRectangle = TRUE;
  155.     /* clipping still needs to be turned on to avoid problems if we try
  156.       to raster outside the bitmap (eg end of Robustness test) */
  157.       
  158.     BlitContext_p->ClipRectangle.PositionX  = 0;
  159.     BlitContext_p->ClipRectangle.PositionY  = 0;
  160.     BlitContext_p->ClipRectangle.Width      = 0;
  161.     BlitContext_p->ClipRectangle.Height     = 0;
  162.     BlitContext_p->WriteInsideClipRectangle = TRUE;
  163.     
  164.     BlitContext_p->EnableFlickerFilter       = FALSE;
  165.     BlitContext_p->JobHandle                 = STBLIT_NO_JOB_HANDLE;
  166.     BlitContext_p->UserTag_p                 = NULL; /* set later to mark avmem to free */    
  167.     memset(&EvtSubscribeParams, 0, sizeof(STEVT_DeviceSubscribeParams_t));
  168.     /* ------------ Subscribe to Blit Completed event ---------------- */
  169.     EvtSubscribeParams.NotifyCallback     = NULL;
  170.     EvtSubscribeParams.SubscriberData_p   = NULL;
  171.     Err = STEVT_SubscribeDeviceEvent(g_KB_EVTHandle[KB_EVT_OSD],BLIT_DeviceName,
  172.                                      STBLIT_BLIT_COMPLETED_EVT,&EvtSubscribeParams);    
  173.     if (Err != ST_NO_ERROR)
  174.     {
  175.         DBGPrint ("Err Subscribe Blit completion : %dn",Err);
  176.         return (Err);
  177.     }
  178.     /* ------------ Get Subscriber ID ------------ */
  179.     Err = STEVT_GetSubscriberID(g_KB_EVTHandle[KB_EVT_OSD],&SubscriberID);
  180.     if (Err != ST_NO_ERROR)
  181.     {
  182.         STTBX_Print(("STEVT_GetSubscriberID %sn", DBGError(Err)));
  183.         return( Err );
  184.     }
  185.     DBGPrint("SubscriberID = %xn", SubscriberID);
  186.     BlitContext_p->EventSubscriberID    = SubscriberID;     
  187.     
  188.     BlitContext_p->NotifyBlitCompletion = FALSE;
  189.     DBGPrint("BlitContext_p->NotifyBlitCompletion = %dn", BlitContext_p->NotifyBlitCompletion);
  190.     return ST_NO_ERROR;
  191.     
  192. }
  193. /* EOF --------------------------------------------------------------------- */