merge trunk head (37902)
[reactos.git] / reactos / 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 Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 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 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 */
22
23 #include "videoprt.h"
24
25 VOID NTAPI
26 IntInterfaceReference(PVOID Context)
27 {
28 /* Do nothing */
29 }
30
31 VOID NTAPI
32 IntInterfaceDereference(PVOID Context)
33 {
34 /* Do nothing */
35 }
36
37 VP_STATUS NTAPI
38 VideoPortQueryServices(
39 IN PVOID HwDeviceExtension,
40 IN VIDEO_PORT_SERVICES ServicesType,
41 IN OUT PINTERFACE Interface)
42 {
43 TRACE_(VIDEOPRT, "VideoPortQueryServices - ServicesType: 0x%x\n", ServicesType);
44
45 switch (ServicesType)
46 {
47 #if defined(_M_IX86)
48 case VideoPortServicesInt10:
49 if (Interface->Version >= VIDEO_PORT_INT10_INTERFACE_VERSION_1 ||
50 Interface->Size >= sizeof(VIDEO_PORT_INT10_INTERFACE))
51 {
52 VIDEO_PORT_INT10_INTERFACE *Int10Interface =
53 (VIDEO_PORT_INT10_INTERFACE *)Interface;
54
55 Interface->InterfaceReference = IntInterfaceReference;
56 Interface->InterfaceDereference = IntInterfaceDereference;
57 Int10Interface->Int10AllocateBuffer = IntInt10AllocateBuffer;
58 Int10Interface->Int10FreeBuffer = IntInt10FreeBuffer;
59 Int10Interface->Int10ReadMemory = IntInt10ReadMemory;
60 Int10Interface->Int10WriteMemory = IntInt10WriteMemory;
61 Int10Interface->Int10CallBios = IntInt10CallBios;
62 return NO_ERROR;
63 }
64 break;
65 #endif
66 case VideoPortServicesAGP:
67 if ((Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_2 &&
68 Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE_2)) ||
69 (Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_1 &&
70 Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE)))
71 {
72 if (NT_SUCCESS(IntAgpGetInterface(HwDeviceExtension, Interface)))
73 {
74 return NO_ERROR;
75 }
76 }
77 break;
78
79 case VideoPortServicesI2C:
80 UNIMPLEMENTED;
81 return ERROR_INVALID_FUNCTION;
82
83 case VideoPortServicesHeadless:
84 UNIMPLEMENTED;
85 return ERROR_INVALID_FUNCTION;
86
87 default:
88 break;
89 }
90
91 return ERROR_INVALID_FUNCTION;
92 }
93
94 BOOLEAN NTAPI
95 VideoPortGetAgpServices(
96 IN PVOID HwDeviceExtension,
97 OUT PVIDEO_PORT_AGP_SERVICES AgpServices)
98 {
99 VIDEO_PORT_AGP_INTERFACE Interface;
100 VP_STATUS Status;
101
102 TRACE_(VIDEOPRT, "VideoPortGetAgpServices\n");
103
104 Interface.Size = sizeof(Interface);
105 Interface.Version = VIDEO_PORT_AGP_INTERFACE_VERSION_1;
106
107 Status = VideoPortQueryServices(HwDeviceExtension, VideoPortServicesAGP,
108 (PINTERFACE)&Interface);
109 if (Status != NO_ERROR)
110 {
111 WARN_(VIDEOPRT, "VideoPortQueryServices() failed!\n");
112 return FALSE;
113 }
114
115 RtlCopyMemory(AgpServices, &Interface.AgpReservePhysical, sizeof(AgpServices));
116 return TRUE;
117 }