Assorted Project 4 Notes

Joshua Wise

Quick overview

Project 4

Why SB16?

Overview of the SB16

  • Command interface distinct from data interface
  • DMA interface off-chip
    • Cannot talk directly to memory!
  • You get to program each of the bits

The SB16

The DMA Talk

A Device's Worth

DMA buffer strategies

Typical scatter-gather setup

ISA DMA

  • Like everything else on the PC, DMA is sad
  • Logic very expensive in the late 1980s
  • DMA controller goes with the bus, not the card
  • What you will implement is a crazy part of PC history, and not "how DMA works" in the real world.

Your buffer

  • Back to the SB16!
  • DMA controller will be programmed
  • You tell it:
    • Location of buffer (over the course of many writes)
    • Size of buffer
  • It feeds samples and loops

Buffer strategy, part 1

  • Naive strategy?
  • Fill it all up, then tell the sound card to interrupt you after reading the whole thing
  • When woken up, you go fill it up again

Buffer strategy, part 1.5

  • What went wrong?
  • Well, the interrupt didn't really get there in time, maybe
  • Or even if it did, by the time you started copying data...
  • Old data got played, and it sounds pretty bad.

Buffer strategy, part 2

  • We really need two buffers
  • While we're filling one, the card is playing from the other
  • We're guaranteed not to intersect the card's play pointer!

Buffer strategy, part 2.5

  • ...except our DMA controller sucks.
  • We only get one buffer. :(
  • So let's split the buffer in the middle.
    • Tell the card the buffer is half as big as it is

Not just 2

  • Since the buffer loops, it might as well be one long buffer
  • Let's consider a different strategy:
    • Interrupt every N
  • For N <<<< the buffer size, we can see it like this:

Pick a N, any N

  • If we get some interrupt, what can we tell?
  • We know where the card just played from... ...so we know what's not in use... ...so we know what we can fill.
  • This is another possible strategy.
    • Which you choose is a design decision.
      • (Sorry.)

In Summary

  • Sound is fun
  • Buffers are a pain
  • DMA controllers are weird
  • You're lucky you're not using PCI
  • Have fun with this!