start implement the system cache buffer.

add helper function InitSurface to determent when we need remap or not the video memory.
in DrvEnableSurface tell it use hook flags for diffent functions, add cached alloc as well 
in DrvDisableSurface, add to free the cached video memory 
rewrote DrvAssertMode to remap the video memory when it is need, and realloc the cache when it is need it
Not tested if this change can be compile, yet. but this framebuf_acc is not setup yet with rbuild build system yet
 

svn path=/trunk/; revision=30024
This commit is contained in:
Magnus Olsen 2007-10-31 20:07:12 +00:00
parent 273ddbf9fd
commit 8c669a8e79
2 changed files with 139 additions and 40 deletions

View file

@ -66,6 +66,14 @@ typedef struct _PDEV
VIDEOMEMORY* pvmList; VIDEOMEMORY* pvmList;
BOOL bDDInitialized; BOOL bDDInitialized;
DDPIXELFORMAT ddpfDisplay; DDPIXELFORMAT ddpfDisplay;
/* System Cached data */
PVOID pVideoMemCache;
PVOID pRealVideoMem;
/* Avail Video memory from Current Screen and the end range */
ULONG VideoMemSize;
} PDEV, *PPDEV; } PDEV, *PPDEV;
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))

View file

@ -1,7 +1,8 @@
/* /*
* ReactOS Generic Framebuffer display driver * ReactOS Generic Framebuffer acclations display driver
* *
* Copyright (C) 2004 Filip Navara * Copyright (C) 2004 Filip Navara
* Copyright (C) 2007 Magnus Olsen
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -20,6 +21,79 @@
#include "framebuf.h" #include "framebuf.h"
BOOL
InitSurface(PPDEV ppdev,
BOOL bForcemapping)
{
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
ULONG returnedDataLength;
ULONG RemappingNeeded = 0;
/*
* Set video mode of our adapter.
*/
if (EngDeviceIoControl(ppdev->hDriver,
IOCTL_VIDEO_SET_CURRENT_MODE,
&(ppdev->ModeIndex),
sizeof(ULONG),
&RemappingNeeded,
sizeof(ULONG),
&returnedDataLength))
{
return FALSE;
}
/* Check if mapping is need it */
if ((!bForcemapping) &&
(!RemappingNeeded))
{
return TRUE;
}
/*
* Map the framebuffer into our memory.
*/
VideoMemory.RequestedVirtualAddress = NULL;
if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_MAP_VIDEO_MEMORY,
&VideoMemory, sizeof(VIDEO_MEMORY),
&VideoMemoryInfo, sizeof(VIDEO_MEMORY_INFORMATION),
&returnedDataLength))
{
return FALSE;
}
/*
* Save the real video memory
*/
ppdev->pRealVideoMem = VideoMemoryInfo.FrameBufferBase;
ppdev->VideoMemSize = VideoMemoryInfo.VideoRamLength;
/*
* Video memory cached
*
* We maby should only ask max 8MB as cached ?, think of the video ram length is 256MB
*/
ppdev->pVideoMemCache = EngAllocMem(0, (ULONG)VideoMemoryInfo.VideoRamLength, ALLOC_TAG);
if (ppdev->pVideoMemCache == NULL)
{
/* cached off for no avail system memory */
ppdev->ScreenPtr = VideoMemoryInfo.FrameBufferBase;
}
else
{
/* cached on, system memory is avail */
ppdev->ScreenPtr = ppdev->pRealVideoMem;
}
/* FIXME hw mouse pointer */
return TRUE;
}
/* /*
* DrvEnableSurface * DrvEnableSurface
* *
@ -38,35 +112,14 @@ DrvEnableSurface(
HSURF hSurface; HSURF hSurface;
ULONG BitmapType; ULONG BitmapType;
SIZEL ScreenSize; SIZEL ScreenSize;
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
ULONG ulTemp;
/*
* Set video mode of our adapter.
*/
if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_SET_CURRENT_MODE, /* Setup surface and force the mapping */
&(ppdev->ModeIndex), sizeof(ULONG), NULL, 0, if (!InitSurface(ppdev, TRUE))
&ulTemp))
{ {
return FALSE; return FALSE;
} }
/*
* Map the framebuffer into our memory.
*/
VideoMemory.RequestedVirtualAddress = NULL;
if (EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_MAP_VIDEO_MEMORY,
&VideoMemory, sizeof(VIDEO_MEMORY),
&VideoMemoryInfo, sizeof(VIDEO_MEMORY_INFORMATION),
&ulTemp))
{
return FALSE;
}
ppdev->ScreenPtr = VideoMemoryInfo.FrameBufferBase;
switch (ppdev->BitsPerPixel) switch (ppdev->BitsPerPixel)
{ {
@ -108,7 +161,9 @@ DrvEnableSurface(
* Associate the surface with our device. * Associate the surface with our device.
*/ */
if (!EngAssociateSurface(hSurface, ppdev->hDevEng, 0)) if (!EngAssociateSurface(hSurface, ppdev->hDevEng, HOOK_BITBLT | HOOK_COPYBITS |
HOOK_FILLPATH | HOOK_TEXTOUT |
HOOK_STROKEPATH | HOOK_LINETO))
{ {
EngDeleteSurface(hSurface); EngDeleteSurface(hSurface);
return FALSE; return FALSE;
@ -140,18 +195,24 @@ DrvDisableSurface(
EngDeleteSurface(ppdev->hSurfEng); EngDeleteSurface(ppdev->hSurfEng);
ppdev->hSurfEng = NULL; ppdev->hSurfEng = NULL;
#ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
/* Clear all mouse pointer surfaces. */ /* Free the video memory cache */
DrvSetPointerShape(NULL, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0); if (ppdev->pVideoMemCache)
#endif {
EngFreeMem(ppdev->pVideoMemCache);
}
/* /*
* Unmap the framebuffer. * Unmap the framebuffer.
*/ */
VideoMemory.RequestedVirtualAddress = ((PPDEV)dhpdev)->ScreenPtr; VideoMemory.RequestedVirtualAddress = ppdev->pRealVideoMem;
EngDeviceIoControl(((PPDEV)dhpdev)->hDriver, IOCTL_VIDEO_UNMAP_VIDEO_MEMORY, EngDeviceIoControl(((PPDEV)dhpdev)->hDriver, IOCTL_VIDEO_UNMAP_VIDEO_MEMORY,
&VideoMemory, sizeof(VIDEO_MEMORY), NULL, 0, &ulTemp); &VideoMemory, sizeof(VIDEO_MEMORY), NULL, 0, &ulTemp);
ppdev->pRealVideoMem = NULL;
ppdev->pVideoMemCache = NULL;
} }
/* /*
@ -175,18 +236,48 @@ DrvAssertMode(
if (bEnable) if (bEnable)
{ {
BOOLEAN Result; BOOLEAN Result;
/* PBYTE pRealVideoMem = ppdev->pRealVideoMem;
* Reinitialize the device to a clean state.
*/ /* Setup surface and remapping if it need it */
Result = EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_SET_CURRENT_MODE, if (!InitSurface(ppdev, FALSE))
&(ppdev->ModeIndex), sizeof(ULONG), NULL, 0,
&ulTemp);
if (ppdev->BitsPerPixel == 8)
{ {
IntSetPalette(dhpdev, ppdev->PaletteEntries, 0, 256); return FALSE;
} }
return Result; /* Check if we got same surface or not */
if (pRealVideoMem != ppdev->pRealVideoMem)
{
if (ppdev->pVideoMemCache == NULL)
{
if ( !EngModifySurface(ppdev->hsurfEng,
ppdev->hdevEng,
ppdev->flHooks | HOOK_SYNCHRONIZE,
MS_NOTSYSTEMMEMORY,
(DHSURF)ppdev,
ppdev->pRealVideoMem,
ppdev->lDeltaScreen,
NULL))
{
return FALSE;
}
}
else
{
if ( !EngModifySurface(ppdev->hsurfEng,
ppdev->hdevEng,
ppdev->flHooks | HOOK_SYNCHRONIZE,
0,
(DHSURF)ppdev,
ppdev->pVideoMemCache,
ppdev->lDeltaScreen,
NULL))
{
return FALSE;
}
}
}
return TRUE;
} }
else else