Chapter 7. User-level device drivers

Introduction to ppdev

The printer is accessible through /dev/lp0; in the same way, the parallel port itself is accessible through /dev/parport0. The difference is in the level of control that you have over the wires in the parallel port cable.

With the printer driver, a user-space program (such as the printer spooler) can send bytes in "printer protocol". Briefly, this means that for each byte, the eight data lines are set up, then a "strobe" line tells the printer to look at the data lines, and the printer sets an "acknowledgement" line to say that it got the byte. The printer driver also allows the user-space program to read bytes in "nibble mode", which is a way of transferring data from the peripheral to the computer half a byte at a time (and so it's quite slow).

In contrast, the ppdev driver (accessed via /dev/parport0) allows you to:

  • examine status lines,

  • set control lines,

  • set/examine data lines (and control the direction of the data lines),

  • wait for an interrupt (triggered by one of the status lines),

  • find out how many new interrupts have occurred,

  • set up a response to an interrupt,

  • use IEEE 1284 negotiation (for telling peripheral which transfer mode, to use)

  • transfer data using a specified IEEE 1284 mode.