📄 dispdrvr.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*
** INTEL CONFIDENTIAL
** Copyright 2000-2003 Intel Corporation All Rights Reserved.
**
** The source code contained or described herein and all documents
** related to the source code (Material) are owned by Intel Corporation
** or its suppliers or licensors. Title to the Material remains with
** Intel Corporation or its suppliers and licensors. The Material contains
** trade secrets and proprietary and confidential information of Intel
** or its suppliers and licensors. The Material is protected by worldwide
** copyright and trade secret laws and treaty provisions. No part of the
** Material may be used, copied, reproduced, modified, published, uploaded,
** posted, transmitted, distributed, or disclosed in any way without Intel抯
** prior express written permission.
** No license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise. Any license under such intellectual property rights
** must be express and approved by Intel in writing.
*/
#include <windows.h>
#include <types.h>
#include <string.h>
#include <stdio.h>
#include <tchar.h>
#include <nkintr.h>
#include <bulverde.h>
#include <ceddk.h>
#include <stdarg.h>
#include <stdlib.h>
#include <wtypes.h>
#include "memdefs.h"
#include "DispDrvr.h"
#define DEFINE_CURSOR_GLOBALS
#include "cursor.h"
#include <bsp.h>
#include "xllp_defs.h"
#include "xllp_serialization.h"
#include "xllp_lcd.h"
#include "xllp_ADCM2650.h"
#include "xllp_bcr.h"
#include "xllp_ost.h"
#include "xllp_dmac.h"
#include "xllp_i2c.h"
#include "F8X14_0.h"
#include "loader.h"
#include "logo.h"
#include "ProgressBar.h"
#include "..\\..\\..\\inc\\MT_Version.hpp"
extern XLLP_STATUS_T XllpDmacInit(void);
extern XLLP_UINT32_T XllpLock(XLLP_PROTECTED_REGISTER Xllp_RegisterID);
extern void XllpUnlock(XLLP_UINT32_T Xllp_LockID);
extern XLLP_STATUS_T XllpLCDInit(P_XLLP_LCD_T pXllpLCD);
extern void XllpLCDLoadPalette(P_XLLP_LCD_T pXllpLCD);
extern void XllpLCDSuspend(P_XLLP_LCD_T pXllpLCD, int SuspendType);
extern void XllpLCDResume(P_XLLP_LCD_T pXllpLCD);
extern EBOOT_CFG g_EbootCFG;
#define NUM_FRAME_BUFFERS 1
PALETTEENTRY _rgbIdentity[];
XLLP_LCD_T XllpLCD;
XLLP_STATUS_T status;
#define FRAME_BUFFER_BASE_PHYSICAL FRAME_BUFFER_0_BASE_PHYSICAL
BOOL gDrawCursorFlag = FALSE;
BOOL gInPowerHandler = FALSE;
BOOL bDoRotation = FALSE;
CRITICAL_SECTION displayMutex;
CRITICAL_SECTION frameDescriptorMutex;
int DispDrvr_cxScreen;
int DispDrvr_cyScreen;
int DispDrvr_cdwStride;
int activeFrameBuffer=0;
unsigned int frameBufferSize = 0;
PBYTE gDibBuffer = NULL; // pointer to first byte of composition buffer
PBYTE gFrameBuffer = NULL; // pointer to first byte of screen memory
PBYTE gBlankFrameBuffer = NULL; // pointer to first byte of screen memory
RECT gCursorRect;
UINT nDisplayType;
DWORD g_DisplayBasePhysical;
DWORD g_DisplayBaseVirtual;
volatile LCDRegs * v_pLcdRegs = NULL;
volatile XLLP_CLKMGR_T * v_pClkRegs = NULL;
volatile XLLP_GPIO_T * v_pGPIORegs = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorCh0fd1 = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorCh0fd2 = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorCh1 = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorPalette = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorTemp = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorCh2_YCbCr_Y = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorCh3_YCbCr_Cb = NULL;
volatile LCD_FRAME_DESCRIPTOR * frameDescriptorCh4_YCbCr_Cr = NULL;
volatile LCD_PALETTE * v_pPaletteBuffer = NULL;
volatile unsigned int * pOSCR = NULL;
///
volatile unsigned int * v_pOSTRegs = NULL;
volatile unsigned int * v_pCIRegs = NULL;
volatile unsigned int * v_pI2C = NULL;
volatile XLLP_DMAC_T * v_pDMAC = NULL;
volatile XSBASE270_G_CPLD_REGS * v_pCPLDRegs = NULL;
HANDLE hIntEventKnown;
HANDLE hIntEvent;
///
void LCDClearStatusReg();
void LcdSetupGPIOs();
void Cleanup();
void InitLCDController();
void EnableLCDController();
void DisableLCDController();
void InitCursor();
BOOL MapVirtualAddress();
BOOL ReadRegistryData(VOID);
void CopyFrameBuffer(BOOL gDirection);
void ClearFrameBuffer(BOOL color);
void ScrollBuffer(int direction);
void Overlay2_Enable(P_XLLP_OVERLAY_T pXllpOverlay);
void Overlay2_Disable(P_XLLP_OVERLAY_T pXllpOverlay);
void Overlay2_DMA_Length(P_XLLP_OVERLAY_T pXllpOverlay);
void ClearDMACInterrupt(int channel);
extern PVOID VirtualAllocCopy(unsigned size,char *str,PVOID pVirtualAddress);
extern PVOID VirtualAllocCopyPhysical(unsigned size,char *str,PVOID pPhysicalAddress);
extern BOOL VirtualSetAttributes(LPVOID lpvAddress, DWORD cbSize, DWORD dwNewFlags, DWORD dwMask, LPDWORD lpdwOldFlags);
extern void msWait(unsigned int);
unsigned char DisplayLightConvert(unsigned char data);//return 1 if success.
unsigned int halted = 0;
XLLP_OVERLAY_T XllpOverlay;
PBYTE pOverlay2_Y = NULL;
PBYTE pOverlay2_Cb = NULL;
PBYTE pOverlay2_Cr = NULL;
unsigned char * fbpY;
unsigned char * fbpCr;
unsigned char * fbpCb;
//
#define _OPT_ASM
#ifdef _OPT_ASM
void dirtyRectDump_core_ASM(WORD *pwSrc, WORD *pwDst,int rowLen, DWORD srcWidthB,
DWORD bytesPerRow, DWORD srcMarginWidth, DWORD dstMarginWidth);
void DirtyRectDumpPortraitLoop_C(BYTE *pDstBuf, BYTE *pSrcBuf, DWORD yTop, DWORD yBottom,
DWORD srcWidthB, DWORD bytesPerRow, DWORD bytesPerPixel, DWORD srcMarginWidth, DWORD dstMarginWidth);
void ellipse_core_ASM(WORD srcColor,DWORD margin,DWORD width,WORD* pDstBuf);
void DispDrvrDirtyRectDump2(LPCRECT prc,DWORD color);
void DirtyRectDumpPortraitLoop_C_rectfill(BYTE *pDstBuf, WORD srcColor,DWORD yTop,DWORD yBottom,
DWORD srcWidthB, DWORD bytesPerRow, DWORD bytesPerPixel, DWORD srcMarginWidth, DWORD dstMarginWidth);
void DispDrvrDirtyRectDump_rectfill(LPCRECT prc, DWORD color);
#endif
DWORD GetDisplayType(void)
{
return g_EbootCFG.dwDisplayType;
}
void DisplayOneChar(F8X14Dots source,int x,int y)
{
static int s=0;
int i,j;
unsigned int val,v1,v2,v3,v4;
unsigned * fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
unsigned *p;
for(j=0;j<MAX_FONT3_Y;j++)
{
for(i=0;i<MAX_FONT3_X;i+=2)
{
if((source.line[j] & (0x80>>(i)))==0)
val=0x0000FFFF;
else
val=0;
if((source.line[j] & (0x80>>(i+1)))==0)
val+=0xFFFF0000;
else
val+=0;
p=(fbp+((y*(MAX_FONT3_Y+2)+j)*DispDrvr_cxScreen/2+(x*MAX_FONT3_X+i)/2));
*p=val;
}
switch(GetDisplayType())
{
case VLFSDD320240:
case AU104:
case NANYALM702:
break;
default:
for(i=0;i<MAX_FONT3_X;i+=4)
{
p=(fbp+((y*(MAX_FONT3_Y+2)+j)*DispDrvr_cxScreen/2+(x*MAX_FONT3_X+i)/2));
v1= (*p) & 0x0000FFFF;
v2= ((*p)>>16);
p++;
v3= (*p) & 0x0000FFFF;
v4= ((*p)>>16);
p=(fbp+((y*(MAX_FONT3_Y+2)+j)*DispDrvr_cxScreen/2+(x*MAX_FONT3_X+i)/2));
*p=(v3<<16)+v4;
p++;
*p=(v1<<16)+v2;
}
break;
}
}
}
void DisplayString(char *str,int x,int y)
{
int i;
int len;
len=strlen(str);
for(i=0;i<DispDrvr_cxScreen/MAX_FONT3_X,i<len;i++)
{
DisplayOneChar(F8X14DotsTbl[str[i]],x+i,y);
}
}
//Description:
// Get LCD width and height
//Author:
// Bruce
//Date:
// 2009-4-10 8:22
//IN:
// unsigned int *cxScreen LCD width point,max is MAX_BMP_WIDTH
// unsigned int cyScreen LCD height point,max is MAX_BMP_HEIGHT
//Return:
// nothing
void GetDispalyXY(unsigned int *cxScreen,unsigned int *cyScreen)
{
int type=GetDisplayType();
switch(type)
{
case NANYALM702:
*cxScreen=640;
*cyScreen=480;
break;
case AU104:
*cxScreen=800;
*cyScreen=600;
break;
case VLFSDD320240:
default:
*cxScreen=320;
*cyScreen=240;
break;
}
}
// Display Eboot software version information
//Author:
// Bruce
//Date:
// 2009-4-10 9:09
//IN:
// nothing
//Return:
// nothing
void ul2string(unsigned long num,char *s)
{
char buf1[30],buf2[30];
int i;
long n=num;
if(num==0)
{
s[0]='0';
s[1]=0;
return;
}
memset(buf1,0,sizeof(buf1));
memset(buf2,0,sizeof(buf2));
for(i=20;i>=0;i--)
{
buf1[i]=n%10+'0';
n/=10;
}
for(i=0;i<20;i++)
{
if(buf1[i]!='0')
break;
}
memcpy(s,&buf1[i],strlen(&buf1[i]));
s[strlen(&buf1[i])]=0;
}
void DisplayVersion(void)
{
char buf[256];
char buf2[256];
unsigned int DispDrvr_cxScreen,DispDrvr_cyScreen;
long sn,ver1,ver2;
sn=MT_EBOOT_SN;
ver1=MT_EBOOT_MAIN_VER;
ver2=MT_EBOOT_SUB_VER;
memset(buf,0,sizeof(buf));
strcpy(buf,"Ver ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -