<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >The IEEE 1284.3 API</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="The Linux 2.4 Parallel Port Subsystem" HREF="book1.html"><LINK REL="UP" TITLE="Structure" HREF="c65.html"><LINK REL="PREVIOUS" TITLE="Pardevices and parport_drivers" HREF="x96.html"><LINK REL="NEXT" TITLE="Device driver's view" HREF="c192.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Linux 2.4 Parallel Port Subsystem</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="x96.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Structure</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="c192.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN123" ></A >The IEEE 1284.3 API</H1 ><P > 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. </P ><P > 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 <TT CLASS="LITERAL" >parport</TT > code in Linux. </P ><P > At initialisation of the parallel port <SPAN CLASS="QUOTE" >"bus"</SPAN >, 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. </P ><P > 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. </P ><P > 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! </P ><P > 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. </P ><DIV CLASS="MEDIAOBJECT" ><P ><IMG SRC="parport-multi.png"></P ></DIV ><P > Each device in the system is numbered at initialisation (by <TT CLASS="FUNCTION" >parport_daisy_init</TT >). You can convert between this device number and its co-ordinates with <TT CLASS="FUNCTION" >parport_device_num</TT > and <TT CLASS="FUNCTION" >parport_device_coords</TT >. </P ><DIV CLASS="FUNCSYNOPSIS" ><A NAME="AEN142" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="FUNCSYNOPSISINFO" >#include <parport.h> </PRE ></TD ></TR ></TABLE ><P ><CODE ><CODE CLASS="FUNCDEF" >int <TT CLASS="FUNCTION" >parport_device_num</TT ></CODE >(int <TT CLASS="PARAMETER" ><I >parport</I ></TT >, int <TT CLASS="PARAMETER" ><I >mux</I ></TT >, int <TT CLASS="PARAMETER" ><I >daisy</I ></TT >);</CODE ></P ><P ></P ></DIV ><DIV CLASS="FUNCSYNOPSIS" ><A NAME="AEN153" ></A ><P ></P ><P ><CODE ><CODE CLASS="FUNCDEF" >int <TT CLASS="FUNCTION" >parport_device_coords</TT ></CODE >(int <TT CLASS="PARAMETER" ><I >devnum</I ></TT >, int *<TT CLASS="PARAMETER" ><I >parport</I ></TT >, int *<TT CLASS="PARAMETER" ><I >mux</I ></TT >, int *<TT CLASS="PARAMETER" ><I >daisy</I ></TT >);</CODE ></P ><P ></P ></DIV ><P > 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 <TT CLASS="CONSTANT" >-1</TT > is used to indicate these cases. </P ><P > Two functions are provided for finding devices based on their IEEE 1284 Device ID: <TT CLASS="FUNCTION" >parport_find_device</TT > and <TT CLASS="FUNCTION" >parport_find_class</TT >. </P ><DIV CLASS="FUNCSYNOPSIS" ><A NAME="AEN170" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="FUNCSYNOPSISINFO" >#include <parport.h> </PRE ></TD ></TR ></TABLE ><P ><CODE ><CODE CLASS="FUNCDEF" >int <TT CLASS="FUNCTION" >parport_find_device</TT ></CODE >(const char *<TT CLASS="PARAMETER" ><I >mfg</I ></TT >, const char *<TT CLASS="PARAMETER" ><I >mdl</I ></TT >, int <TT CLASS="PARAMETER" ><I >from</I ></TT >);</CODE ></P ><P ></P ></DIV ><DIV CLASS="FUNCSYNOPSIS" ><A NAME="AEN181" ></A ><P ></P ><P ><CODE ><CODE CLASS="FUNCDEF" >int <TT CLASS="FUNCTION" >parport_find_class</TT ></CODE >(parport_device_class <TT CLASS="PARAMETER" ><I >cls</I ></TT >, int <TT CLASS="PARAMETER" ><I >from</I ></TT >);</CODE ></P ><P ></P ></DIV ><P > 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 <TT CLASS="CONSTANT" >-1</TT > 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 <TT CLASS="PARAMETER" ><I >from</I ></TT >+1, in other words). </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="x96.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="c192.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Pardevices and parport_drivers</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c65.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Device driver's view</TD ></TR ></TABLE ></DIV ></BODY ></HTML >