The IEEE 1284.3 API

The ability to daisy-chain devices is very useful, but if every device does it in a different way it could lead to lots of complications for device driver writers. Fortunately, the IEEE are standardising it in IEEE 1284.3, which covers daisy-chain devices and port multiplexors.

At the time of writing, IEEE 1284.3 has not been published, but the draft specifies the on-the-wire protocol for daisy-chaining and multiplexing, and also suggests a programming interface for using it. That interface (or most of it) has been implemented in the parport code in Linux.

At initialisation of the parallel port "bus", daisy-chained devices are assigned addresses starting from zero. There can only be four devices with daisy-chain addresses, plus one device on the end that doesn't know about daisy-chaining and thinks it's connected directly to a computer.

Another way of connecting more parallel port devices is to use a multiplexor. The idea is to have a device that is connected directly to a parallel port on a computer, but has a number of parallel ports on the other side for other peripherals to connect to (two or four ports are allowed). The multiplexor switches control to different ports under software control---it is, in effect, a programmable printer switch.

Combining the ability of daisy-chaining five devices together with the ability to multiplex one parallel port between four gives the potential to have twenty peripherals connected to the same parallel port!

In addition, of course, a single computer can have multiple parallel ports. So, each parallel port peripheral in the system can be identified with three numbers, or co-ordinates: the parallel port, the multiplexed port, and the daisy-chain address.

Each device in the system is numbered at initialisation (by parport_daisy_init). You can convert between this device number and its co-ordinates with parport_device_num and parport_device_coords.

#include <parport.h>
    

int parport_device_num(int parport, int mux, int daisy);

int parport_device_coords(int devnum, int *parport, int *mux, int *daisy);

Any parallel port peripheral will be connected directly or indirectly to a parallel port on the system, but it won't have a daisy-chain address if it does not know about daisy-chaining, and it won't be connected through a multiplexor port if there is no multiplexor. The special co-ordinate value -1 is used to indicate these cases.

Two functions are provided for finding devices based on their IEEE 1284 Device ID: parport_find_device and parport_find_class.

#include <parport.h>
    

int parport_find_device(const char *mfg, const char *mdl, int from);

int parport_find_class(parport_device_class cls, int from);

These functions take a device number (in addition to some other things), and return another device number. They walk through the list of detected devices until they find one that matches the requirements, and then return that device number (or -1 if there are no more such devices). They start their search at the device after the one in the list with the number given (at from+1, in other words).