xref: /reactos/sdk/lib/drivers/sound/legacy/hardware.c (revision 5100859e)
1 /*
2     ReactOS Sound System
3     Hardware interaction helper
4 
5     Author:
6         Andrew Greenwood (silverblade@reactos.org)
7 
8     History:
9         25 May 2008 - Created
10 
11     Notes:
12         This uses some obsolete calls (eg: HalGetInterruptVector).
13         Might be worth updating this in future to use some of the
14         recommended functions like IoReportDetectedDevice and
15         IoReportResourceForDetection...
16 */
17 
18 #include <ntddk.h>
19 #include <ntddsnd.h>
20 #include <debug.h>
21 
22 /* NOTE: Disconnect using IoDisconnectInterrupt */
23 
24 NTSTATUS
25 LegacyAttachInterrupt(
26     IN  PDEVICE_OBJECT DeviceObject,
27     IN  UCHAR Irq,
28     IN  PKSERVICE_ROUTINE ServiceRoutine,
29     OUT PKINTERRUPT* InterruptObject)
30 {
31     NTSTATUS Status;
32     ULONG Vector;
33     KIRQL IrqLevel;
34     KAFFINITY Affinity;
35 
36     DPRINT("Obtaining interrupt vector");
37 
38     Vector = HalGetInterruptVector(Isa,
39                                    0,
40                                    Irq,
41                                    Irq,
42                                    &IrqLevel,
43                                    &Affinity);
44 
45     DPRINT("Vector %d", Vector);
46     DPRINT("Connecting IRQ %d", Irq);
47 
48     Status = IoConnectInterrupt(InterruptObject,
49                                 ServiceRoutine,
50                                 DeviceObject,
51                                 NULL,
52                                 Vector,
53                                 IrqLevel,
54                                 IrqLevel,
55                                 Latched,
56                                 FALSE,
57                                 Affinity,
58                                 FALSE);
59 
60     if ( Status == STATUS_INVALID_PARAMETER )
61     {
62         Status = STATUS_DEVICE_CONFIGURATION_ERROR;
63     }
64 
65     return Status;
66 }
67