Import 2.3.25pre1
[davej-history.git] / include / linux / lp.h
bloba02c3fff1344802b4e7cef96c843fc209fbe2c79
1 #ifndef _LINUX_LP_H
2 #define _LINUX_LP_H
4 /*
5 * usr/include/linux/lp.h c.1991-1992 James Wiegand
6 * many modifications copyright (C) 1992 Michael K. Johnson
7 * Interrupt support added 1993 Nigel Gamble
8 * Removed 8255 status defines from inside __KERNEL__ Marcelo Tosatti
9 */
12 * Per POSIX guidelines, this module reserves the LP and lp prefixes
13 * These are the lp_table[minor].flags flags...
15 #define LP_EXIST 0x0001
16 #define LP_SELEC 0x0002
17 #define LP_BUSY 0x0004
18 #define LP_BUSY_BIT_POS 2
19 #define LP_OFFL 0x0008
20 #define LP_NOPA 0x0010
21 #define LP_ERR 0x0020
22 #define LP_ABORT 0x0040
23 #define LP_CAREFUL 0x0080 /* obsoleted -arca */
24 #define LP_ABORTOPEN 0x0100
26 #define LP_TRUST_IRQ_ 0x0200 /* obsolete */
27 #define LP_NO_REVERSE 0x0400 /* No reverse mode available. */
28 #define LP_DATA_AVAIL 0x0800 /* Data is available. */
29 #define LP_HAVE_PORT_BIT 12 /* (0x1000) Port is claimed. */
30 #define LP_PORT_BUSY (1<<13) /* Reading or writing. */
32 /*
33 * bit defines for 8255 status port
34 * base + 1
35 * accessed with LP_S(minor), which gets the byte...
37 #define LP_PBUSY 0x80 /* inverted input, active high */
38 #define LP_PACK 0x40 /* unchanged input, active low */
39 #define LP_POUTPA 0x20 /* unchanged input, active high */
40 #define LP_PSELECD 0x10 /* unchanged input, active high */
41 #define LP_PERRORP 0x08 /* unchanged input, active low */
43 /* timeout for each character. This is relative to bus cycles -- it
44 * is the count in a busy loop. THIS IS THE VALUE TO CHANGE if you
45 * have extremely slow printing, or if the machine seems to slow down
46 * a lot when you print. If you have slow printing, increase this
47 * number and recompile, and if your system gets bogged down, decrease
48 * this number. This can be changed with the tunelp(8) command as well.
51 #define LP_INIT_CHAR 1000
53 /* The parallel port specs apparently say that there needs to be
54 * a .5usec wait before and after the strobe.
57 #define LP_INIT_WAIT 1
59 /* This is the amount of time that the driver waits for the printer to
60 * catch up when the printer's buffer appears to be filled. If you
61 * want to tune this and have a fast printer (i.e. HPIIIP), decrease
62 * this number, and if you have a slow printer, increase this number.
63 * This is in hundredths of a second, the default 2 being .05 second.
64 * Or use the tunelp(8) command, which is especially nice if you want
65 * change back and forth between character and graphics printing, which
66 * are wildly different...
69 #define LP_INIT_TIME 2
71 /* IOCTL numbers */
72 #define LPCHAR 0x0601 /* corresponds to LP_INIT_CHAR */
73 #define LPTIME 0x0602 /* corresponds to LP_INIT_TIME */
74 #define LPABORT 0x0604 /* call with TRUE arg to abort on error,
75 FALSE to retry. Default is retry. */
76 #define LPSETIRQ 0x0605 /* call with new IRQ number,
77 or 0 for polling (no IRQ) */
78 #define LPGETIRQ 0x0606 /* get the current IRQ number */
79 #define LPWAIT 0x0608 /* corresponds to LP_INIT_WAIT */
80 /* NOTE: LPCAREFUL is obsoleted and it' s always the default right now -arca */
81 #define LPCAREFUL 0x0609 /* call with TRUE arg to require out-of-paper, off-
82 line, and error indicators good on all writes,
83 FALSE to ignore them. Default is ignore. */
84 #define LPABORTOPEN 0x060a /* call with TRUE arg to abort open() on error,
85 FALSE to ignore error. Default is ignore. */
86 #define LPGETSTATUS 0x060b /* return LP_S(minor) */
87 #define LPRESET 0x060c /* reset printer */
88 #ifdef LP_STATS
89 #define LPGETSTATS 0x060d /* get statistics (struct lp_stats) */
90 #endif
91 #define LPGETFLAGS 0x060e /* get status flags */
93 /* timeout for printk'ing a timeout, in jiffies (100ths of a second).
94 This is also used for re-checking error conditions if LP_ABORT is
95 not set. This is the default behavior. */
97 #define LP_TIMEOUT_INTERRUPT (60 * HZ)
98 #define LP_TIMEOUT_POLLED (10 * HZ)
100 #ifdef __KERNEL__
102 /* Magic numbers for defining port-device mappings */
103 #define LP_PARPORT_UNSPEC -4
104 #define LP_PARPORT_AUTO -3
105 #define LP_PARPORT_OFF -2
106 #define LP_PARPORT_NONE -1
108 #define LP_F(minor) lp_table[(minor)].flags /* flags for busy, etc. */
109 #define LP_CHAR(minor) lp_table[(minor)].chars /* busy timeout */
110 #define LP_TIME(minor) lp_table[(minor)].time /* wait time */
111 #define LP_WAIT(minor) lp_table[(minor)].wait /* strobe wait */
112 #define LP_IRQ(minor) lp_table[(minor)].dev->port->irq /* interrupt # */
113 /* PARPORT_IRQ_NONE means polled */
114 #ifdef LP_STATS
115 #define LP_STAT(minor) lp_table[(minor)].stats /* statistics area */
116 #endif
117 #define LP_BUFFER_SIZE PAGE_SIZE
119 #define LP_BASE(x) lp_table[(x)].dev->port->base
121 #ifdef LP_STATS
122 struct lp_stats {
123 unsigned long chars;
124 unsigned long sleeps;
125 unsigned int maxrun;
126 unsigned int maxwait;
127 unsigned int meanwait;
128 unsigned int mdev;
130 #endif
132 struct lp_struct {
133 struct pardevice *dev;
134 unsigned long flags;
135 unsigned int chars;
136 unsigned int time;
137 unsigned int wait;
138 char *lp_buffer;
139 #ifdef LP_STATS
140 unsigned int lastcall;
141 unsigned int runchars;
142 struct lp_stats stats;
143 #endif
144 wait_queue_head_t waitq;
145 unsigned int last_error;
146 struct semaphore port_mutex;
147 wait_queue_head_t dataq;
151 * The following constants describe the various signals of the printer port
152 * hardware. Note that the hardware inverts some signals and that some
153 * signals are active low. An example is LP_STROBE, which must be programmed
154 * with 1 for being active and 0 for being inactive, because the strobe signal
155 * gets inverted, but it is also active low.
160 * defines for 8255 control port
161 * base + 2
162 * accessed with LP_C(minor)
164 #define LP_PINTEN 0x10 /* high to read data in or-ed with data out */
165 #define LP_PSELECP 0x08 /* inverted output, active low */
166 #define LP_PINITP 0x04 /* unchanged output, active low */
167 #define LP_PAUTOLF 0x02 /* inverted output, active low */
168 #define LP_PSTROBE 0x01 /* short high output on raising edge */
171 * the value written to ports to test existence. PC-style ports will
172 * return the value written. AT-style ports will return 0. so why not
173 * make them the same ?
175 #define LP_DUMMY 0x00
178 * This is the port delay time, in microseconds.
179 * It is used only in the lp_init() and lp_reset() routine.
181 #define LP_DELAY 50
184 * function prototypes
187 extern int lp_init(void);
189 #endif
191 #endif