ReactOS  0.4.13-dev-551-gf37fb1f
miniport_dmus.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for miniport_dmus.cpp:

Go to the source code of this file.

Classes

class  CMiniportDMusUART
 
class  CMiniportDMusUARTStream
 
struct  SYNCWRITECONTEXT
 

Macros

#define NDEBUG
 
#define kOneMillisec   (10 * 1000)
 
#define MPU401_REG_STATUS   0x01
 
#define MPU401_DRR   0x40
 
#define MPU401_DSR   0x80
 
#define MPU401_REG_DATA   0x00
 
#define MPU401_REG_COMMAND   0x01
 
#define MPU401_CMD_RESET   0xFF
 
#define MPU401_CMD_UART   0x3F
 
#define STR_MODULENAME   "DMusUART:Miniport: "
 
#define UartFifoOkForWrite(status)   ((status & MPU401_DRR) == 0)
 
#define UartFifoOkForRead(status)   ((status & MPU401_DSR) == 0)
 
#define kMaxNumCaptureStreams   1
 
#define kMaxNumLegacyRenderStreams   1
 
#define kMaxNumDMusicRenderStreams   1
 
#define CONST_PCNODE_DESCRIPTOR(n)   { 0, NULL, &n, NULL }
 
#define CONST_PCNODE_DESCRIPTOR_AUTO(n, a)   { 0, &a, &n, NULL }
 
#define kMPUPollTimeout   2
 

Typedefs

typedef struct SYNCWRITECONTEXTPSYNCWRITECONTEXT
 

Enumerations

enum  { eSynthNode = 0, eInputNode }
 
enum  {
  eFilterInputPinLeg = 0, eFilterInputPinDM, eBridgeOutputPin, eBridgeInputPin,
  eFilterOutputPin
}
 

Functions

NTSTATUS NTAPI InitMPU (IN PINTERRUPTSYNC InterruptSync, IN PVOID DynamicContext)
 
NTSTATUS ResetHardware (PUCHAR portBase)
 
NTSTATUS ValidatePropertyRequest (IN PPCPROPERTY_REQUEST pRequest, IN ULONG ulValueSize, IN BOOLEAN fValueRequired)
 
NTSTATUS NTAPI PropertyHandler_Synth (IN PPCPROPERTY_REQUEST PropertyRequest)
 
NTSTATUS NTAPI DMusMPUInterruptServiceRoutine (PINTERRUPTSYNC InterruptSync, PVOID DynamicContext)
 
VOID NTAPI DMusUARTTimerDPC (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
NTSTATUS NTAPI SynchronizedDMusMPUWrite (PINTERRUPTSYNC InterruptSync, PVOID syncWriteContext)
 
 DEFINE_PCAUTOMATION_TABLE_PROP (AutomationSynth, SynthProperties)
 
 DEFINE_PCAUTOMATION_TABLE_PROP (AutomationSynth2, SynthProperties)
 
BOOLEAN TryMPU (IN PUCHAR PortBase)
 
NTSTATUS WriteMPU (IN PUCHAR PortBase, IN BOOLEAN IsCommand, IN UCHAR Value)
 
NTSTATUS NTAPI SynchronizedDMusMPUWrite (IN PINTERRUPTSYNC InterruptSync, IN PVOID syncWriteContext)
 
 SnapTimeStamp (PINTERRUPTSYNC InterruptSync, PVOID pStream)
 
NTSTATUS NTAPI DMusMPUInterruptServiceRoutine (IN PINTERRUPTSYNC InterruptSync, IN PVOID DynamicContext)
 
NTSTATUS NewMiniportDMusUART (OUT PMINIPORT *OutMiniport, IN REFCLSID ClassId)
 
VOID NTAPI DMusUARTTimerDPC (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 

Variables

const BOOLEAN COMMAND = TRUE
 
const BOOLEAN DATA = FALSE
 
const ULONG kMPUInputBufferSize = 128
 
static KSDATARANGE_MUSIC PinDataRangesStreamLegacy
 
static KSDATARANGE_MUSIC PinDataRangesStreamDMusic
 
static PKSDATARANGE PinDataRangePointersStreamLegacy []
 
static PKSDATARANGE PinDataRangePointersStreamDMusic []
 
static PKSDATARANGE PinDataRangePointersStreamCombined []
 
static KSDATARANGE PinDataRangesBridge []
 
static PKSDATARANGE PinDataRangePointersBridge []
 
static PCPROPERTY_ITEM SynthProperties []
 
static PCPIN_DESCRIPTOR MiniportPins []
 
static PCNODE_DESCRIPTOR MiniportNodes []
 
static PCCONNECTION_DESCRIPTOR MiniportConnections []
 
static GUID MiniportCategories []
 
static PCFILTER_DESCRIPTOR MiniportFilterDescriptor
 
const WCHAR wszDescOut [] = L"DMusic MPU-401 Out "
 
const WCHAR wszDescIn [] = L"DMusic MPU-401 In "
 

Macro Definition Documentation

◆ CONST_PCNODE_DESCRIPTOR

#define CONST_PCNODE_DESCRIPTOR (   n)    { 0, NULL, &n, NULL }

Definition at line 559 of file miniport_dmus.cpp.

◆ CONST_PCNODE_DESCRIPTOR_AUTO

#define CONST_PCNODE_DESCRIPTOR_AUTO (   n,
  a 
)    { 0, &a, &n, NULL }

Definition at line 560 of file miniport_dmus.cpp.

◆ kMaxNumCaptureStreams

#define kMaxNumCaptureStreams   1

Definition at line 455 of file miniport_dmus.cpp.

◆ kMaxNumDMusicRenderStreams

#define kMaxNumDMusicRenderStreams   1

Definition at line 457 of file miniport_dmus.cpp.

◆ kMaxNumLegacyRenderStreams

#define kMaxNumLegacyRenderStreams   1

Definition at line 456 of file miniport_dmus.cpp.

◆ kMPUPollTimeout

#define kMPUPollTimeout   2

Definition at line 915 of file miniport_dmus.cpp.

◆ kOneMillisec

#define kOneMillisec   (10 * 1000)

Definition at line 20 of file miniport_dmus.cpp.

◆ MPU401_CMD_RESET

#define MPU401_CMD_RESET   0xFF

Definition at line 33 of file miniport_dmus.cpp.

◆ MPU401_CMD_UART

#define MPU401_CMD_UART   0x3F

Definition at line 34 of file miniport_dmus.cpp.

◆ MPU401_DRR

#define MPU401_DRR   0x40

Definition at line 26 of file miniport_dmus.cpp.

◆ MPU401_DSR

#define MPU401_DSR   0x80

Definition at line 28 of file miniport_dmus.cpp.

◆ MPU401_REG_COMMAND

#define MPU401_REG_COMMAND   0x01

Definition at line 32 of file miniport_dmus.cpp.

◆ MPU401_REG_DATA

#define MPU401_REG_DATA   0x00

Definition at line 31 of file miniport_dmus.cpp.

◆ MPU401_REG_STATUS

#define MPU401_REG_STATUS   0x01

Definition at line 25 of file miniport_dmus.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file miniport_dmus.cpp.

◆ STR_MODULENAME

#define STR_MODULENAME   "DMusUART:Miniport: "

Definition at line 292 of file miniport_dmus.cpp.

◆ UartFifoOkForRead

#define UartFifoOkForRead (   status)    ((status & MPU401_DSR) == 0)

Definition at line 299 of file miniport_dmus.cpp.

◆ UartFifoOkForWrite

#define UartFifoOkForWrite (   status)    ((status & MPU401_DRR) == 0)

Definition at line 298 of file miniport_dmus.cpp.

Typedef Documentation

◆ PSYNCWRITECONTEXT

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
eSynthNode 
eInputNode 

Definition at line 573 of file miniport_dmus.cpp.

573  {
574  eSynthNode = 0
575  , eInputNode
576 };

◆ anonymous enum

anonymous enum
Enumerator
eFilterInputPinLeg 
eFilterInputPinDM 
eBridgeOutputPin 
eBridgeInputPin 
eFilterOutputPin 

Definition at line 578 of file miniport_dmus.cpp.

Function Documentation

◆ DEFINE_PCAUTOMATION_TABLE_PROP() [1/2]

DEFINE_PCAUTOMATION_TABLE_PROP ( AutomationSynth  ,
SynthProperties   
)

◆ DEFINE_PCAUTOMATION_TABLE_PROP() [2/2]

DEFINE_PCAUTOMATION_TABLE_PROP ( AutomationSynth2  ,
SynthProperties   
)

◆ DMusMPUInterruptServiceRoutine() [1/2]

NTSTATUS NTAPI DMusMPUInterruptServiceRoutine ( PINTERRUPTSYNC  InterruptSync,
PVOID  DynamicContext 
)

◆ DMusMPUInterruptServiceRoutine() [2/2]

NTSTATUS NTAPI DMusMPUInterruptServiceRoutine ( IN PINTERRUPTSYNC  InterruptSync,
IN PVOID  DynamicContext 
)

Definition at line 1144 of file miniport_dmus.cpp.

1148 {
1149  DPRINT("DMusMPUInterruptServiceRoutine");
1151 
1153 
1154  NTSTATUS ntStatus;
1155  BOOL newBytesAvailable;
1156  CMiniportDMusUART *that;
1157  NTSTATUS clockStatus;
1158 
1159  that = (CMiniportDMusUART *) DynamicContext;
1160  newBytesAvailable = FALSE;
1161  ntStatus = STATUS_UNSUCCESSFUL;
1162 
1163  UCHAR portStatus = 0xff;
1164 
1165  //
1166  // Read the MPU status byte.
1167  //
1168  if (that->m_pPortBase)
1169  {
1170  portStatus =
1172 
1173  //
1174  // If there is outstanding work to do and there is a port-driver for
1175  // the MPU miniport...
1176  //
1177  if (UartFifoOkForRead(portStatus) && that->m_pPort)
1178  {
1180  while ( (PcGetTimeInterval(startTime) < GTI_MILLISECONDS(50))
1181  && (UartFifoOkForRead(portStatus)) )
1182  {
1184  if ( (that->m_KSStateInput == KSSTATE_RUN)
1185  && (that->m_NumCaptureStreams)
1186  )
1187  {
1188  ULONG buffHead = that->m_MPUInputBufferHead;
1189  if ( (that->m_MPUInputBufferTail + 1 == buffHead)
1190  || (that->m_MPUInputBufferTail + 1 - kMPUInputBufferSize == buffHead))
1191  {
1192  DPRINT("*****MPU Input Buffer Overflow*****");
1193  }
1194  else
1195  {
1196  if (!that->m_InputTimeStamp)
1197  {
1198  clockStatus = that->m_MasterClock->GetTime(&that->m_InputTimeStamp);
1199  if (STATUS_SUCCESS != clockStatus)
1200  {
1201  DPRINT("GetTime failed for clock 0x%08x",that->m_MasterClock);
1202  }
1203  }
1204  newBytesAvailable = TRUE;
1205  // ...place the data in our FIFO...
1206  that->m_MPUInputBuffer[that->m_MPUInputBufferTail] = uDest;
1208 
1209  that->m_MPUInputBufferTail++;
1211  {
1212  that->m_MPUInputBufferTail = 0;
1213  }
1214  }
1215  }
1216  //
1217  // Look for more MIDI data.
1218  //
1219  portStatus =
1221  } // either there's no data or we ran too long
1222  if (newBytesAvailable)
1223  {
1224  //
1225  // ...notify the MPU port driver that we have bytes.
1226  //
1227  that->m_pPort->Notify(that->m_pServiceGroup);
1228  }
1229  ntStatus = STATUS_SUCCESS;
1230  }
1231  }
1232 
1233  return ntStatus;
1234 }
#define MPU401_REG_DATA
#define TRUE
Definition: types.h:120
const ULONG kMPUInputBufferSize
static ULONGLONG startTime
Definition: main.c:115
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
LONG NTSTATUS
Definition: precomp.h:26
ULONGLONG NTAPI PcGetTimeInterval(IN ULONGLONG Since)
Definition: api.cpp:37
REFERENCE_TIME m_InputTimeStamp
PSERVICEGROUP m_pServiceGroup
unsigned int BOOL
Definition: ntddk_ex.h:94
UCHAR m_MPUInputBuffer[kMPUInputBufferSize]
#define GTI_MILLISECONDS(t)
Definition: portcls.h:2429
void DPRINT(...)
Definition: polytest.cpp:61
uint64_t ULONGLONG
Definition: typedefs.h:65
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char UCHAR
Definition: xmlstorage.h:181
PMASTERCLOCK m_MasterClock
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define UartFifoOkForRead(status)
IN PVOID DynamicContext
Definition: portcls.h:839
#define MPU401_REG_STATUS

◆ DMusUARTTimerDPC() [1/2]

VOID NTAPI DMusUARTTimerDPC ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

◆ DMusUARTTimerDPC() [2/2]

VOID NTAPI DMusUARTTimerDPC ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 2433 of file miniport_dmus.cpp.

2439 {
2441 
2442  CMiniportDMusUARTStream *aStream;
2444  if (aStream)
2445  {
2446  DPRINT("DMusUARTTimerDPC");
2447  if (false == aStream->m_fCapture)
2448  {
2449  (void) aStream->ConsumeEvents();
2450  }
2451  // ignores return value!
2452  }
2453 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
void DPRINT(...)
Definition: polytest.cpp:61
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675

◆ InitMPU()

NTSTATUS NTAPI InitMPU ( IN PINTERRUPTSYNC  InterruptSync,
IN PVOID  DynamicContext 
)

Definition at line 702 of file miniport_dmus.cpp.

706 {
707  DPRINT("InitMPU");
708  if (!DynamicContext)
709  {
711  }
712 
713  PUCHAR portBase = PUCHAR(DynamicContext);
714  UCHAR status;
717  NTSTATUS ntStatus = STATUS_SUCCESS;
718 
719  //
720  // Reset the card (puts it into "smart mode")
721  //
722  ntStatus = WriteMPU(portBase,COMMAND,MPU401_CMD_RESET);
723 
724  // wait for the acknowledgement
725  // NOTE: When the Ack arrives, it will trigger an interrupt.
726  // Normally the DPC routine would read in the ack byte and we
727  // would never see it, however since we have the hardware locked (HwEnter),
728  // we can read the port before the DPC can and thus we receive the Ack.
730  success = FALSE;
732  {
734 
735  if (UartFifoOkForRead(status)) // Is data waiting?
736  {
737  READ_PORT_UCHAR(portBase + MPU401_REG_DATA); // yep.. read ACK
738  success = TRUE; // don't need to do more
739  break;
740  }
741  KeStallExecutionProcessor(25); // microseconds
742  }
743 #if (DBG)
744  if (!success)
745  {
746  DPRINT("First attempt to reset the MPU didn't get ACKed.\n");
747  }
748 #endif // (DBG)
749 
750  // NOTE: We cannot check the ACK byte because if the card was already in
751  // UART mode it will not send an ACK but it will reset.
752 
753  // reset the card again
755 
756  // wait for ack (again)
757  startTime = PcGetTimeInterval(0); // This might take a while
758  BYTE dataByte = 0;
759  success = FALSE;
761  {
763  if (UartFifoOkForRead(status)) // Is data waiting?
764  {
765  dataByte = READ_PORT_UCHAR(portBase + MPU401_REG_DATA); // yep.. read ACK
766  success = TRUE; // don't need to do more
767  break;
768  }
770  }
771 
772  if ((0xFE != dataByte) || !success) // Did we succeed? If no second ACK, something is hosed
773  {
774  DPRINT("Second attempt to reset the MPU didn't get ACKed.\n");
775  DPRINT("Init Reset failure error. Ack = %X", ULONG(dataByte));
776 
777  ntStatus = STATUS_IO_DEVICE_ERROR;
778  }
779 
780  return ntStatus;
781 }
#define MPU401_REG_DATA
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static ULONGLONG startTime
Definition: main.c:115
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
LONG NTSTATUS
Definition: precomp.h:26
ULONGLONG NTAPI PcGetTimeInterval(IN ULONGLONG Since)
Definition: api.cpp:37
NTSTATUS WriteMPU(IN PUCHAR PortBase, IN BOOLEAN IsCommand, IN UCHAR Value)
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define GTI_MILLISECONDS(t)
Definition: portcls.h:2429
unsigned char BOOLEAN
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
void DPRINT(...)
Definition: polytest.cpp:61
uint64_t ULONGLONG
Definition: typedefs.h:65
#define success(from, fromstr, to, tostr)
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned char BYTE
Definition: mem.h:68
#define MPU401_CMD_RESET
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
Definition: main.c:14
static SERVICE_STATUS status
Definition: service.c:31
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
#define UartFifoOkForRead(status)
IN PVOID DynamicContext
Definition: portcls.h:839
#define MPU401_REG_STATUS
Definition: ps.c:97

Referenced by CMiniportDMusUART::InitializeHardware(), and CMiniportDMusUART::~CMiniportDMusUART().

◆ NewMiniportDMusUART()

NTSTATUS NewMiniportDMusUART ( OUT PMINIPORT OutMiniport,
IN REFCLSID  ClassId 
)

Definition at line 1264 of file miniport_dmus.cpp.

1267 {
1269  NTSTATUS Status;
1270 
1272  if (!This)
1274 
1275  Status = This->QueryInterface(IID_IMiniport, (PVOID*)OutMiniport);
1276 
1277  if (!NT_SUCCESS(Status))
1278  {
1279  delete This;
1280  }
1281 
1282  DPRINT("NewMiniportDMusUART %p Status %x\n", *OutMiniport, Status);
1283  return Status;
1284 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24

Referenced by PcNewMiniport().

◆ PropertyHandler_Synth()

NTSTATUS NTAPI PropertyHandler_Synth ( IN PPCPROPERTY_REQUEST  PropertyRequest)

Definition at line 2472 of file miniport_dmus.cpp.

2475 {
2476  NTSTATUS ntStatus;
2477 
2478  PAGED_CODE();
2479 
2480  if (pRequest->Verb & KSPROPERTY_TYPE_BASICSUPPORT)
2481  {
2482  ntStatus = ValidatePropertyRequest(pRequest, sizeof(ULONG), TRUE);
2483  if (NT_SUCCESS(ntStatus))
2484  {
2485  // if return buffer can hold a ULONG, return the access flags
2486  PULONG AccessFlags = PULONG(pRequest->Value);
2487 
2488  *AccessFlags = KSPROPERTY_TYPE_BASICSUPPORT;
2489  switch (pRequest->PropertyItem->Id)
2490  {
2491  case KSPROPERTY_SYNTH_CAPS:
2493  *AccessFlags |= KSPROPERTY_TYPE_GET;
2494  }
2495  switch (pRequest->PropertyItem->Id)
2496  {
2498  *AccessFlags |= KSPROPERTY_TYPE_SET;
2499  }
2500  ntStatus = STATUS_SUCCESS;
2501  pRequest->ValueSize = sizeof(ULONG);
2502 
2503  switch (pRequest->PropertyItem->Id)
2504  {
2506  if (pRequest->MinorTarget)
2507  {
2508  *AccessFlags |= KSPROPERTY_TYPE_GET;
2509  }
2510  else
2511  {
2512  pRequest->ValueSize = 0;
2513  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2514  }
2515  }
2516  }
2517  }
2518  else
2519  {
2520  ntStatus = STATUS_SUCCESS;
2521  switch(pRequest->PropertyItem->Id)
2522  {
2523  case KSPROPERTY_SYNTH_CAPS:
2524  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_CAPS");
2525 
2526  if (pRequest->Verb & KSPROPERTY_TYPE_SET)
2527  {
2528  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2529  }
2530 
2531  if (NT_SUCCESS(ntStatus))
2532  {
2533  ntStatus = ValidatePropertyRequest(pRequest, sizeof(SYNTHCAPS), TRUE);
2534 
2535  if (NT_SUCCESS(ntStatus))
2536  {
2537  SYNTHCAPS *caps = (SYNTHCAPS*)pRequest->Value;
2538  int increment;
2539  RtlZeroMemory(caps, sizeof(SYNTHCAPS));
2540  // XXX Different guids for different instances!
2541  //
2542  if (pRequest->Node == eSynthNode)
2543  {
2544  increment = sizeof(wszDescOut) - 2;
2545  RtlCopyMemory( caps->Description,wszDescOut,increment);
2546  caps->Guid = CLSID_MiniportDriverDMusUART;
2547  }
2548  else
2549  {
2550  increment = sizeof(wszDescIn) - 2;
2551  RtlCopyMemory( caps->Description,wszDescIn,increment);
2552  caps->Guid = CLSID_MiniportDriverDMusUARTCapture;
2553  }
2554 
2555  caps->Flags = SYNTH_PC_EXTERNAL;
2556  caps->MemorySize = 0;
2557  caps->MaxChannelGroups = 1;
2558  caps->MaxVoices = 0xFFFFFFFF;
2559  caps->MaxAudioChannels = 0xFFFFFFFF;
2560 
2561  caps->EffectFlags = 0;
2562 
2563  CMiniportDMusUART *aMiniport;
2564  ASSERT(pRequest->MajorTarget);
2565  aMiniport = (CMiniportDMusUART *)(PMINIPORTDMUS)(pRequest->MajorTarget);
2566  WCHAR wszDesc2[16];
2567  int cLen;
2568  cLen = swprintf(wszDesc2,L"[%03x]\0",PtrToUlong(aMiniport->m_pPortBase));
2569 
2570  cLen *= sizeof(WCHAR);
2571  RtlCopyMemory((WCHAR *)((DWORD_PTR)(caps->Description) + increment),
2572  wszDesc2,
2573  cLen);
2574 
2575 
2576  pRequest->ValueSize = sizeof(SYNTHCAPS);
2577  }
2578  }
2579 
2580  break;
2581 
2583  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_PORTPARAMETERS");
2584  {
2585  CMiniportDMusUARTStream *aStream;
2586 
2587  aStream = (CMiniportDMusUARTStream*)(pRequest->MinorTarget);
2588  if (aStream)
2589  {
2590  ntStatus = aStream->HandlePortParams(pRequest);
2591  }
2592  else
2593  {
2594  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2595  }
2596  }
2597  break;
2598 
2600  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_CHANNELGROUPS");
2601 
2602  ntStatus = ValidatePropertyRequest(pRequest, sizeof(ULONG), TRUE);
2603  if (NT_SUCCESS(ntStatus))
2604  {
2605  *(PULONG)(pRequest->Value) = 1;
2606  pRequest->ValueSize = sizeof(ULONG);
2607  }
2608  break;
2609 
2611  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_LATENCYCLOCK");
2612 
2613  if(pRequest->Verb & KSPROPERTY_TYPE_SET)
2614  {
2615  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2616  }
2617  else
2618  {
2619  ntStatus = ValidatePropertyRequest(pRequest, sizeof(ULONGLONG), TRUE);
2620  if(NT_SUCCESS(ntStatus))
2621  {
2622  REFERENCE_TIME rtLatency;
2623  CMiniportDMusUARTStream *aStream;
2624 
2625  aStream = (CMiniportDMusUARTStream*)(pRequest->MinorTarget);
2626  if(aStream == NULL)
2627  {
2628  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2629  }
2630  else
2631  {
2632  aStream->m_pMiniport->m_MasterClock->GetTime(&rtLatency);
2633  *((PULONGLONG)pRequest->Value) = rtLatency;
2634  pRequest->ValueSize = sizeof(ULONGLONG);
2635  }
2636  }
2637  }
2638  break;
2639 
2640  default:
2641  DPRINT("Unhandled property in PropertyHandler_Synth");
2642  break;
2643  }
2644  }
2645  return ntStatus;
2646 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
DWORD MaxVoices
Definition: dmusprop.h:86
DWORD MemorySize
Definition: dmusprop.h:84
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GUID Guid
Definition: dmusprop.h:82
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define PAGED_CODE()
Definition: video.h:57
WCHAR Description[128]
Definition: dmusprop.h:89
CMiniportDMusUART * m_pMiniport
const WCHAR wszDescIn[]
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define PtrToUlong(u)
Definition: config.h:107
#define KSPROPERTY_TYPE_BASICSUPPORT
Definition: dmksctrl.h:45
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define swprintf(buf, format,...)
Definition: sprintf.c:56
DWORD Flags
Definition: dmusprop.h:83
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
uint32_t DWORD_PTR
Definition: typedefs.h:63
DWORD EffectFlags
Definition: dmusprop.h:88
IMiniportDMus * PMINIPORTDMUS
Definition: dmusicks.h:209
unsigned int * PULONG
Definition: retypes.h:1
const WCHAR wszDescOut[]
DWORD MaxChannelGroups
Definition: dmusprop.h:85
#define SYNTH_PC_EXTERNAL
Definition: dmusprop.h:65
DWORD MaxAudioChannels
Definition: dmusprop.h:87
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:390
PMASTERCLOCK m_MasterClock
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS ValidatePropertyRequest(IN PPCPROPERTY_REQUEST pRequest, IN ULONG ulValueSize, IN BOOLEAN fValueRequired)
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
struct _SYNTHCAPS SYNTHCAPS
NTSTATUS HandlePortParams(IN PPCPROPERTY_REQUEST Request)

◆ ResetHardware()

NTSTATUS ResetHardware ( PUCHAR  portBase)

Definition at line 644 of file miniport_dmus.cpp.

645 {
646  PAGED_CODE();
647 
648  return WriteMPU(portBase,COMMAND,MPU401_CMD_UART);
649 }
NTSTATUS WriteMPU(IN PUCHAR PortBase, IN BOOLEAN IsCommand, IN UCHAR Value)
#define PAGED_CODE()
Definition: video.h:57
Definition: main.c:14
#define MPU401_CMD_UART

Referenced by CMiniportDMusUART::InitializeHardware().

◆ SnapTimeStamp()

SnapTimeStamp ( PINTERRUPTSYNC  InterruptSync,
PVOID  pStream 
)

Definition at line 1025 of file miniport_dmus.cpp.

1026 {
1027  CMiniportDMusUARTStream *pMPStream = (CMiniportDMusUARTStream *)pStream;
1028 
1029  // cache the timestamp
1030  pMPStream->m_SnapshotTimeStamp = pMPStream->m_pMiniport->m_InputTimeStamp;
1031 
1032  // if the window is closed, zero the timestamp
1033  if (pMPStream->m_pMiniport->m_MPUInputBufferHead ==
1034  pMPStream->m_pMiniport->m_MPUInputBufferTail)
1035  {
1036  pMPStream->m_pMiniport->m_InputTimeStamp = 0;
1037  }
1038 
1039  return STATUS_SUCCESS;
1040 }
REFERENCE_TIME m_InputTimeStamp
CMiniportDMusUART * m_pMiniport
REFERENCE_TIME m_SnapshotTimeStamp
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ SynchronizedDMusMPUWrite() [1/2]

NTSTATUS NTAPI SynchronizedDMusMPUWrite ( PINTERRUPTSYNC  InterruptSync,
PVOID  syncWriteContext 
)

◆ SynchronizedDMusMPUWrite() [2/2]

NTSTATUS NTAPI SynchronizedDMusMPUWrite ( IN PINTERRUPTSYNC  InterruptSync,
IN PVOID  syncWriteContext 
)

Definition at line 872 of file miniport_dmus.cpp.

876 {
878  context = (PSYNCWRITECONTEXT)syncWriteContext;
879  ASSERT(context->Miniport);
880  ASSERT(context->PortBase);
881  ASSERT(context->BufferAddress);
882  ASSERT(context->Length);
883  ASSERT(context->BytesRead);
884 
885  PUCHAR pChar = PUCHAR(context->BufferAddress);
886  NTSTATUS ntStatus; // , readStatus
887  ntStatus = STATUS_SUCCESS;
888  //
889  // while we're not there yet, and
890  // while we don't have to wait on an aligned byte (including 0)
891  // (we never wait on a byte. Better to come back later)
892  /*readStatus = */ DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
893  while ( (*(context->BytesRead) < context->Length)
894  && ( TryMPU(context->PortBase)
895  || (*(context->BytesRead)%3)
896  ) )
897  {
898  ntStatus = WriteMPU(context->PortBase,DATA,*pChar);
899  if (NT_SUCCESS(ntStatus))
900  {
901  pChar++;
902  *(context->BytesRead) = *(context->BytesRead) + 1;
903 // readStatus = DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
904  }
905  else
906  {
907  DPRINT("SynchronizedDMusMPUWrite failed (0x%08x)",ntStatus);
908  break;
909  }
910  }
911  /*readStatus = */ DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
912  return ntStatus;
913 }
struct SYNCWRITECONTEXT * PSYNCWRITECONTEXT
Definition: http.c:6587
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI DMusMPUInterruptServiceRoutine(PINTERRUPTSYNC InterruptSync, PVOID DynamicContext)
NTSTATUS WriteMPU(IN PUCHAR PortBase, IN BOOLEAN IsCommand, IN UCHAR Value)
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN TryMPU(IN PUCHAR PortBase)
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ TryMPU()

BOOLEAN TryMPU ( IN PUCHAR  PortBase)

Definition at line 928 of file miniport_dmus.cpp.

931 {
933  USHORT numPolls;
934  UCHAR status;
935 
936  DPRINT("TryMPU");
937  numPolls = 0;
938 
939  while (numPolls < kMPUPollTimeout)
940  {
942 
943  if (UartFifoOkForWrite(status)) // Is this a good time to write data?
944  {
945  break;
946  }
947  numPolls++;
948  }
949  if (numPolls >= kMPUPollTimeout)
950  {
951  success = FALSE;
952  DPRINT("TryMPU failed");
953  }
954  else
955  {
956  success = TRUE;
957  }
958 
959  return success;
960 }
#define UartFifoOkForWrite(status)
#define TRUE
Definition: types.h:120
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
#define success(from, fromstr, to, tostr)
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
#define kMPUPollTimeout
static SERVICE_STATUS status
Definition: service.c:31
#define MPU401_REG_STATUS
Definition: ps.c:97

Referenced by SynchronizedDMusMPUWrite().

◆ ValidatePropertyRequest()

NTSTATUS ValidatePropertyRequest ( IN PPCPROPERTY_REQUEST  pRequest,
IN ULONG  ulValueSize,
IN BOOLEAN  fValueRequired 
)

Definition at line 2659 of file miniport_dmus.cpp.

2664 {
2665  NTSTATUS ntStatus;
2666 
2667  if (pRequest->ValueSize >= ulValueSize)
2668  {
2669  if (fValueRequired && NULL == pRequest->Value)
2670  {
2671  ntStatus = STATUS_INVALID_PARAMETER;
2672  }
2673  else
2674  {
2675  ntStatus = STATUS_SUCCESS;
2676  }
2677  }
2678  else if (0 == pRequest->ValueSize)
2679  {
2680  ntStatus = STATUS_BUFFER_OVERFLOW;
2681  }
2682  else
2683  {
2684  ntStatus = STATUS_BUFFER_TOO_SMALL;
2685  }
2686 
2687  if (STATUS_BUFFER_OVERFLOW == ntStatus)
2688  {
2689  pRequest->ValueSize = ulValueSize;
2690  }
2691  else
2692  {
2693  pRequest->ValueSize = 0;
2694  }
2695 
2696  return ntStatus;
2697 } // ValidatePropertyRequest
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by CMiniportDMusUARTStream::HandlePortParams(), and PropertyHandler_Synth().

◆ WriteMPU()

NTSTATUS WriteMPU ( IN PUCHAR  PortBase,
IN BOOLEAN  IsCommand,
IN UCHAR  Value 
)

Definition at line 973 of file miniport_dmus.cpp.

978 {
979  DPRINT("WriteMPU");
980  NTSTATUS ntStatus = STATUS_IO_DEVICE_ERROR;
981 
982  if (!PortBase)
983  {
984  DPRINT("O: PortBase is zero\n");
985  return ntStatus;
986  }
987  PUCHAR deviceAddr = PortBase + MPU401_REG_DATA;
988 
989  if (IsCommand)
990  {
991  deviceAddr = PortBase + MPU401_REG_COMMAND;
992  }
993 
995 
997  {
998  UCHAR status
999  = READ_PORT_UCHAR(PortBase + MPU401_REG_STATUS);
1000 
1001  if (UartFifoOkForWrite(status)) // Is this a good time to write data?
1002  { // yep (Jon comment)
1003  WRITE_PORT_UCHAR(deviceAddr,Value);
1004  DPRINT("WriteMPU emitted 0x%02x",Value);
1005  ntStatus = STATUS_SUCCESS;
1006  break;
1007  }
1008  }
1009  return ntStatus;
1010 }
#define MPU401_REG_COMMAND
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define MPU401_REG_DATA
#define UartFifoOkForWrite(status)
static ULONGLONG startTime
Definition: main.c:115
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
LONG NTSTATUS
Definition: precomp.h:26
ULONGLONG NTAPI PcGetTimeInterval(IN ULONGLONG Since)
Definition: api.cpp:37
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define GTI_MILLISECONDS(t)
Definition: portcls.h:2429
void DPRINT(...)
Definition: polytest.cpp:61
uint64_t ULONGLONG
Definition: typedefs.h:65
unsigned char UCHAR
Definition: xmlstorage.h:181
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define MPU401_REG_STATUS
Definition: ps.c:97

Referenced by InitMPU(), ResetHardware(), and SynchronizedDMusMPUWrite().

Variable Documentation

◆ COMMAND

Definition at line 52 of file miniport_dmus.cpp.

◆ DATA

Definition at line 53 of file miniport_dmus.cpp.

◆ kMPUInputBufferSize

const ULONG kMPUInputBufferSize = 128

Definition at line 54 of file miniport_dmus.cpp.

Referenced by DMusMPUInterruptServiceRoutine().

◆ MiniportCategories

GUID MiniportCategories[]
static
Initial value:
=
{
}
#define KSCATEGORY_RENDER
Definition: ks.h:195
#define KSCATEGORY_CAPTURE
Definition: ks.h:190
const GUID KSCATEGORY_AUDIO
Definition: controls.c:25
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25

Definition at line 603 of file miniport_dmus.cpp.

◆ MiniportConnections

◆ MiniportFilterDescriptor

PCFILTER_DESCRIPTOR MiniportFilterDescriptor
static
Initial value:
=
{
0,
NULL,
sizeof(PCPIN_DESCRIPTOR),
}
static PCCONNECTION_DESCRIPTOR MiniportConnections[]
#define SIZEOF_ARRAY(a)
Definition: ks.h:62
smooth NULL
Definition: ftsmooth.c:416
static PCNODE_DESCRIPTOR MiniportNodes[]
static GUID MiniportCategories[]
static PCPIN_DESCRIPTOR MiniportPins[]

Definition at line 616 of file miniport_dmus.cpp.

Referenced by CMiniportDMusUART::GetDescription().

◆ MiniportNodes

PCNODE_DESCRIPTOR MiniportNodes[]
static
Initial value:
=
{
}
#define CONST_PCNODE_DESCRIPTOR_AUTO(n, a)
const GUID KSNODETYPE_SYNTHESIZER
Definition: controls.c:30

Definition at line 562 of file miniport_dmus.cpp.

◆ MiniportPins

PCPIN_DESCRIPTOR MiniportPins[]
static

Definition at line 465 of file miniport_dmus.cpp.

◆ PinDataRangePointersBridge

PKSDATARANGE PinDataRangePointersBridge[]
static
Initial value:
=
{
}
static KSDATARANGE PinDataRangesBridge[]

Definition at line 409 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamCombined

PKSDATARANGE PinDataRangePointersStreamCombined[]
static
Initial value:
=
{
}
static KSDATARANGE_MUSIC PinDataRangesStreamDMusic
union KSDATAFORMAT * PKSDATARANGE

Definition at line 375 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamDMusic

PKSDATARANGE PinDataRangePointersStreamDMusic[]
static
Initial value:
=
{
}

Definition at line 370 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamLegacy

PKSDATARANGE PinDataRangePointersStreamLegacy[]
static
Initial value:
=
{
}

Definition at line 365 of file miniport_dmus.cpp.

◆ PinDataRangesBridge

KSDATARANGE PinDataRangesBridge[]
static
Initial value:
=
{
{
{
sizeof(KSDATARANGE),
0,
0,
0,
}
}
}
const GUID KSDATAFORMAT_TYPE_MUSIC
Definition: sup.c:35
union KSDATAFORMAT KSDATARANGE
const GUID KSDATAFORMAT_SPECIFIER_NONE
Definition: sup.c:37
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25
#define KSDATAFORMAT_SUBTYPE_MIDI_BUS
Definition: ksmedia.h:1196

Definition at line 387 of file miniport_dmus.cpp.

◆ PinDataRangesStreamDMusic

KSDATARANGE_MUSIC PinDataRangesStreamDMusic
static
Initial value:
=
{
{
{
0,
0,
0,
}
},
0,
0,
0xFFFF
}
const GUID KSDATAFORMAT_TYPE_MUSIC
Definition: sup.c:35
const GUID KSDATAFORMAT_SPECIFIER_NONE
Definition: sup.c:37
#define KSMUSIC_TECHNOLOGY_PORT
Definition: ksmedia.h:1191
#define KSDATAFORMAT_SUBTYPE_DIRECTMUSIC
Definition: dmusprop.h:9
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25

Definition at line 337 of file miniport_dmus.cpp.

◆ PinDataRangesStreamLegacy

KSDATARANGE_MUSIC PinDataRangesStreamLegacy
static
Initial value:
=
{
{
{
0,
0,
0,
}
},
0,
0,
0xFFFF
}
const GUID KSDATAFORMAT_TYPE_MUSIC
Definition: sup.c:35
const GUID KSDATAFORMAT_SPECIFIER_NONE
Definition: sup.c:37
#define KSMUSIC_TECHNOLOGY_PORT
Definition: ksmedia.h:1191
const GUID KSDATAFORMAT_SUBTYPE_MIDI
Definition: sup.c:36
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25

Definition at line 318 of file miniport_dmus.cpp.

◆ SynthProperties

PCPROPERTY_ITEM SynthProperties[]
static

Definition at line 421 of file miniport_dmus.cpp.

◆ wszDescIn

const WCHAR wszDescIn[] = L"DMusic MPU-401 In "

Definition at line 2467 of file miniport_dmus.cpp.

Referenced by PropertyHandler_Synth().

◆ wszDescOut

const WCHAR wszDescOut[] = L"DMusic MPU-401 Out "

Definition at line 2466 of file miniport_dmus.cpp.

Referenced by PropertyHandler_Synth().