lp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * usr/include/linux/lp.h c.1991-1992 James Wiegand
  3. * many modifications copyright (C) 1992 Michael K. Johnson
  4. * Interrupt support added 1993 Nigel Gamble
  5. * Removed 8255 status defines from inside __KERNEL__ Marcelo Tosatti
  6. */
  7. #ifndef _LINUX_LP_H
  8. #define _LINUX_LP_H
  9. #include <linux/wait.h>
  10. #include <linux/mutex.h>
  11. #include <uapi/linux/lp.h>
  12. /* Magic numbers for defining port-device mappings */
  13. #define LP_PARPORT_UNSPEC -4
  14. #define LP_PARPORT_AUTO -3
  15. #define LP_PARPORT_OFF -2
  16. #define LP_PARPORT_NONE -1
  17. #define LP_F(minor) lp_table[(minor)].flags /* flags for busy, etc. */
  18. #define LP_CHAR(minor) lp_table[(minor)].chars /* busy timeout */
  19. #define LP_TIME(minor) lp_table[(minor)].time /* wait time */
  20. #define LP_WAIT(minor) lp_table[(minor)].wait /* strobe wait */
  21. #define LP_IRQ(minor) lp_table[(minor)].dev->port->irq /* interrupt # */
  22. /* PARPORT_IRQ_NONE means polled */
  23. #ifdef LP_STATS
  24. #define LP_STAT(minor) lp_table[(minor)].stats /* statistics area */
  25. #endif
  26. #define LP_BUFFER_SIZE PAGE_SIZE
  27. #define LP_BASE(x) lp_table[(x)].dev->port->base
  28. #ifdef LP_STATS
  29. struct lp_stats {
  30. unsigned long chars;
  31. unsigned long sleeps;
  32. unsigned int maxrun;
  33. unsigned int maxwait;
  34. unsigned int meanwait;
  35. unsigned int mdev;
  36. };
  37. #endif
  38. struct lp_struct {
  39. struct pardevice *dev;
  40. unsigned long flags;
  41. unsigned int chars;
  42. unsigned int time;
  43. unsigned int wait;
  44. char *lp_buffer;
  45. #ifdef LP_STATS
  46. unsigned int lastcall;
  47. unsigned int runchars;
  48. struct lp_stats stats;
  49. #endif
  50. wait_queue_head_t waitq;
  51. unsigned int last_error;
  52. struct mutex port_mutex;
  53. wait_queue_head_t dataq;
  54. long timeout;
  55. unsigned int best_mode;
  56. unsigned int current_mode;
  57. unsigned long bits;
  58. };
  59. /*
  60. * The following constants describe the various signals of the printer port
  61. * hardware. Note that the hardware inverts some signals and that some
  62. * signals are active low. An example is LP_STROBE, which must be programmed
  63. * with 1 for being active and 0 for being inactive, because the strobe signal
  64. * gets inverted, but it is also active low.
  65. */
  66. /*
  67. * defines for 8255 control port
  68. * base + 2
  69. * accessed with LP_C(minor)
  70. */
  71. #define LP_PINTEN 0x10 /* high to read data in or-ed with data out */
  72. #define LP_PSELECP 0x08 /* inverted output, active low */
  73. #define LP_PINITP 0x04 /* unchanged output, active low */
  74. #define LP_PAUTOLF 0x02 /* inverted output, active low */
  75. #define LP_PSTROBE 0x01 /* short high output on raising edge */
  76. /*
  77. * the value written to ports to test existence. PC-style ports will
  78. * return the value written. AT-style ports will return 0. so why not
  79. * make them the same ?
  80. */
  81. #define LP_DUMMY 0x00
  82. /*
  83. * This is the port delay time, in microseconds.
  84. * It is used only in the lp_init() and lp_reset() routine.
  85. */
  86. #define LP_DELAY 50
  87. #endif