Subject: Re: Ultra 1 parallel port lpt0, bpp0, none working, why?
To: None <port-sparc64@NetBSD.org>
From: Rafal Boni <rafal@pobox.com>
List: port-sparc64
Date: 09/22/2003 21:31:16
In message <20030922222721.GA7662@NetBSD.ORG>, Eduardo writes: 

-> On Tue, Sep 23, 2003 at 12:01:15AM +0200, Andreas Ntaflos wrote:
-> > Hello list (again), 
-> >   
-> >   Hopefully someone can give me a bit of advice or input on this; I have
-> >   an "old" Ultrasparc 1 workstation running NetBSD 1.6.1 smoothly. The
-> >   only problem I wasn't able to figure out was how to get any of the
-> >   parallel ports working to recognize a connected printer (a quite new
-> >   HP LaserJet 3300, but that shouldn't matter, should it?). CUPS is what
-> >   I'd like to use and it compiled without any problems (with the needed
-> >   dependencies etc etc).
-> > 
-> >   As for kernel configuration:
-> >   I used the GENERIC and GENERIC32 kernel config files, renaming them to
-> >   HOSTNAME and HOSTNAME32, modifying the "include GENERIC32" line to
-> >   HOSTNAME32 and adding support for IPFilter. Other than that I haven't 
-> >   changed anything in the kernel as it seems to have support for lpt and
-> >   bpp enabled by default in the config files.
-> > 
-> >   So what is it I need to do to get the parallel port(s) (lpt, bpp) 
-> >   working?  Have I forgotten anything? 
-> 
-> Do you have a /dev/bpp?  (BTW, some newer printers use a bi-directional
-> protocol that doesn't seem to play well with the bpp driver.)

I don't know if an Ultra1 has anything but a bpp, but I recently found that
I had to once again up the delay values in sys/dev/ic/lpt.c to get my U5
printing with lpt@ebus (and even then I have to use the interruptless lpa
device as the interrupting lpt device gets stuck waiting for an interrupt
that never arrives and thus prints at the startling rate of 4cps, which for
a GDI WinPrinter is like a page every 1e6+ seconds :-)

A diff below in case anyone cares; ignore the extra "got interrupt in poll-
ing mode" check, it was just to satisfy some paranoia that the driver was
*not* actually getting interrupts at the wrong time.  With this change, the
lowly HP DeskJet 712C hanging off the Ultra5's lpt port prints happily
again.

--rafal

Index: lpt.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/lpt.c,v
retrieving revision 1.63
diff -u -r1.63 lpt.c
--- lpt.c	2003/06/29 22:30:13	1.63
+++ lpt.c	2003/09/23 01:28:00
@@ -311,13 +311,13 @@
 			}
 
 			bus_space_write_1(iot, ioh, lpt_data, *sc->sc_cp++);
-			DELAY(1);
+			DELAY(2);
 			bus_space_write_1(iot, ioh, lpt_control,
 			    control | LPC_STROBE);
-			DELAY(1);
+			DELAY(2);
 			sc->sc_count--;
 			bus_space_write_1(iot, ioh, lpt_control, control);
-			DELAY(1);
+			DELAY(2);
 
 			/* adapt busy-wait algorithm */
 			if (spin*2 + 16 < sc->sc_spinmax)
@@ -392,6 +392,11 @@
 		return 0;
 #endif
 
+	if (sc->sc_flags & LPT_NOINTR) {
+		printf("%s: got interrupt in polling mode!\n", sc->sc_dev.dv_xname);
+		return 0;
+	}
+
 	/* is printer online and ready for output */
 	if (NOT_READY() && NOT_READY_ERR())
 		return 0;
@@ -400,12 +405,12 @@
 		u_char control = sc->sc_control;
 		/* send char */
 		bus_space_write_1(iot, ioh, lpt_data, *sc->sc_cp++);
-		DELAY(1);
+		DELAY(2);
 		bus_space_write_1(iot, ioh, lpt_control, control | LPC_STROBE);
-		DELAY(1);
+		DELAY(2);
 		sc->sc_count--;
 		bus_space_write_1(iot, ioh, lpt_control, control);
-		DELAY(1);
+		DELAY(2);
 		sc->sc_state |= LPT_OBUSY;
 	} else
 		sc->sc_state &= ~LPT_OBUSY;

----
Rafal Boni                                                     rafal@pobox.com
  We are all worms.  But I do believe I am a glowworm.  -- Winston Churchill