ReactOS 0.4.15-dev-7906-g1b85a5f
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 517 of file miniport_dmus.cpp.

◆ CONST_PCNODE_DESCRIPTOR_AUTO

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

Definition at line 518 of file miniport_dmus.cpp.

◆ kMaxNumCaptureStreams

#define kMaxNumCaptureStreams   1

Definition at line 413 of file miniport_dmus.cpp.

◆ kMaxNumDMusicRenderStreams

#define kMaxNumDMusicRenderStreams   1

Definition at line 415 of file miniport_dmus.cpp.

◆ kMaxNumLegacyRenderStreams

#define kMaxNumLegacyRenderStreams   1

Definition at line 414 of file miniport_dmus.cpp.

◆ kMPUPollTimeout

#define kMPUPollTimeout   2

Definition at line 873 of file miniport_dmus.cpp.

◆ kOneMillisec

#define kOneMillisec   (10 * 1000)

Definition at line 17 of file miniport_dmus.cpp.

◆ MPU401_CMD_RESET

#define MPU401_CMD_RESET   0xFF

Definition at line 30 of file miniport_dmus.cpp.

◆ MPU401_CMD_UART

#define MPU401_CMD_UART   0x3F

Definition at line 31 of file miniport_dmus.cpp.

◆ MPU401_DRR

#define MPU401_DRR   0x40

Definition at line 23 of file miniport_dmus.cpp.

◆ MPU401_DSR

#define MPU401_DSR   0x80

Definition at line 25 of file miniport_dmus.cpp.

◆ MPU401_REG_COMMAND

#define MPU401_REG_COMMAND   0x01

Definition at line 29 of file miniport_dmus.cpp.

◆ MPU401_REG_DATA

#define MPU401_REG_DATA   0x00

Definition at line 28 of file miniport_dmus.cpp.

◆ MPU401_REG_STATUS

#define MPU401_REG_STATUS   0x01

Definition at line 22 of file miniport_dmus.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file miniport_dmus.cpp.

◆ STR_MODULENAME

#define STR_MODULENAME   "DMusUART:Miniport: "

Definition at line 250 of file miniport_dmus.cpp.

◆ UartFifoOkForRead

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

Definition at line 257 of file miniport_dmus.cpp.

◆ UartFifoOkForWrite

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

Definition at line 256 of file miniport_dmus.cpp.

Typedef Documentation

◆ PSYNCWRITECONTEXT

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
eSynthNode 
eInputNode 

Definition at line 531 of file miniport_dmus.cpp.

531 {
532 eSynthNode = 0
533 , eInputNode
534};
@ eSynthNode
@ eInputNode

◆ anonymous enum

anonymous enum
Enumerator
eFilterInputPinLeg 
eFilterInputPinDM 
eBridgeOutputPin 
eBridgeInputPin 
eFilterOutputPin 

Definition at line 536 of file miniport_dmus.cpp.

536 {
542};
@ eFilterInputPinDM
@ eFilterInputPinLeg
@ eBridgeOutputPin
@ eBridgeInputPin
@ eFilterOutputPin

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 ( IN PINTERRUPTSYNC  InterruptSync,
IN PVOID  DynamicContext 
)

Definition at line 1101 of file miniport_dmus.cpp.

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

◆ DMusMPUInterruptServiceRoutine() [2/2]

NTSTATUS NTAPI DMusMPUInterruptServiceRoutine ( PINTERRUPTSYNC  InterruptSync,
PVOID  DynamicContext 
)

◆ DMusUARTTimerDPC() [1/2]

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

Definition at line 2390 of file miniport_dmus.cpp.

2397{
2399
2400 CMiniportDMusUARTStream *aStream;
2402 if (aStream)
2403 {
2404 DPRINT("DMusUARTTimerDPC");
2405 if (false == aStream->m_fCapture)
2406 {
2407 (void) aStream->ConsumeEvents();
2408 }
2409 // ignores return value!
2410 }
2411}
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:687

◆ DMusUARTTimerDPC() [2/2]

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

◆ InitMPU()

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

Definition at line 659 of file miniport_dmus.cpp.

664{
665 DPRINT("InitMPU");
666 if (!DynamicContext)
667 {
669 }
670
671 PUCHAR portBase = PUCHAR(DynamicContext);
675 NTSTATUS ntStatus = STATUS_SUCCESS;
676
677 //
678 // Reset the card (puts it into "smart mode")
679 //
680 ntStatus = WriteMPU(portBase,COMMAND,MPU401_CMD_RESET);
681
682 // wait for the acknowledgement
683 // NOTE: When the Ack arrives, it will trigger an interrupt.
684 // Normally the DPC routine would read in the ack byte and we
685 // would never see it, however since we have the hardware locked (HwEnter),
686 // we can read the port before the DPC can and thus we receive the Ack.
688 success = FALSE;
690 {
692
693 if (UartFifoOkForRead(status)) // Is data waiting?
694 {
695 READ_PORT_UCHAR(portBase + MPU401_REG_DATA); // yep.. read ACK
696 success = TRUE; // don't need to do more
697 break;
698 }
699 KeStallExecutionProcessor(25); // microseconds
700 }
701#if (DBG)
702 if (!success)
703 {
704 DPRINT("First attempt to reset the MPU didn't get ACKed.\n");
705 }
706#endif // (DBG)
707
708 // NOTE: We cannot check the ACK byte because if the card was already in
709 // UART mode it will not send an ACK but it will reset.
710
711 // reset the card again
713
714 // wait for ack (again)
715 startTime = PcGetTimeInterval(0); // This might take a while
716 BYTE dataByte = 0;
717 success = FALSE;
719 {
721 if (UartFifoOkForRead(status)) // Is data waiting?
722 {
723 dataByte = READ_PORT_UCHAR(portBase + MPU401_REG_DATA); // yep.. read ACK
724 success = TRUE; // don't need to do more
725 break;
726 }
728 }
729
730 if ((0xFE != dataByte) || !success) // Did we succeed? If no second ACK, something is hosed
731 {
732 DPRINT("Second attempt to reset the MPU didn't get ACKed.\n");
733 DPRINT("Init Reset failure error. Ack = %X", ULONG(dataByte));
734
735 ntStatus = STATUS_IO_DEVICE_ERROR;
736 }
737
738 return ntStatus;
739}
unsigned char BOOLEAN
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
NTSTATUS WriteMPU(IN PUCHAR PortBase, IN BOOLEAN IsCommand, IN UCHAR Value)
#define MPU401_CMD_RESET
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
Definition: main.c:15
Definition: ps.c:97
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define success(from, fromstr, to, tostr)
unsigned char BYTE
Definition: xxhash.c:193

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

◆ NewMiniportDMusUART()

NTSTATUS NewMiniportDMusUART ( OUT PMINIPORT OutMiniport,
IN REFCLSID  ClassId 
)

Definition at line 1222 of file miniport_dmus.cpp.

1225{
1228
1230 if (!This)
1232
1233 Status = This->QueryInterface(IID_IMiniport, (PVOID*)OutMiniport);
1234
1235 if (!NT_SUCCESS(Status))
1236 {
1237 delete This;
1238 }
1239
1240 DPRINT("NewMiniportDMusUART %p Status %x\n", *OutMiniport, Status);
1241 return Status;
1242}
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
#define TAG_PORTCLASS
Definition: private.hpp:24
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by PcNewMiniport().

◆ PropertyHandler_Synth()

NTSTATUS NTAPI PropertyHandler_Synth ( IN PPCPROPERTY_REQUEST  PropertyRequest)

Definition at line 2429 of file miniport_dmus.cpp.

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

◆ ResetHardware()

NTSTATUS ResetHardware ( PUCHAR  portBase)

Definition at line 602 of file miniport_dmus.cpp.

603{
604 PAGED_CODE();
605
606 return WriteMPU(portBase,COMMAND,MPU401_CMD_UART);
607}
#define MPU401_CMD_UART

Referenced by CMiniportDMusUART::InitializeHardware().

◆ SnapTimeStamp()

SnapTimeStamp ( PINTERRUPTSYNC  InterruptSync,
PVOID  pStream 
)

Definition at line 983 of file miniport_dmus.cpp.

984{
985 CMiniportDMusUARTStream *pMPStream = (CMiniportDMusUARTStream *)pStream;
986
987 // cache the timestamp
988 pMPStream->m_SnapshotTimeStamp = pMPStream->m_pMiniport->m_InputTimeStamp;
989
990 // if the window is closed, zero the timestamp
991 if (pMPStream->m_pMiniport->m_MPUInputBufferHead ==
993 {
994 pMPStream->m_pMiniport->m_InputTimeStamp = 0;
995 }
996
997 return STATUS_SUCCESS;
998}
REFERENCE_TIME m_SnapshotTimeStamp

◆ SynchronizedDMusMPUWrite() [1/2]

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

Definition at line 829 of file miniport_dmus.cpp.

834{
836 context = (PSYNCWRITECONTEXT)syncWriteContext;
837 ASSERT(context->Miniport);
838 ASSERT(context->PortBase);
839 ASSERT(context->BufferAddress);
840 ASSERT(context->Length);
841 ASSERT(context->BytesRead);
842
843 PUCHAR pChar = PUCHAR(context->BufferAddress);
844 NTSTATUS ntStatus; // , readStatus
845 ntStatus = STATUS_SUCCESS;
846 //
847 // while we're not there yet, and
848 // while we don't have to wait on an aligned byte (including 0)
849 // (we never wait on a byte. Better to come back later)
850 /*readStatus = */ DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
851 while ( (*(context->BytesRead) < context->Length)
852 && ( TryMPU(context->PortBase)
853 || (*(context->BytesRead)%3)
854 ) )
855 {
856 ntStatus = WriteMPU(context->PortBase,DATA,*pChar);
857 if (NT_SUCCESS(ntStatus))
858 {
859 pChar++;
860 *(context->BytesRead) = *(context->BytesRead) + 1;
861// readStatus = DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
862 }
863 else
864 {
865 DPRINT("SynchronizedDMusMPUWrite failed (0x%08x)",ntStatus);
866 break;
867 }
868 }
869 /*readStatus = */ DMusMPUInterruptServiceRoutine(InterruptSync,PVOID(context->Miniport));
870 return ntStatus;
871}
struct SYNCWRITECONTEXT * PSYNCWRITECONTEXT
NTSTATUS NTAPI DMusMPUInterruptServiceRoutine(PINTERRUPTSYNC InterruptSync, PVOID DynamicContext)
BOOLEAN TryMPU(IN PUCHAR PortBase)
Definition: http.c:7252
void * PVOID
Definition: typedefs.h:50

◆ SynchronizedDMusMPUWrite() [2/2]

NTSTATUS NTAPI SynchronizedDMusMPUWrite ( PINTERRUPTSYNC  InterruptSync,
PVOID  syncWriteContext 
)

◆ TryMPU()

BOOLEAN TryMPU ( IN PUCHAR  PortBase)

Definition at line 885 of file miniport_dmus.cpp.

889{
891 USHORT numPolls;
893
894 DPRINT("TryMPU");
895 numPolls = 0;
896
897 while (numPolls < kMPUPollTimeout)
898 {
900
901 if (UartFifoOkForWrite(status)) // Is this a good time to write data?
902 {
903 break;
904 }
905 numPolls++;
906 }
907 if (numPolls >= kMPUPollTimeout)
908 {
909 success = FALSE;
910 DPRINT("TryMPU failed");
911 }
912 else
913 {
914 success = TRUE;
915 }
916
917 return success;
918}
#define kMPUPollTimeout
#define UartFifoOkForWrite(status)
unsigned short USHORT
Definition: pedump.c:61

Referenced by SynchronizedDMusMPUWrite().

◆ ValidatePropertyRequest()

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

Definition at line 2616 of file miniport_dmus.cpp.

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

Referenced by CMiniportDMusUARTStream::HandlePortParams().

◆ WriteMPU()

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

Definition at line 930 of file miniport_dmus.cpp.

936{
937 DPRINT("WriteMPU");
939
940 if (!PortBase)
941 {
942 DPRINT("O: PortBase is zero\n");
943 return ntStatus;
944 }
945 PUCHAR deviceAddr = PortBase + MPU401_REG_DATA;
946
947 if (IsCommand)
948 {
949 deviceAddr = PortBase + MPU401_REG_COMMAND;
950 }
951
953
955 {
958
959 if (UartFifoOkForWrite(status)) // Is this a good time to write data?
960 { // yep (Jon comment)
961 WRITE_PORT_UCHAR(deviceAddr,Value);
962 DPRINT("WriteMPU emitted 0x%02x",Value);
963 ntStatus = STATUS_SUCCESS;
964 break;
965 }
966 }
967 return ntStatus;
968}
#define MPU401_REG_COMMAND
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

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

Variable Documentation

◆ COMMAND

Definition at line 49 of file miniport_dmus.cpp.

◆ DATA

Definition at line 50 of file miniport_dmus.cpp.

◆ kMPUInputBufferSize

const ULONG kMPUInputBufferSize = 128

Definition at line 51 of file miniport_dmus.cpp.

Referenced by DMusMPUInterruptServiceRoutine().

◆ MiniportCategories

GUID MiniportCategories[]
static
Initial value:
=
{
}
#define STATICGUIDOF(guid)
Definition: dmksctrl.h:25
#define KSCATEGORY_CAPTURE
Definition: ks.h:160
#define KSCATEGORY_RENDER
Definition: ks.h:165
#define KSCATEGORY_AUDIO
Definition: ksmedia.h:172

Definition at line 561 of file miniport_dmus.cpp.

◆ MiniportConnections

◆ MiniportFilterDescriptor

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

Definition at line 574 of file miniport_dmus.cpp.

Referenced by CMiniportDMusUART::GetDescription(), and STDMETHODIMP_().

◆ MiniportNodes

PCNODE_DESCRIPTOR MiniportNodes[]
static
Initial value:
=
{
}
#define KSNODETYPE_SYNTHESIZER
Definition: ksmedia.h:1306
#define CONST_PCNODE_DESCRIPTOR_AUTO(n, a)

Definition at line 520 of file miniport_dmus.cpp.

◆ MiniportPins

PCPIN_DESCRIPTOR MiniportPins[]
static

Definition at line 423 of file miniport_dmus.cpp.

Referenced by CMiniport::BuildDataRangeInformation().

◆ PinDataRangePointersBridge

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

Definition at line 367 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamCombined

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

Definition at line 333 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamDMusic

PKSDATARANGE PinDataRangePointersStreamDMusic[]
static
Initial value:
=
{
}

Definition at line 328 of file miniport_dmus.cpp.

◆ PinDataRangePointersStreamLegacy

PKSDATARANGE PinDataRangePointersStreamLegacy[]
static
Initial value:
=
{
}

Definition at line 323 of file miniport_dmus.cpp.

◆ PinDataRangesBridge

KSDATARANGE PinDataRangesBridge[]
static
Initial value:
=
{
{
{
sizeof(KSDATARANGE),
0,
0,
0,
}
}
}
#define KSDATAFORMAT_SPECIFIER_NONE
Definition: ks.h:1157
union KSDATAFORMAT KSDATARANGE
#define KSDATAFORMAT_SUBTYPE_MIDI_BUS
Definition: ksmedia.h:1296
#define KSDATAFORMAT_TYPE_MUSIC
Definition: ksmedia.h:1005

Definition at line 345 of file miniport_dmus.cpp.

◆ PinDataRangesStreamDMusic

KSDATARANGE_MUSIC PinDataRangesStreamDMusic
static
Initial value:

Definition at line 295 of file miniport_dmus.cpp.

◆ PinDataRangesStreamLegacy

KSDATARANGE_MUSIC PinDataRangesStreamLegacy
static
Initial value:

Definition at line 276 of file miniport_dmus.cpp.

◆ SynthProperties

PCPROPERTY_ITEM SynthProperties[]
static

Definition at line 379 of file miniport_dmus.cpp.

◆ wszDescIn

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

Definition at line 2425 of file miniport_dmus.cpp.

◆ wszDescOut

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

Definition at line 2424 of file miniport_dmus.cpp.