How to start a DMA in AVStream minidriver?

Discussion in 'Windows Vista Drivers' started by eraser, Feb 6, 2009.

  1. eraser

    eraser Guest

    I'm writing a MPEG-4 video Capture & Compress card minidriver.
    I've read the "Common Buffer DMA in AVStream" part in the DDK.
    It says that:

    the following steps take place before AVStream calls

    1.The minidriver sets up its common buffer transfers.
    2.The kernel calls the ISR that the vendor has previously registered.
    In the ISR, the minidriver queues a deferred procedure call (DPC).
    3.When the common buffer is full, the minidriver calls
    KsPinAttemptProcessing from the DPC.

    There are some questions as follows:
    1.What should I do to setup up the common buffer transfers in the
    2.When will the kernel call the ISR? It seems that when a DMA transfer
    is completed, there will generate a interrupt. But how can I make the
    DMA start?
    3.How can I know when the common buffer will be full?

    Thanks a lot!
    eraser, Feb 6, 2009
    1. Advertisements

  2. eraser

    Tim Roberts Guest

    Did you read the documentation of the DMA adapter? Start at
    IoGetDmaAdapter. You'll note that DMA_OPERATIONS includes functions for
    AllocateCommonBuffer and FreeCommonBuffer
    This is all entirely up to your device. Remember that it is your DEVICE
    that actually does the DMA transfer. Your device will have a register, or
    set of registers, where you write the DMA information and trigger a
    transfer. Then, it is up to your device to generate an interrupt when a
    DMA transfer is complete, so your driver can schedule another transfer.
    Well, I guess you had better keep track of that. ;) Since you have to
    schedule all of the transfers and notify the card, you'll know when you've
    scheduled enough to fill the buffer.
    Tim Roberts, Feb 8, 2009
    1. Advertisements

  3. eraser

    eraser Guest

    Thank you for your reply!
    I've read the chapter about DMA adapter, it seems that in the
    "AdapterControl" routine, when "AdapterObject->DmaOperations-
    eraser, Feb 10, 2009
  4. I've read the chapter about DMA adapter, it seems that in the
    It begins when you program the hardware to start it.
    Maxim S. Shatskih, Feb 10, 2009
  5. eraser

    Tim Roberts Guest

    Maxim is quite right. DMA is not automatic, it is not done by the
    processor, and it is not controlled by the system. DMA is a feature that
    your PCI board CAN implement (the hardware guys usually call it "bus
    mastering"). If your board can do bus mastering it, then the
    AdapterObject->DmaOperations functions provide a way for you to get the
    memory information you need to tell your device what to do.

    If your board does not implement bus mastering, then your driver cannot use
    DMA. It's just that simple.
    Tim Roberts, Feb 12, 2009
  6. eraser

    eraser Guest

    If I want to start a bus-mastering Packet-based DMA in the AVStream
    minidriver, how can I provide the StartIO routine?
    I know that there is a pDriverObject->DriverStartIo = XxxStartIo in
    WDM driver's DriverEntry, but I can't find the similar entry point in
    the AVStream driver. So how to realize the same function in the
    eraser, Feb 20, 2009
  7. eraser

    Tim Roberts Guest

    StartIo has nothing to do with DMA. It's just a way to manage a queue if
    Have you read through the AVStream samples? They cover all this. Your
    pin's Process dispatch will be called when empty buffers arrive. It's up
    to you to decide whether to wait for Process, then lock-and-map those
    buffers and hand them to your DMA engine, or start your DMA loop using a
    circular buffer, then copy them to the user buffers. Both techniques work.
    Tim Roberts, Feb 21, 2009
  8. eraser

    eraser Guest

    Thank you for your reply! I'll follow your guide.
    eraser, Feb 22, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.