Skip to content

Commit

Permalink
Update to SysVAD, Wave test and public sample of KS Position Test (#496)
Browse files Browse the repository at this point in the history
* Update to Wave test and public sample of KS Position test.
* Update to the SysVAD audio driver sample.
* Add the PnpLockDown property.
  • Loading branch information
darugeri authored May 13, 2020
1 parent b78312c commit bf0b0fe
Show file tree
Hide file tree
Showing 32 changed files with 1,905 additions and 630 deletions.
2 changes: 1 addition & 1 deletion audio/sysvad/EndpointsCommon/mintopo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ Return Value:
// 0x00000002 - JACKDESC2_DYNAMIC_FORMAT_CHANGE_CAPABILITY
//
pDesc->JackCapabilities = JackCapabilities;

ntStatus = STATUS_SUCCESS;
}
}
Expand Down
14 changes: 7 additions & 7 deletions audio/sysvad/EndpointsCommon/mintopo.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ class CMiniportTopology :

NTSTATUS PropertyHandlerJackDescription
(
_In_ PPCPROPERTY_REQUEST PropertyRequest,
_In_ ULONG cJackDescriptions,
_In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions
_In_ PPCPROPERTY_REQUEST PropertyRequest,
_In_ ULONG cJackDescriptions,
_In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION *JackDescriptions
);

NTSTATUS PropertyHandlerJackDescription2
(
_In_ PPCPROPERTY_REQUEST PropertyRequest,
_In_ ULONG cJackDescriptions,
_In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION * JackDescriptions,
_In_ DWORD JackCapabilities
_In_ PPCPROPERTY_REQUEST PropertyRequest,
_In_ ULONG cJackDescriptions,
_In_reads_(cJackDescriptions) PKSJACK_DESCRIPTION *JackDescriptions,
_In_ DWORD JackCapabilities
);

#if defined(SYSVAD_BTH_BYPASS) || defined(SYSVAD_USB_SIDEBAND)
Expand Down
4 changes: 2 additions & 2 deletions audio/sysvad/EndpointsCommon/minwavertstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,12 +968,12 @@ NTSTATUS CMiniportWaveRTStream::GetReadPacket
// Return next packet number to be read
*PacketNumber = availablePacketNumber;

// Compute and return timestamp corresponding to start of the available packet. In a real hardware
// Compute and return timestamp corresponding to the end of the available packet. In a real hardware
// driver, the timestamp would be computed in a driver and hardware specific manner. In this sample
// driver, it is extrapolated from the sample driver's internal simulated position correlation
// [m_ullLinearPosition @ m_ullDmaTimeStamp] and the sample's internal 64-bit packet counter, subtracting
// 1 from the packet counter to compute the time at the start of that last completed packet.
ULONGLONG linearPositionOfAvailablePacket = (packetCounter - 1) * (m_ulDmaBufferSize / m_ulNotificationsPerBuffer);
ULONGLONG linearPositionOfAvailablePacket = packetCounter * (m_ulDmaBufferSize / m_ulNotificationsPerBuffer);
// Need to divide by (1000 * 10000 because m_ulDmaMovementRate is average bytes per sec
ULONGLONG carryForwardBytes = (hnsElapsedTimeCarryForward * m_ulDmaMovementRate) / 10000000;
ULONGLONG deltaLinearPosition = ullLinearPosition + carryForwardBytes - linearPositionOfAvailablePacket;
Expand Down
1 change: 0 additions & 1 deletion audio/sysvad/EndpointsCommon/speakertopo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Module Name:


#pragma code_seg("PAGE")

//=============================================================================
NTSTATUS
PropertyHandler_SpeakerTopoFilter
Expand Down
13 changes: 8 additions & 5 deletions audio/sysvad/EndpointsCommon/speakertoptable.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ PCPIN_DESCRIPTOR SpeakerTopoMiniportPins[] =

//=============================================================================
static
KSJACK_DESCRIPTION SpeakerJackDescSpeakers =
KSJACK_DESCRIPTION SpeakerJackDescBridge =
{
KSAUDIO_SPEAKER_STEREO,
0xB3C98C, // Color spec for green
Expand All @@ -101,7 +101,7 @@ static
PKSJACK_DESCRIPTION SpeakerJackDescriptions[] =
{
NULL,
&SpeakerJackDescSpeakers
&SpeakerJackDescBridge
};

//=============================================================================
Expand All @@ -120,17 +120,20 @@ PCPROPERTY_ITEM PropertiesSpeakerTopoFilter[] =
{
&KSPROPSETID_Jack,
KSPROPERTY_JACK_DESCRIPTION,
KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT,
KSPROPERTY_TYPE_GET |
KSPROPERTY_TYPE_BASICSUPPORT,
PropertyHandler_SpeakerTopoFilter
},
{
&KSPROPSETID_Jack,
KSPROPERTY_JACK_DESCRIPTION2,
KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT,
KSPROPERTY_TYPE_GET |
KSPROPERTY_TYPE_BASICSUPPORT,
PropertyHandler_SpeakerTopoFilter
}
};


DEFINE_PCAUTOMATION_TABLE_PROP(AutomationSpeakerTopoFilter, PropertiesSpeakerTopoFilter);

//=============================================================================
Expand All @@ -152,4 +155,4 @@ PCFILTER_DESCRIPTOR SpeakerTopoMiniportFilterDescriptor =
};

#endif // _SYSVAD_SPEAKERTOPTABLE_H_

4 changes: 2 additions & 2 deletions audio/sysvad/Package/package.VcxProj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM64">
Expand Down Expand Up @@ -109,4 +109,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Binary file modified audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx
Binary file not shown.
Binary file modified audio/sysvad/TabletAudioSample/ComponentizedAudioSample.inx
Binary file not shown.
Binary file not shown.
Binary file modified audio/sysvad/TabletAudioSample/tabletaudiosample.inx
Binary file not shown.
2 changes: 1 addition & 1 deletion audio/sysvad/sysvad.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
Expand Down
215 changes: 215 additions & 0 deletions audio/tests/KSPosTst/KsPosTestTaef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
// ------------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File Name:
//
// KsPosTestTaef.cpp
//
// Abstract:
//
// Implementation file for KsPosTestTaef
//
// -------------------------------------------------------------------------------
#include "PreComp.h"
#include "KsPosTestTaef.h"
#include "tests.h"

using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;

#define RUN_TEST_CASE(testfn) \
{ \
SetVerifyOutput verifySettings(VerifyOutputSettings::LogOnlyFailures); \
testfn(); \
}

IBasicLog * g_pBasicLog = NULL;
WDMAudio::KsPosTest* g_pKsPosTst = NULL;

TIMER_MECHANISM g_Timer =
{
tpQPC, "QueryPerformanceCounter"
};

void LogWaveFormat(WAVEFORMATEX* pwfx)
{
WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)pwfx;

switch (pwfx->wFormatTag)
{
case WAVE_FORMAT_PCM:
LOG(g_pBasicLog, L" wFormatTag = WAVE_FORMAT_PCM");
break;
case WAVE_FORMAT_IEEE_FLOAT:
LOG(g_pBasicLog, L" wFormatTag = WAVE_FORMAT_IEEE_FLOAT");
break;
case WAVE_FORMAT_EXTENSIBLE:
LOG(g_pBasicLog, L" wFormatTag = WAVE_FORMAT_EXTENSIBLE");
if (wfex->SubFormat.Data1 == WAVE_FORMAT_PCM)
LOG(g_pBasicLog, L" SubFormat = WAVE_FORMAT_PCM");
if (wfex->SubFormat.Data1 == WAVE_FORMAT_IEEE_FLOAT)
LOG(g_pBasicLog, L" SubFormat = WAVE_FORMAT_IEEE_FLOAT");
break;
default:
LOG(g_pBasicLog, L" wFormatTag = UNKNOWN!");
}
LOG(g_pBasicLog, L" nChannel = %d", pwfx->nChannels);
LOG(g_pBasicLog, L" nSamplesPerSec = %d", pwfx->nSamplesPerSec);
LOG(g_pBasicLog, L" nAvgBytesPerSe = %d", pwfx->nAvgBytesPerSec);
LOG(g_pBasicLog, L" nBlockAlign = %d", pwfx->nBlockAlign);
LOG(g_pBasicLog, L" wBitsPerSample = %d", pwfx->wBitsPerSample);


if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
LOG(g_pBasicLog, L" wValidBitsPerSample = %d", wfex->Samples.wValidBitsPerSample);
LOG(g_pBasicLog, L" dwChannelMask = %hd", wfex->dwChannelMask);
}
}

// -------------------------------------------------------------------------------
namespace WDMAudio
{
BEGIN_MODULE()
MODULE_PROPERTY(L"Feature", L"PortCls HCK Tests")
MODULE_PROPERTY(L"TestResourceDependent", L"true")
END_MODULE()

// Create WEXBasicLog, Coinitialize Etc
MODULE_SETUP(WDMAudioSetup)

// Release stuff acquired in WDMAudioSetup
MODULE_CLEANUP(WDMAudioCleanup)
};

