📄 dispdrvr.c
字号:
ul2string(sn,buf2);
strcat(buf,buf2);
strcat(buf,".");
ul2string(ver1,buf2);
strcat(buf,buf2);
strcat(buf,".");
ul2string(ver2,buf2);
strcat(buf,buf2);
strcat(buf," ");
strcat(buf,__DATE__);
GetDispalyXY(&DispDrvr_cxScreen,&DispDrvr_cyScreen);
DisplayString(buf, (DispDrvr_cxScreen-strlen(buf)*8)/8/2, DispDrvr_cyScreen*4/5/14);
EdbgOutputDebugString(buf);
EdbgOutputDebugString("\r\n");
}
void lcd_test()
{
DWORD i,j;
int color = 0;
unsigned int DispDrvr_cxScreen,DispDrvr_cyScreen;
// DWORD rmask=0xF800F800, gmask=0x07E007E0, bmask = 0x001F001F;
// DWORD rmask=0x88888888, gmask=0x66666666, bmask = 0x33333333;
DWORD bmask[] ={0x00000000,0x00010001,0x00030003,0x00070007,0x000F000F,0x001F001F};
BYTE r = 0x7F, g = 0x7F , b = 0x7F;
UINT32 CurrTime,PreTime=0;
unsigned * fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
DisplayLightConvert((unsigned char)(g_EbootCFG.dwContrast)*(255/9));
// EdbgOutputDebugString("DispDrvr_cxScreen=%d,DispDrvr_cyScreen=%d\r\n",DispDrvr_cxScreen,DispDrvr_cyScreen);
// for(j=0;j<25;)
// {
// CurrTime = OEMEthGetSecs();
// if(CurrTime>PreTime+1)
// {
// j++;
// PreTime=CurrTime;
// DisplayString("Welcome to RTPO MTCN",10,7);
// DisplayLightConvert(j*10);
// EdbgOutputDebugString("DisplayLightConvert\r\n");
// /*color++;
// if(color>1)
// color=0;
// r=0;
// g=0;
// b=0;
// fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
// EdbgOutputDebugString("fbp=%d\n",fbp);
// */
// }
// else
// continue;
// /*for(i=0;i<15;i++)
// {
// DisplayOneChar(F8X14DotsTbl['A'+i],0,i);
// }
//
// DisplayString("Welcome to RTPO MTCN",10,7);*/
// }
fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
DisplayLogo(fbp,GetDisplayType());
GetDispalyXY(&DispDrvr_cxScreen,&DispDrvr_cyScreen);
if(DispDrvr_cxScreen>MAX_BMP_WIDTH)
return;
if(DispDrvr_cyScreen>MAX_BMP_HEIGHT)
return;
DisplayVersion();
fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
ProgressBar_Init(fbp,DispDrvr_cxScreen/6,DispDrvr_cyScreen*3/4,DispDrvr_cxScreen*4/6,DispDrvr_cxScreen/12,DispDrvr_cxScreen);
}
void DispDrvrSetDibBuffer(void *data)
{
gDibBuffer = data;
}
void DispDrvrSetPalette (const PALETTEENTRY source[],unsigned short firstEntry,unsigned short numEntries)
{
int i;
int end = firstEntry + numEntries;
// Don't walk off the end of the palette buffer.
if (firstEntry > sizeof(source) || end >= sizeof(source))
{
return;
}
//2007-9-12 10:38 QCM
// EnterCriticalSection(&frameDescriptorMutex);
// Store the palette entries into palette ram
for(i=firstEntry;i<end;i++)
{
// store 5 bits red, 6 bits green, and 5 bits blue
v_pPaletteBuffer->palette[i] = (
(source[i].peBlue) >> 3 |
((source[i].peGreen & 0xfc) << 3) |
((source[i].peRed & 0xf8) << 8)
);
}
XllpLCDLoadPalette(&XllpLCD);
//2007-9-12 10:37 QCM
// LeaveCriticalSection(&frameDescriptorMutex);
}
void DispDrvrInitialize (void)
{
// Read display driver configuration from system registry
ReadRegistryData();
frameBufferSize = bpp * DispDrvr_cxScreen * DispDrvr_cyScreen/ 8;
// Map registers, the frame buffer, and frame descriptors from Kernel mode virtual address
// into our user mode virtual address space
if (!MapVirtualAddress())
{
return;
}
// Initialize for use with Suspend resume macros
// msWait(1);
XllpLCD.GPIO = (XLLP_VUINT32_T *) v_pGPIORegs;
XllpLCD.CLKMan = (XLLP_VUINT32_T *) v_pClkRegs;
XllpLCD.LCDC = (XLLP_VUINT32_T *) v_pLcdRegs;
XllpLCD.DisplayType = nDisplayType;
XllpLCD.FrameBufferWidth = DispDrvr_cxScreen;
XllpLCD.FrameBufferHeight = DispDrvr_cyScreen;
XllpLCD.BPP = BPP_16;
XllpLCD.PixelDataFormat = PDFOR_00; //with overlays enabled use PDFOR_11 for 16bpp
XllpLCD.CurrentPage = 0;
XllpLCD._FRAME_BUFFER_BASE_PHYSICAL = FRAME_BUFFER_BASE_PHYSICAL;
XllpLCD._PALETTE_BUFFER_BASE_PHYSICAL = PALETTE_BUFFER_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_PHYSICAL = DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD._PALETTE_FRAME_DESCRIPTOR_BASE_PHYSICAL = PALETTE_FRAME_DESCRIPTOR_BASE_PHYSICAL;
XllpLCD.frameDescriptorCh0fd1 = frameDescriptorCh0fd1;
XllpLCD.frameDescriptorCh0fd2 = frameDescriptorCh0fd2;
XllpLCD.frameDescriptorCh1 = frameDescriptorCh1;
XllpLCD.frameDescriptorPalette = frameDescriptorPalette;
XllpLCD.frameDescriptorTemp = frameDescriptorTemp;
//2007-9-12 10:58 Bruce
// InitializeCriticalSection(&displayMutex);
// InitializeCriticalSection(&frameDescriptorMutex);
// Initialize Cursor
InitCursor();
ClearFrameBuffer(TRUE);
//Turn on backlight,Add by Terry@2005-2-6
//remarked by Bruce 2008-4-17 14:38
// v_pCPLDRegs->BCR1 |= BCR_LCD_PWR;
// Initialize the LCD Controller and Board Control Register
XllpLCDInit(&XllpLCD);
//InitRegs((XLLP_OST_T *)v_pOSTRegs, (P_XLLP_I2C_T)v_pI2C);
//2007-9-12 10:59 Bruce
// XllpI2cInit((P_XLLP_I2C_T)v_pI2C, (P_XLLP_GPIO_T) v_pGPIORegs, (P_XLLP_CLKMGR_T) v_pClkRegs, (XLLP_UINT32_T) 0);
pOSCR = v_pOSTRegs + 4;
// Use this event to signal the IST that we now know the dynamically assigned DMA channel
// And with that information, we know which event to wait on for the interrupt.
//2007-9-12 10:59 Bruce
// hIntEventKnown = CreateEvent(NULL,FALSE,FALSE,NULL);
//RETAILMSG(1,(TEXT("Display Driver Initialization Complete\r\n")));
//add by Bruce 2007-9-25 10:31
// DispDrvrSetPalette (_rgbIdentity,0,255);
return;
}
void InitCursor()
{
gDrawCursorFlag = FALSE;
gCursorRect.left = (DispDrvr_cxScreen - CURSOR_XSIZE) >> 1;
gCursorRect.right = gCursorRect.left + CURSOR_XSIZE;
gCursorRect.top = (DispDrvr_cyScreen - CURSOR_YSIZE) >> 1;
gCursorRect.bottom = gCursorRect.top + CURSOR_YSIZE;
gxHot = gyHot = 0;
memset ((BYTE *)gCursorMask, 0xFF, sizeof(gCursorMask));
}
//char disp[640*480*2+0x10000];
BOOL MapVirtualAddress()
{
// DMA_ADAPTER_OBJECT Adapter;
// PHYSICAL_ADDRESS PhysAddr;
//
// Adapter.ObjectSize = sizeof (DMA_ADAPTER_OBJECT);
// Adapter.InterfaceType = Internal;
// Adapter.BusNumber = 0;
//
// g_DisplayBaseVirtual = (DWORD)HalAllocateCommonBuffer(&Adapter, DISPLAY_BUFFER_SIZE, &PhysAddr, FALSE);
// g_DisplayBasePhysical = PhysAddr.LowPart;
//
// if (!g_DisplayBaseVirtual)
// {
// Cleanup();
// return FALSE;
// }
g_DisplayBaseVirtual =(DWORD)OALPAtoVA(0xA3A80000, FALSE);
g_DisplayBasePhysical=(DWORD)(0xA3A80000);
v_pDMAC = (P_XLLP_DMAC_T)OALPAtoVA(BULVERDE_BASE_REG_PA_DMAC, FALSE);
if (!v_pDMAC)
{
Cleanup();
return FALSE;
}
v_pI2C = (volatile unsigned int *)OALPAtoVA(BULVERDE_BASE_REG_PA_I2C, FALSE);
if (!v_pI2C)
{
Cleanup();
return FALSE;
}
v_pOSTRegs = (volatile unsigned int *)OALPAtoVA(BULVERDE_BASE_REG_PA_OST, FALSE);
if (!v_pOSTRegs)
{
Cleanup();
return FALSE;
}
v_pLcdRegs = (volatile LCDRegs *)OALPAtoVA(BULVERDE_BASE_REG_PA_LCD, FALSE);
if (!v_pLcdRegs)
{
Cleanup();
return FALSE;
}
v_pClkRegs = (volatile XLLP_CLKMGR_T *)OALPAtoVA(BULVERDE_BASE_REG_PA_CLKMGR, FALSE);
if (!v_pClkRegs)
{
Cleanup();
return FALSE;
}
v_pGPIORegs = (volatile XLLP_GPIO_T *)OALPAtoVA(BULVERDE_BASE_REG_PA_GPIO, FALSE);
if (!v_pGPIORegs)
{
Cleanup();
return FALSE;
}
v_pCPLDRegs = (volatile XSBASE270_G_CPLD_REGS *)OALPAtoVA(XSBASE270_G_BASE_REG_PA_CPLD, FALSE);
if (!v_pCPLDRegs)
{
Cleanup();
return FALSE;
}
frameDescriptorCh0fd1 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_0_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorCh0fd2 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_0_ALT_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorCh1 = (volatile LCD_FRAME_DESCRIPTOR *)(DMA_CHANNEL_1_FRAME_DESCRIPTOR_BASE_VIRTUAL);
frameDescriptorPalette = (volatile LCD_FRAME_DESCRIPTOR *)(PALETTE_FRAME_DESCRIPTOR_BASE_VIRTUAL);
v_pPaletteBuffer = (volatile LCD_PALETTE *)(PALETTE_BUFFER_BASE_VIRTUAL);
// Enter into Kernel mode to enable us to modify the section descriptor
// so that we may set the bufferable bit. This enables write coalescing
// for frame buffer writes when using the section mapped address.
//
// GAPI uses the section mapped address always.
// Now configure the frame buffer's section descriptor.
// The function GetDescriptorAddress shows how to obtain the correct descriptor address.
// This descriptor is one of two descriptors that map the the frame buffer.
// The first descriptor found maps the cached virtual address, while the second
// descriptor found maps the uncached virtual address. We want to modify the
// second descriptor, that which maps the uncached virtual address since the uncached virtual
// address is the address we've chosen to use throughout the codebase.
//
// NOTE:
// The section descriptor covers a 1MB section. If the frame buffer ever exceeds 1MB
// in size, you'll need to modify additional section descriptors.
//
// DDraw requires that the frame buffer pointer be in the shared memory space so
// is can be shared between processes.
// {
// PVOID pPhysAddr;
// size_t offset;
// size_t size;
//
// pPhysAddr = (PVOID)(FRAME_BUFFER_0_BASE_PHYSICAL);
// size = frameBufferSize * NUM_FRAME_BUFFERS;
// offset = (unsigned)pPhysAddr & (0x1000 - 1);
// size += (offset ? 0x1000 : 0);
// pPhysAddr = (PVOID)((unsigned)pPhysAddr - offset);
//
// if (size >= 1024*1024*2)
// {
// gFrameBuffer = (PBYTE)VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
// }
// else
// {
// gFrameBuffer = (PBYTE)VirtualAlloc(NULL, 1024*1024*2, MEM_RESERVE, PAGE_NOACCESS);
// }
//
// if (!VirtualCopy(gFrameBuffer, (LPVOID)((unsigned long)pPhysAddr >> 8), size, (PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL)))
// {
// gFrameBuffer = NULL;
// }
// else
// {
// gFrameBuffer += offset;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -