📄 msapi_gop.c
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// [Doxygen]
/// @file msAPI_GOP.h
/// @brief API for Graphics output path (GOP)
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////
#define MSAPI_GOP_C
//******************************************************************************
// Header Files
//******************************************************************************
#include <stdio.h>
#include "datatype.h"
#include "debug.h"
#include "drvge.h"
#include "drvgop.h"
#include "drvmiu.h"
#include "drvtimer.h"
#include "msapi_GOP.h"
#include "msAPI_OSD.h"
#ifndef GOP_TEST_CODE
#define GOP_TEST_CODE 0
#endif
//******************************************************************************
// Local
// *****************************************************************************
U16 rolX[MAX_GWIN_SUPPORT] = {0, 0, 0, 0};
U16 rolY[MAX_GWIN_SUPPORT] = {0, 0, 0, 0};
#if 1// kevin 071224 //(!BOOTLOADER_SYSTEM)
//******************************************************************************
// Functions
// [Doxygen]
/// API for initialize the GOP DWIN \r\n
/// Init to YUV format, and source from scaler
//******************************************************************************
void msAPI_GOP_DWIN_Init(void)
{
/* MDrv_GOP_DWIN_SelectSourceFmt(GOPDWIN_DATA_FMT_YUV); //*/
MDrv_GOP_DWIN_SelectSource(GOPDWIN_DATA_SRC_SCALAR);
MDrv_GOP_DWIN_Set_CTRL0(0x0000, 0xFFFF); // Clear all
MDrv_GOP_DWIN_Set_CTRL0(0x3000, 0x3000); // Set DMA length
MDrv_GOP_DWIN_Set_CTRL0(0x0000, 0x0080); // Set continuous capture
}
//******************************************************************************
// [Doxygen]
/// API for enable or disable DWIN
/// @param bEnable \b IN DWIN enable or not
//******************************************************************************
void msAPI_GOP_DWIN_Enable(BOOLEAN bEnable)
{
MDrv_GOP_DWIN_EnableCaptureStream(bEnable);
MDrv_Timer_Delayms(50); //wait at least 1 PAL frame
}
//******************************************************************************
// [Doxygen]
/// Get DWIN property
/// @param pproperty \b OUT buffer to store DWIN property
//******************************************************************************
void msAPI_GOP_DWIN_GetWinProperty(GOP_DWIN_Property *pproperty)
{
GOP_DWIN_INFO info;
MDrv_GOP_DWIN_GetWinInfo(&info);
pproperty->u32fbaddr0 = info.u32TFDRAMAddr;
pproperty->u32fbaddr1 = info.u32BFDRAMAddr;
pproperty->u16x = info.u16HPixelStart;
pproperty->u16w = info.u16HPixelEnd - info.u16HPixelStart ;
pproperty->u16y = info.u16VPixelStart;
pproperty->u16h = info.u16VPixelEnd - info.u16VPixelStart ;
pproperty->u16fbw = pproperty->u16w - info.u16DRAMJumpLen/2;
}
//******************************************************************************
// [Doxygen]
/// Set DWIN property
/// @param pproperty \b IN buffer to store DWIN property
//******************************************************************************
void msAPI_GOP_DWIN_SetWinProperty(GOP_DWIN_Property *pproperty)
{
GOP_DWIN_INFO info;
info.u16HPixelStart = pproperty->u16x;// + PANEL_H_DE;
info.u16HPixelEnd = info.u16HPixelStart + pproperty->u16w ;
info.u16VPixelStart = (pproperty->u16y == 0) ? (pproperty->u16y) : pproperty->u16y;// + PANEL_H_DE;
info.u16VPixelEnd = info.u16VPixelStart + pproperty->u16h;// - 1;
info.u32TFDRAMAddr = pproperty->u32fbaddr0;
info.u32BFDRAMAddr = pproperty->u32fbaddr1;
info.u16DRAMJumpLen = (pproperty->u16fbw - pproperty->u16w) * 2; // 1 pixel occupy 2 bytes
MDrv_GOP_DWIN_SetWinInfo(&info);
}
//******************************************************************************
// [Doxygen]
/// Set DWIN data source scan type
/// @param enScanMode \b IN: EN_DWIN_SCAN_MODE
//******************************************************************************
void msAPI_GOP_DWIN_SelectSourceScanType(EN_DWIN_SCAN_MODE enScanMode)
{
MDrv_GOP_DWIN_SelectSourceScanType(enScanMode);
}
//******************************************************************************
// [Doxygen]
/// Set DWIN Capture format
/// @param fmt \b IN: buffer format to store DWIN content
//******************************************************************************
void msAPI_GOP_DWIN_SetDataFmt(EN_DWIN_DATA_FMT fmt)
{
MDrv_GOP_DWIN_SetDataFmt(fmt);
}
//******************************************************************************
// [Doxygen]
/// Set DWIN Capture constant alpha value for format ARGB8888
/// @param u8AlphaVal \b IN: constant alpha value
//******************************************************************************
void msAPI_GOP_DWIN_SetAlphaValue(U8 u8AlphaVal)
{
MDrv_GOP_DWIN_SetAlphaValue(u8AlphaVal);
}
#endif // #if (!BOOTLOADER_SYSTEM)
//******************************************************************************
/// Create GWIN
/// @param width \b IN GWIN width
/// @param height \b IN GWIN height
/// @param fbFmt \b IN frame buffer pixel format
/// - #0xFFFF default FB format
/// @return The id for the created GWIN
//******************************************************************************
U8 msAPI_GOP_GWIN_CreateWin(U16 width, U16 height, U16 fbFmt)
{
U8 winId;
winId = MDrv_GOP_GWIN_CreateWin(0,0,width,height,fbFmt);
return winId;
}
//******************************************************************************
/// Enable GWIN for display
/// @param winId \b IN GWIN id
/// @param bEnable \b IN
/// - # TRUE Show GWIN
/// - # FALSE Hide GWIN
//******************************************************************************
void msAPI_GOP_GWIN_Enable(U8 winId, BOOLEAN bEnable)
{
//printf("GWINID=%u,Enable=%u\n",(U16)winId,(U16)bEnable);
if (!MDrv_GOP_GWIN_IsGwinExist(winId))
{
DEBUG_INFO( printf("msAPI_GOP_GWIN_Enable: winId=%d is not in existence\n",winId));
return;
}
MDrv_GOP_GWIN_Enable(winId, bEnable);
}
BOOLEAN msAPI_GOP_GWIN_IsAllGWINDisabled(void)
{
return MDrv_GOP_GWIN_IsEnabled();
}
BOOLEAN msAPI_GOP_GWIN_IsGWINEnabled(U8 winId)
{
return MDrv_GOP_GWIN_IsGWINEnabled(winId);
}
//******************************************************************************
/// Set GWIN horizontal and vertical duplication
/// @param hext \b IN
/// - 0 disable horizontal pixel duplication
/// - 1 enable horizontal pixel duplication
/// @param vext \b IN
/// - 0 disable vertical line duplication
/// - 1 enable vertical line duplication
//******************************************************************************
void msAPI_GOP_GWIN_SetDuplication(U8 hext, U8 vext)
{
MDrv_GOP_GWIN_SetDuplication(hext, vext);
return;
}
/******************************************************************************/
/// Delete the GWIN, free corresponding frame buffe
/// @param winId \b IN GWIN id
/******************************************************************************/
void msAPI_GOP_GWIN_DeleteWin(U8 winId)
{
MDrv_GOP_GWIN_DestroyWin(winId);
}
/******************************************************************************/
/// Set the GWIN's position
/// @param winId \b IN GWIN id
/// @param dispX \b IN x coordinate
/// @param dispY \b IN y coordinate
/******************************************************************************/
void msAPI_GOP_GWIN_SetWinPosition(U8 winId, U16 dispX, U16 dispY)
{
if (!MDrv_GOP_GWIN_IsGwinExist(winId))
{
DEBUG_INFO( printf("msAPI_GOP_GWIN_SetWinPosition: winId=%d is not in existence\n",winId));
return;
}
MDrv_GOP_GWIN_SetWinDispPosition(winId, dispX, dispY);
}
/*****************************************************************************/
void msAPI_GOP_GWIN_SetWinPositionOffset(U8 winId, U16 x, U16 y)
{
GOP_GWIN_INFO gwin;
if (!MDrv_GOP_GWIN_IsGwinExist(winId))
{
DEBUG_INFO( printf("msAPI_GOP_GWIN_SetWinPosition: winId=%d is not in existence\n",winId));
return;
}
// MDrv_GOP_GWIN_Enable(winId, FALSE);
MDrv_GOP_GWIN_GetWinInfo(winId, &gwin);
gwin.u16WinX = x;
gwin.u16WinY = y;
MDrv_GOP_GWIN_SetWinInfo(winId, &gwin);
// MDrv_GOP_GWIN_Enable(winId, TRUE);
}
/*****************************************************************************/
void msAPI_GOP_GWIN_SetWinProperty(GOP_GWIN_DISP_PROPERTY WinProperty)
{
MDrv_GOP_GWIN_SetWinProperty(WinProperty);
}
/******************************************************************************/
/// Switch GE to render on a GWIN's frame buffer
/// @param winId \b IN GWIN id
/******************************************************************************/
void msAPI_GOP_GWIN_Switch2Gwin(U8 winId)
{
MDrv_GOP_GWIN_Switch2Win(winId);
}
U8 msAPI_GOP_GWIN_GetCurrentWinId(){
return MDrv_GOP_GWIN_GetCurrentWinId();
}
/******************************************************************************/
/// Switch current active GOP
/// @param u8GOP \b IN : Number of GOP
/******************************************************************************/
void msAPI_GOP_GWIN_SwitchGOP(U8 u8GOP){
MDrv_GOP_BANK_SEL(u8GOP, TRUE);
}
/******************************************************************************/
/// Configure the destination of a specific GOP
/// @param u8GOP \b IN : Number of GOP
/// @param dsttype \b IN : GOP destination
/******************************************************************************/
void msAPI_GOP_GWIN_SetGOPDst(U8 u8GOP, U8 dsttype){
MDrv_GOP_DstPlane_Set(u8GOP, dsttype);
}
/*****************************************************************************/
// not used
#if (KEEP_UNUSED_FUNC == 1)
void msAPI_GOP_GWIN_Switch2OSDwin()
{
MDrv_GOP_GWIN_Back2DefaultOSDWin();
}
/*****************************************************************************/
// not used
void msAPI_GOP_GWIN_Switch2PrevGwin()
{
MDrv_GOP_GWIN_Back2PrevWin();
}
/*****************************************************************************/
// not used
void msAPI_GOP_GWIN_ScrollLine(U8 winId, SCROLL_DIR dir, U16 pixLines, BOOLEAN bEnableGwin)
{
GOP_GWIN_INFO gwin;
U16 scrX, scrY;
U16 x,y, winW, winH;
if (!MDrv_GOP_GWIN_IsGwinExist(winId))
{
DEBUG_INFO( printf("msAPI_GOP_GWIN_ScrollLine: winId=%d is not in existence\n",winId));
return;
}
if (bEnableGwin)
{
MDrv_GOP_GWIN_GetWinInfo(winId, &gwin);
winW = gwin.u16RBlkHPixSize;
winH = gwin.u16RBlkVPixSize;
scrX = (U16)(gwin.u32scrX);
scrY = (U16)(gwin.u32scrY);
x = rolX[winId];
y = rolY[winId];
switch (dir)
{
case SCROLL_UP:
y = ((y + pixLines) % winH);
break;
case SCROLL_DOWN:
y = ((winH + y - pixLines) % winH);
break;
case SCROLL_RIGHT:
x = ((winW +x - pixLines) % winW);
break;
case SCROLL_LEFT:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -