1/* For ASUS Space-Link by Neo Shih */
2#undef _LINUX_LP_H
3
4#ifndef _LINUX_LP_H
5#define _LINUX_LP_H
6/*
7 * usr/include/linux/lp.h c.1991-1992 James Wiegand
8 * many modifications copyright (C) 1992 Michael K. Johnson
9 * Interrupt support added 1993 Nigel Gamble
10 * Removed 8255 status defines from inside __KERNEL__ Marcelo Tosatti
11 */
12
13/*
14 * Per POSIX guidelines, this module reserves the LP and lp prefixes
15 * These are the lp_table[minor].flags flags...
16 */
17#define LP_EXIST 0x0001
18#define LP_SELEC 0x0002
19#define LP_BUSY	 0x0004
20#define LP_BUSY_BIT_POS 2
21#define LP_OFFL	 0x0008
22#define LP_NOPA  0x0010
23#define LP_ERR   0x0020
24#define LP_ABORT 0x0040
25#define LP_CAREFUL 0x0080 /* obsoleted -arca */
26#define LP_ABORTOPEN 0x0100
27
28#define LP_TRUST_IRQ_  0x0200 /* obsolete */
29#define LP_NO_REVERSE  0x0400 /* No reverse mode available. */
30#define LP_DATA_AVAIL  0x0800 /* Data is available. */
31
32/*
33 * bit defines for 8255 status port
34 * base + 1
35 * accessed with LP_S(minor), which gets the byte...
36 */
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 */
42
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.
49 */
50
51#define LP_INIT_CHAR 1000
52
53/* The parallel port specs apparently say that there needs to be
54 * a .5usec wait before and after the strobe.
55 */
56
57#define LP_INIT_WAIT 1
58
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...
67 */
68
69#define LP_INIT_TIME 2
70
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
89
90// Neo
91/*===========================================================================*/
92#define LPGETID		0x0610 	/* get printer's device ID */
93#define LPFINDMODE	0x0611	/* find all modes supported by printer */
94#define LPSETMODE	0x0612  /* set printer to a specific mode */
95
96#define LPWRITEDATA	0x0613	/* write data to printer */
97#define LPWRITEADDR	0x0614  /* write address to printer */
98#define LPREADDATA	0x0615	/* read data from pinter */
99#define LPREADADDR	0x0616	/* read address from pinter */
100
101struct print_buffer{
102int len;
103char *buf;
104};
105/*===========================================================================*/
106
107
108#ifdef LP_STATS
109#define LPGETSTATS  0x060d  /* get statistics (struct lp_stats) */
110#endif
111#define LPGETFLAGS  0x060e  /* get status flags */
112#define LPSETTIMEOUT 0x060f /* set parport timeout */
113
114
115/* timeout for printk'ing a timeout, in jiffies (100ths of a second).
116   This is also used for re-checking error conditions if LP_ABORT is
117   not set.  This is the default behavior. */
118
119#define LP_TIMEOUT_INTERRUPT	(60 * HZ)
120#define LP_TIMEOUT_POLLED	(10 * HZ)
121
122#ifdef __KERNEL__
123
124/* Magic numbers for defining port-device mappings */
125#define LP_PARPORT_UNSPEC -4
126#define LP_PARPORT_AUTO -3
127#define LP_PARPORT_OFF -2
128#define LP_PARPORT_NONE -1
129
130#define LP_F(minor)	lp_table[(minor)].flags		/* flags for busy, etc. */
131#define LP_CHAR(minor)	lp_table[(minor)].chars		/* busy timeout */
132#define LP_TIME(minor)	lp_table[(minor)].time		/* wait time */
133#define LP_WAIT(minor)	lp_table[(minor)].wait		/* strobe wait */
134#define LP_IRQ(minor)	lp_table[(minor)].dev->port->irq /* interrupt # */
135					/* PARPORT_IRQ_NONE means polled */
136#ifdef LP_STATS
137#define LP_STAT(minor)	lp_table[(minor)].stats		/* statistics area */
138#endif
139#define LP_BUFFER_SIZE PAGE_SIZE
140
141#define LP_BASE(x)	lp_table[(x)].dev->port->base
142
143#ifdef LP_STATS
144struct lp_stats {
145	unsigned long chars;
146	unsigned long sleeps;
147	unsigned int maxrun;
148	unsigned int maxwait;
149	unsigned int meanwait;
150	unsigned int mdev;
151};
152#endif
153
154struct lp_struct {
155	struct pardevice *dev;
156	unsigned long flags;
157	unsigned int chars;
158	unsigned int time;
159	unsigned int wait;
160	char *lp_buffer;
161#ifdef LP_STATS
162	unsigned int lastcall;
163	unsigned int runchars;
164	struct lp_stats stats;
165#endif
166	wait_queue_head_t waitq;
167	unsigned int last_error;
168	struct semaphore port_mutex;
169	wait_queue_head_t dataq;
170	long timeout;
171};
172
173/*
174 * The following constants describe the various signals of the printer port
175 * hardware.  Note that the hardware inverts some signals and that some
176 * signals are active low.  An example is LP_STROBE, which must be programmed
177 * with 1 for being active and 0 for being inactive, because the strobe signal
178 * gets inverted, but it is also active low.
179 */
180
181
182/*
183 * defines for 8255 control port
184 * base + 2
185 * accessed with LP_C(minor)
186 */
187#define LP_PINTEN	0x10  /* high to read data in or-ed with data out */
188#define LP_PSELECP	0x08  /* inverted output, active low */
189#define LP_PINITP	0x04  /* unchanged output, active low */
190#define LP_PAUTOLF	0x02  /* inverted output, active low */
191#define LP_PSTROBE	0x01  /* short high output on raising edge */
192
193/*
194 * the value written to ports to test existence. PC-style ports will
195 * return the value written. AT-style ports will return 0. so why not
196 * make them the same ?
197 */
198#define LP_DUMMY	0x00
199
200/*
201 * This is the port delay time, in microseconds.
202 * It is used only in the lp_init() and lp_reset() routine.
203 */
204#define LP_DELAY 	50
205
206/*
207 * function prototypes
208 */
209
210extern int lp_init(void);
211
212#endif
213
214#endif
215