vmix.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:12k
- /*****************************************************************************
- File name : vmix.c
- Description: VMIX functions
- COPYRIGHT (C) STMicroelectronics 2004.
- *****************************************************************************/
- /* Includes --------------------------------------------------------------- */
- #include <string.h>
- #include "stddefs.h"
- #include "stlite.h"
- #include "stdevice.h"
- #include "stvid.h"
- #include "stgxobj.h"
- #include "sttbx.h"
- #include "section.h" /* memory partitions */
- #include "errors.h"
- #include "evt.h"
- #include "layer.h"
- #include "vtg.h"
- #include "vout.h"
- #include "vmix.h"
- #include "avmem.h"
- #include "osd.h"
- /* Private Types ------------------------------------------------------ */
- /* Private Constants -------------------------------------------------- */
- #ifdef OSD_SUPPORT
- #define NUM_VMIX_LAYERS (NUM_LAYERS+1)
- #else
- #define NUM_VMIX_LAYERS (NUM_LAYERS)
- #endif
- /* Private Variables -------------------------------------------------- */
- static STVMIX_LayerDisplayParams_t *VMIXLayerArray_p[NUM_VMIX_LAYERS];
- static STVMIX_LayerDisplayParams_t VMIXLayerParam[NUM_VMIX_LAYERS];
- /* Private Macros ----------------------------------------------------- */
- /* Private Function prototypes ---------------------------------------- */
- /* Global Variables ------------------------------------------------------- */
- STVMIX_Handle_t g_KB_VmixHandle = 0;
- ST_DeviceName_t g_KB_VmixDeviceName = "VMIX";
- //added by whale 07/06/26
- STGXOBJ_AspectRatio_t g_KB_VmixAspectRatio = STGXOBJ_ASPECT_RATIO_4TO3;
- /* Functions -------------------------------------------------------------- */
- /*-------------------------------------------------------------------------
- * Function : KB_VmixSetup
- * Input : None
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_VmixSetup(void)
- {
- ST_ErrorCode_t ST_ErrorCode;
- ST_DeviceName_t VoutDeviceNames[KB_VOUT_MAX_DEVICES+1];
- STVMIX_InitParams_t STVMIX_InitParams;
- STVMIX_OpenParams_t STVMIX_OpenParams = { 0 }; /* dummy parameter */
- U8 Index;
- STVMIX_InitParams.CPUPartition_p = SystemPartition;
- STVMIX_InitParams.BaseAddress_p = (void *)KB_VMIX_BASE_ADDRESS;
- STVMIX_InitParams.DeviceBaseAddress_p = (void *)KB_VMIX_DEVICE_BASE_ADDRESS;
- STVMIX_InitParams.DeviceType = KB_VMIX_DEVICE_TYPE;
- STVMIX_InitParams.MaxOpen = 2;
- STVMIX_InitParams.MaxLayer = NUM_VMIX_LAYERS;
- switch (KB_VMIX_DEVICE_TYPE)
- {
- case STVMIX_OMEGA1_SD :
- strcpy(VoutDeviceNames[0], "" );
- strcpy(VoutDeviceNames[1], "" );
- strcpy(VoutDeviceNames[2], "" );
- break;
- case STVMIX_GENERIC_GAMMA_TYPE_5528 :
- strcpy(VoutDeviceNames[0], "VOUT_CVBS" );
- strcpy(VoutDeviceNames[1], "" );
- strcpy(VoutDeviceNames[2], "" );
- break;
- case STVMIX_COMPOSITOR :
- case STVMIX_COMPOSITOR_FIELD: /* included for field based composition */
- case STVMIX_COMPOSITOR_FIELD_SDRAM:
- case STVMIX_COMPOSITOR_422:
- case STVMIX_COMPOSITOR_FIELD_422: /* included for field based composition */
- case STVMIX_COMPOSITOR_FIELD_SDRAM_422:
- case STVMIX_COMPOSITOR_FIELD_COMBINED:
- case STVMIX_COMPOSITOR_FIELD_COMBINED_422:
- case STVMIX_COMPOSITOR_FIELD_COMBINED_SDRAM:
- case STVMIX_COMPOSITOR_FIELD_COMBINED_SDRAM_422:
- {
- STGXOBJ_Bitmap_t CacheBitmap;
- STAVMEM_AllocBlockParams_t AllocBlockParams;
- STAVMEM_BlockHandle_t VMIX_AVMEMHandle;
- STVMIX_InitParams.RegisterInfo.CompoBaseAddress_p = (void*)KB_VMIX_COMPO_BASE_ADDRESS;
- STVMIX_InitParams.RegisterInfo.GdmaBaseAddress_p = (void*)KB_VMIX_GDMA_BASE_ADDRESS;
- STVMIX_InitParams.RegisterInfo.VoutBaseAddress_p = (void*)VOUT_BASE_ADDRESS;
- STVMIX_InitParams.AVMEM_Partition = g_KBAvmemPartitionHandle[0];
- CacheBitmap.ColorType = STGXOBJ_COLOR_TYPE_UNSIGNED_YCBCR888_444;
- CacheBitmap.ColorSpaceConversion = STGXOBJ_ITU_R_BT601;
- AllocBlockParams.PartitionHandle = g_KBAvmemPartitionHandle[0];
- STVMIX_InitParams.AVMEM_Partition2 = g_KBAvmemPartitionHandle[0];
- AllocBlockParams.Alignment = 16;
- AllocBlockParams.Size = 16*1024;
- AllocBlockParams.AllocMode = STAVMEM_ALLOC_MODE_BOTTOM_TOP;
- AllocBlockParams.NumberOfForbiddenRanges = 0;
- AllocBlockParams.ForbiddenRangeArray_p = NULL;
- AllocBlockParams.NumberOfForbiddenBorders = 0;
- AllocBlockParams.ForbiddenBorderArray_p = NULL;
- ST_ErrorCode= STAVMEM_AllocBlock(&AllocBlockParams,&VMIX_AVMEMHandle);
- ST_ErrorCode = STAVMEM_GetBlockAddress(VMIX_AVMEMHandle,&CacheBitmap.Data1_p);
- CacheBitmap.Size1 = AllocBlockParams.Size;
- STVMIX_InitParams.CacheBitmap_p = &CacheBitmap;
- }
- strcpy(VoutDeviceNames[0], "VOUT_CVBS" );
- strcpy(VoutDeviceNames[1], "" );
- strcpy(VoutDeviceNames[2], "" );
- break;
- default :
- break;
- }
- STVMIX_InitParams.OutputArray_p = VoutDeviceNames;
- strcpy(STVMIX_InitParams.VTGName, "VTG" );
- strcpy(STVMIX_InitParams.EvtHandlerName, "EVT" );
- STTBX_Print(("KB_VmixSetup(%s)=", g_KB_VmixDeviceName ));
- ST_ErrorCode = STVMIX_Init(g_KB_VmixDeviceName, &STVMIX_InitParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- STTBX_Print(("%sn", STVMIX_GetRevision() ));
- STTBX_Print(("VMIX_Open="));
- ST_ErrorCode = STVMIX_Open(g_KB_VmixDeviceName, &STVMIX_OpenParams, &g_KB_VmixHandle);
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = STVMIX_SetTimeBase( g_KB_VmixHandle, g_KB_VtgDeviceName );
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("VMIX_SetTimeBase=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- }
- strcpy(VMIXLayerParam[0].DeviceName, g_KB_LayerDeviceName[LAYER_VIDEO] );
- #ifdef PIP_SUPPORT /*! Louie(7/13/2005): PIP */
- strcpy(VMIXLayerParam[1].DeviceName, g_KB_LayerDeviceName[LAYER_AUX_VIDEO] );
- strcpy(VMIXLayerParam[2].DeviceName, g_KB_LayerDeviceName[LAYER_OSD] );
- #ifdef MOSAIC_FEATURE_ON_WITH_STILL
- strcpy(VMIXLayerParam[3].DeviceName, g_KB_LayerDeviceName[LAYER_STILL] );
- #endif
- #else
- strcpy(VMIXLayerParam[1].DeviceName, g_KB_LayerDeviceName[LAYER_OSD] );
- #ifdef MOSAIC_FEATURE_ON_WITH_STILL
- strcpy(VMIXLayerParam[2].DeviceName, g_KB_LayerDeviceName[LAYER_STILL] );
- #endif
- #endif
- for ( Index = 0; Index < NUM_LAYERS; Index++ )
- {
- #if defined(MOSAIC_FEATURE_ON) || defined(MOSAIC_FEATURE_ON_WITH_STILL)
- strcpy(VMIXLayerParam[Index].DeviceName, g_KB_LayerDeviceName[Index] );
- #else
- strcpy(VMIXLayerParam[Index].DeviceName, g_KB_LayerDeviceName[Index] );
- #endif /* defined(MOSAIC_FEATURE_ON) */
- VMIXLayerParam[Index].ActiveSignal = TRUE;
- VMIXLayerArray_p[Index] = &VMIXLayerParam[Index];
- }
- #ifdef OSD_SUPPORT
- ST_ErrorCode = STOSD_GetLayerName(VMIXLayerParam[Index].DeviceName);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("STOSD_GetLayerName=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- VMIXLayerParam[Index].ActiveSignal = TRUE;
- VMIXLayerArray_p[Index] = &VMIXLayerParam[Index];
- #endif
- ST_ErrorCode = STVMIX_ConnectLayers(g_KB_VmixHandle,
- (const STVMIX_LayerDisplayParams_t* const *)VMIXLayerArray_p,
- NUM_VMIX_LAYERS);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("VMIX_ConnectLayers=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- ST_ErrorCode = KB_VmixSetScreenParams();
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("KB_VmixSetScreenParams=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- ST_ErrorCode = STVMIX_Enable(g_KB_VmixHandle);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("VMIX_Enable=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- }
- return( ST_ErrorCode );
- }
- /*-------------------------------------------------------------------------
- * Function : KB_VmixSetScreenParams
- * Input : None
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_VmixSetScreenParams(void)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STVMIX_ScreenParams_t STVMIX_ScreenParams;
- ST_ErrorCode = KB_VtgGetMode(); /* get Active area */
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- #if 0 /* has to enable when STVMIX_CLDelayWA does not hang */
- /* KB_VmixSetScreenParams is called whenever there is change in Frame Rate in which case STVTG_SetMode is called */
- ST_ErrorCode = STVMIX_CLDelayWA(g_KB_VmixHandle, g_KB_VtgTimingMode);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("VMIX_CLDelayWA=%sn", KB_ErrorGetText(ST_ErrorCode)));
- return( ST_ErrorCode );
- }
- #endif
- /* Set VMIX mode same as VTG */
- //modified by whale 07/06/26
- //STVMIX_ScreenParams.AspectRatio = STGXOBJ_ASPECT_RATIO_4TO3;
- STVMIX_ScreenParams.AspectRatio = g_KB_VmixAspectRatio;
- STVMIX_ScreenParams.ScanType = g_KB_VtgModeParams.ScanType;
- STVMIX_ScreenParams.FrameRate = g_KB_VtgModeParams.FrameRate;
- STVMIX_ScreenParams.Width = g_KB_VtgModeParams.ActiveAreaWidth;
- STVMIX_ScreenParams.Height = g_KB_VtgModeParams.ActiveAreaHeight;
- STVMIX_ScreenParams.XStart = g_KB_VtgModeParams.ActiveAreaXStart;
- STVMIX_ScreenParams.YStart = g_KB_VtgModeParams.ActiveAreaYStart;
- ST_ErrorCode = STVMIX_SetScreenParams(g_KB_VmixHandle, &STVMIX_ScreenParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("KB_VmixSetScreenParams=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- STTBX_Print(("KB_VmixSetScreenParams(%s, %d,%d,%d,%d, %d,%d,%d)n", g_KB_VmixDeviceName,
- STVMIX_ScreenParams.XStart, STVMIX_ScreenParams.YStart,
- STVMIX_ScreenParams.Width, STVMIX_ScreenParams.Height,
- STVMIX_ScreenParams.FrameRate, STVMIX_ScreenParams.ScanType,
- STVMIX_ScreenParams.AspectRatio ));
- return( ST_ErrorCode );
- }
- //added by whale 07/06/26 start
- ST_ErrorCode_t KB_VmixSetAspectRatio(STGXOBJ_AspectRatio_t nAspectRatio)
- {
- ST_ErrorCode_t ST_ErrorCode;
- g_KB_VmixAspectRatio = nAspectRatio;
- ST_ErrorCode = KB_VmixSetScreenParams();
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("KB_VmixSetAspectRatio=%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- return( ST_ErrorCode );
- }
- //added by whale 07/06/26 end
- /* EOF --------------------------------------------------------------------- */