ReactOS  0.4.15-dev-4917-g934e521
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 520 of file miniport_dmus.cpp.

◆ CONST_PCNODE_DESCRIPTOR_AUTO

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

Definition at line 521 of file miniport_dmus.cpp.

◆ kMaxNumCaptureStreams

#define kMaxNumCaptureStreams   1

Definition at line 416 of file miniport_dmus.cpp.

◆ kMaxNumDMusicRenderStreams

#define kMaxNumDMusicRenderStreams   1

Definition at line 418 of file miniport_dmus.cpp.

◆ kMaxNumLegacyRenderStreams

#define kMaxNumLegacyRenderStreams   1

Definition at line 417 of file miniport_dmus.cpp.

◆ kMPUPollTimeout

#define kMPUPollTimeout   2

Definition at line 876 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 253 of file miniport_dmus.cpp.

◆ UartFifoOkForRead

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

Definition at line 260 of file miniport_dmus.cpp.

◆ UartFifoOkForWrite

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

Definition at line 259 of file miniport_dmus.cpp.

Typedef Documentation

◆ PSYNCWRITECONTEXT

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
eSynthNode 
eInputNode 

Definition at line 534 of file miniport_dmus.cpp.

534  {
535  eSynthNode = 0
536  , eInputNode
537 };

◆ anonymous enum

anonymous enum
Enumerator
eFilterInputPinLeg 
eFilterInputPinDM 
eBridgeOutputPin 
eBridgeInputPin 
eFilterOutputPin 

Definition at line 539 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 1105 of file miniport_dmus.cpp.

1109 {
1110  DPRINT("DMusMPUInterruptServiceRoutine");
1112 
1114 
1115  NTSTATUS ntStatus;
1116  BOOL newBytesAvailable;
1117  CMiniportDMusUART *that;
1118  NTSTATUS clockStatus;
1119 
1120  that = (CMiniportDMusUART *) DynamicContext;
1121  newBytesAvailable = FALSE;
1122  ntStatus = STATUS_UNSUCCESSFUL;
1123 
1124  UCHAR portStatus = 0xff;
1125 
1126  //
1127  // Read the MPU status byte.
1128  //
1129  if (that->m_pPortBase)
1130  {
1131  portStatus =
1133 
1134  //
1135  // If there is outstanding work to do and there is a port-driver for
1136  // the MPU miniport...
1137  //
1138  if (UartFifoOkForRead(portStatus) && that->m_pPort)
1139  {
1142  && (UartFifoOkForRead(portStatus)) )
1143  {
1145  if ( (that->m_KSStateInput == KSSTATE_RUN)
1146  && (that->m_NumCaptureStreams)
1147  )
1148  {
1149  ULONG buffHead = that->m_MPUInputBufferHead;
1150  if ( (that->m_MPUInputBufferTail + 1 == buffHead)
1151  || (that->m_MPUInputBufferTail + 1 - kMPUInputBufferSize == buffHead))
1152  {
1153  DPRINT("*****MPU Input Buffer Overflow*****");
1154  }
1155  else
1156  {
1157  if (!that->m_InputTimeStamp)
1158  {
1159  clockStatus = that->m_MasterClock->GetTime(&that->m_InputTimeStamp);
1160  if (STATUS_SUCCESS != clockStatus)
1161  {
1162  DPRINT("GetTime failed for clock 0x%08x",that->m_MasterClock);
1163  }
1164  }
1165  newBytesAvailable = TRUE;
1166  // ...place the data in our FIFO...
1167  that->m_MPUInputBuffer[that->m_MPUInputBufferTail] = uDest;
1169 
1170  that->m_MPUInputBufferTail++;
1172  {
1173  that->m_MPUInputBufferTail = 0;
1174  }
1175  }
1176  }
1177  //
1178  // Look for more MIDI data.
1179  //
1180  portStatus =
1182  } // either there's no data or we ran too long
1183  if (newBytesAvailable)
1184  {
1185  //
1186  // ...notify the MPU port driver that we have bytes.
1187  //
1188  that->m_pPort->Notify(that->m_pServiceGroup);
1189  }
1190  ntStatus = STATUS_SUCCESS;
1191  }
1192  }
1193 
1194  return ntStatus;
1195 }
#define MPU401_REG_DATA
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
const ULONG kMPUInputBufferSize
#define TRUE
Definition: types.h:120
static ULONGLONG startTime
Definition: main.c:113
LONG NTSTATUS
Definition: precomp.h:26
ULONGLONG NTAPI PcGetTimeInterval(IN ULONGLONG Since)
Definition: api.cpp:37
REFERENCE_TIME m_InputTimeStamp
PSERVICEGROUP m_pServiceGroup
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
UCHAR m_MPUInputBuffer[kMPUInputBufferSize]
#define GTI_MILLISECONDS(t)
Definition: portcls.h:2502
#define ASSERT(a)
Definition: mode.c:44
uint64_t ULONGLONG
Definition: typedefs.h:67
#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
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define UartFifoOkForRead(status)
IN PVOID DynamicContext
Definition: portcls.h:849
#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 2394 of file miniport_dmus.cpp.

2400 {
2402 
2403  CMiniportDMusUARTStream *aStream;
2405  if (aStream)
2406  {
2407  DPRINT("DMusUARTTimerDPC");
2408  if (false == aStream->m_fCapture)
2409  {
2410  (void) aStream->ConsumeEvents();
2411  }
2412  // ignores return value!
2413  }
2414 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ASSERT(a)
Definition: mode.c:44
#define DPRINT
Definition: sndvol32.h:71
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675

◆ InitMPU()

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

Definition at line 663 of file miniport_dmus.cpp.

667 {
668  DPRINT("InitMPU");
669  if (!DynamicContext)
670  {
672  }
673 
674  PUCHAR portBase = PUCHAR(DynamicContext);
675  UCHAR status;
678  NTSTATUS ntStatus = STATUS_SUCCESS;
679 
680  //
681  // Reset the card (puts it into "smart mode")
682  //
683  ntStatus = WriteMPU(portBase,COMMAND,MPU401_CMD_RESET);
684 
685  // wait for the acknowledgement
686  // NOTE: When the Ack arrives, it will trigger an interrupt.
687  // Normally the DPC routine would read in the ack byte and we
688  // would never see it, however since we have the hardware locked (HwEnter),
689  // we can read the port before the DPC can and thus we receive the Ack.
691  success = FALSE;
693  {
695 
696  if (UartFifoOkForRead(status)) // Is data waiting?
697  {
698  READ_PORT_UCHAR(portBase + MPU401_REG_DATA); // yep.. read ACK
699  success = TRUE; // don't need to do more
700  break;
701  }
702  KeStallExecutionProcessor(25); // microseconds
703  }
704 #if (DBG)
705  if (!success)
706  {
707  DPRINT("First attempt to reset the MPU didn't get ACKed.\n");
708  }
709 #endif // (DBG)
710 
711  // NOTE: We cannot check the ACK byte because if the card was already in
712  // UART mode it will not send an ACK but it will reset.
713 
714  // reset the card again
716 
717  // wait for ack (again)
718  startTime = PcGetTimeInterval(0); // This might take a while
719  BYTE dataByte = 0;
720  success = FALSE;
722  {
724  if (UartFifoOkForRead(status)) // Is data waiting?
725  {
726  dataByte = READ_PORT_UCHAR(portBase + MPU401_REG_DATA); // yep.. read ACK
727  success = TRUE; // don't need to do more
728  break;
729  }
731  }
732 
733  if ((0xFE != dataByte) || !success) // Did we succeed? If no second ACK, something is hosed
734  {
735  DPRINT("Second attempt to reset the MPU didn't get ACKed.\n");
736  DPRINT("Init Reset failure error. Ack = %X", ULONG(dataByte));
737 
738  ntStatus = STATUS_IO_DEVICE_ERROR;
739  }
740 
741  return ntStatus;
742 }
#define MPU401_REG_DATA
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define TRUE
Definition: types.h:120
static ULONGLONG startTime
Definition: main.c:113
unsigned char * PUCHAR
Definition: retypes.h:3
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 FALSE
Definition: types.h:117
#define GTI_MILLISECONDS(t)
Definition: portcls.h:2502
unsigned char BOOLEAN
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
uint64_t ULONGLONG
Definition: typedefs.h:67
#define success(from, fromstr, to, tostr)
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned char BYTE
Definition: xxhash.c:193
#define MPU401_CMD_RESET
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
Definition: main.c:14
static SERVICE_STATUS status
Definition: service.c:31
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
#define UartFifoOkForRead(status)
IN PVOID DynamicContext
Definition: portcls.h:849
#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 1225 of file miniport_dmus.cpp.

1228 {
1230  NTSTATUS Status;
1231 
1233  if (!This)
1235 
1236  Status = This->QueryInterface(IID_IMiniport, (PVOID*)OutMiniport);
1237 
1238  if (!NT_SUCCESS(Status))
1239  {
1240  delete This;
1241  }
1242 
1243  DPRINT("NewMiniportDMusUART %p Status %x\n", *OutMiniport, Status);
1244  return Status;
1245 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71

Referenced by PcNewMiniport().

◆ PropertyHandler_Synth()

NTSTATUS NTAPI PropertyHandler_Synth ( IN PPCPROPERTY_REQUEST  PropertyRequest)

Definition at line 2433 of file miniport_dmus.cpp.

2436 {
2437  NTSTATUS ntStatus;
2438 
2439  PAGED_CODE();
2440 
2442  {
2443  ntStatus = ValidatePropertyRequest(pRequest, sizeof(ULONG), TRUE);
2444  if (NT_SUCCESS(ntStatus))
2445  {
2446  // if return buffer can hold a ULONG, return the access flags
2447  PULONG AccessFlags = PULONG(pRequest->Value);
2448 
2449  *AccessFlags = KSPROPERTY_TYPE_BASICSUPPORT;
2450  switch (pRequest->PropertyItem->Id)
2451  {
2452  case KSPROPERTY_SYNTH_CAPS:
2454  *AccessFlags |= KSPROPERTY_TYPE_GET;
2455  }
2456  switch (pRequest->PropertyItem->Id)
2457  {
2459  *AccessFlags |= KSPROPERTY_TYPE_SET;
2460  }
2461  ntStatus = STATUS_SUCCESS;
2462  pRequest->ValueSize = sizeof(ULONG);
2463 
2464  switch (pRequest->PropertyItem->Id)
2465  {
2467  if (pRequest->MinorTarget)
2468  {
2469  *AccessFlags |= KSPROPERTY_TYPE_GET;
2470  }
2471  else
2472  {
2473  pRequest->ValueSize = 0;
2474  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2475  }
2476  }
2477  }
2478  }
2479  else
2480  {
2481  ntStatus = STATUS_SUCCESS;
2482  switch(pRequest->PropertyItem->Id)
2483  {
2484  case KSPROPERTY_SYNTH_CAPS:
2485  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_CAPS");
2486 
2487  if (pRequest->Verb & KSPROPERTY_TYPE_SET)
2488  {
2489  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2490  }
2491 
2492  if (NT_SUCCESS(ntStatus))
2493  {
2494  ntStatus = ValidatePropertyRequest(pRequest, sizeof(SYNTHCAPS), TRUE);
2495 
2496  if (NT_SUCCESS(ntStatus))
2497  {
2498  SYNTHCAPS *caps = (SYNTHCAPS*)pRequest->Value;
2499  int increment;
2500  RtlZeroMemory(caps, sizeof(SYNTHCAPS));
2501  // XXX Different guids for different instances!
2502  //
2503  if (pRequest->Node == eSynthNode)
2504  {
2505  increment = sizeof(wszDescOut) - 2;
2506  RtlCopyMemory( caps->Description,wszDescOut,increment);
2507  caps->Guid = CLSID_MiniportDriverDMusUART;
2508  }
2509  else
2510  {
2511  increment = sizeof(wszDescIn) - 2;
2512  RtlCopyMemory( caps->Description,wszDescIn,increment);
2513  caps->Guid = CLSID_MiniportDriverDMusUARTCapture;
2514  }
2515 
2516  caps->Flags = SYNTH_PC_EXTERNAL;
2517  caps->MemorySize = 0;
2518  caps->MaxChannelGroups = 1;
2519  caps->MaxVoices = 0xFFFFFFFF;
2520  caps->MaxAudioChannels = 0xFFFFFFFF;
2521 
2522  caps->EffectFlags = 0;
2523 
2524  CMiniportDMusUART *aMiniport;
2525  ASSERT(pRequest->MajorTarget);
2526  aMiniport = (CMiniportDMusUART *)(PMINIPORTDMUS)(pRequest->MajorTarget);
2527  WCHAR wszDesc2[16];
2528  int cLen;
2529  cLen = swprintf(wszDesc2,L"[%03x]\0",PtrToUlong(aMiniport->m_pPortBase));
2530 
2531  cLen *= sizeof(WCHAR);
2532  RtlCopyMemory((WCHAR *)((DWORD_PTR)(caps->Description) + increment),
2533  wszDesc2,
2534  cLen);
2535 
2536 
2537  pRequest->ValueSize = sizeof(SYNTHCAPS);
2538  }
2539  }
2540 
2541  break;
2542 
2544  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_PORTPARAMETERS");
2545  {
2546  CMiniportDMusUARTStream *aStream;
2547 
2548  aStream = (CMiniportDMusUARTStream*)(pRequest->MinorTarget);
2549  if (aStream)
2550  {
2551  ntStatus = aStream->HandlePortParams(pRequest);
2552  }
2553  else
2554  {
2555  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2556  }
2557  }
2558  break;
2559 
2561  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_CHANNELGROUPS");
2562 
2563  ntStatus = ValidatePropertyRequest(pRequest, sizeof(ULONG), TRUE);
2564  if (NT_SUCCESS(ntStatus))
2565  {
2566  *(PULONG)(pRequest->Value) = 1;
2567  pRequest->ValueSize = sizeof(ULONG);
2568  }
2569  break;
2570 
2572  DPRINT("PropertyHandler_Synth:KSPROPERTY_SYNTH_LATENCYCLOCK");
2573 
2574  if(pRequest->Verb & KSPROPERTY_TYPE_SET)
2575  {
2576  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2577  }
2578  else
2579  {
2580  ntStatus = ValidatePropertyRequest(pRequest, sizeof(ULONGLONG), TRUE);
2581  if(NT_SUCCESS(ntStatus))
2582  {
2583  REFERENCE_TIME rtLatency;
2584  CMiniportDMusUARTStream *aStream;
2585 
2586  aStream = (CMiniportDMusUARTStream*)(pRequest->MinorTarget);
2587  if(aStream == NULL)
2588  {
2589  ntStatus = STATUS_INVALID_DEVICE_REQUEST;
2590  }
2591  else
2592  {
2593  aStream->m_pMiniport->m_MasterClock->GetTime(&rtLatency);
2594  *((PULONGLONG)pRequest->Value) = rtLatency;
2595  pRequest->ValueSize = sizeof(ULONGLONG);
2596  }
2597  }
2598  }
2599  break;
2600 
2601  default:
2602  DPRINT("Unhandled property in PropertyHandler_Synth");
2603  break;
2604  }
2605  }
2606  return ntStatus;
2607 }
DWORD MaxVoices
Definition: dmusprop.h:86
DWORD MemorySize
Definition: dmusprop.h:84
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
FxRequest * pRequest
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
GUID Guid
Definition: dmusprop.h:82
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
WCHAR Description[128]
Definition: dmusprop.h:89
#define L(x)
Definition: ntvdm.h:50
CMiniportDMusUART * m_pMiniport
const WCHAR wszDescIn[]
#define PtrToUlong(u)
Definition: config.h:107
#define KSPROPERTY_TYPE_BASICSUPPORT
Definition: dmksctrl.h:45
#define ASSERT(a)
Definition: mode.c:44
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:67
DWORD Flags
Definition: dmusprop.h:83
int _cdecl swprintf(const WCHAR *,...)
uint32_t DWORD_PTR
Definition: typedefs.h:65
DWORD EffectFlags
Definition: dmusprop.h:88
IMiniportDMus * PMINIPORTDMUS
Definition: dmusicks.h:209
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
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:383
PMASTERCLOCK m_MasterClock
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
NTSTATUS ValidatePropertyRequest(IN PPCPROPERTY_REQUEST pRequest, IN ULONG ulValueSize, IN BOOLEAN fValueRequired)
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
struct _SYNTHCAPS SYNTHCAPS
NTSTATUS HandlePortParams(IN PPCPROPERTY_REQUEST Request)
#define PAGED_CODE()

◆ ResetHardware()

NTSTATUS ResetHardware ( PUCHAR  portBase)

Definition at line 605 of file miniport_dmus.cpp.

606 {
607  PAGED_CODE();
608 
609  return WriteMPU(portBase,COMMAND,MPU401_CMD_UART);
610 }
NTSTATUS WriteMPU(IN PUCHAR PortBase, IN BOOLEAN IsCommand, IN UCHAR Value)
Definition: main.c:14
#define MPU401_CMD_UART
#define PAGED_CODE()

Referenced by CMiniportDMusUART::InitializeHardware().

◆ SnapTimeStamp()

SnapTimeStamp ( PINTERRUPTSYNC  InterruptSync,
PVOID  pStream 
)

Definition at line 986 of file miniport_dmus.cpp.

987 {
988  CMiniportDMusUARTStream *pMPStream = (CMiniportDMusUARTStream *)pStream;
989 
990  // cache the timestamp
991  pMPStream->m_SnapshotTimeStamp = pMPStream->m_pMiniport->m_InputTimeStamp;
992 
993  // if the window is closed, zero the timestamp
994  if (pMPStream->m_pMiniport->m_MPUInputBufferHead ==
995  pMPStream->m_pMiniport->m_MPUInputBufferTail)
996  {
997  pMPStream->m_pMiniport->m_InputTimeStamp = 0;
998  }
999 
1000  return STATUS_SUCCESS;
1001 }
REFERENCE_TIME m_InputTimeStamp
CMiniportDMusUART * m_pMiniport
REFERENCE_TIME m_SnapshotTimeStamp
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ 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 833 of file miniport_dmus.cpp.

837 {
839  context = (PSYNCWRITECONTEXT)syncWriteContext;
840  ASSERT(context->Miniport);
841  ASSERT(context->PortBase);
842  ASSERT(context->BufferAddress);
843  ASSERT(context->Length);
844  ASSERT(context->BytesRead);
845 
846  PUCHAR pChar = PUCHAR(context->BufferAddress);
847  NTSTATUS ntStatus; // , readStatus
848  ntStatus = STATUS_SUCCESS;
849  //
850  // while we're not there yet, and
851  // while we don't have to wait on an aligned byte (including 0)
852  // (we never wait on a byte. Better to come back later)
853  /*readStatus = */ DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
854  while ( (*(context->BytesRead) < context->Length)
855  && ( TryMPU(context->PortBase)
856  || (*(context->BytesRead)%3)
857  ) )
858  {
859  ntStatus = WriteMPU(context->PortBase,DATA,*pChar);
860  if (NT_SUCCESS(ntStatus))
861  {
862  pChar++;
863  *(context->BytesRead) = *(context->BytesRead) + 1;
864 // readStatus = DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
865  }
866  else
867  {
868  DPRINT("SynchronizedDMusMPUWrite failed (0x%08x)",ntStatus);
869  break;
870  }
871  }
872  /*readStatus = */ DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
873  return ntStatus;
874 }
struct SYNCWRITECONTEXT * PSYNCWRITECONTEXT
Definition: http.c:7251
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 * PVOID
Definition: retypes.h:9
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
Definition: wdfdriver.h:113
BOOLEAN TryMPU(IN PUCHAR PortBase)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ TryMPU()

BOOLEAN TryMPU ( IN PUCHAR  PortBase)

Definition at line 889 of file miniport_dmus.cpp.

892 {
894  USHORT numPolls;
895  UCHAR status;
896 
897  DPRINT("TryMPU");
898  numPolls = 0;
899 
900  while (numPolls < kMPUPollTimeout)
901  {
903 
904  if (UartFifoOkForWrite(status)) // Is this a good time to write data?
905  {
906  break;
907  }
908  numPolls++;
909  }
910  if (numPolls >= kMPUPollTimeout)
911  {
912  success = FALSE;
913  DPRINT("TryMPU failed");
914  }
915  else
916  {
917  success = TRUE;
918  }
919 
920  return success;
921 }
#define UartFifoOkForWrite(status)
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#define success(from, fromstr, to, tostr)
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
#define kMPUPollTimeout
#define DPRINT
Definition: sndvol32.h:71
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 2620 of file miniport_dmus.cpp.

2625 {
2626  NTSTATUS ntStatus;
2627 
2628  if (pRequest->ValueSize >= ulValueSize)
2629  {
2630  if (fValueRequired && NULL == pRequest->Value)
2631  {
2632  ntStatus = STATUS_INVALID_PARAMETER;
2633  }
2634  else
2635  {
2636  ntStatus = STATUS_SUCCESS;
2637  }
2638  }
2639  else if (0 == pRequest->ValueSize)
2640  {
2641  ntStatus = STATUS_BUFFER_OVERFLOW;
2642  }
2643  else
2644  {
2645  ntStatus = STATUS_BUFFER_TOO_SMALL;
2646  }
2647 
2648  if (STATUS_BUFFER_OVERFLOW == ntStatus)
2649  {
2650  pRequest->ValueSize = ulValueSize;
2651  }
2652  else
2653  {
2654  pRequest->ValueSize = 0;
2655  }
2656 
2657  return ntStatus;
2658 } // ValidatePropertyRequest
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
FxRequest * pRequest
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

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

◆ WriteMPU()

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

Definition at line 934 of file miniport_dmus.cpp.

939 {
940  DPRINT("WriteMPU");
941  NTSTATUS ntStatus = STATUS_IO_DEVICE_ERROR;
942 
943  if (!PortBase)
944  {
945  DPRINT("O: PortBase is zero\n");
946  return ntStatus;
947  }
948  PUCHAR deviceAddr = PortBase + MPU401_REG_DATA;
949 
950  if (IsCommand)
951  {
952  deviceAddr = PortBase + MPU401_REG_COMMAND;
953  }
954 
956 
958  {
959  UCHAR status
960  = READ_PORT_UCHAR(PortBase + MPU401_REG_STATUS);
961 
962  if (UartFifoOkForWrite(status)) // Is this a good time to write data?
963  { // yep (Jon comment)
964  WRITE_PORT_UCHAR(deviceAddr,Value);
965  DPRINT("WriteMPU emitted 0x%02x",Value);
966  ntStatus = STATUS_SUCCESS;
967  break;
968  }
969  }
970  return ntStatus;
971 }
#define MPU401_REG_COMMAND
#define MPU401_REG_DATA
#define UartFifoOkForWrite(status)
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
static ULONGLONG startTime
Definition: main.c:113
unsigned char * PUCHAR
Definition: retypes.h:3
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:2502
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned char UCHAR
Definition: xmlstorage.h:181
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#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:165
#define KSCATEGORY_CAPTURE
Definition: ks.h:160
const GUID KSCATEGORY_AUDIO
Definition: controls.c:25
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25

Definition at line 564 of file miniport_dmus.cpp.

◆ MiniportConnections

◆ MiniportFilterDescriptor

PCFILTER_DESCRIPTOR MiniportFilterDescriptor
static
Initial value:
=
{
0,
NULL,
sizeof(PCPIN_DESCRIPTOR),
}
static PCCONNECTION_DESCRIPTOR MiniportConnections[]
static PCNODE_DESCRIPTOR MiniportNodes[]
#define SIZEOF_ARRAY(ar)
Definition: cdrom.h:1482
static GUID MiniportCategories[]
static PCPIN_DESCRIPTOR MiniportPins[]
#define NULL
Definition: types.h:112

Definition at line 577 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 523 of file miniport_dmus.cpp.

◆ MiniportPins

PCPIN_DESCRIPTOR MiniportPins[]
static

Definition at line 426 of file miniport_dmus.cpp.

◆ PinDataRangePointersBridge

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

Definition at line 370 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamCombined

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

Definition at line 336 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamDMusic

PKSDATARANGE PinDataRangePointersStreamDMusic[]
static
Initial value:
=
{
}

Definition at line 331 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamLegacy

PKSDATARANGE PinDataRangePointersStreamLegacy[]
static
Initial value:
=
{
}

Definition at line 326 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:1296

Definition at line 348 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:1291
#define KSDATAFORMAT_SUBTYPE_DIRECTMUSIC
Definition: dmusprop.h:9
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25

Definition at line 298 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:1291
const GUID KSDATAFORMAT_SUBTYPE_MIDI
Definition: sup.c:36
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25

Definition at line 279 of file miniport_dmus.cpp.

◆ SynthProperties

PCPROPERTY_ITEM SynthProperties[]
static

Definition at line 382 of file miniport_dmus.cpp.

◆ wszDescIn

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

Definition at line 2428 of file miniport_dmus.cpp.

Referenced by PropertyHandler_Synth().

◆ wszDescOut

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

Definition at line 2427 of file miniport_dmus.cpp.

Referenced by PropertyHandler_Synth().