📄 compo_ov.c
字号:
/*****************************************************************************File name : Comp_ov.cDescription : Compositor Overlay source fileCOPYRIGHT (C) STMicroelectronics 2000.Date Modification Name---- ------------ ----02 April 2003 Created TM*******************************************************************************//* Private preliminary definitions (internal use only) ---------------------- *//* Includes ----------------------------------------------------------------- */#include <string.h>#include "stddefs.h"#include "compo.h"#include "compo_rect.h"#include "compo_pool.h"#include "halc_rect.h"/* Private Types ------------------------------------------------------------ *//* Private Constants -------------------------------------------------------- *//* Private Variables (static)------------------------------------------------ *//* Global Variables --------------------------------------------------------- *//* Private Macros ----------------------------------------------------------- *//* Private Function prototypes ---------------------------------------------- *//* Functions ---------------------------------------------------------------- *//******************************************************************************Name : STCOMPO_CreateOverlayDescription : This function allows the caller to create a new overlay. The new handle is returned in Overlay_p. If the mode pointer is not null, the overlay will be created using this operating mode.Parameters :Assumptions : Params_p->Rect.IORect2_p->DstRect ignoredLimitations :Returns :*******************************************************************************/ST_ErrorCode_t STCOMPO_CreateOverlay(STCOMPO_Handle_t CompoHandle, STCOMPO_OverlayHandle_t *Overlay_p, STCOMPO_OverlayParams_t *Params_p){ ST_ErrorCode_t Err=ST_NO_ERROR; stcompo_Overlay_t* New_p; stcompo_Device_t* Device_p = (stcompo_Device_t*)CompoHandle; U8 Constant; STCOMPO_OverlayParams_t HalParams; STCOMPO_QueueUsed_t QueueUsed;#ifdef COMPO_ENABLE_SETTINGS_TRACE COMPO_TRACE("\r\nStt:Setting:CtOv:%d",time_now());#endif /* Data structure Protection */#ifdef ST_OS21 semaphore_wait (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_wait (&Device_p->AccessControlSemaphore);#endif if ((Device_p->HalComposeScreen) == HALCOMPO_ComposeScreenCQ) { QueueUsed = STCOMPO_MAIN; } else { QueueUsed = STCOMPO_AUX; } /* Get a free Overlay structure */#ifndef COMPO_DEBUG_CHECK_ERROR stcompo_GetElement(&(Device_p->OverlayDataPool), (void**) &New_p);#else Err = stcompo_GetElement(&(Device_p->OverlayDataPool), (void**) &New_p); if ( Err != ST_NO_ERROR) { /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif return Err; }#endif /* Set Overlay params */ New_p->WriteParams.DstRect = Params_p->Rect.IORect1_p->DstRect; /* Params_p->Rect.IORect2_p->DstRect ignored */ New_p->WriteParams.Flags = Params_p->Flags; if ((!(Params_p->Flags & STCOMPO_OVERLAY_MODE_CONSTANT_ALPHA)) && (Params_p->Flags & STCOMPO_OVERLAY_MODE_PERPIXEL_ALPHA)) { /* Set Constant Alpha */ Constant = 0x80; } else { Constant = Params_p->ConstantAlpha; } /* Remove CONSTANT ALPHA Flags if constantAlpha = opaque */ if ((Params_p->Flags & STCOMPO_OVERLAY_MODE_CONSTANT_ALPHA) && (Constant == 0x80)) { New_p->WriteParams.Flags &= ~(U32)STCOMPO_OVERLAY_MODE_CONSTANT_ALPHA; } /* Set Constant alpha */ New_p->WriteParams.ConstantAlpha = Constant; New_p->WriteParams.ConstantAlpha1 = Params_p->ConstantAlpha1; /* Insert at top of overlay stack as default */ New_p->WriteParams.Behind = (STCOMPO_OverlayHandle_t)Device_p->WriteParams.Front_p; New_p->WriteParams.Infront = (STCOMPO_OverlayHandle_t)NULL; /* Update device structure */ if (Device_p->WriteParams.Front_p) { Device_p->WriteParams.Front_p->WriteParams.Infront = (STCOMPO_OverlayHandle_t)New_p; } Device_p->WriteParams.Front_p = New_p; if ((Params_p->Flags & STCOMPO_OVERLAY_MODE_DISABLE) == 0) { Device_p->UpdateComposition = TRUE; } /* Associate it with device structure */ New_p->CompoHandle = (STCOMPO_Handle_t)Device_p; /* Hal Create overlay */ HalParams.Flags = New_p->WriteParams.Flags; HalParams.Src = Params_p->Src; HalParams.Rect = Params_p->Rect; HalParams.ConstantAlpha = Constant; HalParams.ConstantAlpha1 = Params_p->ConstantAlpha1; HalParams.UseSSBA = Params_p->UseSSBA;#ifndef COMPO_DEBUG_CHECK_ERROR HALCOMPO_CreateOverlay(Device_p->HalCompoHandle, &(New_p->HalOverlay),&HalParams, QueueUsed);#else Err = HALCOMPO_CreateOverlay(Device_p->HalCompoHandle, &(New_p->HalOverlay),&HalParams, QueueUsed); if ( Err != ST_NO_ERROR) { /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif return Err; }#endif /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif /* Return handle to the user */ *Overlay_p = (STCOMPO_OverlayHandle_t) New_p; return Err;}/*******************************************************************************Name : STCOMPO_DestroyOverlayDescription : This function disables and destroys the overlay. This handle can no longer be used.Parameters :Assumptions :Limitations :Returns :*******************************************************************************/ST_ErrorCode_t STCOMPO_DestroyOverlay(STCOMPO_OverlayHandle_t Overlay){ ST_ErrorCode_t Err = ST_NO_ERROR; stcompo_Overlay_t* Overlay_p = (stcompo_Overlay_t*) Overlay; stcompo_Device_t* Device_p = (stcompo_Device_t*)Overlay_p->CompoHandle;#ifdef COMPO_ENABLE_SETTINGS_TRACE COMPO_TRACE("\r\nStt:Setting:DsOv:%d",time_now());#endif /* Data structure Protection */#ifdef ST_OS21 semaphore_wait (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_wait (&Device_p->AccessControlSemaphore);#endif /* Hal Destroy overlay */#ifndef COMPO_DEBUG_CHECK_ERROR HALCOMPO_DestroyOverlay(Overlay_p->HalOverlay);#else Err = HALCOMPO_DestroyOverlay(Overlay_p->HalOverlay); if ( Err != ST_NO_ERROR) { /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif return Err; }#endif /* Update Device overlay Front pointer */ if (Device_p->WriteParams.Front_p == Overlay_p) { Device_p->WriteParams.Front_p = (stcompo_Overlay_t*)Overlay_p->WriteParams.Behind; } /* Update overlay linked list */ if (Overlay_p->WriteParams.Infront != (STCOMPO_OverlayHandle_t)NULL) { ((stcompo_Overlay_t*)(Overlay_p->WriteParams.Infront))->WriteParams.Behind = Overlay_p->WriteParams.Behind; } if (Overlay_p->WriteParams.Behind != (STCOMPO_OverlayHandle_t)NULL) { ((stcompo_Overlay_t*)(Overlay_p->WriteParams.Behind))->WriteParams.Infront = Overlay_p->WriteParams.Infront; } /* Update device */ if ((Overlay_p->WriteParams.Flags & STCOMPO_OVERLAY_MODE_DISABLE) == 0) { Device_p->UpdateComposition = TRUE; } /* Update deleted overlay linked list */ Overlay_p->WriteParams.Behind = Device_p->LastOverlayDeleted; Device_p->LastOverlayDeleted = Overlay; /* Overlay_p pointer can not be free at this stage because it may be used by another thread doing Composition (for read params for exemple) It will be released on Commit */ /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif return Err;}/*******************************************************************************Name : STCOMPO_SetOverlayParamsDescription : This function sets up the operation of an overlay. The flags field in the mode structure is used to indicate what data fields are valid in the mode structure. This function can be used to start an overlay running, to disable it, to change the viewing rectangles, blending etc.Parameters :Assumptions :Limitations :Returns :*******************************************************************************/ST_ErrorCode_t STCOMPO_SetOverlayParams(STCOMPO_OverlayHandle_t Overlay, STCOMPO_OverlayParams_t* Params_p){ ST_ErrorCode_t Err = ST_NO_ERROR; stcompo_Overlay_t* Overlay_p = (stcompo_Overlay_t*) Overlay; stcompo_Device_t* Device_p = (stcompo_Device_t*)Overlay_p->CompoHandle; U8 Constant; STCOMPO_OverlayParams_t HalParams; STCOMPO_QueueUsed_t QueueUsed;#ifdef COMPO_ENABLE_SETTINGS_TRACE COMPO_TRACE("\r\nStt:Setting:StOP:%d",time_now());#endif /* Data structure Protection */#ifdef ST_OS21 semaphore_wait (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_wait (&Device_p->AccessControlSemaphore);#endif if ((Device_p->HalComposeScreen) == HALCOMPO_ComposeScreenCQ) { QueueUsed = STCOMPO_MAIN; } else { QueueUsed = STCOMPO_AUX; } /* Update overlay structure */ Overlay_p->WriteParams.DstRect = Params_p->Rect.IORect1_p->DstRect; /* Assumption is that IORect1_p->DstRect == IORect2_p->DstRect */ Overlay_p->WriteParams.Flags = Params_p->Flags; if ((!(Params_p->Flags & STCOMPO_OVERLAY_MODE_CONSTANT_ALPHA)) && (Params_p->Flags & STCOMPO_OVERLAY_MODE_PERPIXEL_ALPHA)) { /* Set Constant Alpha */ Constant = 0x80; } else { Constant = Params_p->ConstantAlpha; } /* Remove CONSTANT ALPHA Flags if constantAlpha = opaque */ if ((Params_p->Flags & STCOMPO_OVERLAY_MODE_CONSTANT_ALPHA) && (Constant == 0x80)) { Overlay_p->WriteParams.Flags &= ~(U32)STCOMPO_OVERLAY_MODE_CONSTANT_ALPHA; } /* Set Overlay params */ HalParams.Flags = Overlay_p->WriteParams.Flags; HalParams.Src = Params_p->Src; HalParams.Rect = Params_p->Rect; HalParams.ConstantAlpha = Constant; HalParams.ConstantAlpha1 = Params_p->ConstantAlpha1; HalParams.UseSSBA = Params_p->UseSSBA;#ifndef COMPO_DEBUG_CHECK_ERROR HALCOMPO_SetOverlayParams(Overlay_p->HalOverlay, &HalParams, QueueUsed, TRUE);#else Err = HALCOMPO_SetOverlayParams(Overlay_p->HalOverlay, &HalParams, QueueUsed, TRUE); if ( Err != ST_NO_ERROR) { /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif return Err; }#endif /* Update device */ if ((Overlay_p->WriteParams.Flags & STCOMPO_OVERLAY_MODE_DISABLE) == 0) { Device_p->UpdateComposition = TRUE; } /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_signal (&Device_p->AccessControlSemaphore);#endif return Err;}/*******************************************************************************Name : STCOMPO_SetOverlayIORectangleDescription : This function sets the IO rectangle of an overlayParameters :Assumptions : IORect1_p->DstRect == IORect2_p->DstRectLimitations :Returns :*******************************************************************************/ST_ErrorCode_t STCOMPO_SetOverlayIORectangle(STCOMPO_OverlayHandle_t Overlay, STCOMPO_Rectangle_t* Rect_p){ ST_ErrorCode_t Err = ST_NO_ERROR; stcompo_Overlay_t* Overlay_p = (stcompo_Overlay_t*) Overlay; stcompo_Device_t* Device_p = (stcompo_Device_t*)Overlay_p->CompoHandle;#ifdef COMPO_ENABLE_SETTINGS_TRACE COMPO_TRACE("\r\nStt:Setting:StOR:%d",time_now());#endif /* Data structure Protection */#ifdef ST_OS21 semaphore_wait (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20 semaphore_wait (&Device_p->AccessControlSemaphore);#endif /* Set IO Rectangle */ Overlay_p->WriteParams.DstRect = Rect_p->IORect1_p->DstRect; /* Assumption is that IORect1_p->DstRect == IORect2_p->DstRect */#ifndef COMPO_DEBUG_CHECK_ERROR HALCOMPO_SetOverlayIORectangle(Overlay_p->HalOverlay,Rect_p);#else Err = HALCOMPO_SetOverlayIORectangle(Overlay_p->HalOverlay,Rect_p); if ( (Err != ST_NO_ERROR) && (Err != ST_ERROR_BAD_PARAMETER) ) { /* Data structure Protection */#ifdef ST_OS21 semaphore_signal (Device_p->AccessControlSemaphore_p);#endif#ifdef ST_OS20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -