WDD
Thu Jun 03 15:52:03 CDT 2004
Found the DOC, this is newer DDK info than the 3790.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/stream/hh/stream/avsover_2753.asp
Cheers
WDD wrote:
> Thanks, I would have loved to read this before, can you direct me to the
> MSDN documentation(www link if available).
>
> BTW, Bond, "James" Bond
> Great White North.
>
> Igor Slewsarev wrote:
>
>>> Well, as per DDK "A KSPIN that is performing DMA to or from hardware
>>> must specify the flag KSPIN_FLAG_GENERATE_MAPPINGS." Doesn't mention
>>> anything about ScatterGather support or not, actually I should be able
>>> to program the DMA op with the PhysicalAddress given in the Mappings
>>> directly. No? Especially if they give me 1 mapping in each stream
>>> pointer since I don't set the scatter gather support ot TRUE.
>>
>>
>>
>> This is quotation from MSDN:
>> "Packet-based direct memory access (DMA) occurs when your minidriver
>> reads data directly from and writes data directly to capture buffers
>> received from user mode...
>> To implement a packet-based DMA scheme:
>> Specify KSPIN_FLAG_GENERATE_MAPPINGS in the Flags member of relevant
>> KSPIN_DESCRIPTOR_EX structures. Note that this flag should only be
>> used
>> by a bus master with SCATTER/GATHER support.
>> Register an interrupt service routine (ISR) as described in Writing
>> AVStream Minidrivers for Hardware.
>> Then in the AVStrMiniDeviceStart start dispatch:
>> Set up a DMA adapter object using IoGetDmaAdapter.
>> Register the DMA adapter object with AVStream by calling
>> KsDeviceRegisterAdapterObject."
>>
>> If You don't specify ScatterGather flag this means that you want media
>> samples with physically contigious memory buffer. Now think, could
>> usermode allocators allocate such memory? I also suppose that even
>> KM allocator provided by ks.sys is unable to allocate such memory.
>> (and sometimes it's really impossible. I have some sad experience in
>> allocating 512K contigiuos blocks with
>> MmAllocateContiguousMemorySpecifyCache)
>>
>>
>>> Initially I wasn't using Common Buffer DMA, but have since changed to
>>> that. In any case what would be no difference in setting the
>>> KSPIN_FLAG_GENERATE_MAPPINGS flag, admittedly I cause KS to do more work
>>> for me, but I still populate the buffer via Pointer->StreamHeader->Data
>>> member(which is identical to the OffsetOut->Data) at DPC time?
>>
>>
>> Another quotation:
>> "To use common buffer DMA in your AVStream minidriver:
>> Acquire a DMA adapter by calling IoGetDmaAdapter, as in packet-based
>> DMA. Do not specify KSPIN_FLAG_GENERATE_MAPPINGS in the Flags member
>> of the KSPIN_DESCRIPTOR_EX structure, and do not register your DMA
>> adapter with AVStream. You might need to implement your own private
>> buffer/copy scheme." and etc.
>>
>> Pointer->StreamHeader->Data points to the begining of frame buffer;
>> Pointer->OffsetOut.Data points to the current write position;
>> Suppose that you receive media sample which cann't be filled in one
>> DMA xaction (e.g. Your capure board transfers one field per xaction).
>> in this case You have to advance stream pointer Offset field.
>> Next time Your DPC is called You retrieve the second field and
>> write it right after first and finally eject frame;
>>
>> BTW what's Your name and from where You are?
>>
>> S.Y.
>> Igor V. Slewsarev
>>
>>