1 /*
2  * PROJECT:         ReactOS Framebuffer Display Driver
3  * LICENSE:         Microsoft NT4 DDK Sample Code License
4  * FILE:            win32ss/drivers/displays/vga_new/driver.h
5  * PURPOSE:         Main Driver Header File
6  * PROGRAMMERS:     Copyright (c) 1992-1995 Microsoft Corporation
7  *                  ReactOS Portable Systems Group
8  */
9 
10 //#define DBG 1
11 #include "stddef.h"
12 #include <stdarg.h>
13 #include "windef.h"
14 #include "wingdi.h"
15 #include "winddi.h"
16 #include "devioctl.h"
17 #include "ntddvdeo.h"
18 #include "debug.h"
19 
20 typedef struct  _PDEV
21 {
22     HANDLE  hDriver;                    // Handle to \Device\Screen
23     HDEV    hdevEng;                    // Engine's handle to PDEV
24     HSURF   hsurfEng;                   // Engine's handle to surface
25     HPALETTE hpalDefault;               // Handle to the default palette for device.
26     PBYTE   pjScreen;                   // This is pointer to base screen address
27     ULONG   cxScreen;                   // Visible screen width
28     ULONG   cyScreen;                   // Visible screen height
29     ULONG   ulMode;                     // Mode the mini-port driver is in.
30     LONG    lDeltaScreen;               // Distance from one scan to the next.
31     ULONG   cScreenSize;                // size of video memory, including
32                                         // offscreen memory.
33     PVOID   pOffscreenList;             // linked list of DCI offscreen surfaces.
34     FLONG   flRed;                      // For bitfields device, Red Mask
35     FLONG   flGreen;                    // For bitfields device, Green Mask
36     FLONG   flBlue;                     // For bitfields device, Blue Mask
37     ULONG   cPaletteShift;              // number of bits the 8-8-8 palette must
38                                         // be shifted by to fit in the hardware
39                                         // palette.
40     ULONG   ulBitCount;                 // # of bits per pel 8,16,24,32 are only supported.
41     POINTL  ptlHotSpot;                 // adjustment for pointer hot spot
42     VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
43     PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes
44     DWORD   cjPointerAttributes;        // Size of buffer allocated
45     BOOL    fHwCursorActive;            // Are we currently using the hw cursor
46     PALETTEENTRY *pPal;                 // If this is pal managed, this is the pal
47     BOOL    bSupportDCI;                // Does the miniport support DCI?
48 // eVb: 3.1 [DDK Change] - Support new VGA Miniport behavior w.r.t updated framebuffer remapping
49     LONG flHooks;
50 // eVb: 3.1 [END]
51 // eVb: 3.1 [VGARISC Change] - Add new fields for VGA support
52     SURFOBJ* pso;
53     UCHAR* pjBase;
54 // eVb: 3.1 [END]
55 } PDEV, *PPDEV;
56 
57 DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
58 BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
59 BOOL bInitSURF(PPDEV, BOOL);
60 BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
61 BOOL bInitPointer(PPDEV, DEVINFO *);
62 BOOL bInit256ColorPalette(PPDEV);
63 VOID vDisablePalette(PPDEV);
64 VOID vDisableSURF(PPDEV);
65 
66 #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
67 
68 //
69 // Determines the size of the DriverExtra information in the DEVMODE
70 // structure passed to and from the display driver.
71 //
72 
73 #define DRIVER_EXTRA_SIZE 0
74 
75 // eVb: 3.2 [VGARISC Change] - Transform into VGA driver
76 #define DLL_NAME                L"vga"   // Name of the DLL in UNICODE
77 #define STANDARD_DEBUG_PREFIX   "Vga risc: "  // All debug output is prefixed
78 #define ALLOC_TAG               'rgvD'        // Four byte tag (characters in
79                                               // reverse order) used for memory
80                                               // allocations
81 // eVb: 3.2 [END]
82 
83 // eVb: 3.3 [VGARISC Change] - Add new macros for VGA usage
84 //
85 // Each pixel in 4BPP being a nibble, the color data for that pixel is thus
86 // located at the xth bit within the nibble, where x is the plane number [0-3].
87 // Each nibble being 4 bytes, the color data is thus at the (nibble * 4 + x).
88 // That color data is then taken from its linear position and shifted to the
89 // correct position within the 16-bit planar buffer word.
90 //
91 #define VAL(data, px, pl, pos)   ((data) >> (((px) * 4) + (pl)) & 1) << (pos)
92 
93 //
94 // This figures out which pixel in the planar word data corresponds to which pixel
95 // in the 4BPP linear data.
96 //
97 #define SET_PLANE_DATA(x, y, a, b)  \
98     (x) |= VAL(y, (((-1 + ((((b) % 8) % 2) << 1) - (((b) % 8) + 1) + 8))), a, b)
99 
100 /* Alignment Macros */
101 #define ALIGN_DOWN_BY(size, align) \
102     ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1))
103 
104 #define ALIGN_UP_BY(size, align) \
105     (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align))
106 // eVb: 3.3 [END]
107