sync with trunk r47227
[reactos.git] / drivers / video / videoprt / event.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 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.
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 * Lesser General Public License for more details.
15 *
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
19 *
20 */
21
22 #include "videoprt.h"
23
24 /* PUBLIC FUNCTIONS ***********************************************************/
25
26 /*
27 * @implemented
28 */
29
30 VP_STATUS NTAPI
31 VideoPortCreateEvent(
32 IN PVOID HwDeviceExtension,
33 IN ULONG EventFlag,
34 IN PVOID Unused,
35 OUT PEVENT *Event)
36 {
37 PVIDEO_PORT_EVENT VpEvent;
38 EVENT_TYPE Type = SynchronizationEvent;
39
40 /* Allocate storage for the event structure */
41 VpEvent = ExAllocatePoolWithTag(
42 NonPagedPool,
43 sizeof(VIDEO_PORT_EVENT),
44 TAG_VIDEO_PORT);
45
46 /* Fail if not enough memory */
47 if (!VpEvent) return ERROR_NOT_ENOUGH_MEMORY;
48
49 /* Initialize the event structure */
50 RtlZeroMemory(VpEvent, sizeof(VIDEO_PORT_EVENT));
51 VpEvent->pKEvent = &VpEvent->Event;
52
53 /* Determine the event type */
54 if (EventFlag & NOTIFICATION_EVENT)
55 Type = NotificationEvent;
56
57 /* Initialize kernel event */
58 KeInitializeEvent(VpEvent->pKEvent, Type, EventFlag & INITIAL_EVENT_SIGNALED);
59
60 /* Indicate success */
61 return NO_ERROR;
62 }
63
64 /*
65 * @implemented
66 */
67
68 VP_STATUS NTAPI
69 VideoPortDeleteEvent(
70 IN PVOID HwDeviceExtension,
71 IN PEVENT Event)
72 {
73 /* Free storage */
74 ExFreePool(Event);
75
76 /* Indicate success */
77 return NO_ERROR;
78 }
79
80 /*
81 * @implemented
82 */
83
84 LONG NTAPI
85 VideoPortSetEvent(
86 IN PVOID HwDeviceExtension,
87 IN PEVENT Event)
88 {
89 return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE);
90 }
91
92 /*
93 * @implemented
94 */
95
96 VOID NTAPI
97 VideoPortClearEvent(
98 IN PVOID HwDeviceExtension,
99 IN PEVENT Event)
100 {
101 KeClearEvent(Event->pKEvent);
102 }
103
104 /*
105 * @implemented
106 */
107
108 VP_STATUS NTAPI
109 VideoPortWaitForSingleObject(
110 IN PVOID HwDeviceExtension,
111 IN PVOID Object,
112 IN PLARGE_INTEGER Timeout OPTIONAL)
113 {
114 return KeWaitForSingleObject(
115 Object,
116 Executive,
117 KernelMode,
118 FALSE,
119 Timeout);
120 }