lp.h 2.8 KB

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