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 /* PRIVATE FUNCTIONS **********************************************************/
27 IntVideoPortInterruptRoutine(
28 IN
struct _KINTERRUPT
*Interrupt
,
29 IN PVOID ServiceContext
)
31 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
= ServiceContext
;
33 ASSERT(DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt
!= NULL
);
35 return DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt(
36 &DeviceExtension
->MiniPortDeviceExtension
);
40 IntVideoPortSetupInterrupt(
41 IN PDEVICE_OBJECT DeviceObject
,
42 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension
,
43 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo
)
46 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
48 DeviceExtension
= (PVIDEO_PORT_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
51 * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
52 * HwVidFindAdapter function finds that the video adapter does not generate
53 * interrupts or that it cannot determine a valid interrupt vector/level for
54 * the adapter, HwVidFindAdapter should set both BusInterruptVector and
55 * BusInterruptLevel to zero.
58 if (DriverExtension
->InitializationData
.HwInterrupt
!= NULL
&&
59 (ConfigInfo
->BusInterruptLevel
!= 0 ||
60 ConfigInfo
->BusInterruptVector
!= 0))
62 ULONG InterruptVector
;
66 InterruptVector
= HalGetInterruptVector(
67 ConfigInfo
->AdapterInterfaceType
,
68 ConfigInfo
->SystemIoBusNumber
,
69 ConfigInfo
->BusInterruptLevel
,
70 ConfigInfo
->BusInterruptVector
,
74 if (InterruptVector
== 0)
76 WARN_(VIDEOPRT
, "HalGetInterruptVector failed\n");
80 KeInitializeSpinLock(&DeviceExtension
->InterruptSpinLock
);
81 Status
= IoConnectInterrupt(
82 &DeviceExtension
->InterruptObject
,
83 IntVideoPortInterruptRoutine
,
85 &DeviceExtension
->InterruptSpinLock
,
89 ConfigInfo
->InterruptMode
,
90 DeviceExtension
->InterruptShared
,
94 if (!NT_SUCCESS(Status
))
96 WARN_(VIDEOPRT
, "IoConnectInterrupt failed with status 0x%08x\n", Status
);
104 /* PUBLIC FUNCTIONS ***********************************************************/
111 VideoPortEnableInterrupt(IN PVOID HwDeviceExtension
)
114 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
115 BOOLEAN InterruptValid
;
117 /* Get the device extension */
118 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
120 /* Fail if the driver didn't register an ISR */
121 if (!DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt
)
123 /* No ISR, no interrupts */
124 return ERROR_INVALID_FUNCTION
;
127 /* Re-enable the interrupt and return */
128 InterruptValid
= HalEnableSystemInterrupt((UCHAR
)DeviceExtension
->InterruptVector
,
130 DeviceExtension
->InterruptLevel
);
132 /* Make sure the interrupt was valid */
133 ASSERT(InterruptValid
== TRUE
);
135 /* Return to caller */
138 /* FIXME: Function still present? If so what to use instead of HalEnableSystemInterrupt? */
140 return ERROR_INVALID_FUNCTION
;
149 VideoPortDisableInterrupt(IN PVOID HwDeviceExtension
)
152 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension
;
154 /* Get the device extension */
155 DeviceExtension
= VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension
);
157 /* Fail if the driver didn't register an ISR */
158 if (!DeviceExtension
->DriverExtension
->InitializationData
.HwInterrupt
)
160 /* No ISR, no interrupts */
161 return ERROR_INVALID_FUNCTION
;
164 /* Disable the interrupt and return */
165 HalDisableSystemInterrupt((UCHAR
)DeviceExtension
->InterruptVector
,
169 /* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */
171 return ERROR_INVALID_FUNCTION
;