patch for lp

Philip Blundell (pjb27@cam.ac.uk)
Mon, 31 Jul 1995 13:19:53 +0100 (BST)


Here is a short patch for the 1.3.13 lp driver. It adds a new ioctl,
LPBITOP. This allows you to directly access the bits in the data
register, so you can use a printer port as a general-purpose output port.

--- linux/drivers/char/lp.c Tue Jun 27 06:33:29 1995
+++ linux/drivers/char/lp.c Sun Jul 30 21:26:12 1995
@@ -6,6 +6,7 @@
* Copyright (C) 1993 by Nigel Gamble (added interrupt code)
* Copyright (C) 1994 by Alan Cox (Modularised it)
* LPCAREFUL, LPABORT, LPGETSTATUS added by Chris Metcalf, metcalf@lcs.mit.edu
+ * LPBITOP added by Philip Blundell <pjb27@cam.ac.uk>
*/

#ifdef MODULE
@@ -507,6 +508,9 @@
break;
case LPRESET:
lp_reset(minor);
+ break;
+ case LPBITOP:
+ outb_p((inb_p(LP_B(minor)) & ((arg & 0xff00) >> 8)) ^ (arg & 0xff), LP_B(minor));
break;
default:
retval = -EINVAL;
--- linux/include/linux/lp.h Sun Jul 23 19:47:19 1995
+++ linux/include/linux/lp.h Sun Jul 30 21:29:35 1995
@@ -68,6 +68,9 @@
FALSE to ignore error. Default is ignore. */
#define LPGETSTATUS 0x060b /* return LP_S(minor) */
#define LPRESET 0x060c /* reset printer */
+#define LPBITOP 0x060f /* tweak bits in data register; the old value is
+ ANDed with bits 8..15 of arg and EORed with
+ bits 0..7 to get the new value */

/* timeout for printk'ing a timeout, in jiffies (100ths of a second).
This is also used for re-checking error conditions if LP_ABORT is

--
Philip Blundell <pjb27@cam.ac.uk>       phone +44 1223 302522
.sig under construction