Sync with trunk head
[reactos.git] / drivers / video / videoprt / services.c
1 /*
2 * VideoPort driver
3 *
4 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #include "videoprt.h"
23
24 VOID NTAPI
25 IntInterfaceReference(PVOID Context)
26 {
27 /* Do nothing */
28 }
29
30 VOID NTAPI
31 IntInterfaceDereference(PVOID Context)
32 {
33 /* Do nothing */
34 }
35
36 VP_STATUS NTAPI
37 VideoPortQueryServices(
38 IN PVOID HwDeviceExtension,
39 IN VIDEO_PORT_SERVICES ServicesType,
40 IN OUT PINTERFACE Interface)
41 {
42 TRACE_(VIDEOPRT, "VideoPortQueryServices - ServicesType: 0x%x\n", ServicesType);
43
44 switch (ServicesType)
45 {
46 case VideoPortServicesInt10:
47 if (Interface->Version >= VIDEO_PORT_INT10_INTERFACE_VERSION_1 ||
48 Interface->Size >= sizeof(VIDEO_PORT_INT10_INTERFACE))
49 {
50 VIDEO_PORT_INT10_INTERFACE *Int10Interface =
51 (VIDEO_PORT_INT10_INTERFACE *)Interface;
52
53 Interface->InterfaceReference = IntInterfaceReference;
54 Interface->InterfaceDereference = IntInterfaceDereference;
55 Int10Interface->Int10AllocateBuffer = IntInt10AllocateBuffer;
56 Int10Interface->Int10FreeBuffer = IntInt10FreeBuffer;
57 Int10Interface->Int10ReadMemory = IntInt10ReadMemory;
58 Int10Interface->Int10WriteMemory = IntInt10WriteMemory;
59 Int10Interface->Int10CallBios = IntInt10CallBios;
60 return NO_ERROR;
61 }
62 break;
63
64 case VideoPortServicesAGP:
65 if ((Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_2 &&
66 Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE_2)) ||
67 (Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_1 &&
68 Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE)))
69 {
70 if (NT_SUCCESS(IntAgpGetInterface(HwDeviceExtension, Interface)))
71 {
72 return NO_ERROR;
73 }
74 }
75 break;
76
77 case VideoPortServicesI2C:
78 UNIMPLEMENTED;
79 return ERROR_INVALID_FUNCTION;
80
81 case VideoPortServicesHeadless:
82 UNIMPLEMENTED;
83 return ERROR_INVALID_FUNCTION;
84
85 default:
86 break;
87 }
88
89 return ERROR_INVALID_FUNCTION;
90 }
91
92 BOOLEAN NTAPI
93 VideoPortGetAgpServices(
94 IN PVOID HwDeviceExtension,
95 OUT PVIDEO_PORT_AGP_SERVICES AgpServices)
96 {
97 VIDEO_PORT_AGP_INTERFACE Interface;
98 VP_STATUS Status;
99
100 TRACE_(VIDEOPRT, "VideoPortGetAgpServices\n");
101
102 Interface.Size = sizeof(Interface);
103 Interface.Version = VIDEO_PORT_AGP_INTERFACE_VERSION_1;
104
105 Status = VideoPortQueryServices(HwDeviceExtension, VideoPortServicesAGP,
106 (PINTERFACE)&Interface);
107 if (Status != NO_ERROR)
108 {
109 WARN_(VIDEOPRT, "VideoPortQueryServices() failed!\n");
110 return FALSE;
111 }
112
113 RtlCopyMemory(AgpServices, &Interface.AgpReservePhysical, sizeof(AgpServices));
114 return TRUE;
115 }