⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compo_init.c

📁 COMPO source code for reference
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************File name   : compo_init.cDescription : Compositor init module standard API functions source fileCOPYRIGHT (C) STMicroelectronics 2000.Date               Modification                                     Name----               ------------                                     ----02 April 2003        Created                                           TM*******************************************************************************//* Includes ----------------------------------------------------------------- */#include <stdlib.h>#include <string.h>#include "stddefs.h"#include "compo.h"#include "compo_rect.h"#include "compo_pool.h"#include "halc_rect.h"#ifdef COMPO_USE_TEST_PIO#include "pio_utils.h"#endif#ifdef COMPO_USE_EVENT_NOTIFY#include "stevt.h"#endif/* Private Types ------------------------------------------------------------ *//* Private Constants -------------------------------------------------------- *//* Private Variables (static)------------------------------------------------ *//* Global Variables --------------------------------------------------------- *//* Private Macros ----------------------------------------------------------- *//* Private Function prototypes ---------------------------------------------- *//* Functions ---------------------------------------------------------------- *//* Events management */#ifdef COMPO_USE_EVENT_NOTIFY/*******************************************************************************Name        : stcompo_EvtRegisterDescription :Parameters  :Assumptions :Limitations :Returns     :*******************************************************************************/ST_ErrorCode_t stcompo_EvtRegister(ST_DeviceName_t EVTDeviceName,stcompo_Device_t *Dev_p){    STEVT_OpenParams_t   OpenParams;    ST_ErrorCode_t       Err = ST_NO_ERROR;    halcompo_Device_t*   Device_p = (halcompo_Device_t*)Dev_p->HalCompoHandle;    Err = STEVT_Open( EVTDeviceName,&OpenParams ,&Dev_p->EvtHandle );    if(Err != ST_NO_ERROR)            return Err;    if( Device_p->IsCompositionQueue )    {        /* Main Instance */        Err = STEVT_Register(Dev_p->EvtHandle,STCOMPO_CQ_COMPLETED_EVT,&Dev_p->EventID[0]);        if(Err != ST_NO_ERROR)        {                STEVT_Unregister(Dev_p->EvtHandle, Dev_p->EventID[0]);                STEVT_Close(Dev_p->EvtHandle);                return Err;        }    }    else    {        /* Aux Instance */        Err = STEVT_Register(Dev_p->EvtHandle,STCOMPO_AQ4_COMPLETED_EVT,&Dev_p->EventID[0]);        if(Err != ST_NO_ERROR)        {                STEVT_Unregister(Dev_p->EvtHandle, Dev_p->EventID[0]);                STEVT_Close(Dev_p->EvtHandle);                return Err;        }    }    Device_p->EvtHandle  = Dev_p->EvtHandle;    Device_p->EventID    = Dev_p->EventID[0];    return Err;}/*******************************************************************************Name        : stcompo_EvtUnRegisterDescription :Parameters  :Assumptions :Limitations :Returns     :*******************************************************************************/static ST_ErrorCode_t stcompo_EvtUnRegister(stcompo_Device_t * Dev_p){    ST_ErrorCode_t     ErrCode = ST_NO_ERROR;    /* Un register the event submitted */    /* Main Instance */    if( Dev_p->HalComposeScreen==HALCOMPO_ComposeScreenCQ )    {        ErrCode = STEVT_Unregister(Dev_p->EvtHandle,STCOMPO_CQ_COMPLETED_EVT);        if ( ErrCode != ST_NO_ERROR)                return ErrCode;    }    /* Aux Instance */    if( Dev_p->HalComposeScreen==HALCOMPO_ComposeScreenAQ )    {        ErrCode = STEVT_Unregister(Dev_p->EvtHandle,STCOMPO_AQ4_COMPLETED_EVT);        if ( ErrCode != ST_NO_ERROR)                return ErrCode;    }    /* Close the event handler even if the above function retrieves an error*/    STEVT_Close(Dev_p->EvtHandle);    return ErrCode ;}#endif/*******************************************************************************Name        : stoverlay_bppDescription : Calculate number of bit per pixel for a color formatParameters  :Assumptions :Limitations :Returns     :*******************************************************************************/static U32 stoverlay_bpp(STGXOBJ_ColorType_t Type){    switch (Type)    {    case STGXOBJ_COLOR_TYPE_ARGB8888:	case STGXOBJ_COLOR_TYPE_ARGB8888_255:        return 32;    case STGXOBJ_COLOR_TYPE_RGB888:    case STGXOBJ_COLOR_TYPE_ARGB8565:    case STGXOBJ_COLOR_TYPE_SIGNED_YCBCR888_444:    case STGXOBJ_COLOR_TYPE_UNSIGNED_YCBCR888_444:    case STGXOBJ_COLOR_TYPE_UNSIGNED_AYCBCR6888_444:        return 24;    case STGXOBJ_COLOR_TYPE_RGB565:    case STGXOBJ_COLOR_TYPE_ARGB1555:    case STGXOBJ_COLOR_TYPE_ARGB4444:    case STGXOBJ_COLOR_TYPE_ACLUT88:    case STGXOBJ_COLOR_TYPE_SIGNED_YCBCR888_422:    case STGXOBJ_COLOR_TYPE_UNSIGNED_YCBCR888_422:        return 16;    case STGXOBJ_COLOR_TYPE_SIGNED_YCBCR888_420:    case STGXOBJ_COLOR_TYPE_UNSIGNED_YCBCR888_420:        return 12;    case STGXOBJ_COLOR_TYPE_CLUT8:    case STGXOBJ_COLOR_TYPE_ACLUT44:    case STGXOBJ_COLOR_TYPE_ALPHA8:    case STGXOBJ_COLOR_TYPE_BYTE:        return 8;    case STGXOBJ_COLOR_TYPE_CLUT4:    case STGXOBJ_COLOR_TYPE_ALPHA4:        return 4;    case STGXOBJ_COLOR_TYPE_CLUT2:        return 2;    case STGXOBJ_COLOR_TYPE_CLUT1:    case STGXOBJ_COLOR_TYPE_ALPHA1:        return 1;    default:        /*Invalid Colour Format Type*/        return 0;    }}/*--------------------------------------------------------------------------------Init--------------------------------------------------------------------------------*/ST_ErrorCode_t STCOMPO_Init(const STCOMPO_InitParams_t* const InitParams_p,                            STCOMPO_Handle_t * const CompoHandle_p){    stcompo_Device_t*       Device_p;    HALCOMPO_InitParams_t   HalInitParams;    ST_ErrorCode_t          Err = ST_NO_ERROR;    stcompo_ScreenRect_t*   Next_p;#ifdef TEST_PARAMETER    if ((CompoHandle_p == NULL) || (InitParams_p == NULL))    {        return(ST_ERROR_BAD_PARAMETER);    }#endif    /* Allocate Device structure */    Device_p = (stcompo_Device_t *) memory_allocate(InitParams_p->CPUPartition_p,sizeof(stcompo_Device_t));#ifdef TEST_PARAMETER    if (Device_p == NULL)    {        /* Error: allocation failed */        return(ST_ERROR_NO_MEMORY);    }#endif    Device_p->CPUPartition_p = InitParams_p->CPUPartition_p;    /* Overlay management initialization */    Device_p->OverlayNumber = InitParams_p->OverlayMaxNumber;    if (Device_p->OverlayNumber != 0)    {        void*              Elembuffer_p;        void**             Handlebuffer_p;    Elembuffer_p = (void*) memory_allocate(Device_p->CPUPartition_p,Device_p->OverlayNumber * sizeof(stcompo_Overlay_t));        if (Elembuffer_p == NULL)        {            memory_deallocate(Device_p->CPUPartition_p,Device_p);            return(ST_ERROR_NO_MEMORY);        }        Handlebuffer_p = (void**) memory_allocate(Device_p->CPUPartition_p,Device_p->OverlayNumber * sizeof(stcompo_Overlay_t*));        if (Handlebuffer_p == NULL)        {            memory_deallocate(Device_p->CPUPartition_p,Device_p);            memory_deallocate(Device_p->CPUPartition_p,Elembuffer_p);            return(ST_ERROR_NO_MEMORY);        }        stcompo_InitDataPool(&(Device_p->OverlayDataPool),                             Device_p->OverlayNumber,                             sizeof(stcompo_Overlay_t),                             Elembuffer_p,                             Handlebuffer_p);    }    /* Cache related info */    Device_p->BlitterCacheBitmap.Data1_p              = InitParams_p->Cache_p;    Device_p->BlitterCacheBitmap.Size1                = InitParams_p->CacheSize;    /*Device_p->BlitterCacheBitmap.Size2                = ; */    Device_p->BlitterCacheBitmap.ColorType            = InitParams_p->CacheType;    Device_p->BlitterCacheBitmap.BitmapType           = STGXOBJ_BITMAP_TYPE_RASTER_PROGRESSIVE;    Device_p->BlitterCacheBitmap.PreMultipliedColor   = FALSE;    Device_p->BlitterCacheBitmap.ColorSpaceConversion = InitParams_p->CacheColorSpaceConversion;    Device_p->BlitterCacheBitmap.AspectRatio          = STGXOBJ_ASPECT_RATIO_4TO3;    Device_p->BlitterCacheBitmap.Offset               = 0;    Device_p->CacheBpp                                = stoverlay_bpp(InitParams_p->CacheType);    Device_p->BackgroundOverlay.CompoHandle           = (STCOMPO_Handle_t) Device_p;    Device_p->BackgroundOverlay.WriteParams.Infront   = (STCOMPO_OverlayHandle_t)NULL;    Device_p->BackgroundOverlay.WriteParams.Behind    = (STCOMPO_OverlayHandle_t)NULL;    /* Set write params  */    Device_p->WriteParams.OutputBitmap     = *(InitParams_p->OutputBitmap_p);    Device_p->WriteParams.ScreenWidth      = InitParams_p->OutputBitmap_p->Width;   /* TBD!!! */    Device_p->WriteParams.ScreenHeight     = InitParams_p->OutputBitmap_p->Height;  /* TBD!!! */    Device_p->WriteParams.BackgroundColor  = *(InitParams_p->BackgroundColor_p);    Device_p->WriteParams.Front_p          = &(Device_p->BackgroundOverlay);    /* Set composition mode */    Device_p->CompositionType     = InitParams_p->CompositionType;    /* A composition can be performed unless UpdateCompositionCommitted == TRUE */    Device_p->UpdateCompositionCommitted                = FALSE;    /* By default graphic composition is not allowed */    Device_p->RemainingGraphicComposition               = 0;    /* Nodes generation anticipation is not allowed unless video params are committed */    Device_p->StartAnticipation                         = FALSE;    /* A composition top (bottom) can be performed unless UpdateTopFieldComposition == TRUE (UpdateBottomFieldComposition) */    if ( Device_p->CompositionType != STCOMPO_COMPOSITION_FRAME ) /* Field based composition mode */    {        Device_p->UpdateTopFieldComposition     = FALSE;        Device_p->UpdateBottomFieldComposition  = FALSE;    }    /* UpdateComposition always because there is at least Background color on !*/    Device_p->UpdateComposition  = TRUE;    /* UpdateExecution is FALSE first time Update Screen Composition is done */    Device_p->UpdateExecution   = FALSE;    /* StartExecution is FALSE first time Update Screen Composition is done */    Device_p->StartExecution    = FALSE;    /* No execution if it is done by another compo instance */    Device_p->ExecutionOn = InitParams_p->ExecutionOn;    /* Nothing to delete */    Device_p->LastOverlayDeleted = (STCOMPO_OverlayHandle_t)NULL;    /* Initialized Screen rect list */    Device_p->FirstAllocatedScreenRect_p = (stcompo_ScreenRect_t *) memory_allocate(Device_p->CPUPartition_p,sizeof(stcompo_ScreenRect_t) * DEFAULT_SCREENRECTS);    Device_p->FirstScreenRect_p = Device_p->FirstAllocatedScreenRect_p;    if (Device_p->FirstScreenRect_p == NULL)    {        memory_deallocate(Device_p->CPUPartition_p,Device_p);        memory_deallocate(Device_p->CPUPartition_p,Device_p->OverlayDataPool.HandleArray_p);        memory_deallocate(Device_p->CPUPartition_p,Device_p->OverlayDataPool.ElemArray_p);        return(ST_ERROR_NO_MEMORY);    }    Device_p->LastScreenRect_p   = Device_p->FirstScreenRect_p + DEFAULT_SCREENRECTS;    Device_p->NextScreenRect_p   = Device_p->FirstScreenRect_p;    for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->LastScreenRect_p; Next_p++)    {        Next_p->Overlay_pp = Next_p->Overlays;    }#ifdef COMPO_USE_EVENT_NOTIFY    /* Event related info */    strcpy(Device_p->EventHandlerName,InitParams_p->EVTDeviceName);#endif    /* Init semaphore */#ifdef ST_OS21    Device_p->AccessControlSemaphore_p = semaphore_create_fifo (1);#endif#ifdef ST_OS20    semaphore_init_fifo (&Device_p->AccessControlSemaphore, 1);#endif    /* Set Hal composition function */    if (InitParams_p->QueueType == STCOMPO_QUEUE_TYPE_COMPOSITION)    {        Device_p->HalComposeScreen = HALCOMPO_ComposeScreenCQ;        HalInitParams.IsCompositionQueue = TRUE;    }#if !defined(ST_5105) && !defined(ST_5188) && !defined(ST_5107) && !defined(ST_5162)    else   /* STCOMPO_QUEUE_TYPE_APPLICATION  */    {        Device_p->HalComposeScreen = HALCOMPO_ComposeScreenAQ;        HalInitParams.IsCompositionQueue = FALSE;    }#else    else   /* STCOMPO_QUEUE_TYPE_APPLICATION  */    {        return ST_ERROR_BAD_PARAMETER;    }#endif /* !defined(ST_5105) && !defined(ST_5188) && !defined(ST_5107) && !defined(ST_5162) */    /* Do hardware dependent init */    HalInitParams.CPUPartition_p               = InitParams_p->CPUPartition_p;    HalInitParams.BaseAddress_p                = InitParams_p->BaseAddress_p;    HalInitParams.BlitterCacheBitmap_p         = &(Device_p->BlitterCacheBitmap);    HalInitParams.OutputBitmap_p               = InitParams_p->OutputBitmap_p;    HalInitParams.BackgroundColor_p            = InitParams_p->BackgroundColor_p;    HalInitParams.FilterBuffer_p               = InitParams_p->FilterBuffer_p;    HalInitParams.FilterBufferSize             = InitParams_p->FilterBufferSize;    HalInitParams.NodeBuffer_p                 = InitParams_p->NodeBuffer_p;    HalInitParams.NodeNumber                   = InitParams_p->NodeNumber;    HalInitParams.HalBackgroundOverlayHandle_p = (HALCOMPO_OverlayHandle_t*) &(Device_p->BackgroundOverlay.HalOverlay);    HalInitParams.OverlayMaxNumber             = Device_p->OverlayNumber;    HalInitParams.CompositionType              = InitParams_p->CompositionType; /* Set composition mode */    Err = HALCOMPO_Init(&HalInitParams, &(Device_p->HalCompoHandle));#ifdef TEST_PARAMETER    if ( Err != ST_NO_ERROR )    {        if (ST_ERROR_NO_MEMORY == NULL)        {            memory_deallocate(Device_p->CPUPartition_p,Device_p);            memory_deallocate(Device_p->CPUPartition_p,Device_p->OverlayDataPool.HandleArray_p);            memory_deallocate(Device_p->CPUPartition_p,Device_p->OverlayDataPool.ElemArray_p);            for (Next_p = Device_p->FirstScreenRect_p; Next_p != Device_p->LastScreenRect_p; Next_p++)            {                if (Next_p->Overlay_pp != Next_p->Overlays)                {                    memory_deallocate(Device_p->CPUPartition_p,Next_p->Overlay_pp);                }            }        }        return(Err);    }#endif    /* Set Handle */    *CompoHandle_p = (STCOMPO_Handle_t) Device_p;#ifdef COMPO_USE_TEST_PIO    Err = pio_setup();#ifdef TEST_PARAMETER    if ( Err != ST_NO_ERROR )    {        return(Err);    }#endif#endif /* COMPO_USE_TEST_PIO */#ifdef COMPO_USE_EVENT_NOTIFY    if( stcompo_EvtRegister(Device_p->EventHandlerName,Device_p) != ST_NO_ERROR )                return STCOMPO_ERROR_EVENT_REGISTER;#endif#ifdef COMPO_USE_MEMORY_TRACE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -