* Sync up to trunk HEAD (r62975).
[reactos.git] / win32ss / drivers / videoprt / timer.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 #define NDEBUG
25 #include <debug.h>
26
27 /* PRIVATE FUNCTIONS **********************************************************/
28
29 VOID NTAPI
30 IntVideoPortTimerRoutine(
31 IN PDEVICE_OBJECT DeviceObject,
32 IN PVOID ServiceContext)
33 {
34 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = ServiceContext;
35
36 ASSERT(DeviceExtension->DriverExtension->InitializationData.HwTimer != NULL);
37
38 DeviceExtension->DriverExtension->InitializationData.HwTimer(
39 &DeviceExtension->MiniPortDeviceExtension);
40 }
41
42 BOOLEAN NTAPI
43 IntVideoPortSetupTimer(
44 IN PDEVICE_OBJECT DeviceObject,
45 IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
46 {
47 NTSTATUS Status;
48 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
49
50 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
51
52 if (DriverExtension->InitializationData.HwTimer != NULL)
53 {
54 INFO_(VIDEOPRT, "Initializing timer\n");
55
56 Status = IoInitializeTimer(
57 DeviceObject,
58 IntVideoPortTimerRoutine,
59 DeviceExtension);
60
61 if (!NT_SUCCESS(Status))
62 {
63 ERR_(VIDEOPRT, "IoInitializeTimer failed with status 0x%08x\n", Status);
64 return FALSE;
65 }
66 }
67
68 return TRUE;
69 }
70
71 /* PUBLIC FUNCTIONS ***********************************************************/
72
73 /*
74 * @implemented
75 */
76
77 VOID NTAPI
78 VideoPortStartTimer(IN PVOID HwDeviceExtension)
79 {
80 TRACE_(VIDEOPRT, "VideoPortStartTimer\n");
81 IoStartTimer(VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->FunctionalDeviceObject);
82 }
83
84 /*
85 * @implemented
86 */
87
88 VOID NTAPI
89 VideoPortStopTimer(IN PVOID HwDeviceExtension)
90 {
91 TRACE_(VIDEOPRT, "VideoPortStopTimer\n");
92 IoStopTimer(VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->FunctionalDeviceObject);
93 }