#include "videoprt.h"
+#include <ndk/inbvfuncs.h>
+#include <ndk/psfuncs.h>
+
+#define NDEBUG
+#include <debug.h>
+
/* GLOBAL VARIABLES ***********************************************************/
PVIDEO_PORT_DEVICE_EXTENSION ResetDisplayParametersDeviceExtension = NULL;
return "<unknown ioctl code";
}
+static
+NTSTATUS
+VideoPortUseDeviceInSession(
+ _Inout_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState,
+ _In_ ULONG BufferLength,
+ _Out_ PULONG_PTR Information)
+{
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
+
+ /* Check buffer size */
+ *Information = sizeof(VIDEO_DEVICE_SESSION_STATUS);
+ if (BufferLength < sizeof(VIDEO_DEVICE_SESSION_STATUS))
+ {
+ ERR_(VIDEOPRT, "Buffer too small for VIDEO_DEVICE_SESSION_STATUS: %lx\n",
+ BufferLength);
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ /* Get the device extension */
+ DeviceExtension = DeviceObject->DeviceExtension;
+
+ /* Shall we enable the session? */
+ if (SessionState->bEnable)
+ {
+ /* Check if we have no session yet */
+ if (DeviceExtension->SessionId == -1)
+ {
+ /* Use this session and return success */
+ DeviceExtension->SessionId = PsGetCurrentProcessSessionId();
+ SessionState->bSuccess = TRUE;
+ }
+ else
+ {
+ ERR_(VIDEOPRT, "Requested to set session, but session is already set to: 0x%lx\n",
+ DeviceExtension->SessionId);
+ SessionState->bSuccess = FALSE;
+ }
+ }
+ else
+ {
+ /* Check if we belong to the current session */
+ if (DeviceExtension->SessionId == PsGetCurrentProcessSessionId())
+ {
+ /* Reset the session and return success */
+ DeviceExtension->SessionId = -1;
+ SessionState->bSuccess = TRUE;
+ }
+ else
+ {
+ ERR_(VIDEOPRT, "Requested to reset session, but session is not set\n");
+ SessionState->bSuccess = FALSE;
+ }
+ }
+
+ return STATUS_SUCCESS;
+}
+
static
NTSTATUS
VideoPortInitWin32kCallbacks(
- IN PDEVICE_OBJECT DeviceObject,
- PVIDEO_WIN32K_CALLBACKS Win32kCallbacks,
- ULONG BufferLength)
+ _In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks,
+ _In_ ULONG BufferLength,
+ _Out_ PULONG_PTR Information)
{
+ *Information = sizeof(VIDEO_WIN32K_CALLBACKS);
if (BufferLength < sizeof(VIDEO_WIN32K_CALLBACKS))
{
+ ERR_(VIDEOPRT, "Buffer too small for VIDEO_WIN32K_CALLBACKS: %lx\n",
+ BufferLength);
return STATUS_BUFFER_TOO_SMALL;
}
INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
Status = VideoPortInitWin32kCallbacks(DeviceObject,
Irp->AssociatedIrp.SystemBuffer,
- IrpStack->Parameters.DeviceIoControl.InputBufferLength);
+ IrpStack->Parameters.DeviceIoControl.InputBufferLength,
+ &Irp->IoStatus.Information);
+ break;
+
+ case IOCTL_VIDEO_USE_DEVICE_IN_SESSION:
+ INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
+ Status = VideoPortUseDeviceInSession(DeviceObject,
+ Irp->AssociatedIrp.SystemBuffer,
+ IrpStack->Parameters.DeviceIoControl.InputBufferLength,
+ &Irp->IoStatus.Information);
break;
default:
ResourceListSize);
/* Get the interrupt level/vector - needed by HwFindAdapter sometimes */
- for (FullList = AllocatedResources->List;
- FullList < AllocatedResources->List + AllocatedResources->Count;
- FullList++)
+ FullList = AllocatedResources->List;
+ ASSERT(AllocatedResources->Count == 1);
+ INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
+ FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
+
+ /* FIXME: Is this ASSERT ok for resources from the PNP manager? */
+ ASSERT(FullList->InterfaceType == PCIBus);
+ ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
+ ASSERT(1 == FullList->PartialResourceList.Version);
+ ASSERT(1 == FullList->PartialResourceList.Revision);
+ for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
+ Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
+ Descriptor++)
{
- INFO_(VIDEOPRT, "InterfaceType %u BusNumber List %u Device BusNumber %u Version %u Revision %u\n",
- FullList->InterfaceType, FullList->BusNumber, DeviceExtension->SystemIoBusNumber, FullList->PartialResourceList.Version, FullList->PartialResourceList.Revision);
-
- /* FIXME: Is this ASSERT ok for resources from the PNP manager? */
- ASSERT(FullList->InterfaceType == PCIBus);
- ASSERT(FullList->BusNumber == DeviceExtension->SystemIoBusNumber);
- ASSERT(1 == FullList->PartialResourceList.Version);
- ASSERT(1 == FullList->PartialResourceList.Revision);
- for (Descriptor = FullList->PartialResourceList.PartialDescriptors;
- Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count;
- Descriptor++)
+ if (Descriptor->Type == CmResourceTypeInterrupt)
{
- if (Descriptor->Type == CmResourceTypeInterrupt)
- {
- DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
- DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
- if (Descriptor->ShareDisposition == CmResourceShareShared)
- DeviceExtension->InterruptShared = TRUE;
- else
- DeviceExtension->InterruptShared = FALSE;
- }
+ DeviceExtension->InterruptLevel = Descriptor->u.Interrupt.Level;
+ DeviceExtension->InterruptVector = Descriptor->u.Interrupt.Vector;
+ if (Descriptor->ShareDisposition == CmResourceShareShared)
+ DeviceExtension->InterruptShared = TRUE;
+ else
+ DeviceExtension->InterruptShared = FALSE;
}
}
}
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- return STATUS_NOT_IMPLEMENTED;
+ PIO_STACK_LOCATION IrpSp;
+ NTSTATUS Status = Irp->IoStatus.Status;
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+
+ IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+ if (DeviceExtension->Common.Fdo)
+ {
+ PoStartNextPowerIrp(Irp);
+ IoSkipCurrentIrpStackLocation(Irp);
+ return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+ }
+ else
+ {
+ switch (IrpSp->MinorFunction)
+ {
+ case IRP_MN_QUERY_POWER:
+ case IRP_MN_SET_POWER:
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ PoStartNextPowerIrp(Irp);
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
}
NTSTATUS
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status;
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+
+ if (DeviceExtension->Common.Fdo)
+ {
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+ }
+ else
+ {
+ Status = Irp->IoStatus.Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
}
VOID