ReactOS 0.4.15-dev-7942-gd23573b
CMiniport Class Reference

#include <miniport.h>

Inheritance diagram for CMiniport:
Collaboration diagram for CMiniport:

Public Member Functions

NTSTATUS ProcessResources (IN PRESOURCELIST ResourceList)
 
NTSTATUS TestDataFormat (IN PKSDATAFORMAT Format, IN WavePins Pin)
 
NTSTATUS ValidateFormat (IN PKSDATAFORMAT DataFormat, IN WavePins Pin)
 
NTSTATUS BuildDataRangeInformation (void)
 
 ~CMiniport ()
 
 STDMETHODIMP_ (NTSTATUS) Init(_In_ PUNKNOWN UnknownAdapter
 
NTSTATUS NonDelegatingQueryInterface (_In_ REFIID Interface, _COM_Outptr_ PVOID *Object, _In_ REFIID iMiniPort, _In_ PMINIPORT miniPort)
 

Static Public Member Functions

static NTSTATUS NTAPI InterruptServiceRoutine (IN PINTERRUPTSYNC InterruptSync, IN PVOID StaticContext)
 
static NTSTATUS NTAPI PropertyChannelConfig (IN PPCPROPERTY_REQUEST PropertyRequest)
 

Public Attributes

CMiniportStreamStreams [PIN_MICIN_OFFSET+1]
 
PPORT_ Port
 
PADAPTERCOMMON AdapterCommon
 
PINTERRUPTSYNC InterruptSync
 
PDMACHANNEL DmaChannel
 
DEVICE_POWER_STATE m_PowerState
 
DWORD m_dwChannelMask
 
WORD m_wChannels
 
 IMP_IMiniport
 
 IMP_IPowerNotify
 
_In_ PRESOURCELIST ResourceList
 
_In_ PRESOURCELIST _In_ PPORT Port_
 

Detailed Description

Definition at line 26 of file miniport.h.

Constructor & Destructor Documentation

◆ ~CMiniport()

CMiniport::~CMiniport ( )

Definition at line 1287 of file miniport.cpp.

1288{
1289 PAGED_CODE ();
1290
1291 DOUT (DBG_PRINT, ("[CMiniport::~CMiniport]"));
1292
1296 obj_Release((PVOID *)&Port);
1297}
#define PAGED_CODE()
PINTERRUPTSYNC InterruptSync
Definition: miniport.h:32
PADAPTERCOMMON AdapterCommon
Definition: miniport.h:31
PDMACHANNEL DmaChannel
Definition: miniport.h:33
PPORT_ Port
Definition: miniport.h:30
#define DOUT(lvl, strings)
Definition: debug.h:82
void __fastcall obj_Release(void **ppvObject)
Definition: miniport.cpp:1273
#define DBG_PRINT(ppi, ch, level)
Definition: win32kdebug.h:168

Member Function Documentation

◆ BuildDataRangeInformation()

NTSTATUS CMiniport::BuildDataRangeInformation ( void  )

Definition at line 401 of file miniport.cpp.

402{
403 PAGED_CODE ();
404
405 NTSTATUS ntStatus;
406 int nWavePlaybackEntries = 0;
407 int nWaveRecordingEntries = 0;
408 int nMicEntries = 0;
409 int nChannels;
410 int nLoop;
411
412 DOUT (DBG_PRINT, ("[CMiniport::BuildDataRangeInformation]"));
413
414 //
415 // Calculate the number of max. channels available in the codec.
416 //
417 if (AdapterCommon->GetPinConfig (PINC_SURROUND_PRESENT))
418 {
419 if (AdapterCommon->GetPinConfig (PINC_CENTER_LFE_PRESENT))
420 {
421 nChannels = 6;
422 }
423 else
424 {
425 nChannels = 4;
426 }
427 }
428 else
429 {
430 nChannels = 2;
431 }
432
433 // Check for the render sample rates.
434 for (nLoop = 0; nLoop < WAVE_SAMPLERATES_TESTED; nLoop++)
435 {
436 ntStatus = AdapterCommon->ProgramSampleRate (AC97REG_FRONT_SAMPLERATE,
437 dwWaveSampleRates[nLoop]);
438
439 // We support the sample rate?
440 if (NT_SUCCESS (ntStatus))
441 {
442 // Add it to the PinDataRange
444 PinDataRangesPCMStreamRender[nWavePlaybackEntries].DataRange.Flags = 0;
446 PinDataRangesPCMStreamRender[nWavePlaybackEntries].DataRange.Reserved = 0;
451 PinDataRangesPCMStreamRender[nWavePlaybackEntries].MinimumBitsPerSample = 16;
452 PinDataRangesPCMStreamRender[nWavePlaybackEntries].MaximumBitsPerSample = 16;
455
456 // Add it to the PinDataRangePointer
457 PinDataRangePointersPCMStreamRender[nWavePlaybackEntries] = (PKSDATARANGE)&PinDataRangesPCMStreamRender[nWavePlaybackEntries];
458
459 // Increase count
460 nWavePlaybackEntries++;
461 }
462 }
463
464 // Check for the capture sample rates.
465 for (nLoop = 0; nLoop < WAVE_SAMPLERATES_TESTED; nLoop++)
466 {
467 ntStatus = AdapterCommon->ProgramSampleRate (AC97REG_RECORD_SAMPLERATE, dwWaveSampleRates[nLoop]);
468
469 // We support the sample rate?
470 if (NT_SUCCESS (ntStatus))
471 {
472 // Add it to the PinDataRange
474 PinDataRangesPCMStreamCapture[nWaveRecordingEntries].DataRange.Flags = 0;
475 PinDataRangesPCMStreamCapture[nWaveRecordingEntries].DataRange.SampleSize = 4;
476 PinDataRangesPCMStreamCapture[nWaveRecordingEntries].DataRange.Reserved = 0;
480 PinDataRangesPCMStreamCapture[nWaveRecordingEntries].MaximumChannels = 2;
481 PinDataRangesPCMStreamCapture[nWaveRecordingEntries].MinimumBitsPerSample = 16;
482 PinDataRangesPCMStreamCapture[nWaveRecordingEntries].MaximumBitsPerSample = 16;
485
486 // Add it to the PinDataRangePointer
487 PinDataRangePointersPCMStreamCapture[nWaveRecordingEntries] = (PKSDATARANGE)&PinDataRangesPCMStreamCapture[nWaveRecordingEntries];
488
489 // Increase count
490 nWaveRecordingEntries++;
491 }
492 }
493
494 // Check for the MIC sample rates.
495 for (nLoop = 0; nLoop < int(MIC_SAMPLERATES_TESTED); nLoop++)
496 {
497 ntStatus = AdapterCommon->ProgramSampleRate (AC97REG_MIC_SAMPLERATE, dwMicSampleRates[nLoop]);
498
499 // We support the sample rate?
500 if (NT_SUCCESS (ntStatus))
501 {
502 // Add it to the PinDataRange
504 PinDataRangesMicStream[nMicEntries].DataRange.Flags = 0;
515
516 // Add it to the PinDataRangePointer
518
519 // Increase count
520 nMicEntries++;
521 }
522 }
523
524 // Now go through the pin descriptor list and change the data range entries to the actual number.
525 for (nLoop = 0; nLoop < int(SIZEOF_ARRAY(MiniportPins)); nLoop++)
526 {
527 if (MiniportPins[nLoop].KsPinDescriptor.DataRanges == PinDataRangePointersPCMStreamRender)
528 MiniportPins[nLoop].KsPinDescriptor.DataRangesCount = nWavePlaybackEntries;
529 if (MiniportPins[nLoop].KsPinDescriptor.DataRanges == PinDataRangePointersPCMStreamCapture)
530 MiniportPins[nLoop].KsPinDescriptor.DataRangesCount = nWaveRecordingEntries;
531 if (MiniportPins[nLoop].KsPinDescriptor.DataRanges == PinDataRangePointersMicStream)
532 MiniportPins[nLoop].KsPinDescriptor.DataRangesCount = nMicEntries;
533 }
534
535 return STATUS_SUCCESS;
536}
@ AC97REG_MIC_SAMPLERATE
Definition: ac97reg.h:46
@ AC97REG_RECORD_SAMPLERATE
Definition: ac97reg.h:45
@ AC97REG_FRONT_SAMPLERATE
Definition: ac97reg.h:42
LONG NTSTATUS
Definition: precomp.h:26
#define SIZEOF_ARRAY(ar)
Definition: cdrom.h:1482
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static KSDATARANGE_AUDIO PinDataRangesMicStream[MIC_SAMPLERATES_TESTED]
Definition: miniport.cpp:18
static KSDATARANGE_AUDIO PinDataRangesPCMStreamRender[WAVE_SAMPLERATES_TESTED]
Definition: miniport.cpp:16
static PKSDATARANGE PinDataRangePointersPCMStreamRender[WAVE_SAMPLERATES_TESTED]
Definition: miniport.cpp:40
static PKSDATARANGE PinDataRangePointersPCMStreamCapture[WAVE_SAMPLERATES_TESTED]
Definition: miniport.cpp:41
static PKSDATARANGE PinDataRangePointersMicStream[MIC_SAMPLERATES_TESTED]
Definition: miniport.cpp:42
static KSDATARANGE_AUDIO PinDataRangesPCMStreamCapture[WAVE_SAMPLERATES_TESTED]
Definition: miniport.cpp:17
const DWORD dwMicSampleRates[MIC_SAMPLERATES_TESTED]
Definition: miniport.h:18
const int MIC_SAMPLERATES_TESTED
Definition: miniport.h:14
const DWORD dwWaveSampleRates[WAVE_SAMPLERATES_TESTED]
Definition: miniport.h:16
const int WAVE_SAMPLERATES_TESTED
Definition: miniport.h:13
@ PINC_SURROUND_PRESENT
Definition: shared.h:74
@ PINC_CENTER_LFE_PRESENT
Definition: shared.h:75
union KSDATAFORMAT * PKSDATARANGE
#define KSDATAFORMAT_SUBTYPE_PCM
Definition: ksmedia.h:1021
#define KSDATAFORMAT_TYPE_AUDIO
Definition: ksmedia.h:983
#define KSDATAFORMAT_SPECIFIER_WAVEFORMATEX
Definition: ksmedia.h:1031
static PCPIN_DESCRIPTOR MiniportPins[]
int nChannels
Definition: pcmconverter.c:95
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG MaximumChannels
Definition: ksmedia.h:680
ULONG MinimumBitsPerSample
Definition: ksmedia.h:681
ULONG MaximumBitsPerSample
Definition: ksmedia.h:682
ULONG MaximumSampleFrequency
Definition: ksmedia.h:684
KSDATARANGE DataRange
Definition: ksmedia.h:679
ULONG MinimumSampleFrequency
Definition: ksmedia.h:683
KSPIN_DESCRIPTOR KsPinDescriptor
Definition: portcls.h:343

◆ InterruptServiceRoutine()

NTSTATUS CMiniport::InterruptServiceRoutine ( IN PINTERRUPTSYNC  InterruptSync,
IN PVOID  StaticContext 
)
static

Definition at line 1314 of file miniport.cpp.

1319{
1321
1323 ASSERT (DynamicContext);
1324
1325 ULONG GlobalStatus;
1326 USHORT DMAStatusRegister;
1327
1328 //
1329 // Get our context which is a pointer to class CAC97MiniportWaveRT.
1330 //
1331 CMiniport *that = (CMiniport *)DynamicContext;
1332
1333 //
1334 // Check for a valid AdapterCommon pointer.
1335 //
1336 if (!that->AdapterCommon)
1337 {
1338 //
1339 // In case we didn't handle the interrupt, unsuccessful tells the system
1340 // to call the next interrupt handler in the chain.
1341 //
1342 return STATUS_UNSUCCESSFUL;
1343 }
1344
1345 //
1346 // From this point down, basically in the complete ISR, we cannot use
1347 // relative addresses (stream class base address + X_CR for example)
1348 // cause we might get called when the stream class is destroyed or
1349 // not existent. This doesn't make too much sense (that there is an
1350 // interrupt for a non-existing stream) but could happen and we have
1351 // to deal with the interrupt.
1352 //
1353
1354 //
1355 // Read the global register to check the interrupt bits
1356 //
1357 GlobalStatus = that->AdapterCommon->ReadBMControlRegister32 (GLOB_STA);
1358
1359 //
1360 // Check for weird return values. Could happen if the PCI device is already
1361 // disabled and another device that shares this interrupt generated an
1362 // interrupt.
1363 // The register should never have all bits cleared or set.
1364 //
1365 if (!GlobalStatus || (GlobalStatus == 0xFFFFFFFF))
1366 {
1367 return STATUS_UNSUCCESSFUL;
1368 }
1369
1370 //
1371 // Check for PCM out interrupt.
1372 //
1373 NTSTATUS ntStatus = STATUS_UNSUCCESSFUL;
1374 if (GlobalStatus & GLOB_STA_POINT)
1375 {
1376 //
1377 // Read PCM out DMA status registers.
1378 //
1379 DMAStatusRegister = (USHORT)that->AdapterCommon->
1380 ReadBMControlRegister16 (PO_SR);
1381
1382
1383 //
1384 // We could now check for every possible error condition
1385 // (like FIFO error) and monitor the different errors, but currently
1386 // we have the same action for every INT and therefore we simplify
1387 // this routine enormous with just clearing the bits.
1388 //
1389 if (that->Streams[PIN_WAVEOUT_OFFSET])
1390 {
1391 //
1392 // ACK the interrupt.
1393 //
1394 that->AdapterCommon->WriteBMControlRegister (PO_SR, DMAStatusRegister);
1395 ntStatus = STATUS_SUCCESS;
1396
1397 //
1398
1400 }
1401 }
1402
1403 //
1404 // Check for PCM in interrupt.
1405 //
1406 if (GlobalStatus & GLOB_STA_PIINT)
1407 {
1408 //
1409 // Read PCM in DMA status registers.
1410 //
1411 DMAStatusRegister = (USHORT)that->AdapterCommon->
1412 ReadBMControlRegister16 (PI_SR);
1413
1414 //
1415 // We could now check for every possible error condition
1416 // (like FIFO error) and monitor the different errors, but currently
1417 // we have the same action for every INT and therefore we simplify
1418 // this routine enormous with just clearing the bits.
1419 //
1420 if (that->Streams[PIN_WAVEIN_OFFSET])
1421 {
1422 //
1423 // ACK the interrupt.
1424 //
1425 that->AdapterCommon->WriteBMControlRegister (PI_SR, DMAStatusRegister);
1426 ntStatus = STATUS_SUCCESS;
1427
1429 }
1430 }
1431
1432 //
1433 // Check for MIC in interrupt.
1434 //
1435 if (GlobalStatus & GLOB_STA_MINT)
1436 {
1437 //
1438 // Read MIC in DMA status registers.
1439 //
1440 DMAStatusRegister = (USHORT)that->AdapterCommon->
1441 ReadBMControlRegister16 (MC_SR);
1442
1443 //
1444 // We could now check for every possible error condition
1445 // (like FIFO error) and monitor the different errors, but currently
1446 // we have the same action for every INT and therefore we simplify
1447 // this routine enormous with just clearing the bits.
1448 //
1449 if (that->Streams[PIN_MICIN_OFFSET])
1450 {
1451 //
1452 // ACK the interrupt.
1453 //
1454 that->AdapterCommon->WriteBMControlRegister (MC_SR, DMAStatusRegister);
1455 ntStatus = STATUS_SUCCESS;
1456
1458 }
1459 }
1460
1461 return ntStatus;
1462}
virtual void InterruptServiceRoutine() PURE
CMiniportStream * Streams[PIN_MICIN_OFFSET+1]
Definition: miniport.h:29
const int PIN_WAVEIN_OFFSET
Definition: miniport.h:22
const int PIN_MICIN_OFFSET
Definition: miniport.h:23
const int PIN_WAVEOUT_OFFSET
Definition: miniport.h:21
const ULONG MC_SR
Definition: ichreg.h:38
const ULONG PI_SR
Definition: ichreg.h:24
const ULONG PO_SR
Definition: ichreg.h:31
const ULONG GLOB_STA_PIINT
Definition: ichreg.h:89
const ULONG GLOB_STA_POINT
Definition: ichreg.h:88
const ULONG GLOB_STA
Definition: ichreg.h:43
const ULONG GLOB_STA_MINT
Definition: ichreg.h:87
#define ASSERT(a)
Definition: mode.c:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
unsigned short USHORT
Definition: pedump.c:61
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by ProcessResources().

◆ NonDelegatingQueryInterface()

NTSTATUS CMiniport::NonDelegatingQueryInterface ( _In_ REFIID  Interface,
_COM_Outptr_ PVOID Object,
_In_ REFIID  iMiniPort,
_In_ PMINIPORT  miniPort 
)

Definition at line 1143 of file miniport.cpp.

1150{
1151 PAGED_CODE ();
1152
1153 ASSERT (Object);
1154
1155 DOUT (DBG_PRINT, ("[CMiniport::NonDelegatingQueryInterface]"));
1156
1157 // Is it IID_IUnknown?
1159 {
1160 *Object = (PVOID)miniPort;
1161 }
1162 // or IID_IMiniport ...
1163 else if (IsEqualGUIDAligned (Interface, IID_IMiniport))
1164 {
1165 *Object = (PVOID)miniPort;
1166 }
1167 // or IID_IMiniportWavePci ...
1168 else if (IsEqualGUIDAligned (Interface, iMiniPort))
1169 {
1170 *Object = (PVOID)miniPort;
1171 }
1172 // or IID_IPowerNotify ...
1173 else if (IsEqualGUIDAligned (Interface, IID_IPowerNotify))
1174 {
1175 *Object = (PVOID)(PPOWERNOTIFY)this;
1176 }
1177 else
1178 {
1179 // nothing found, must be an unknown interface.
1180 *Object = NULL;
1182 }
1183
1184 //
1185 // We reference the interface for the caller.
1186 //
1187 ((PUNKNOWN)(*Object))->AddRef();
1188 return STATUS_SUCCESS;
1189}
const GUID IID_IUnknown
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define NULL
Definition: types.h:112
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
IPowerNotify * PPOWERNOTIFY
Definition: portcls.h:2059
void * PVOID
Definition: typedefs.h:50
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

◆ ProcessResources()

NTSTATUS CMiniport::ProcessResources ( IN PRESOURCELIST  ResourceList)

Definition at line 1074 of file miniport.cpp.

1078{
1079 PAGED_CODE ();
1080
1082
1083
1084 DOUT (DBG_PRINT, ("[CMiniport::ProcessResources]"));
1085
1086
1087 ULONG countIRQ = ResourceList->NumberOfInterrupts ();
1088 if (countIRQ < 1)
1089 {
1090 DOUT (DBG_ERROR, ("Unknown configuration for wave miniport!"));
1092 }
1093
1094 //
1095 // Create an interrupt sync object
1096 //
1097 NTSTATUS ntStatus = STATUS_SUCCESS;
1098 ntStatus = PcNewInterruptSync (&InterruptSync,
1099 NULL,
1101 0,
1103
1104 if (!NT_SUCCESS (ntStatus) || !InterruptSync)
1105 {
1106 DOUT (DBG_ERROR, ("Failed to create an interrupt sync!"));
1108 }
1109
1110 //
1111 // Register our ISR.
1112 //
1113 ntStatus = InterruptSync->RegisterServiceRoutine (InterruptServiceRoutine,
1114 (PVOID)this, FALSE);
1115 if (!NT_SUCCESS (ntStatus))
1116 {
1117 DOUT (DBG_ERROR, ("Failed to register ISR!"));
1118 return ntStatus;
1119 }
1120
1121 //
1122 // Connect the interrupt.
1123 //
1124 ntStatus = InterruptSync->Connect ();
1125 if (!NT_SUCCESS (ntStatus))
1126 {
1127 DOUT (DBG_ERROR, ("Failed to connect the ISR with InterruptSync!"));
1128 return ntStatus;
1129 }
1130
1131 //
1132 // On failure object is destroyed which cleans up.
1133 //
1134 return STATUS_SUCCESS;
1135}
static NTSTATUS NTAPI InterruptServiceRoutine(IN PINTERRUPTSYNC InterruptSync, IN PVOID StaticContext)
Definition: miniport.cpp:1315
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI PcNewInterruptSync(OUT PINTERRUPTSYNC *OutInterruptSync, IN PUNKNOWN OuterUnknown OPTIONAL, IN PRESOURCELIST ResourceList, IN ULONG ResourceIndex, IN INTERRUPTSYNCMODE Mode)
Definition: interrupt.cpp:295
#define DBG_ERROR
Definition: nfs41_debug.h:78
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
@ InterruptSyncModeNormal
Definition: portcls.h:840
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

◆ PropertyChannelConfig()

NTSTATUS CMiniport::PropertyChannelConfig ( IN PPCPROPERTY_REQUEST  PropertyRequest)
static

Definition at line 313 of file miniport.cpp.

317{
318 PAGED_CODE ();
319
320 ASSERT (PropertyRequest);
321
322 DOUT (DBG_PRINT, ("[CMiniport::PropertyChannelConfig]"));
323
325
326 // The major target is the object pointer to the wave miniport.
327 // HACK ALERT - unsafe pointer cast - HACK ALERT
329 (PMINIPORTWAVEPCI)PropertyRequest->MajorTarget;
330
331 ASSERT (that);
332
333 // We only have a set defined.
334 if (PropertyRequest->Verb & KSPROPERTY_TYPE_SET)
335 {
336 // validate buffer size.
337 if (PropertyRequest->ValueSize < sizeof(LONG))
338 return ntStatus;
339
340 // The "Value" is the input buffer with the channel config.
341 if (PropertyRequest->Value)
342 {
343 // We can accept different channel configurations, depending
344 // on the number of channels we can play.
345 if (that->AdapterCommon->GetPinConfig (PINC_SURROUND_PRESENT))
346 {
347 if (that->AdapterCommon->GetPinConfig (PINC_CENTER_LFE_PRESENT))
348 {
349 // we accept 5.1
350 if (*(PLONG)PropertyRequest->Value == KSAUDIO_SPEAKER_5POINT1)
351 {
352 that->m_dwChannelMask = *(PLONG)PropertyRequest->Value;
353 that->m_wChannels = 6;
354 that->AdapterCommon->WriteChannelConfigDefault (that->m_dwChannelMask);
355 ntStatus = STATUS_SUCCESS;
356 }
357 }
358
359 // accept also surround or quad.
360 if ((*(PLONG)PropertyRequest->Value == KSAUDIO_SPEAKER_QUAD) ||
361 (*(PLONG)PropertyRequest->Value == KSAUDIO_SPEAKER_SURROUND))
362 {
363 that->m_dwChannelMask = *(PLONG)PropertyRequest->Value;
364 that->m_wChannels = 4;
365 that->AdapterCommon->WriteChannelConfigDefault (that->m_dwChannelMask);
366 ntStatus = STATUS_SUCCESS;
367 }
368 }
369
370 // accept also stereo speakers.
371 if (*(PLONG)PropertyRequest->Value == KSAUDIO_SPEAKER_STEREO)
372 {
373 that->m_dwChannelMask = *(PLONG)PropertyRequest->Value;
374 that->m_wChannels = 2;
375 that->AdapterCommon->WriteChannelConfigDefault (that->m_dwChannelMask);
376 ntStatus = STATUS_SUCCESS;
377 }
378 }
379 }
380
381 return ntStatus;
382}
DWORD m_dwChannelMask
Definition: miniport.h:35
WORD m_wChannels
Definition: miniport.h:36
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define KSAUDIO_SPEAKER_SURROUND
Definition: ksmedia.h:1457
#define KSAUDIO_SPEAKER_5POINT1
Definition: ksmedia.h:1459
#define KSAUDIO_SPEAKER_QUAD
Definition: ksmedia.h:1455
#define KSAUDIO_SPEAKER_STEREO
Definition: ksmedia.h:1454
long LONG
Definition: pedump.c:60
IMiniportWavePci * PMINIPORTWAVEPCI
Definition: portcls.h:1697
int32_t * PLONG
Definition: typedefs.h:58

◆ STDMETHODIMP_()

CMiniport::STDMETHODIMP_ ( NTSTATUS  )

◆ TestDataFormat()

NTSTATUS CMiniport::TestDataFormat ( IN PKSDATAFORMAT  Format,
IN WavePins  Pin 
)

Definition at line 826 of file miniport.cpp.

831{
832 PAGED_CODE ();
833
834 ASSERT (Format);
835
836 DOUT (DBG_PRINT, ("[CMiniport::TestDataFormat]"));
837
838 //
839 // KSDATAFORMAT contains three GUIDs to support extensible format. The
840 // first two GUIDs identify the type of data. The third indicates the
841 // type of specifier used to indicate format specifics. We are only
842 // supporting PCM audio formats that use WAVEFORMATEX.
843 //
847 {
848 DOUT (DBG_ERROR, ("[TestDataFormat] Invalid format type!"));
850 }
851
852 PWAVEFORMATPCMEX waveFormat = (PWAVEFORMATPCMEX)(Format + 1);
853
854 //
855 // If the size doesn't match, then something is messed up.
856 //
857 if (Format->FormatSize < (sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX)))
858 {
859 DOUT (DBG_WARNING, ("[TestDataFormat] Invalid FormatSize!"));
861 }
862
863 //
864 // We only support PCM, 16-bit.
865 //
866 if (waveFormat->Format.wBitsPerSample != 16)
867 {
868 DOUT (DBG_WARNING, ("[TestDataFormat] Bits Per Sample must be 16!"));
870 }
871
872 //
873 // We support WaveFormatPCMEX (=WAVEFORMATEXTENSIBLE) or WaveFormatPCM.
874 //
875 if ((waveFormat->Format.wFormatTag != WAVE_FORMAT_EXTENSIBLE) &&
876 (waveFormat->Format.wFormatTag != WAVE_FORMAT_PCM))
877 {
878 DOUT (DBG_WARNING, ("[TestDataFormat] Invalid Format Tag!"));
880 }
881
882 //
883 // Make additional checks for the WAVEFORMATEXTENSIBLE
884 //
885 if (waveFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
886 {
887 //
888 // If the size doesn't match, then something is messed up.
889 //
890 if (Format->FormatSize < (sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATPCMEX)))
891 {
892 DOUT (DBG_WARNING, ("[TestDataFormat] Invalid FormatSize!"));
894 }
895
896 //
897 // Check also the subtype (PCM) and the size of the extended data.
898 //
900 (waveFormat->Format.cbSize < (sizeof(WAVEFORMATPCMEX) - sizeof(WAVEFORMATEX))))
901 {
902 DOUT (DBG_WARNING, ("[TestDataFormat] Unsupported WAVEFORMATEXTENSIBLE!"));
904 }
905
906 //
907 // Check the channel mask. We support 1, 2 channels or whatever was set
908 // with the Speaker config dialog.
909 //
910 if (((waveFormat->Format.nChannels == 1) &&
911 (waveFormat->dwChannelMask != KSAUDIO_SPEAKER_MONO)) ||
912 ((waveFormat->Format.nChannels == 2) &&
913 (waveFormat->dwChannelMask != KSAUDIO_SPEAKER_STEREO)) ||
914 ((waveFormat->Format.nChannels == m_wChannels) &&
915 (waveFormat->dwChannelMask != m_dwChannelMask)))
916 {
917 DOUT (DBG_WARNING, ("[TestDataFormat] Channel Mask!"));
919 }
920 }
921
922 //
923 // Check the number of channels.
924 //
925 switch (Pin)
926 {
927 case PIN_MICIN: // 1 channel
928 if (waveFormat->Format.nChannels != 1)
929 {
930 DOUT (DBG_WARNING, ("[TestDataFormat] Invalid Number of Channels for PIN_MICIN!"));
932 }
933 break;
934 case PIN_WAVEIN: // 2 channels
935 if (waveFormat->Format.nChannels != 2)
936 {
937 DOUT (DBG_WARNING, ("[TestDataFormat] Invalid Number of Channels for PIN_WAVEIN!"));
939 }
940 break;
941 case PIN_WAVEOUT: // channel and mask from PropertyChannelConfig or standard.
942 if (waveFormat->Format.nChannels != m_wChannels)
943 {
944 DOUT (DBG_WARNING, ("[TestDataFormat] Invalid Number of Channels for PIN_WAVEOUT!"));
946 }
947 break;
948 }
949
950 //
951 // Print the information.
952 //
953 if (waveFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE)
954 {
955 DOUT (DBG_STREAM, ("[TestDataFormat] PCMEX - Frequency: %d, Channels: %d, bps: %d, ChannelMask: %X",
956 waveFormat->Format.nSamplesPerSec, waveFormat->Format.nChannels,
957 waveFormat->Format.wBitsPerSample, waveFormat->dwChannelMask));
958 }
959 else
960 {
961 DOUT (DBG_STREAM, ("[TestDataFormat] PCM - Frequency: %d, Channels: %d, bps: %d",
962 waveFormat->Format.nSamplesPerSec, waveFormat->Format.nChannels,
963 waveFormat->Format.wBitsPerSample));
964 }
965
966 return STATUS_SUCCESS;
967}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
const int DBG_STREAM
Definition: debug.h:22
const int DBG_WARNING
Definition: debug.h:18
@ PIN_MICIN
Definition: shared.h:322
@ PIN_WAVEOUT
Definition: shared.h:318
@ PIN_WAVEIN
Definition: shared.h:320
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:427
#define KSAUDIO_SPEAKER_MONO
Definition: ksmedia.h:1453
#define WAVE_FORMAT_EXTENSIBLE
Definition: ksmedia.h:651
WAVEFORMATPCMEX * PWAVEFORMATPCMEX
Definition: mmreg.h:468
WAVEFORMATEX Format
Definition: ksmedia.h:638
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD nSamplesPerSec
Definition: audioclient.idl:42

Referenced by ValidateFormat().

◆ ValidateFormat()

NTSTATUS CMiniport::ValidateFormat ( IN PKSDATAFORMAT  DataFormat,
IN WavePins  Pin 
)

Definition at line 780 of file miniport.cpp.

785{
786 //
787 // Validate the channel (pin id).
788 //
789 if ((Pin != PIN_WAVEOUT) && (Pin != PIN_WAVEIN) &&
790 (Pin != PIN_MICIN))
791 {
792 DOUT (DBG_ERROR, ("[NewStream] Invalid channel passed!"));
794 }
795
796 //
797 // Check if the pin is already in use
798 //
799 if (Streams[Pin/2])
800 {
801 DOUT (DBG_ERROR, ("[NewStream] Pin is already in use!"));
802 return STATUS_UNSUCCESSFUL;
803 }
804
805 //
806 // Check parameters.
807 //
809 if (!NT_SUCCESS (ntStatus))
810 {
811 DOUT (DBG_VSR, ("[NewStream] TestDataFormat failed!"));
812 return ntStatus;
813 }
814
815 return ntStatus;
816}
NTSTATUS TestDataFormat(IN PKSDATAFORMAT Format, IN WavePins Pin)
Definition: miniport.cpp:827
const int DBG_VSR
Definition: debug.h:28

