[wdmaudiodev] Re: Need help in Passing a test case from KS-Position test

  • From: Gaurav Khuntale <gauravkhuntale@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Thu, 22 May 2014 14:25:09 +0530

Hi Matthew,

If i use below code in GetPosition, then complete KS-Position test is
getting passed,

        LARGE_INTEGER currentTime = { 0 };

        currentTime = KeQueryPerformanceCounter( NULL );

        ULONGLONG timeElapsedInUs = currentTime.QuadPart -
m_dmaStartTime.QuadPart;

        timeElapsedInUs = timeElapsedInUs * 1000000;

        timeElapsedInUs = ( timeElapsedInUs + m_ullElapsedTimeCarryForward
) / m_startFrequency.QuadPart ;

        m_ullElapsedTimeCarryForward = ( timeElapsedInUs +
m_ullElapsedTimeCarryForward ) % m_startFrequency.QuadPart ;

        ULONG bytesDisplaceMent = ( m_ulDmaMovementRate *
(ULONG)timeElapsedInUs + m_ulByteDisplacementCarryForward ) / 1000000 ;

        m_ulByteDisplacementCarryForward = ( m_ulDmaMovementRate *
(ULONG)timeElapsedInUs + m_ulByteDisplacementCarryForward) % 1000000;

        m_ulDmaPosition = ( m_ulDmaPosition + bytesDisplaceMent )%
m_ulDmaBufferSize;

        *Position = m_ulDmaPosition;

        m_dmaStartTime = currentTime;

Thanks.


On Thu, May 22, 2014 at 6:02 AM, Matthew van Eerde <
Matthew.van.Eerde@xxxxxxxxxxxxx> wrote:

>  > I’m working on a better version which attempts to maintain sample
> granularity but eliminates the slop.
>
> OK, I think I have something. Just want to run it few some tests before I
> share.
>
> Unfortunately the WaveCyclic model does not allow miniports to report a
> correlated time + QPC, so extrapolation is forced. MSVad doesn't care much,
> but hardware-based drivers are affected.
>  ------------------------------
> From: Gaurav Khuntale <gauravkhuntale@xxxxxxxxx>
> Sent: ‎5/‎5/‎2014 7:01 AM
>
> To: wdmaudiodev@xxxxxxxxxxxxx
> Subject: [wdmaudiodev] Re: Need help in Passing a test case from
> KS-Position test
>
>    Hi Matthew,
>
>  I tried below code in GetPosition() and driver passed the test case.
>
> ULONGLONG currentTime = KeQueryInterruptTime();
>
> ULONG timeElapsedInNS = (ULONG) (currentTime - m_ullDmaTimeStamp);
> // Diff in nanoseconds
>
> ULONGLONG bytesDisplaceMent = (ULONGLONG)( (ULONGLONG)m_ulDmaMovementRate
> * (ULONGLONG)timeElapsedInNS ) / 10000000;
>
> m_ulDmaPosition = (m_ulDmaPosition + (ULONG)bytesDisplaceMent) %
> m_ulDmaBufferSize;
>
> *Position = m_ulDmaPosition;
>
> m_ullDmaTimeStamp = currentTime;
>
>  Is this a proper way to update position from GetPosition?
>
>  Thanks,
>  Gaurav
>
>
> On Sun, May 4, 2014 at 10:19 AM, Gaurav Khuntale <gauravkhuntale@xxxxxxxxx
> > wrote:
>
>>  Hmmm..i don't have a way to get a position from the layer below me
>> because i am throwing the data over the network after processing it. I
>> don't have any hardware for which my driver is working.
>>
>>  Can you please let me know when your better version with sample
>> granularity is ready?
>>
>>  Thanks.
>>
>>
>> On Sat, May 3, 2014 at 6:09 PM, Matthew van Eerde <
>> Matthew.van.Eerde@xxxxxxxxxxxxx> wrote:
>>
>>>  Do you have any way of getting a real position from the layer below
>>> you? That would be much better than relying on KeQueryInterruptTime(). Or
>>> are you throwing the data on the floor like MSVad does?
>>>
>>>
>>>
>>> Don’t use my code; it’s just a proof-of-concept to demonstrate that you
>>> can get much better than 0.29 ms jitter using sample accuracy instead of
>>> millisecond accuracy.
>>>
>>> In particular, I really don’t like this line:
>>>
>>>
>>>
>>> ULONG ulByteDisplacement = (ULONG)((m_ulDmaMovementRate * ullElapsed +
>>> ullHnsInHalfASec) / ullHnsPerSec);
>>>
>>>
>>>
>>> This line introduces slop into the byte position which accumulates over
>>> time. I think that’s why my skew actually regressed (but I’m not sure.)
>>>
>>>
>>>
>>> I’m working on a better version which attempts to maintain sample
>>> granularity but eliminates the slop.
>>>
>>>
>>>
>>>
>>>
>>
>>
>

Other related posts: