vtg.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:6k
- /*****************************************************************************
- File name: vtg.c
- Description: VTG functions
- COPYRIGHT (C) STMicroelectronics 2004.
- *****************************************************************************/
- /* Includes --------------------------------------------------------------- */
- #include <string.h>
- #include "stddefs.h"
- #include "stlite.h"
- #include "stdevice.h"
- #include "sttbx.h"
- #include "errors.h"
- #include "evt.h"
- #include "denc.h"
- #include "vtg.h"
- #include "service.h"
- /* Private Types ------------------------------------------------------ */
- /* Private Constants -------------------------------------------------- */
- /* Private Variables -------------------------------------------------- */
- /* Private Macros ----------------------------------------------------- */
- /* Private Function prototypes ---------------------------------------- */
- /* Global ---------------------------------------------------------- */
- STVTG_Handle_t g_KB_VtgHandle;
- ST_DeviceName_t g_KB_VtgDeviceName = "VTG";
- STVTG_ModeParams_t g_KB_VtgModeParams;
- STVTG_TimingMode_t g_KB_VtgTimingMode;
- /* Functions ---------------------------------------------------------- */
- /*-------------------------------------------------------------------------
- * Function : KB_VtgSetup
- * Input : display mode
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_VtgSetup(KB_ServiceDisplay SERVICE_Display)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STVTG_InitParams_t STVTG_InitParams;
- STVTG_OpenParams_t STVTG_OpenParams = { 0 }; /* dummy parameter */
- STVTG_InitParams.DeviceType = KB_VTG_DEVICE_TYPE;
- strcpy( STVTG_InitParams.EvtHandlerName, "EVT" );
- switch(KB_VTG_DEVICE_TYPE)
- {
- case STVTG_DEVICE_TYPE_DENC :
- STVTG_InitParams.MaxOpen = 1;
- strcpy( STVTG_InitParams.Target.DencName, "DENC" );
- break;
- case STVTG_DEVICE_TYPE_VFE2 :
- STVTG_InitParams.MaxOpen = 2;
- STVTG_InitParams.Target.VtgCell2.BaseAddress_p = (void*)KB_VTG_BASE_ADDRESS;
- STVTG_InitParams.Target.VtgCell2.DeviceBaseAddress_p = (void*)NULL;
- STVTG_InitParams.Target.VtgCell2.InterruptNumber = KB_VTG_INTERRUPT_NUMBER;
- STVTG_InitParams.Target.VtgCell2.InterruptLevel = KB_VTG_INTERRUPT_LEVEL;
- break;
- default :
- STTBX_Print(("Invalid VTG Device Type!"));
- break;
- }
- #ifdef STVTG_VSYNC_WITHOUT_VIDEO
- STVTG_InitParams.VideoBaseAddress_p = (void*) VIDEO_BASE_ADDRESS;
- STVTG_InitParams.VideoDeviceBaseAddress_p = (void*) NULL;
- STVTG_InitParams.VideoInterruptNumber = VIDEO_INTERRUPT;
- STVTG_InitParams.VideoInterruptLevel = VIDEO_INTERRUPT_LEVEL;
- #endif /* #ifdef STVTG_VSYNC_WITHOUT_VIDEO */
- STTBX_Print(("KB_VtgSetup(%s)=", g_KB_VtgDeviceName ));
- ST_ErrorCode = STVTG_Init(g_KB_VtgDeviceName, &STVTG_InitParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- STTBX_Print(("%sn", STVTG_GetRevision() ));
- STTBX_Print(("VTG_Open="));
- ST_ErrorCode = STVTG_Open(g_KB_VtgDeviceName, &STVTG_OpenParams, &g_KB_VtgHandle);
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- switch(SERVICE_Display)
- {
- case SERVICE_DISPLAY_PAL:
- ST_ErrorCode = KB_VtgSetMode( STDENC_MODE_PALBDGHI );
- break;
- case SERVICE_DISPLAY_NTSC:
- ST_ErrorCode = KB_VtgSetMode( STDENC_MODE_NTSCM );
- break;
- case SERVICE_DISPLAY_SECAM:
- ST_ErrorCode = KB_VtgSetMode( STDENC_MODE_SECAM );
- break;
- default:
- ST_ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
- break;
- }
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- ST_ErrorCode = KB_VtgGetMode();
- return( ST_ErrorCode );
- }
- /*-------------------------------------------------------------------------
- * Function : KB_VtgGetMode
- * Input : Timing Mode
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_VtgGetMode(void)
- {
- ST_ErrorCode_t ST_ErrorCode;
- ST_ErrorCode = STVTG_GetMode(g_KB_VtgHandle, &g_KB_VtgTimingMode, &g_KB_VtgModeParams);
- STTBX_Print(("KB_VtgGetMode(XYWH %d,%d,%d,%d, %d,%d)=%sn",
- g_KB_VtgModeParams.ActiveAreaXStart, g_KB_VtgModeParams.ActiveAreaYStart,
- g_KB_VtgModeParams.ActiveAreaWidth, g_KB_VtgModeParams.ActiveAreaHeight,
- g_KB_VtgModeParams.FrameRate, g_KB_VtgModeParams.ScanType,
- KB_ErrorGetText(ST_ErrorCode) ));
- return ( ST_ErrorCode );
- }
- /*-------------------------------------------------------------------------
- * Function : KB_VtgSetMode
- * Input : Timing Mode
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_VtgSetMode(STDENC_Mode_t STDENC_Mode)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STTBX_Print(("KB_VtgSetMode("));
- switch(STDENC_Mode)
- {
- case STDENC_MODE_NTSCM:
- STTBX_Print(("STDENC_MODE_NTSCM)="));
- g_KB_VtgTimingMode = STVTG_TIMING_MODE_480I59940_13500;
- break;
- case STDENC_MODE_PALBDGHI:
- STTBX_Print(("STDENC_MODE_PALBDGHI)="));
- g_KB_VtgTimingMode = STVTG_TIMING_MODE_576I50000_13500;
- break;
- case STDENC_MODE_SECAM:
- STTBX_Print(("STDENC_MODE_SECAM)="));
- g_KB_VtgTimingMode = STVTG_TIMING_MODE_576I50000_13500;
- break;
- case STDENC_MODE_NTSCM_J:
- case STDENC_MODE_NTSCM_443:
- case STDENC_MODE_PALM:
- case STDENC_MODE_PALN:
- case STDENC_MODE_PALN_C:
- default:
- STTBX_Print(("?)=mode not supported.n"));
- return( ST_ERROR_BAD_PARAMETER );
- }
- ST_ErrorCode = STVTG_SetMode(g_KB_VtgHandle, g_KB_VtgTimingMode);
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- /* EOF --------------------------------------------------------------------- */