Member Data Documentation

◆ AdapterCommon

◆ DmaChannel

◆ IMP_IMiniport

CMiniport::IMP_IMiniport

Definition at line 72 of file miniport.h.

◆ IMP_IPowerNotify

CMiniport::IMP_IPowerNotify

Definition at line 77 of file miniport.h.

◆ InterruptSync

PINTERRUPTSYNC CMiniport::InterruptSync

Definition at line 32 of file miniport.h.

Referenced by InterruptServiceRoutine(), ProcessResources(), STDMETHODIMP_(), and ~CMiniport().

◆ m_dwChannelMask

DWORD CMiniport::m_dwChannelMask

Definition at line 35 of file miniport.h.

Referenced by PropertyChannelConfig(), and TestDataFormat().

◆ m_PowerState

DEVICE_POWER_STATE CMiniport::m_PowerState

Definition at line 34 of file miniport.h.

Referenced by STDMETHODIMP_().

◆ m_wChannels

WORD CMiniport::m_wChannels

Definition at line 36 of file miniport.h.

Referenced by PropertyChannelConfig(), and TestDataFormat().

◆ Port

PPORT_ CMiniport::Port

◆ Port_

_In_ PRESOURCELIST _In_ PPORT CMiniport::Port_

Definition at line 97 of file miniport.h.

Referenced by STDMETHODIMP_().

◆ ResourceList

_In_ PRESOURCELIST CMiniport::ResourceList

Definition at line 96 of file miniport.h.

◆ Streams


The documentation for this class was generated from the following files: