+/* PRIVATE FUNCTIONS **********************************************************/
+
+BOOLEAN NTAPI
+IntVideoPortInterruptRoutine(
+ IN struct _KINTERRUPT *Interrupt,
+ IN PVOID ServiceContext)
+{
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = ServiceContext;
+
+ ASSERT(DeviceExtension->DriverExtension->InitializationData.HwInterrupt != NULL);
+
+ return DeviceExtension->DriverExtension->InitializationData.HwInterrupt(
+ &DeviceExtension->MiniPortDeviceExtension);
+}
+
+BOOLEAN NTAPI
+IntVideoPortSetupInterrupt(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
+ IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
+{
+ NTSTATUS Status;
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
+
+ DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ /*
+ * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
+ * HwVidFindAdapter function finds that the video adapter does not generate
+ * interrupts or that it cannot determine a valid interrupt vector/level for
+ * the adapter, HwVidFindAdapter should set both BusInterruptVector and
+ * BusInterruptLevel to zero.
+ */
+
+ if (DriverExtension->InitializationData.HwInterrupt != NULL &&
+ (ConfigInfo->BusInterruptLevel != 0 ||
+ ConfigInfo->BusInterruptVector != 0))
+ {
+ ULONG InterruptVector;
+ KIRQL Irql;
+ KAFFINITY Affinity;
+
+ InterruptVector = HalGetInterruptVector(
+ ConfigInfo->AdapterInterfaceType,
+ ConfigInfo->SystemIoBusNumber,
+ ConfigInfo->BusInterruptLevel,
+ ConfigInfo->BusInterruptVector,
+ &Irql,
+ &Affinity);
+
+ if (InterruptVector == 0)
+ {
+ WARN_(VIDEOPRT, "HalGetInterruptVector failed\n");
+ return FALSE;
+ }
+
+ KeInitializeSpinLock(&DeviceExtension->InterruptSpinLock);
+ Status = IoConnectInterrupt(
+ &DeviceExtension->InterruptObject,
+ IntVideoPortInterruptRoutine,
+ DeviceExtension,
+ &DeviceExtension->InterruptSpinLock,
+ InterruptVector,
+ Irql,
+ Irql,
+ ConfigInfo->InterruptMode,
+ DeviceExtension->InterruptShared,
+ Affinity,
+ FALSE);
+
+ if (!NT_SUCCESS(Status))
+ {
+ WARN_(VIDEOPRT, "IoConnectInterrupt failed with status 0x%08x\n", Status);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+