4 * Copyright (C) 2002, 2003, 2004 ReactOS Team
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.
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.
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
24 #include <ndk/halfuncs.h>
29 /* PRIVATE FUNCTIONS **********************************************************/
32 IntVideoPortInterruptRoutine(
33 IN
struct _KINTERRUPT
*Interrupt
,
34 IN PVOID ServiceContext
)
36 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
= ServiceContext
;
38 ASSERT(DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt
!= NULL
);
40 return DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt(
41 &DeviceExtension
->MiniPortDeviceExtension
);
45 IntVideoPortSetupInterrupt(
46 IN PDEVICE_OBJECT DeviceObject
,
47 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension
,
48 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo
)
51 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
53 DeviceExtension
= (PVIDEO_PORT_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
56 * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
57 * HwVidFindAdapter function finds that the video adapter does not generate
58 * interrupts or that it cannot determine a valid interrupt vector/level for
59 * the adapter, HwVidFindAdapter should set both BusInterruptVector and
60 * BusInterruptLevel to zero.
63 if (DriverExtension
->InitializationData
.HwInterrupt
!= NULL
&&
64 (ConfigInfo
->BusInterruptLevel
!= 0 ||
65 ConfigInfo
->BusInterruptVector
!= 0))
67 ULONG InterruptVector
;
71 InterruptVector
= HalGetInterruptVector(
72 ConfigInfo
->AdapterInterfaceType
,
73 ConfigInfo
->SystemIoBusNumber
,
74 ConfigInfo
->BusInterruptLevel
,
75 ConfigInfo
->BusInterruptVector
,
79 if (InterruptVector
== 0)
81 WARN_(VIDEOPRT
, "HalGetInterruptVector failed\n");
85 KeInitializeSpinLock(&DeviceExtension
->InterruptSpinLock
);
86 Status
= IoConnectInterrupt(
87 &DeviceExtension
->InterruptObject
,
88 IntVideoPortInterruptRoutine
,
90 &DeviceExtension
->InterruptSpinLock
,
94 ConfigInfo
->InterruptMode
,
95 DeviceExtension
->InterruptShared
,
99 if (!NT_SUCCESS(Status
))
101 WARN_(VIDEOPRT
, "IoConnectInterrupt failed with status 0x%08x\n", Status
);
109 /* PUBLIC FUNCTIONS ***********************************************************/
116 VideoPortEnableInterrupt(IN PVOID HwDeviceExtension
)
119 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
120 BOOLEAN InterruptValid
;
122 /* Get the device extension */
123 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
125 /* Fail if the driver didn't register an ISR */
126 if (!DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt
)
128 /* No ISR, no interrupts */
129 return ERROR_INVALID_FUNCTION
;
132 /* Re-enable the interrupt and return */
133 InterruptValid
= HalEnableSystemInterrupt(DeviceExtension
->InterruptVector
,
135 DeviceExtension
->InterruptLevel
);
137 /* Make sure the interrupt was valid */
138 ASSERT(InterruptValid
== TRUE
);
140 /* Return to caller */
143 /* FIXME: Function still present? If so what to use instead of HalEnableSystemInterrupt? */
145 return ERROR_INVALID_FUNCTION
;
154 VideoPortDisableInterrupt(IN PVOID HwDeviceExtension
)
157 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
159 /* Get the device extension */
160 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
162 /* Fail if the driver didn't register an ISR */
163 if (!DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt
)
165 /* No ISR, no interrupts */
166 return ERROR_INVALID_FUNCTION
;
169 /* Disable the interrupt and return */
170 HalDisableSystemInterrupt(DeviceExtension
->InterruptVector
, 0);
173 /* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */
175 return ERROR_INVALID_FUNCTION
;