ReactOS  0.4.15-dev-5500-g82cf6c2
enable.c
Go to the documentation of this file.
1 /*
2  * ReactOS Generic Framebuffer display driver
3  *
4  * Copyright (C) 2004 Filip Navara
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "framebuf.h"
22 
24 {
37 
38 };
39 
40 /*
41  * DrvEnableDirectDraw
42  */
43 
46  DHPDEV dhpdev,
47  DD_CALLBACKS *pCallbacks,
48  DD_SURFACECALLBACKS *pSurfaceCallbacks,
49  DD_PALETTECALLBACKS *pPaletteCallbacks)
50 {
51  RtlZeroMemory(pCallbacks, sizeof(*pCallbacks));
52  RtlZeroMemory(pSurfaceCallbacks, sizeof(*pSurfaceCallbacks));
53  RtlZeroMemory(pPaletteCallbacks, sizeof(*pPaletteCallbacks));
54 
55  pCallbacks->dwSize = sizeof(*pCallbacks);
56  pSurfaceCallbacks->dwSize = sizeof(*pSurfaceCallbacks);
57  pPaletteCallbacks->dwSize = sizeof(*pPaletteCallbacks);
58 
59  /* We don't support any optional callback */
60 
61  return TRUE;
62 }
63 
64 /*
65  * DrvDisableDirectDraw
66  */
67 
70  DHPDEV dhpdev)
71 {
72 }
73 
74 /*
75  * DrvEnableDriver
76  *
77  * Initial driver entry point exported by the driver DLL. It fills in a
78  * DRVENABLEDATA structure with the driver's DDI version number and the
79  * calling addresses of all DDI functions supported by the driver.
80  *
81  * Status
82  * @implemented
83  */
84 
87  ULONG iEngineVersion,
88  ULONG cj,
89  PDRVENABLEDATA pded)
90 {
91  if (cj >= sizeof(DRVENABLEDATA))
92  {
93  pded->c = sizeof(DrvFunctionTable) / sizeof(DRVFN);
94  pded->pdrvfn = DrvFunctionTable;
96  return TRUE;
97  }
98  else
99  {
100  return FALSE;
101  }
102 }
103 
104 /*
105  * DrvEnablePDEV
106  *
107  * Returns a description of the physical device's characteristics to GDI.
108  *
109  * Status
110  * @implemented
111  */
112 
115  IN DEVMODEW *pdm,
117  IN ULONG cPat,
118  OUT HSURF *phsurfPatterns,
119  IN ULONG cjCaps,
120  OUT ULONG *pdevcaps,
122  OUT DEVINFO *pdi,
123  IN HDEV hdev,
125  IN HANDLE hDriver)
126 {
127  PPDEV ppdev;
128  GDIINFO GdiInfo;
129  DEVINFO DevInfo;
130 
131  ppdev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
132  if (ppdev == NULL)
133  {
134  return NULL;
135  }
136 
137  ppdev->hDriver = hDriver;
138 
139  if (!IntInitScreenInfo(ppdev, pdm, &GdiInfo, &DevInfo))
140  {
141  EngFreeMem(ppdev);
142  return NULL;
143  }
144 
145  if (!IntInitDefaultPalette(ppdev, &DevInfo))
146  {
147  EngFreeMem(ppdev);
148  return NULL;
149  }
150 
151  memcpy(pdi, &DevInfo, min(sizeof(DEVINFO), cjDevInfo));
152  memcpy(pdevcaps, &GdiInfo, min(sizeof(GDIINFO), cjCaps));
153 
154  return (DHPDEV)ppdev;
155 }
156 
157 /*
158  * DrvCompletePDEV
159  *
160  * Stores the GDI handle (hdev) of the physical device in dhpdev. The driver
161  * should retain this handle for use when calling GDI services.
162  *
163  * Status
164  * @implemented
165  */
166 
169  IN DHPDEV dhpdev,
170  IN HDEV hdev)
171 {
172  ((PPDEV)dhpdev)->hDevEng = hdev;
173 }
174 
175 /*
176  * DrvDisablePDEV
177  *
178  * Release the resources allocated in DrvEnablePDEV. If a surface has been
179  * enabled DrvDisableSurface will have already been called.
180  *
181  * Status
182  * @implemented
183  */
184 
187  IN DHPDEV dhpdev)
188 {
189  if (((PPDEV)dhpdev)->DefaultPalette)
190  {
192  }
193 
194  if (((PPDEV)dhpdev)->PaletteEntries != NULL)
195  {
196  EngFreeMem(((PPDEV)dhpdev)->PaletteEntries);
197  }
198 
199  EngFreeMem(dhpdev);
200 }
#define IN
Definition: typedefs.h:39
BOOL IntInitScreenInfo(PPDEV ppdev, LPDEVMODEW pDevMode, PGDIINFO pGdiInfo, PDEVINFO pDevInfo)
Definition: screen.c:120
_In_ ULONG cj
Definition: winddi.h:3540
#define INDEX_DrvCompletePDEV
Definition: winddi.h:417
typedef DHPDEV(APIENTRY FN_DrvEnablePDEV)(_In_ DEVMODEW *pdm
ULONG NTAPI DrvGetModes(HANDLE hDriver, ULONG cjSize, DEVMODEW *pdm)
Definition: enable.c:374
#define TRUE
Definition: types.h:120
#define INDEX_DrvGetModes
Definition: winddi.h:457
#define EngFreeMem
Definition: polytest.cpp:56
HSURF NTAPI DrvEnableSurface(DHPDEV dhpdev)
Definition: enable.c:200
#define INDEX_DrvEnablePDEV
Definition: winddi.h:416
BOOL NTAPI DrvAssertMode(DHPDEV dhpdev, BOOL bEnable)
Definition: enable.c:302
VOID APIENTRY DrvDisablePDEV(IN DHPDEV dhpdev)
Definition: enable.c:186
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
BOOL IntInitDefaultPalette(PPDEV ppdev, PDEVINFO pDevInfo)
Definition: palette.c:60
#define ALLOC_TAG
Definition: btrfs_drv.h:87
static const UCHAR DefaultPalette[]
Definition: blue.c:69
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE hDriver
Definition: framebuf.h:35
#define INDEX_DrvDisableDirectDraw
Definition: winddi.h:477
#define INDEX_DrvAssertMode
Definition: winddi.h:421
BOOL APIENTRY DrvEnableDirectDraw(DHPDEV dhpdev, DD_CALLBACKS *pCallbacks, DD_SURFACECALLBACKS *pSurfaceCallbacks, DD_PALETTECALLBACKS *pPaletteCallbacks)
Definition: enable.c:45
#define DDI_DRIVER_VERSION_NT5
Definition: winddi.h:537
BOOL APIENTRY DrvEnableDriver(ULONG iEngineVersion, ULONG cj, PDRVENABLEDATA pded)
Definition: enable.c:86
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
DRVFN * pdrvfn
Definition: winddi.h:544
_In_ LPWSTR pwszLogAddress
Definition: winddi.h:3548
FN_DrvSetPalette DrvSetPalette
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
struct _PDEV * PPDEV
#define INDEX_DrvSetPointerShape
Definition: winddi.h:445
Definition: framebuf.h:33
static DRVFN DrvFunctionTable[]
Definition: enable.c:23
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
#define INDEX_DrvSetPalette
Definition: winddi.h:438
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define INDEX_DrvEnableDirectDraw
Definition: winddi.h:476
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)
#define INDEX_DrvDisableSurface
Definition: winddi.h:420
FN_DrvMovePointer DrvMovePointer
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR pwszDeviceName
Definition: winddi.h:3553
DHPDEV APIENTRY DrvEnablePDEV(IN DEVMODEW *pdm, IN LPWSTR pwszLogAddress, IN ULONG cPat, OUT HSURF *phsurfPatterns, IN ULONG cjCaps, OUT ULONG *pdevcaps, IN ULONG cjDevInfo, OUT DEVINFO *pdi, IN HDEV hdev, IN LPWSTR pwszDeviceName, IN HANDLE hDriver)
Definition: enable.c:114
#define INDEX_DrvEnableSurface
Definition: winddi.h:419
FN_DrvSetPointerShape DrvSetPointerShape
BOOLEAN(* PFN)(PARGS)
Definition: parse.h:47
VOID APIENTRY DrvCompletePDEV(IN DHPDEV dhpdev, IN HDEV hdev)
Definition: enable.c:168
_In_ LPWSTR _In_ ULONG cPat
Definition: winddi.h:3548
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG cjDevInfo
Definition: winddi.h:3553
ULONG iDriverVersion
Definition: winddi.h:542
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
VOID APIENTRY DrvDisableDirectDraw(DHPDEV dhpdev)
Definition: enable.c:69
#define INDEX_DrvDisablePDEV
Definition: winddi.h:418
#define INDEX_DrvMovePointer
Definition: winddi.h:446
_In_ LPWSTR _In_ ULONG _In_ ULONG cjCaps
Definition: winddi.h:3551
#define OUT
Definition: typedefs.h:40
DWORD dwSize
Definition: ddrawint.h:498
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID NTAPI DrvDisableSurface(DHPDEV dhpdev)
Definition: enable.c:287
Definition: winddi.h:529
_In_ HDEV hdev
Definition: winddi.h:3449
#define APIENTRY
Definition: api.h:79
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3553