2004-03-19 20:58:32 +00:00
|
|
|
/*
|
2011-01-01 18:15:25 +00:00
|
|
|
* PROJECT: ReactOS Video Port Driver
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
2015-11-05 18:07:00 +00:00
|
|
|
* FILE: win32ss/drivers/videoprt/event.c
|
2011-01-01 18:15:25 +00:00
|
|
|
* PURPOSE: Event Support Routines
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
2004-03-19 20:58:32 +00:00
|
|
|
*/
|
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
#include "videoprt.h"
|
2012-04-01 20:42:43 +00:00
|
|
|
#include "../../gdi/eng/engevent.h"
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2014-02-04 17:15:06 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-01-01 18:15:25 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2019-11-24 23:29:36 +00:00
|
|
|
VideoPortCreateEvent(
|
|
|
|
_In_ PVOID HwDeviceExtension,
|
|
|
|
_In_ ULONG EventFlag,
|
|
|
|
_In_ PVOID Unused,
|
|
|
|
_Out_ PEVENT* pEvent)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2011-01-01 18:15:25 +00:00
|
|
|
VP_STATUS Result = NO_ERROR;
|
|
|
|
PVIDEO_PORT_EVENT EngEvent;
|
|
|
|
|
|
|
|
/* Allocate memory for the event structure */
|
|
|
|
EngEvent = ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
sizeof(VIDEO_PORT_EVENT) + sizeof(KEVENT),
|
|
|
|
TAG_VIDEO_PORT);
|
|
|
|
if (EngEvent)
|
|
|
|
{
|
2019-02-20 20:01:46 +00:00
|
|
|
/* Zero flags */
|
|
|
|
EngEvent->fFlags = 0;
|
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Set KEVENT pointer */
|
|
|
|
EngEvent->pKEvent = EngEvent + 1;
|
2019-11-24 23:29:36 +00:00
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Initialize the kernel event */
|
|
|
|
KeInitializeEvent(EngEvent->pKEvent,
|
|
|
|
(EventFlag & EVENT_TYPE_MASK) ?
|
|
|
|
NotificationEvent : SynchronizationEvent,
|
|
|
|
EventFlag & INITIAL_EVENT_STATE_MASK);
|
|
|
|
|
|
|
|
/* Pass pointer to our structure to the caller */
|
2019-11-24 23:29:36 +00:00
|
|
|
*pEvent = (PEVENT)EngEvent;
|
2011-01-01 18:15:25 +00:00
|
|
|
DPRINT("VideoPortCreateEvent() created %p\n", EngEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Out of memory */
|
2019-11-24 23:29:36 +00:00
|
|
|
DPRINT("VideoPortCreateEvent() failed\n");
|
2011-01-01 18:15:25 +00:00
|
|
|
Result = ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return result */
|
|
|
|
return Result;
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-01-01 18:15:25 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2019-11-24 23:29:36 +00:00
|
|
|
VideoPortDeleteEvent(
|
|
|
|
_In_ PVOID HwDeviceExtension,
|
|
|
|
_In_ PEVENT Event)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Handle error cases */
|
|
|
|
if (!Event) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (Event->fFlags & ENG_EVENT_USERMAPPED) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (!Event->pKEvent) return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* Free storage */
|
2019-11-24 23:32:28 +00:00
|
|
|
ExFreePoolWithTag(Event, TAG_VIDEO_PORT);
|
2009-06-30 13:42:42 +00:00
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Indicate success */
|
|
|
|
return NO_ERROR;
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-01-01 18:15:25 +00:00
|
|
|
LONG
|
|
|
|
NTAPI
|
2019-11-24 23:29:36 +00:00
|
|
|
VideoPortSetEvent(
|
|
|
|
_In_ PVOID HwDeviceExtension,
|
|
|
|
_In_ PEVENT Event)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2019-11-24 23:32:28 +00:00
|
|
|
ASSERT(Event);
|
2011-01-01 18:15:25 +00:00
|
|
|
return KeSetEvent(Event->pKEvent, IO_NO_INCREMENT, FALSE);
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-01-01 18:15:25 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2019-11-24 23:29:36 +00:00
|
|
|
VideoPortClearEvent(
|
|
|
|
_In_ PVOID HwDeviceExtension,
|
|
|
|
_In_ PEVENT Event)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2019-11-24 23:32:28 +00:00
|
|
|
ASSERT(Event);
|
2011-01-01 18:15:25 +00:00
|
|
|
KeClearEvent(Event->pKEvent);
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
|
|
|
|
2019-11-24 20:26:26 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
LONG
|
|
|
|
NTAPI
|
|
|
|
VideoPortReadStateEvent(
|
|
|
|
_In_ PVOID HwDeviceExtension,
|
|
|
|
_In_ PEVENT Event)
|
|
|
|
{
|
|
|
|
ASSERT(Event);
|
|
|
|
return KeReadStateEvent(Event->pKEvent);
|
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-01-01 18:15:25 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2019-11-24 23:29:36 +00:00
|
|
|
VideoPortWaitForSingleObject(
|
|
|
|
_In_ PVOID HwDeviceExtension,
|
|
|
|
_In_ PVOID Event,
|
|
|
|
_In_opt_ PLARGE_INTEGER Timeout)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2011-01-01 18:15:25 +00:00
|
|
|
PVIDEO_PORT_EVENT EngEvent = Event;
|
|
|
|
NTSTATUS Status;
|
2019-11-24 23:29:36 +00:00
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Handle error cases */
|
|
|
|
if (!EngEvent) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (!EngEvent->pKEvent) return ERROR_INVALID_PARAMETER;
|
|
|
|
if (EngEvent->fFlags & ENG_EVENT_USERMAPPED) return ERROR_INVALID_PARAMETER;
|
2019-11-24 23:29:36 +00:00
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Do the actual wait */
|
|
|
|
Status = KeWaitForSingleObject(EngEvent->pKEvent,
|
|
|
|
Executive,
|
|
|
|
KernelMode,
|
|
|
|
FALSE,
|
|
|
|
Timeout);
|
|
|
|
if (Status == STATUS_TIMEOUT)
|
|
|
|
{
|
|
|
|
/* Convert to wait timeout, otherwise NT_SUCCESS would return NO_ERROR */
|
|
|
|
return WAIT_TIMEOUT;
|
|
|
|
}
|
|
|
|
else if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* All other success codes are Win32 success */
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
2019-11-24 23:29:36 +00:00
|
|
|
|
2011-01-01 18:15:25 +00:00
|
|
|
/* Otherwise, return default Win32 failure */
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
2011-01-01 18:15:25 +00:00
|
|
|
|
|
|
|
/* EOF */
|