Andrea Arcangeli (andrea@e-mind.com)
Mon, 14 Dec 1998 19:07:30 +0100 (CET)
On Mon, 14 Dec 1998, Andrea Arcangeli wrote:
>Today I finally had 2/3 hour to look into your new 1284 code. The 1284
>code is sure a good thing since it allow us to avoids code duplication and
>simplify the code. I have some bugfix or improvement against Tim' s latest
>patch.
Here some other patch:
This is a cleanup of lp:
--- /home/andrea/linux-ac9+timieee/drivers/char/lp.c Mon Dec 14 17:52:11 1998
+++ linux/drivers/char/lp.c Mon Dec 14 18:46:09 1998
@@ -27,6 +27,9 @@
* Obsoleted the CAREFUL flag since a printer that doesn' t work with
* CAREFUL will block a bit after in lp_check_status().
* Andrea Arcangeli, 15 Oct 1998
+ * Obsoleted and removed all the lowlevel stuff implemented in the last
+ * month to use the IEEE1284 functions (that handle the _new_ compatibilty mode
+ * fine).
*/
/* This driver should, in theory, work with any parallel port that has an
@@ -58,74 +61,6 @@
* # insmod lp.o reset=1
*/
-/*
- * LP OPTIMIZATIONS
- *
- * - TRUST_IRQ flag
- *
- * Epson Stylus Color, HP and many other new printers want the TRUST_IRQ flag
- * set when printing with interrupts. This is a long story. Such printers
- * use a broken handshake (see the timing graph below) when printing with
- * interrupts. The lp driver as default is just able to handle such bogus
- * handshake, but setting such flag cause lp to go faster and probably do
- * what such printers want (even if not documented).
- *
- * NOTE that setting the TRUST_IRQ flag in some printer can cause the irq
- * printing to fail completly. You must try, to know if your printer
- * will handle it. I suggest a graphics printing to force a major flow of
- * characters to the printer for do the test. NOTE also that the TRUST_IRQ
- * flag _should_ be fine everywhere but there is a lot of buggy hardware out
- * there, so I am forced to implement it as a not-default thing.
- * WARNING: before to do the test, be sure to have not played with the
- * `-w' parameter of tunelp!
- *
- * Note also that lp automagically warn you (with a KERN_WARNING) if it
- * detects that you could _try_ to set the TRUST_IRQ flag to speed up the
- * printing and decrease the CPU load.
- *
- * To set the TRUST_IRQ flag you can use this command:
- *
- * tunelp /dev/lp? -T on
- *
- * If you have an old tunelp executable you can (hack and) use this simple
- * C lazy proggy to set the flag in the lp driver:
-
--------------------------- cut here -------------------------------------
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-#define LPTRUSTIRQ 0x060f
-
-int main(int argc, char **argv)
-{
- int fd = open("/dev/lp0", O_RDONLY);
- ioctl(fd, LPTRUSTIRQ, argc - 1);
- if (argc - 1)
- printf("trusting the irq\n");
- else
- printf("untrusting the irq\n");
- return 0;
-}
--------------------------- cut here -------------------------------------
-
- * - LP_WAIT time
- *
- * You can use this setting if your printer is fast enough and/or your
- * machine is slow enough ;-).
- *
- * tunelp /dev/lp? -w 0
- *
- * - LP_CHAR tries
- *
- * If you print with irqs probably you can decrease the CPU load a lot using
- * this setting. This is not the default because the printing is reported to
- * be jerky somewhere...
- *
- * tunelp /dev/lp? -c 1
- *
- * 11 Nov 1998, Andrea Arcangeli
- */
-
/* COMPATIBILITY WITH OLD KERNELS
*
* Under Linux 2.0 and previous versions, lp devices were bound to ports at
@@ -162,6 +97,14 @@
* this case fine too.
*
* 15 Oct 1998, Andrea Arcangeli
+ *
+ * The so called `buggy' handshake is really the well documented compatibility
+ * mode IEEE1284 handshake. They changed the well known Centronics handshake
+ * acking in the middle of busy expecting to not break drivers or legacy
+ * application, while they broken linux lp until I fixed it reverse engeneering
+ * the protocol by hand some month ago...
+ *
+ * 14 Dec 1998, Andrea Arcangeli
*/
#include <linux/module.h>
@@ -194,7 +137,7 @@
#ifdef LP_STATS
0, 0, {0},
#endif
- NULL, 0, 0, 0}
+ NULL, 0,}
};
/* Test if printer is ready */
@@ -232,29 +175,6 @@
#define w_ctr(x,y) do { parport_write_control(lp_table[(x)].dev->port, (y)); } while (0)
#define w_dtr(x,y) do { parport_write_data(lp_table[(x)].dev->port, (y)); } while (0)
-static __inline__ void lp_yield (int minor)
-{
- if (!parport_yield_blocking (lp_table[minor].dev))
- {
- if (current->need_resched)
- schedule ();
- } else
- lp_table[minor].irq_missed = 1;
-}
-
-static __inline__ void lp_schedule(int minor, long timeout)
-{
- struct pardevice *dev = lp_table[minor].dev;
- register unsigned long int timeslip = (jiffies - dev->time);
- if ((timeslip > dev->timeslice) && (dev->port->waithead != NULL)) {
- lp_parport_release(minor);
- lp_table[minor].irq_missed = 1;
- schedule_timeout(timeout);
- lp_parport_claim(minor);
- } else
- schedule_timeout(timeout);
-}
-
static int lp_reset(int minor)
{
int retval;
@@ -267,8 +187,6 @@
return retval;
}
-#define lp_wait(minor) udelay(LP_WAIT(minor))
-
static void lp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
struct lp_struct *lp_dev = (struct lp_struct *) dev_id;
--- /home/andrea/linux-ac9+timieee/include/linux/lp.h Sat Dec 5 11:16:38 1998
+++ linux/include/linux/lp.h Mon Dec 14 18:45:38 1998
@@ -125,8 +125,6 @@
#endif
struct wait_queue *wait_q;
unsigned int last_error;
- volatile unsigned int irq_detected:1;
- volatile unsigned int irq_missed:1;
};
/*
@@ -171,9 +169,6 @@
* It is used only in the lp_init() and lp_reset() routine.
*/
#define LP_DELAY 50
-
-#define LP_POLLED(minor) (lp_table[(minor)].dev->port->irq == PARPORT_IRQ_NONE)
-#define LP_PREEMPTED(minor) (lp_table[(minor)].dev->port->waithead != NULL)
/*
* function prototypes
This instead should avoid the kernel to stall on the printing in presence
of a very very fast printer...
--- /home/andrea/linux-ac9+timieee/drivers/misc/parport_ieee1284_ops.c Mon Dec 14 17:52:11 1998
+++ linux/drivers/misc/parport_ieee1284_ops.c Mon Dec 14 19:00:48 1998
@@ -6,7 +6,7 @@
#include <linux/parport.h>
#include <linux/delay.h>
-#define DEBUG /* undef me for production */
+#undef DEBUG /* undef me for production */
#ifdef DEBUG
#define DPRINTK(stuff...) printk (stuff)
@@ -114,6 +114,9 @@
| PARPORT_STATUS_ERROR
| PARPORT_STATUS_BUSY);
+ if (current->need_resched)
+ schedule();
+
/* Write the character to the data lines. */
parport_write_data (port, *byte++);
udelay (1);
-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:18:54 EST