From bd41ac7ef94469bca15c05d7e2137cc8cf425374 Mon Sep 17 00:00:00 2001 From: evb Date: Tue, 14 Dec 2010 03:17:29 +0000 Subject: [PATCH] - Add the new vga miniport to build - Replace the framebuf_new spec rc rbuild with vga_new spec rc rbuild - Delete pointer.c - Start make changes, driver.h new fields for VGA, change driver short/long name/tag, add macros and in enable.c remove hw pointer support svn path=/trunk/; revision=50026 --- .../drivers/video/displays/directory.rbuild | 3 + .../drivers/video/displays/vga_new/debug.h | 4 +- .../drivers/video/displays/vga_new/driver.h | 37 +- .../drivers/video/displays/vga_new/enable.c | 8 + .../video/displays/vga_new/framebuf_new.rc | 5 - .../drivers/video/displays/vga_new/pointer.c | 455 ------------------ .../{framebuf_new.rbuild => vga_new.rbuild} | 9 +- .../drivers/video/displays/vga_new/vga_new.rc | 5 + .../{framebuf_new.spec => vga_new.spec} | 0 9 files changed, 56 insertions(+), 470 deletions(-) delete mode 100644 reactos/drivers/video/displays/vga_new/framebuf_new.rc delete mode 100755 reactos/drivers/video/displays/vga_new/pointer.c rename reactos/drivers/video/displays/vga_new/{framebuf_new.rbuild => vga_new.rbuild} (61%) create mode 100644 reactos/drivers/video/displays/vga_new/vga_new.rc rename reactos/drivers/video/displays/vga_new/{framebuf_new.spec => vga_new.spec} (100%) diff --git a/reactos/drivers/video/displays/directory.rbuild b/reactos/drivers/video/displays/directory.rbuild index 514fd432fd2..37342e84499 100644 --- a/reactos/drivers/video/displays/directory.rbuild +++ b/reactos/drivers/video/displays/directory.rbuild @@ -7,6 +7,9 @@ + + + diff --git a/reactos/drivers/video/displays/vga_new/debug.h b/reactos/drivers/video/displays/vga_new/debug.h index d73a223baaf..4a5764d4953 100755 --- a/reactos/drivers/video/displays/vga_new/debug.h +++ b/reactos/drivers/video/displays/vga_new/debug.h @@ -1,7 +1,7 @@ /* - * PROJECT: ReactOS Framebuffer Display Driver + * PROJECT: ReactOS VGA Display Driver * LICENSE: Microsoft NT4 DDK Sample Code License - * FILE: boot/drivers/video/displays/framebuf/debug.h + * FILE: boot/drivers/video/displays/vga/debug.h * PURPOSE: Debug Support Header * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation */ diff --git a/reactos/drivers/video/displays/vga_new/driver.h b/reactos/drivers/video/displays/vga_new/driver.h index e9e617190c0..f060f17bed6 100755 --- a/reactos/drivers/video/displays/vga_new/driver.h +++ b/reactos/drivers/video/displays/vga_new/driver.h @@ -48,6 +48,10 @@ typedef struct _PDEV // eVb: 3.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping LONG flHooks; // eVb: 3.1 [END] +// eVb: 3.1 [VGARISC Change] - Add new fields for VGA support + SURFOBJ* pso; + UCHAR* pjBase; +// eVb: 3.1 [END] } PDEV, *PPDEV; DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); @@ -68,8 +72,35 @@ VOID vDisableSURF(PPDEV); #define DRIVER_EXTRA_SIZE 0 -#define DLL_NAME L"framebuf" // Name of the DLL in UNICODE -#define STANDARD_DEBUG_PREFIX "FRAMEBUF: " // All debug output is prefixed -#define ALLOC_TAG 'bfDD' // Four byte tag (characters in +// eVb: 3.2 [VGARISC Change] - Transform into VGA driver +#define DLL_NAME L"vga" // Name of the DLL in UNICODE +#define STANDARD_DEBUG_PREFIX "Vga risc: " // All debug output is prefixed +#define ALLOC_TAG 'rgvD' // Four byte tag (characters in // reverse order) used for memory // allocations +// eVb: 3.2 [END] + +// eVb: 3.3 [VGARISC Change] - Add new macros for VGA usage +// +// Each pixel in 4BPP being a nibble, the color data for that pixel is thus +// located at the xth bit within the nibble, where x is the plane number [0-3]. +// Each nibble being 4 bytes, the color data is thus at the (nibble * 4 + x). +// That color data is then taken from its linear position and shifted to the +// correct position within the 16-bit planar buffer word. +// +#define VAL(data, px, pl, pos) ((data) >> (((px) * 4) + (pl)) & 1) << (pos) + +// +// This figures out which pixel in the planar word data corresponds to which pixel +// in the 4BPP linear data. +// +#define SET_PLANE_DATA(x, y, a, b) \ + (x) |= VAL(y, (((-1 + ((((b) % 8) % 2) << 1) - (((b) % 8) + 1) + 8))), a, b) + +/* Alignment Macros */ +#define ALIGN_DOWN_BY(size, align) \ + ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) + +#define ALIGN_UP_BY(size, align) \ + (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align)) +// eVb: 3.3 [END] diff --git a/reactos/drivers/video/displays/vga_new/enable.c b/reactos/drivers/video/displays/vga_new/enable.c index 8031da8a173..4e232961504 100644 --- a/reactos/drivers/video/displays/vga_new/enable.c +++ b/reactos/drivers/video/displays/vga_new/enable.c @@ -20,8 +20,12 @@ static DRVFN gadrvfn[] = { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, { INDEX_DrvSetPalette, (PFN) DrvSetPalette }, +// eVb: 1.1 [VGARISC Change] - Disable hardware pointer support +#if 0 { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, +#endif +// eVb: 1.1 [END] { INDEX_DrvGetModes, (PFN) DrvGetModes } }; @@ -126,6 +130,8 @@ HANDLE hDriver) // Handle to base driver goto error_free; } +// eVb: 1.2 [VGARISC Change] - Disable hardware pointer support +#if 0 // Initialize the cursor information. if (!bInitPointer(ppdev, &DevInfo)) @@ -134,6 +140,8 @@ HANDLE hDriver) // Handle to base driver DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n")); } +#endif +// eVb: 1.2 [END] // Initialize palette information. if (!bInitPaletteInfo(ppdev, &DevInfo)) diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.rc b/reactos/drivers/video/displays/vga_new/framebuf_new.rc deleted file mode 100644 index 98ba2627f11..00000000000 --- a/reactos/drivers/video/displays/vga_new/framebuf_new.rc +++ /dev/null @@ -1,5 +0,0 @@ -#define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "Framebuffer Display Driver\0" -#define REACTOS_STR_INTERNAL_NAME "framebuf\0" -#define REACTOS_STR_ORIGINAL_FILENAME "framebuf.dll\0" -#include diff --git a/reactos/drivers/video/displays/vga_new/pointer.c b/reactos/drivers/video/displays/vga_new/pointer.c deleted file mode 100755 index d3752a2763c..00000000000 --- a/reactos/drivers/video/displays/vga_new/pointer.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * PROJECT: ReactOS Framebuffer Display Driver - * LICENSE: Microsoft NT4 DDK Sample Code License - * FILE: boot/drivers/video/displays/framebuf/pointer.c - * PURPOSE: Hardware Pointer Support - * PROGRAMMERS: Copyright (c) 1992-1995 Microsoft Corporation - */ - -#include "driver.h" - -BOOL bCopyColorPointer( -PPDEV ppdev, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo); - -BOOL bCopyMonoPointer( -PPDEV ppdev, -SURFOBJ *psoMask); - -BOOL bSetHardwarePointerShape( -SURFOBJ *pso, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo, -LONG x, -LONG y, -FLONG fl); - -/******************************Public*Routine******************************\ -* DrvMovePointer -* -* Moves the hardware pointer to a new position. -* -\**************************************************************************/ - -VOID DrvMovePointer -( - SURFOBJ *pso, - LONG x, - LONG y, - RECTL *prcl -) -{ - PPDEV ppdev = (PPDEV) pso->dhpdev; - DWORD returnedDataLength; - VIDEO_POINTER_POSITION NewPointerPosition; - - // We don't use the exclusion rectangle because we only support - // hardware Pointers. If we were doing our own Pointer simulations - // we would want to update prcl so that the engine would call us - // to exclude out pointer before drawing to the pixels in prcl. - - UNREFERENCED_PARAMETER(prcl); - - if (x == -1) - { - // - // A new position of (-1,-1) means hide the pointer. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_DISABLE_POINTER, - NULL, - 0, - NULL, - 0, - &returnedDataLength)) - { - // - // Not the end of the world, print warning in checked build. - // - - DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_DISABLE_POINTER\n")); - } - } - else - { - NewPointerPosition.Column = (SHORT) x - (SHORT) (ppdev->ptlHotSpot.x); - NewPointerPosition.Row = (SHORT) y - (SHORT) (ppdev->ptlHotSpot.y); - - // - // Call miniport driver to move Pointer. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_SET_POINTER_POSITION, - &NewPointerPosition, - sizeof(VIDEO_POINTER_POSITION), - NULL, - 0, - &returnedDataLength)) - { - // - // Not the end of the world, print warning in checked build. - // - - DISPDBG((1, "DISP vMoveHardwarePointer failed IOCTL_VIDEO_SET_POINTER_POSITION\n")); - } - } -} - -/******************************Public*Routine******************************\ -* DrvSetPointerShape -* -* Sets the new pointer shape. -* -\**************************************************************************/ - -ULONG DrvSetPointerShape -( - SURFOBJ *pso, - SURFOBJ *psoMask, - SURFOBJ *psoColor, - XLATEOBJ *pxlo, - LONG xHot, - LONG yHot, - LONG x, - LONG y, - RECTL *prcl, - FLONG fl -) -{ - PPDEV ppdev = (PPDEV) pso->dhpdev; - DWORD returnedDataLength; - - // We don't use the exclusion rectangle because we only support - // hardware Pointers. If we were doing our own Pointer simulations - // we would want to update prcl so that the engine would call us - // to exclude out pointer before drawing to the pixels in prcl. - UNREFERENCED_PARAMETER(prcl); - - if (ppdev->pPointerAttributes == (PVIDEO_POINTER_ATTRIBUTES) NULL) - { - // Mini-port has no hardware Pointer support. - return(SPS_ERROR); - } - - // See if we are being asked to hide the pointer - - if (psoMask == (SURFOBJ *) NULL) - { - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_DISABLE_POINTER, - NULL, - 0, - NULL, - 0, - &returnedDataLength)) - { - // - // It should never be possible to fail. - // Message supplied for debugging. - // - - DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); - } - - return(TRUE); - } - - ppdev->ptlHotSpot.x = xHot; - ppdev->ptlHotSpot.y = yHot; - - if (!bSetHardwarePointerShape(pso,psoMask,psoColor,pxlo,x,y,fl)) - { - if (ppdev->fHwCursorActive) { - ppdev->fHwCursorActive = FALSE; - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_DISABLE_POINTER, - NULL, - 0, - NULL, - 0, - &returnedDataLength)) { - - DISPDBG((1, "DISP bSetHardwarePointerShape failed IOCTL_VIDEO_DISABLE_POINTER\n")); - } - } - - // - // Mini-port declines to realize this Pointer - // - - return(SPS_DECLINE); - } - else - { - ppdev->fHwCursorActive = TRUE; - } - - return(SPS_ACCEPT_NOEXCLUDE); -} - -/******************************Public*Routine******************************\ -* bSetHardwarePointerShape -* -* Changes the shape of the Hardware Pointer. -* -* Returns: True if successful, False if Pointer shape can't be hardware. -* -\**************************************************************************/ - -BOOL bSetHardwarePointerShape( -SURFOBJ *pso, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo, -LONG x, -LONG y, -FLONG fl) -{ - PPDEV ppdev = (PPDEV) pso->dhpdev; - PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; - DWORD returnedDataLength; - - if (psoColor != (SURFOBJ *) NULL) - { - if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER) && - bCopyColorPointer(ppdev, psoMask, psoColor, pxlo)) - { - pPointerAttributes->Flags |= VIDEO_MODE_COLOR_POINTER; - } else { - return(FALSE); - } - - } else { - - if ((ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER) && - bCopyMonoPointer(ppdev, psoMask)) - { - pPointerAttributes->Flags |= VIDEO_MODE_MONO_POINTER; - } else { - return(FALSE); - } - } - - // - // Initialize Pointer attributes and position - // - - pPointerAttributes->Enable = 1; - - // - // if x,y = -1,-1 then pass them directly to the miniport so that - // the cursor will be disabled - - pPointerAttributes->Column = (SHORT)(x); - pPointerAttributes->Row = (SHORT)(y); - - if ((x != -1) || (y != -1)) { - pPointerAttributes->Column -= (SHORT)(ppdev->ptlHotSpot.x); - pPointerAttributes->Row -= (SHORT)(ppdev->ptlHotSpot.y); - } - - // - // set animate flags - // - - if (fl & SPS_ANIMATESTART) { - pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_START; - } else if (fl & SPS_ANIMATEUPDATE) { - pPointerAttributes->Flags |= VIDEO_MODE_ANIMATE_UPDATE; - } - - // - // Set the new Pointer shape. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_SET_POINTER_ATTR, - pPointerAttributes, - ppdev->cjPointerAttributes, - NULL, - 0, - &returnedDataLength)) { - - DISPDBG((1, "DISP:Failed IOCTL_VIDEO_SET_POINTER_ATTR call\n")); - return(FALSE); - } - - return(TRUE); -} - -/******************************Public*Routine******************************\ -* bCopyMonoPointer -* -* Copies two monochrome masks into a buffer of the maximum size handled by the -* miniport, with any extra bits set to 0. The masks are converted to topdown -* form if they aren't already. Returns TRUE if we can handle this pointer in -* hardware, FALSE if not. -* -\**************************************************************************/ - -BOOL bCopyMonoPointer( - PPDEV ppdev, - SURFOBJ *pso) -{ - ULONG cy; - PBYTE pjSrcAnd, pjSrcXor; - LONG lDeltaSrc, lDeltaDst; - LONG lSrcWidthInBytes; - ULONG cxSrc = pso->sizlBitmap.cx; - ULONG cySrc = pso->sizlBitmap.cy; - ULONG cxSrcBytes; - PVIDEO_POINTER_ATTRIBUTES pPointerAttributes = ppdev->pPointerAttributes; - PBYTE pjDstAnd = pPointerAttributes->Pixels; - PBYTE pjDstXor = pPointerAttributes->Pixels; - - // Make sure the new pointer isn't too big to handle - // (*2 because both masks are in there) - if ((cxSrc > ppdev->PointerCapabilities.MaxWidth) || - (cySrc > (ppdev->PointerCapabilities.MaxHeight * 2))) - { - return(FALSE); - } - - pjDstXor += ((ppdev->PointerCapabilities.MaxWidth + 7) / 8) * - ppdev->pPointerAttributes->Height; - - // set the desk and mask to 0xff - RtlFillMemory(pjDstAnd, ppdev->pPointerAttributes->WidthInBytes * - ppdev->pPointerAttributes->Height, 0xFF); - - // Zero the dest XOR mask - RtlZeroMemory(pjDstXor, ppdev->pPointerAttributes->WidthInBytes * - ppdev->pPointerAttributes->Height); - - cxSrcBytes = (cxSrc + 7) / 8; - - if ((lDeltaSrc = pso->lDelta) < 0) - { - lSrcWidthInBytes = -lDeltaSrc; - } else { - lSrcWidthInBytes = lDeltaSrc; - } - - pjSrcAnd = (PBYTE) pso->pvBits; - - // If the incoming pointer bitmap is bottomup, we'll flip it to topdown to - // save the miniport some work - if (!(pso->fjBitmap & BMF_TOPDOWN)) - { - // Copy from the bottom - pjSrcAnd += lSrcWidthInBytes * (cySrc - 1); - } - - // Height of just AND mask - cySrc = cySrc / 2; - - // Point to XOR mask - pjSrcXor = pjSrcAnd + (cySrc * lDeltaSrc); - - // Offset from end of one dest scan to start of next - lDeltaDst = ppdev->pPointerAttributes->WidthInBytes; - - for (cy = 0; cy < cySrc; ++cy) - { - RtlCopyMemory(pjDstAnd, pjSrcAnd, cxSrcBytes); - RtlCopyMemory(pjDstXor, pjSrcXor, cxSrcBytes); - - // Point to next source and dest scans - pjSrcAnd += lDeltaSrc; - pjSrcXor += lDeltaSrc; - pjDstAnd += lDeltaDst; - pjDstXor += lDeltaDst; - } - - return(TRUE); -} - -/******************************Public*Routine******************************\ -* bCopyColorPointer -* -* Copies the mono and color masks into the buffer of maximum size -* handled by the miniport with any extra bits set to 0. Color translation -* is handled at this time. The masks are converted to topdown form if they -* aren't already. Returns TRUE if we can handle this pointer in hardware, -* FALSE if not. -* -\**************************************************************************/ -BOOL bCopyColorPointer( -PPDEV ppdev, -SURFOBJ *psoMask, -SURFOBJ *psoColor, -XLATEOBJ *pxlo) -{ - return(FALSE); -} - - -/******************************Public*Routine******************************\ -* bInitPointer -* -* Initialize the Pointer attributes. -* -\**************************************************************************/ - -BOOL bInitPointer(PPDEV ppdev, DEVINFO *pdevinfo) -{ - DWORD returnedDataLength; - - ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES) NULL; - ppdev->cjPointerAttributes = 0; // initialized in screen.c - - // - // Ask the miniport whether it provides pointer support. - // - - if (EngDeviceIoControl(ppdev->hDriver, - IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES, - &ppdev->ulMode, - sizeof(PVIDEO_MODE), - &ppdev->PointerCapabilities, - sizeof(ppdev->PointerCapabilities), - &returnedDataLength)) - { - return(FALSE); - } - - // - // If neither mono nor color hardware pointer is supported, there's no - // hardware pointer support and we're done. - // - - if ((!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER)) && - (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))) - { - return(TRUE); - } - - // - // Note: The buffer itself is allocated after we set the - // mode. At that time we know the pixel depth and we can - // allocate the correct size for the color pointer if supported. - // - - // - // Set the asynchronous support status (async means miniport is capable of - // drawing the Pointer at any time, with no interference with any ongoing - // drawing operation) - // - - if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER) - { - pdevinfo->flGraphicsCaps |= GCAPS_ASYNCMOVE; - } - else - { - pdevinfo->flGraphicsCaps &= ~GCAPS_ASYNCMOVE; - } - - return(TRUE); -} diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild b/reactos/drivers/video/displays/vga_new/vga_new.rbuild similarity index 61% rename from reactos/drivers/video/displays/vga_new/framebuf_new.rbuild rename to reactos/drivers/video/displays/vga_new/vga_new.rbuild index de7c4a1d3be..21f0e2deb73 100644 --- a/reactos/drivers/video/displays/vga_new/framebuf_new.rbuild +++ b/reactos/drivers/video/displays/vga_new/vga_new.rbuild @@ -1,15 +1,14 @@ - - - . + + + . win32k debug.c enable.c palette.c - pointer.c screen.c - framebuf_new.rc + vga_new.rc -mrtd diff --git a/reactos/drivers/video/displays/vga_new/vga_new.rc b/reactos/drivers/video/displays/vga_new/vga_new.rc new file mode 100644 index 00000000000..493bdb8a729 --- /dev/null +++ b/reactos/drivers/video/displays/vga_new/vga_new.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "VGA Display Driver\0" +#define REACTOS_STR_INTERNAL_NAME "vga\0" +#define REACTOS_STR_ORIGINAL_FILENAME "vga.dll\0" +#include diff --git a/reactos/drivers/video/displays/vga_new/framebuf_new.spec b/reactos/drivers/video/displays/vga_new/vga_new.spec similarity index 100% rename from reactos/drivers/video/displays/vga_new/framebuf_new.spec rename to reactos/drivers/video/displays/vga_new/vga_new.spec