blit.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:9k
- /*****************************************************************************
- File name: blit.c
- Description: blit setup
- COPYRIGHT (C) 2004 STMicroelectronics
- *****************************************************************************/
- /* Includes --------------------------------------------------------------- */
- #include <string.h>
- #include "stddefs.h"
- #include "stdevice.h"
- #include "sttbx.h"
- #include "gendef.h"
- #include "section.h"
- #include "errors.h"
- #include "evt.h" /* for KB_EVT_OSD */
- #include "avmem.h"
- #include "blit.h"
- #include "osd.h"
- #include "osp.h"
- /* Private Macros --------------------------------------------------------- */
- #define NODE_MAX_NUMBER 1024
- #define WORK_BUFFER_SIZE 1024
- /* Private Types ---------------------------------------------------------- */
- /* Private Constants ------------------------------------------------------ */
- /* Private Variables ------------------------------------------------------ */
- /* Private Function prototypes -------------------------------------------- */
- static ST_ErrorCode_t BLIT_InitContext(STBLIT_BlitContext_t * BlitContext_p);
- /* Constants -------------------------------------------------------------- */
- /* Global Variables ------------------------------------------------------- */
- ST_DeviceName_t BLIT_DeviceName = "BLIT";
- STBLIT_Handle_t BLIT_Handle;
- STBLIT_BlitContext_t GtBlitContext;
- /* Functions -------------------------------------------------------------- */
- /*-----------------------------------------------------------------------------
- * Function : BLIT_Init
- *
- * Input :
- * Output :
- * --------------------------------------------------------------------------*/
- ST_ErrorCode_t BLIT_Setup(void)
- {
- ST_ErrorCode_t ErrCode;
- STBLIT_InitParams_t InitParams;
- STBLIT_OpenParams_t OpenParams;
- #if 1
- InitParams.DeviceType = STBLIT_DEVICE_TYPE_BDISP_5105;
- InitParams.BaseAddress_p = (void*)BLITTER_BASE_ADDRESS;
- InitParams.SharedMemoryBaseAddress_p = (void*)SDRAM_BASE_ADDRESS;
- InitParams.BlitInterruptEvent = STBLIT_BLIT_COMPLETED_EVT;
- InitParams.CPUPartition_p = SystemPartition;
- InitParams.AVMEMPartition = g_KBAvmemPartitionHandle[0];
- strcpy(InitParams.EventHandlerName, g_KB_EVTDeviceName[KB_EVT_OSD]);
- InitParams.MaxHandles = 2;
- InitParams.SingleBlitNodeBufferUserAllocated = FALSE;
- InitParams.SingleBlitNodeMaxNumber = NODE_MAX_NUMBER;
- InitParams.SingleBlitNodeBuffer_p = NULL;
- InitParams.JobBlitNodeBufferUserAllocated = FALSE;
- InitParams.JobBlitNodeMaxNumber = 1;
- InitParams.JobBlitNodeBuffer_p = NULL;
- InitParams.JobBlitBufferUserAllocated = FALSE;
- InitParams.JobBlitMaxNumber = 1;
- InitParams.JobBlitBuffer_p = NULL;
- InitParams.JobBufferUserAllocated = FALSE;
- InitParams.JobMaxNumber = 1;
- InitParams.JobBuffer_p = NULL;
- InitParams.WorkBufferUserAllocated = FALSE;
- InitParams.WorkBufferSize = WORK_BUFFER_SIZE;
- InitParams.WorkBuffer_p = NULL;
- InitParams.BigNotLittle = FALSE;
- InitParams.BlitInterruptNumber = BLIT_INTERRUPT;
- InitParams.BlitInterruptLevel = BLIT_INTERRUPT_LEVEL;
- #else
-
- InitParams.SingleBlitNodeMaxNumber = 100; //500; //TTM 4000;
-
- InitParams.JobBlitNodeMaxNumber = 1;
- InitParams.JobBlitMaxNumber = 1;
- InitParams.JobMaxNumber = 1;
- InitParams.WorkBufferSize = WORK_BUFFER_SIZE;
- /*TMTM note: MinWorkBufferSize = STBLIT_DEFAULT_FILTER_BUFFER_SIZE + STBLIT_ALPHA4TO8_CONVERSION_PALETTE_SIZE;
- //size to store the 5-TAP filter coefficients + Alpha4 to Alpha8 conversion palette */
- InitParams.CPUPartition_p = SystemPartition;
-
- InitParams.DeviceType = STBLIT_DEVICE_TYPE_BDISP_5105;
-
- InitParams.BaseAddress_p = (void*)BLITTER_BASE_ADDRESS;
- /* (STBLIT_EMULATOR == TRUE) */
- InitParams.AVMEMPartition = g_KBAvmemPartitionHandle[0];
- InitParams.SharedMemoryBaseAddress_p = (void *)SDRAM_BASE_ADDRESS;
- strcpy( InitParams.EventHandlerName, g_KB_EVTDeviceName[KB_EVT_OSD]);
- InitParams.BlitInterruptEvent = STBLIT_BLIT_COMPLETED_EVT;
- InitParams.BlitInterruptNumber = BLIT_INTERRUPT;
- InitParams.BlitInterruptLevel = BLIT_INTERRUPT_LEVEL;
- InitParams.MaxHandles = 5;
- InitParams.SingleBlitNodeBufferUserAllocated = FALSE;
- InitParams.SingleBlitNodeBuffer_p = NULL;
- InitParams.JobBlitNodeBufferUserAllocated = FALSE;
- //InitParams.JobBlitNodeMaxNumber = 400;
- InitParams.JobBlitNodeBuffer_p = NULL;
- InitParams.JobBlitBufferUserAllocated = FALSE;
- InitParams.JobBlitBuffer_p = NULL;
- InitParams.JobBufferUserAllocated = FALSE;
- InitParams.JobBuffer_p = NULL;
- InitParams.WorkBufferUserAllocated = FALSE;
- InitParams.WorkBuffer_p = NULL;
- InitParams.BigNotLittle = FALSE;
-
- #endif
- STTBX_Print(("BLIT_Setup(%s)=",BLIT_DeviceName));
- ErrCode = STBLIT_Init(BLIT_DeviceName, &InitParams);
- if (ErrCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", DBGError(ErrCode)));
- return( ErrCode );
- }
- ErrCode = STBLIT_Open(BLIT_DeviceName, &OpenParams, &BLIT_Handle);
- if (ErrCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", DBGError(ErrCode)));
- return( ErrCode );
- }
-
- STTBX_Print(("%sn", STBLIT_GetRevision()));
- memset(&GtBlitContext, 0, sizeof(STBLIT_BlitContext_t));
- BLIT_InitContext(&GtBlitContext);
- return (ErrCode);
- } /* end BLIT_Init */
- static ST_ErrorCode_t BLIT_InitContext(STBLIT_BlitContext_t * BlitContext_p)
- {
- STEVT_DeviceSubscribeParams_t EvtSubscribeParams;
- ST_ErrorCode_t Err;
- STEVT_SubscriberID_t SubscriberID;
-
- BlitContext_p->ColorKeyCopyMode = STBLIT_COLOR_KEY_MODE_NONE;
- /* BlitContext_p->ColorKey = 0; undefined */
- BlitContext_p->AluMode = STBLIT_ALU_COPY;
- BlitContext_p->EnableMaskWord = FALSE;
- /* BlitContext_p->MaskWord */
- BlitContext_p->EnableMaskBitmap = FALSE;
- /* BlitContext_p->MaskBitmap_p */
- /* BlitContext_p->MaskRectangle */
- /* BlitContext_p->WorkBuffer_p = ((stgfx_Unit_t*)Handle)->BdfFgndWB_p; */
- /* BlitContext_p->WorkBuffer_p = KB_OSDAllocate(200, 200); */
- BlitContext_p->EnableColorCorrection = FALSE;
- /* BlitContext_p->ColorCorrectionTable_p */
- #if 1
- BlitContext_p->Trigger.EnableTrigger = FALSE;
- #else
- BlitContext_p->Trigger.EnableTrigger = TRUE;
- BlitContext_p->Trigger.Type = STBLIT_TRIGGER_TYPE_PROGRESSIVE_VSYNC;
- #endif
- BlitContext_p->GlobalAlpha = 255;
- /* previously 255, ignored except for STBLIT_ALU_ALPHA_BLEND */
-
- BlitContext_p->EnableClipRectangle = TRUE;
- /* clipping still needs to be turned on to avoid problems if we try
- to raster outside the bitmap (eg end of Robustness test) */
-
- BlitContext_p->ClipRectangle.PositionX = 0;
- BlitContext_p->ClipRectangle.PositionY = 0;
- BlitContext_p->ClipRectangle.Width = 0;
- BlitContext_p->ClipRectangle.Height = 0;
- BlitContext_p->WriteInsideClipRectangle = TRUE;
-
- BlitContext_p->EnableFlickerFilter = FALSE;
- BlitContext_p->JobHandle = STBLIT_NO_JOB_HANDLE;
- BlitContext_p->UserTag_p = NULL; /* set later to mark avmem to free */
- memset(&EvtSubscribeParams, 0, sizeof(STEVT_DeviceSubscribeParams_t));
- /* ------------ Subscribe to Blit Completed event ---------------- */
- EvtSubscribeParams.NotifyCallback = NULL;
- EvtSubscribeParams.SubscriberData_p = NULL;
- Err = STEVT_SubscribeDeviceEvent(g_KB_EVTHandle[KB_EVT_OSD],BLIT_DeviceName,
- STBLIT_BLIT_COMPLETED_EVT,&EvtSubscribeParams);
- if (Err != ST_NO_ERROR)
- {
- DBGPrint ("Err Subscribe Blit completion : %dn",Err);
- return (Err);
- }
- /* ------------ Get Subscriber ID ------------ */
- Err = STEVT_GetSubscriberID(g_KB_EVTHandle[KB_EVT_OSD],&SubscriberID);
- if (Err != ST_NO_ERROR)
- {
- STTBX_Print(("STEVT_GetSubscriberID %sn", DBGError(Err)));
- return( Err );
- }
- DBGPrint("SubscriberID = %xn", SubscriberID);
- BlitContext_p->EventSubscriberID = SubscriberID;
-
- BlitContext_p->NotifyBlitCompletion = FALSE;
- DBGPrint("BlitContext_p->NotifyBlitCompletion = %dn", BlitContext_p->NotifyBlitCompletion);
- return ST_NO_ERROR;
-
- }
- /* EOF --------------------------------------------------------------------- */