kbd_kern.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #ifndef _KBD_KERN_H
  2. #define _KBD_KERN_H
  3. #include <linux/tty.h>
  4. #include <linux/interrupt.h>
  5. #include <linux/keyboard.h>
  6. extern struct tasklet_struct keyboard_tasklet;
  7. extern char *func_table[MAX_NR_FUNC];
  8. extern char func_buf[];
  9. extern char *funcbufptr;
  10. extern int funcbufsize, funcbufleft;
  11. /*
  12. * kbd->xxx contains the VC-local things (flag settings etc..)
  13. *
  14. * Note: externally visible are LED_SCR, LED_NUM, LED_CAP defined in kd.h
  15. * The code in KDGETLED / KDSETLED depends on the internal and
  16. * external order being the same.
  17. *
  18. * Note: lockstate is used as index in the array key_map.
  19. */
  20. struct kbd_struct {
  21. unsigned char lockstate;
  22. /* 8 modifiers - the names do not have any meaning at all;
  23. they can be associated to arbitrarily chosen keys */
  24. #define VC_SHIFTLOCK KG_SHIFT /* shift lock mode */
  25. #define VC_ALTGRLOCK KG_ALTGR /* altgr lock mode */
  26. #define VC_CTRLLOCK KG_CTRL /* control lock mode */
  27. #define VC_ALTLOCK KG_ALT /* alt lock mode */
  28. #define VC_SHIFTLLOCK KG_SHIFTL /* shiftl lock mode */
  29. #define VC_SHIFTRLOCK KG_SHIFTR /* shiftr lock mode */
  30. #define VC_CTRLLLOCK KG_CTRLL /* ctrll lock mode */
  31. #define VC_CTRLRLOCK KG_CTRLR /* ctrlr lock mode */
  32. unsigned char slockstate; /* for `sticky' Shift, Ctrl, etc. */
  33. unsigned char ledmode:1;
  34. #define LED_SHOW_FLAGS 0 /* traditional state */
  35. #define LED_SHOW_IOCTL 1 /* only change leds upon ioctl */
  36. unsigned char ledflagstate:4; /* flags, not lights */
  37. unsigned char default_ledflagstate:4;
  38. #define VC_SCROLLOCK 0 /* scroll-lock mode */
  39. #define VC_NUMLOCK 1 /* numeric lock mode */
  40. #define VC_CAPSLOCK 2 /* capslock mode */
  41. #define VC_KANALOCK 3 /* kanalock mode */
  42. unsigned char kbdmode:3; /* one 3-bit value */
  43. #define VC_XLATE 0 /* translate keycodes using keymap */
  44. #define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
  45. #define VC_RAW 2 /* raw (scancode) mode */
  46. #define VC_UNICODE 3 /* Unicode mode */
  47. #define VC_OFF 4 /* disabled mode */
  48. unsigned char modeflags:5;
  49. #define VC_APPLIC 0 /* application key mode */
  50. #define VC_CKMODE 1 /* cursor key mode */
  51. #define VC_REPEAT 2 /* keyboard repeat */
  52. #define VC_CRLF 3 /* 0 - enter sends CR, 1 - enter sends CRLF */
  53. #define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */
  54. };
  55. extern int kbd_init(void);
  56. extern void setledstate(struct kbd_struct *kbd, unsigned int led);
  57. extern int do_poke_blanked_console;
  58. extern void (*kbd_ledfunc)(unsigned int led);
  59. extern int set_console(int nr);
  60. extern void schedule_console_callback(void);
  61. /* FIXME: review locking for vt.c callers */
  62. static inline void set_leds(void)
  63. {
  64. tasklet_schedule(&keyboard_tasklet);
  65. }
  66. static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag)
  67. {
  68. return ((kbd->modeflags >> flag) & 1);
  69. }
  70. static inline int vc_kbd_led(struct kbd_struct * kbd, int flag)
  71. {
  72. return ((kbd->ledflagstate >> flag) & 1);
  73. }
  74. static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag)
  75. {
  76. kbd->modeflags |= 1 << flag;
  77. }
  78. static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag)
  79. {
  80. kbd->ledflagstate |= 1 << flag;
  81. }
  82. static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag)
  83. {
  84. kbd->modeflags &= ~(1 << flag);
  85. }
  86. static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag)
  87. {
  88. kbd->ledflagstate &= ~(1 << flag);
  89. }
  90. static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag)
  91. {
  92. kbd->lockstate ^= 1 << flag;
  93. }
  94. static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag)
  95. {
  96. kbd->slockstate ^= 1 << flag;
  97. }
  98. static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag)
  99. {
  100. kbd->modeflags ^= 1 << flag;
  101. }
  102. static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
  103. {
  104. kbd->ledflagstate ^= 1 << flag;
  105. }
  106. #define U(x) ((x) ^ 0xf000)
  107. #define BRL_UC_ROW 0x2800
  108. /* keyboard.c */
  109. struct console;
  110. void compute_shiftstate(void);
  111. /* defkeymap.c */
  112. extern unsigned int keymap_count;
  113. #endif