Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _KBD_KERN_H |
| 2 | #define _KBD_KERN_H |
| 3 | |
| 4 | #include <linux/tty.h> |
| 5 | #include <linux/interrupt.h> |
| 6 | #include <linux/keyboard.h> |
| 7 | |
| 8 | extern struct tasklet_struct keyboard_tasklet; |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | extern char *func_table[MAX_NR_FUNC]; |
| 11 | extern char func_buf[]; |
| 12 | extern char *funcbufptr; |
| 13 | extern int funcbufsize, funcbufleft; |
| 14 | |
| 15 | /* |
| 16 | * kbd->xxx contains the VC-local things (flag settings etc..) |
| 17 | * |
| 18 | * Note: externally visible are LED_SCR, LED_NUM, LED_CAP defined in kd.h |
| 19 | * The code in KDGETLED / KDSETLED depends on the internal and |
| 20 | * external order being the same. |
| 21 | * |
| 22 | * Note: lockstate is used as index in the array key_map. |
| 23 | */ |
| 24 | struct kbd_struct { |
| 25 | |
| 26 | unsigned char lockstate; |
| 27 | /* 8 modifiers - the names do not have any meaning at all; |
| 28 | they can be associated to arbitrarily chosen keys */ |
| 29 | #define VC_SHIFTLOCK KG_SHIFT /* shift lock mode */ |
| 30 | #define VC_ALTGRLOCK KG_ALTGR /* altgr lock mode */ |
| 31 | #define VC_CTRLLOCK KG_CTRL /* control lock mode */ |
| 32 | #define VC_ALTLOCK KG_ALT /* alt lock mode */ |
| 33 | #define VC_SHIFTLLOCK KG_SHIFTL /* shiftl lock mode */ |
| 34 | #define VC_SHIFTRLOCK KG_SHIFTR /* shiftr lock mode */ |
| 35 | #define VC_CTRLLLOCK KG_CTRLL /* ctrll lock mode */ |
| 36 | #define VC_CTRLRLOCK KG_CTRLR /* ctrlr lock mode */ |
| 37 | unsigned char slockstate; /* for `sticky' Shift, Ctrl, etc. */ |
| 38 | |
| 39 | unsigned char ledmode:2; /* one 2-bit value */ |
| 40 | #define LED_SHOW_FLAGS 0 /* traditional state */ |
| 41 | #define LED_SHOW_IOCTL 1 /* only change leds upon ioctl */ |
| 42 | #define LED_SHOW_MEM 2 /* `heartbeat': peek into memory */ |
| 43 | |
| 44 | unsigned char ledflagstate:4; /* flags, not lights */ |
| 45 | unsigned char default_ledflagstate:4; |
| 46 | #define VC_SCROLLOCK 0 /* scroll-lock mode */ |
| 47 | #define VC_NUMLOCK 1 /* numeric lock mode */ |
| 48 | #define VC_CAPSLOCK 2 /* capslock mode */ |
| 49 | #define VC_KANALOCK 3 /* kanalock mode */ |
| 50 | |
Arthur Taylor | 9fc3de9 | 2011-02-04 13:55:50 -0800 | [diff] [blame] | 51 | unsigned char kbdmode:3; /* one 3-bit value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #define VC_XLATE 0 /* translate keycodes using keymap */ |
| 53 | #define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */ |
| 54 | #define VC_RAW 2 /* raw (scancode) mode */ |
| 55 | #define VC_UNICODE 3 /* Unicode mode */ |
Arthur Taylor | 9fc3de9 | 2011-02-04 13:55:50 -0800 | [diff] [blame] | 56 | #define VC_OFF 4 /* disabled mode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
| 58 | unsigned char modeflags:5; |
| 59 | #define VC_APPLIC 0 /* application key mode */ |
| 60 | #define VC_CKMODE 1 /* cursor key mode */ |
| 61 | #define VC_REPEAT 2 /* keyboard repeat */ |
| 62 | #define VC_CRLF 3 /* 0 - enter sends CR, 1 - enter sends CRLF */ |
| 63 | #define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */ |
| 64 | }; |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | extern int kbd_init(void); |
| 67 | |
| 68 | extern unsigned char getledstate(void); |
| 69 | extern void setledstate(struct kbd_struct *kbd, unsigned int led); |
| 70 | |
| 71 | extern int do_poke_blanked_console; |
| 72 | |
| 73 | extern void (*kbd_ledfunc)(unsigned int led); |
| 74 | |
Andrew Johnson | b257bc0 | 2007-03-16 13:38:24 -0800 | [diff] [blame] | 75 | extern int set_console(int nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | extern void schedule_console_callback(void); |
| 77 | |
Alan Cox | 079c953 | 2012-02-28 14:49:23 +0000 | [diff] [blame] | 78 | /* FIXME: review locking for vt.c callers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | static inline void set_leds(void) |
| 80 | { |
| 81 | tasklet_schedule(&keyboard_tasklet); |
| 82 | } |
| 83 | |
| 84 | static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag) |
| 85 | { |
| 86 | return ((kbd->modeflags >> flag) & 1); |
| 87 | } |
| 88 | |
| 89 | static inline int vc_kbd_led(struct kbd_struct * kbd, int flag) |
| 90 | { |
| 91 | return ((kbd->ledflagstate >> flag) & 1); |
| 92 | } |
| 93 | |
| 94 | static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag) |
| 95 | { |
| 96 | kbd->modeflags |= 1 << flag; |
| 97 | } |
| 98 | |
| 99 | static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag) |
| 100 | { |
| 101 | kbd->ledflagstate |= 1 << flag; |
| 102 | } |
| 103 | |
| 104 | static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag) |
| 105 | { |
| 106 | kbd->modeflags &= ~(1 << flag); |
| 107 | } |
| 108 | |
| 109 | static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag) |
| 110 | { |
| 111 | kbd->ledflagstate &= ~(1 << flag); |
| 112 | } |
| 113 | |
| 114 | static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag) |
| 115 | { |
| 116 | kbd->lockstate ^= 1 << flag; |
| 117 | } |
| 118 | |
| 119 | static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag) |
| 120 | { |
| 121 | kbd->slockstate ^= 1 << flag; |
| 122 | } |
| 123 | |
| 124 | static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag) |
| 125 | { |
| 126 | kbd->modeflags ^= 1 << flag; |
| 127 | } |
| 128 | |
| 129 | static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag) |
| 130 | { |
| 131 | kbd->ledflagstate ^= 1 << flag; |
| 132 | } |
| 133 | |
| 134 | #define U(x) ((x) ^ 0xf000) |
| 135 | |
Samuel Thibault | b9ec4e1 | 2006-04-02 00:10:28 -0500 | [diff] [blame] | 136 | #define BRL_UC_ROW 0x2800 |
| 137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | /* keyboard.c */ |
| 139 | |
| 140 | struct console; |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | void compute_shiftstate(void); |
| 143 | |
| 144 | /* defkeymap.c */ |
| 145 | |
| 146 | extern unsigned int keymap_count; |
| 147 | |
| 148 | /* console.c */ |
| 149 | |
| 150 | static inline void con_schedule_flip(struct tty_struct *t) |
| 151 | { |
Paul Fulghum | 808249c | 2006-02-03 03:04:41 -0800 | [diff] [blame] | 152 | unsigned long flags; |
| 153 | spin_lock_irqsave(&t->buf.lock, flags); |
Paul Fulghum | 33b37a3 | 2006-06-28 04:26:49 -0700 | [diff] [blame] | 154 | if (t->buf.tail != NULL) |
Paul Fulghum | 8977d92 | 2006-02-10 01:51:14 -0800 | [diff] [blame] | 155 | t->buf.tail->commit = t->buf.tail->used; |
Paul Fulghum | 808249c | 2006-02-03 03:04:41 -0800 | [diff] [blame] | 156 | spin_unlock_irqrestore(&t->buf.lock, flags); |
Linus Torvalds | f23eb2b | 2011-03-22 16:17:32 -0700 | [diff] [blame] | 157 | schedule_work(&t->buf.work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | #endif |