bool WDMAudio::WDMAudioSetup()
{
if (NULL == g_pBasicLog)
{
if (!(VERIFY_SUCCEEDED(CreateWexBasicLog(&g_pBasicLog))))
{
return false;
}
}

return true;
}

bool WDMAudio::WDMAudioCleanup()
{
if (g_pBasicLog)
{
g_pBasicLog->Release();
}

return true;
}

// -------------------------------------------------------------------------------
bool WDMAudio::KsPosTest::KsPosTestSetup()
{
g_pKsPosTst = this;
m_pTimer = &g_Timer;
// The histograms can be displayed by using the command line parameter checked below
// If the parameter is not specified, the default is to not log anything
bool param = true;
WEX::TestExecution::RuntimeParameters::TryGetValue(L"logHistograms", param);
m_fLogHistograms = param;
return true;
}

bool WDMAudio::KsPosTest::KsPosTestCleanUp()
{
g_pKsPosTst = NULL;

return true;
}

// -------------------------------------------------------------------------------
bool WDMAudio::KsPosTest::TestCaseSetup()
{
CComPtr<ITestResource> spResource;
CComQIPtr<IHalfAppContainer> spHalfContainer;

SetVerifyOutput verifySettings(VerifyOutputSettings::LogOnlyFailures);

Log::Comment(L"");
Log::Comment(L"------------------------------------------------------");
Log::Comment(L"Running test case setup");

size_t count = Resources::Count();
if (!VERIFY_ARE_EQUAL(count, (size_t)1)) { return false; }
if (!VERIFY_SUCCEEDED(Resources::Item(0, &spResource))) { return false; }

// 1. Assign m_pHalf
spHalfContainer = spResource;
if (!VERIFY_IS_NOT_NULL(spHalfContainer)) { return false; }
if (!VERIFY_SUCCEEDED(spHalfContainer->GetHalfApp(&m_pHalf))) { return false; }

// 2. Check if this is a loopback pin. If so, assign the host pin's HalfApp
if (m_pHalf->m_ConnectorType == eLoopbackConnector)
{
VERIFY_SUCCEEDED(m_pHalf->GetHostHalfApp(&m_pHostHalf));
}
else
{
m_pHostHalf = NULL;
}

Log::Comment(L"The test will run on the following format:");
if (m_pHostHalf != NULL)
{
LogWaveFormat(m_pHostHalf->m_pCurrentFormat.get());
}
else
{
LogWaveFormat(m_pHalf->m_pCurrentFormat.get());
}

return true;
}

bool WDMAudio::KsPosTest::TestCaseCleanUp()
{
// Stop the timer here, in case any latency test fails
NtSetTimerResolution(0, FALSE, &actualTimerResolution);

if (!CompareWaveFormat(m_pHalf->m_pCurrentFormat.get(), m_pHalf->m_pPreferredFormat.get())) {
CloneWaveFormat(m_pHalf->m_pPreferredFormat.get(), wil::out_param(m_pHalf->m_pCurrentFormat));
m_pHalf->m_u32CurrentDefaultPeriodicityInFrames = m_pHalf->m_u32DefaultPeriodicityInFrames;
m_pHalf->m_u32CurrentFundamentalPeriodicityInFrames = m_pHalf->m_u32FundamentalPeriodicityInFrames;
m_pHalf->m_u32CurrentMinPeriodicityInFrames = m_pHalf->m_u32MinPeriodicityInFrames;
m_pHalf->m_u32CurrentMaxPeriodicityInFrames = m_pHalf->m_u32MaxPeriodicityInFrames;
}

if (m_pHostHalf != NULL) {
if (!VERIFY_SUCCEEDED(m_pHostHalf->CleanupStream())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHostHalf->ReleaseEndpoint())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHostHalf->ReleaseSineToneDataBuffer())) { return false; }
delete m_pHostHalf;
m_pHostHalf = NULL;
}

if (m_pHalf != NULL) {
if (!VERIFY_SUCCEEDED(m_pHalf->CleanupStream())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHalf->ReleaseEndpoint())) { return false; }
if (!VERIFY_SUCCEEDED(m_pHalf->ReleaseSineToneDataBuffer())) { return false; }

m_pHalf = NULL;
}

return true;
}

// -------------------------------------------------------------------------------
void WDMAudio::KsPosTest::TAEF_DriftAndJitter()
{
RUN_TEST_CASE(Test_DriftAndJitter_Default);
}

void WDMAudio::KsPosTest::TAEF_Latency()
{
RUN_TEST_CASE(Test_Latency_Default);
}
Loading

0 comments on commit bf0b0fe

Please sign in to comment.