1/* For ASUS Space-Link by Neo Shih */ 2 3#ifndef _LINUX_LP_H 4#define _LINUX_LP_H 5 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 101#define LPSETID 0x0617 /* set process id to printer, added by Joey */ 102 103struct print_buffer{ 104int len; 105char *buf; 106}; 107/*===========================================================================*/ 108 109 110#ifdef LP_STATS 111#define LPGETSTATS 0x060d /* get statistics (struct lp_stats) */ 112#endif 113#define LPGETFLAGS 0x060e /* get status flags */ 114#define LPSETTIMEOUT 0x060f /* set parport timeout */ 115 116 117/* timeout for printk'ing a timeout, in jiffies (100ths of a second). 118 This is also used for re-checking error conditions if LP_ABORT is 119 not set. This is the default behavior. */ 120 121#define LP_TIMEOUT_INTERRUPT (60 * HZ) 122#define LP_TIMEOUT_POLLED (10 * HZ) 123 124#ifdef __KERNEL__ 125 126/* Magic numbers for defining port-device mappings */ 127#define LP_PARPORT_UNSPEC -4 128#define LP_PARPORT_AUTO -3 129#define LP_PARPORT_OFF -2 130#define LP_PARPORT_NONE -1 131 132#define LP_F(minor) lp_table[(minor)].flags /* flags for busy, etc. */ 133#define LP_CHAR(minor) lp_table[(minor)].chars /* busy timeout */ 134#define LP_TIME(minor) lp_table[(minor)].time /* wait time */ 135#define LP_WAIT(minor) lp_table[(minor)].wait /* strobe wait */ 136#define LP_IRQ(minor) lp_table[(minor)].dev->port->irq /* interrupt # */ 137 /* PARPORT_IRQ_NONE means polled */ 138#ifdef LP_STATS 139#define LP_STAT(minor) lp_table[(minor)].stats /* statistics area */ 140#endif 141#define LP_BUFFER_SIZE PAGE_SIZE 142 143#define LP_BASE(x) lp_table[(x)].dev->port->base 144 145#ifdef LP_STATS 146struct lp_stats { 147 unsigned long chars; 148 unsigned long sleeps; 149 unsigned int maxrun; 150 unsigned int maxwait; 151 unsigned int meanwait; 152 unsigned int mdev; 153}; 154#endif 155 156struct lp_struct { 157 struct pardevice *dev; 158 unsigned long flags; 159 unsigned int chars; 160 unsigned int time; 161 unsigned int wait; 162 char *lp_buffer; 163#ifdef LP_STATS 164 unsigned int lastcall; 165 unsigned int runchars; 166 struct lp_stats stats; 167#endif 168 wait_queue_head_t waitq; 169 unsigned int last_error; 170 struct semaphore port_mutex; 171 wait_queue_head_t dataq; 172 long timeout; 173}; 174 175/* 176 * The following constants describe the various signals of the printer port 177 * hardware. Note that the hardware inverts some signals and that some 178 * signals are active low. An example is LP_STROBE, which must be programmed 179 * with 1 for being active and 0 for being inactive, because the strobe signal 180 * gets inverted, but it is also active low. 181 */ 182 183 184/* 185 * defines for 8255 control port 186 * base + 2 187 * accessed with LP_C(minor) 188 */ 189#define LP_PINTEN 0x10 /* high to read data in or-ed with data out */ 190#define LP_PSELECP 0x08 /* inverted output, active low */ 191#define LP_PINITP 0x04 /* unchanged output, active low */ 192#define LP_PAUTOLF 0x02 /* inverted output, active low */ 193#define LP_PSTROBE 0x01 /* short high output on raising edge */ 194 195/* 196 * the value written to ports to test existence. PC-style ports will 197 * return the value written. AT-style ports will return 0. so why not 198 * make them the same ? 199 */ 200#define LP_DUMMY 0x00 201 202/* 203 * This is the port delay time, in microseconds. 204 * It is used only in the lp_init() and lp_reset() routine. 205 */ 206#define LP_DELAY 50 207 208/* 209 * function prototypes 210 */ 211 212extern int lp_init(void); 213 214#endif 215 216#endif 217 218#define MAX_CLASS_NAME 16 219#define MAX_MFR 16 220#define MAX_MODEL 32 221#define MAX_DESCRIPT 64 222 223struct parport_splink_device_info { 224 const char class_name[MAX_CLASS_NAME]; 225 const char mfr[MAX_MFR]; 226 const char model[MAX_MODEL]; 227 const char description[MAX_DESCRIPT]; 228 const char status[4]; 229}; 230