1 /*
2  * PROJECT:     ReactOS Xbox miniport video driver
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     Simple framebuffer driver for NVIDIA NV2A XGPU
5  * COPYRIGHT:   Copyright 2004 Ge van Geldorp
6  *              Copyright 2004 Filip Navara
7  *              Copyright 2019-2020 Stanislav Motylkov (x86corez@gmail.com)
8  */
9 
10 #pragma once
11 
12 /* INCLUDES *******************************************************************/
13 
14 /*
15  * FIXME: specify headers properly in the triangle brackets and rearrange them
16  * in a way so it would be simpler to add NDK and other headers for debugging.
17  */
18 #include "ntdef.h"
19 #define PAGE_SIZE 4096
20 #include "dderror.h"
21 #include "devioctl.h"
22 #include "miniport.h"
23 #include "ioaccess.h"
24 #include "video.h"
25 
26 #define NV2A_VIDEO_MEMORY_SIZE    (4 * 1024 * 1024)
27 
28 #define NV2A_CONTROL_FRAMEBUFFER_ADDRESS_OFFSET 0x600800
29 #define NV2A_CRTC_REGISTER_INDEX                0x6013D4
30 #define NV2A_CRTC_REGISTER_VALUE                0x6013D5
31 #define NV2A_RAMDAC_FP_HVALID_END               0x680838
32 #define NV2A_RAMDAC_FP_VVALID_END               0x680818
33 
34 typedef struct
35 {
36     PHYSICAL_ADDRESS PhysControlStart;
37     ULONG ControlLength;
38     PVOID VirtControlStart;
39     PHYSICAL_ADDRESS PhysFrameBufferStart;
40 } XBOXVMP_DEVICE_EXTENSION, *PXBOXVMP_DEVICE_EXTENSION;
41 
42 VP_STATUS
43 NTAPI
44 XboxVmpFindAdapter(
45     IN PVOID HwDeviceExtension,
46     IN PVOID HwContext,
47     IN PWSTR ArgumentString,
48     IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
49     OUT PUCHAR Again);
50 
51 BOOLEAN
52 NTAPI
53 XboxVmpInitialize(
54     PVOID HwDeviceExtension);
55 
56 BOOLEAN
57 NTAPI
58 XboxVmpStartIO(
59     PVOID HwDeviceExtension,
60     PVIDEO_REQUEST_PACKET RequestPacket);
61 
62 BOOLEAN
63 NTAPI
64 XboxVmpResetHw(
65     PVOID DeviceExtension,
66     ULONG Columns,
67     ULONG Rows);
68 
69 VP_STATUS
70 NTAPI
71 XboxVmpGetPowerState(
72     PVOID HwDeviceExtension,
73     ULONG HwId,
74     PVIDEO_POWER_MANAGEMENT VideoPowerControl);
75 
76 VP_STATUS
77 NTAPI
78 XboxVmpSetPowerState(
79     PVOID HwDeviceExtension,
80     ULONG HwId,
81     PVIDEO_POWER_MANAGEMENT VideoPowerControl);
82 
83 BOOLEAN
84 FASTCALL
85 XboxVmpSetCurrentMode(
86     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
87     PVIDEO_MODE RequestedMode,
88     PSTATUS_BLOCK StatusBlock);
89 
90 BOOLEAN
91 FASTCALL
92 XboxVmpResetDevice(
93     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
94     PSTATUS_BLOCK StatusBlock);
95 
96 BOOLEAN
97 FASTCALL
98 XboxVmpMapVideoMemory(
99     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
100     PVIDEO_MEMORY RequestedAddress,
101     PVIDEO_MEMORY_INFORMATION MapInformation,
102     PSTATUS_BLOCK StatusBlock);
103 
104 BOOLEAN
105 FASTCALL
106 XboxVmpUnmapVideoMemory(
107     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
108     PVIDEO_MEMORY VideoMemory,
109     PSTATUS_BLOCK StatusBlock);
110 
111 BOOLEAN
112 FASTCALL
113 XboxVmpQueryNumAvailModes(
114     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
115     PVIDEO_NUM_MODES Modes,
116     PSTATUS_BLOCK StatusBlock);
117 
118 BOOLEAN
119 FASTCALL
120 XboxVmpQueryAvailModes(
121     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
122     PVIDEO_MODE_INFORMATION ReturnedModes,
123     PSTATUS_BLOCK StatusBlock);
124 
125 BOOLEAN
126 FASTCALL
127 XboxVmpQueryCurrentMode(
128     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
129     PVIDEO_MODE_INFORMATION VideoModeInfo,
130     PSTATUS_BLOCK StatusBlock);
131 
132 BOOLEAN
133 FASTCALL
134 XboxVmpSetColorRegisters(
135     PXBOXVMP_DEVICE_EXTENSION DeviceExtension,
136     PVIDEO_CLUT ColorLookUpTable,
137     PSTATUS_BLOCK StatusBlock);
138 
139 /* EOF */
140