Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * usr/include/linux/lp.h c.1991-1992 James Wiegand
0004  * many modifications copyright (C) 1992 Michael K. Johnson
0005  * Interrupt support added 1993 Nigel Gamble
0006  * Removed 8255 status defines from inside __KERNEL__ Marcelo Tosatti 
0007  */
0008 #ifndef _LINUX_LP_H
0009 #define _LINUX_LP_H
0010 
0011 
0012 #include <linux/wait.h>
0013 #include <linux/mutex.h>
0014 #include <uapi/linux/lp.h>
0015 
0016 /* Magic numbers for defining port-device mappings */
0017 #define LP_PARPORT_UNSPEC -4
0018 #define LP_PARPORT_AUTO -3
0019 #define LP_PARPORT_OFF -2
0020 #define LP_PARPORT_NONE -1
0021 
0022 #define LP_F(minor) lp_table[(minor)].flags     /* flags for busy, etc. */
0023 #define LP_CHAR(minor)  lp_table[(minor)].chars     /* busy timeout */
0024 #define LP_TIME(minor)  lp_table[(minor)].time      /* wait time */
0025 #define LP_WAIT(minor)  lp_table[(minor)].wait      /* strobe wait */
0026 #define LP_IRQ(minor)   lp_table[(minor)].dev->port->irq /* interrupt # */
0027                     /* PARPORT_IRQ_NONE means polled */
0028 #ifdef LP_STATS
0029 #define LP_STAT(minor)  lp_table[(minor)].stats     /* statistics area */
0030 #endif
0031 #define LP_BUFFER_SIZE PAGE_SIZE
0032 
0033 #define LP_BASE(x)  lp_table[(x)].dev->port->base
0034 
0035 #ifdef LP_STATS
0036 struct lp_stats {
0037     unsigned long chars;
0038     unsigned long sleeps;
0039     unsigned int maxrun;
0040     unsigned int maxwait;
0041     unsigned int meanwait;
0042     unsigned int mdev;
0043 };
0044 #endif
0045 
0046 struct lp_struct {
0047     struct pardevice *dev;
0048     unsigned long flags;
0049     unsigned int chars;
0050     unsigned int time;
0051     unsigned int wait;
0052     char *lp_buffer;
0053 #ifdef LP_STATS
0054     unsigned int lastcall;
0055     unsigned int runchars;
0056     struct lp_stats stats;
0057 #endif
0058     wait_queue_head_t waitq;
0059     unsigned int last_error;
0060     struct mutex port_mutex;
0061     wait_queue_head_t dataq;
0062     long timeout;
0063     unsigned int best_mode;
0064     unsigned int current_mode;
0065     unsigned long bits;
0066 };
0067 
0068 /*
0069  * The following constants describe the various signals of the printer port
0070  * hardware.  Note that the hardware inverts some signals and that some
0071  * signals are active low.  An example is LP_STROBE, which must be programmed
0072  * with 1 for being active and 0 for being inactive, because the strobe signal
0073  * gets inverted, but it is also active low.
0074  */
0075 
0076 
0077 /* 
0078  * defines for 8255 control port
0079  * base + 2 
0080  * accessed with LP_C(minor)
0081  */
0082 #define LP_PINTEN   0x10  /* high to read data in or-ed with data out */
0083 #define LP_PSELECP  0x08  /* inverted output, active low */
0084 #define LP_PINITP   0x04  /* unchanged output, active low */
0085 #define LP_PAUTOLF  0x02  /* inverted output, active low */
0086 #define LP_PSTROBE  0x01  /* short high output on raising edge */
0087 
0088 /* 
0089  * the value written to ports to test existence. PC-style ports will 
0090  * return the value written. AT-style ports will return 0. so why not
0091  * make them the same ? 
0092  */
0093 #define LP_DUMMY    0x00
0094 
0095 /*
0096  * This is the port delay time, in microseconds.
0097  * It is used only in the lp_init() and lp_reset() routine.
0098  */
0099 #define LP_DELAY    50
0100 
0101 #endif