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
|
|
|
|
* FILE: drivers/video/videoprt/event.c
|
|
|
|
* 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
|
|
|
|
VideoPortCreateEvent(IN PVOID HwDeviceExtension,
|
|
|
|
IN ULONG EventFlag,
|
|
|
|
IN PVOID Unused,
|
|
|
|
OUT PEVENT *Event)
|
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)
|
|
|
|
{
|
|
|
|
/* Set KEVENT pointer */
|
|
|
|
EngEvent->pKEvent = EngEvent + 1;
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
*Event = (PEVENT)EngEvent;
|
|
|
|
DPRINT("VideoPortCreateEvent() created %p\n", EngEvent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Out of memory */
|
|
|
|
DPRINT("VideoPortCreateEvent() failed\n");
|
|
|
|
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
|
|
|
|
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 */
|
|
|
|
ExFreePool(Event);
|
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
|
|
|
|
VideoPortSetEvent(IN PVOID HwDeviceExtension,
|
|
|
|
IN PEVENT Event)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
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
|
|
|
|
VideoPortClearEvent(IN PVOID HwDeviceExtension,
|
|
|
|
IN PEVENT Event)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2011-01-01 18:15:25 +00:00
|
|
|
KeClearEvent(Event->pKEvent);
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2011-01-01 18:15:25 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
|
|
|
VideoPortWaitForSingleObject(IN PVOID HwDeviceExtension,
|
|
|
|
IN PVOID Event,
|
|
|
|
IN PLARGE_INTEGER Timeout OPTIONAL)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2011-01-01 18:15:25 +00:00
|
|
|
PVIDEO_PORT_EVENT EngEvent = Event;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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 */
|