Merge branch 'docs-next' of git://git.lwn.net/linux-2.6
[linux-2.6/next.git] / include / linux / kbd_kern.h
blob8bdb16bfe5fb698eb2d8e0a0fe8c6785434e53d0
1 #ifndef _KBD_KERN_H
2 #define _KBD_KERN_H
4 #include <linux/tty.h>
5 #include <linux/interrupt.h>
6 #include <linux/keyboard.h>
8 extern struct tasklet_struct keyboard_tasklet;
10 extern int shift_state;
12 extern char *func_table[MAX_NR_FUNC];
13 extern char func_buf[];
14 extern char *funcbufptr;
15 extern int funcbufsize, funcbufleft;
18 * kbd->xxx contains the VC-local things (flag settings etc..)
20 * Note: externally visible are LED_SCR, LED_NUM, LED_CAP defined in kd.h
21 * The code in KDGETLED / KDSETLED depends on the internal and
22 * external order being the same.
24 * Note: lockstate is used as index in the array key_map.
26 struct kbd_struct {
28 unsigned char lockstate;
29 /* 8 modifiers - the names do not have any meaning at all;
30 they can be associated to arbitrarily chosen keys */
31 #define VC_SHIFTLOCK KG_SHIFT /* shift lock mode */
32 #define VC_ALTGRLOCK KG_ALTGR /* altgr lock mode */
33 #define VC_CTRLLOCK KG_CTRL /* control lock mode */
34 #define VC_ALTLOCK KG_ALT /* alt lock mode */
35 #define VC_SHIFTLLOCK KG_SHIFTL /* shiftl lock mode */
36 #define VC_SHIFTRLOCK KG_SHIFTR /* shiftr lock mode */
37 #define VC_CTRLLLOCK KG_CTRLL /* ctrll lock mode */
38 #define VC_CTRLRLOCK KG_CTRLR /* ctrlr lock mode */
39 unsigned char slockstate; /* for `sticky' Shift, Ctrl, etc. */
41 unsigned char ledmode:2; /* one 2-bit value */
42 #define LED_SHOW_FLAGS 0 /* traditional state */
43 #define LED_SHOW_IOCTL 1 /* only change leds upon ioctl */
44 #define LED_SHOW_MEM 2 /* `heartbeat': peek into memory */
46 unsigned char ledflagstate:4; /* flags, not lights */
47 unsigned char default_ledflagstate:4;
48 #define VC_SCROLLOCK 0 /* scroll-lock mode */
49 #define VC_NUMLOCK 1 /* numeric lock mode */
50 #define VC_CAPSLOCK 2 /* capslock mode */
51 #define VC_KANALOCK 3 /* kanalock mode */
53 unsigned char kbdmode:2; /* one 2-bit value */
54 #define VC_XLATE 0 /* translate keycodes using keymap */
55 #define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
56 #define VC_RAW 2 /* raw (scancode) mode */
57 #define VC_UNICODE 3 /* Unicode mode */
59 unsigned char modeflags:5;
60 #define VC_APPLIC 0 /* application key mode */
61 #define VC_CKMODE 1 /* cursor key mode */
62 #define VC_REPEAT 2 /* keyboard repeat */
63 #define VC_CRLF 3 /* 0 - enter sends CR, 1 - enter sends CRLF */
64 #define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */
67 extern struct kbd_struct kbd_table[];
69 extern int kbd_init(void);
71 extern unsigned char getledstate(void);
72 extern void setledstate(struct kbd_struct *kbd, unsigned int led);
74 extern int do_poke_blanked_console;
76 extern void (*kbd_ledfunc)(unsigned int led);
78 extern int set_console(int nr);
79 extern void schedule_console_callback(void);
81 static inline void set_leds(void)
83 tasklet_schedule(&keyboard_tasklet);
86 static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag)
88 return ((kbd->modeflags >> flag) & 1);
91 static inline int vc_kbd_led(struct kbd_struct * kbd, int flag)
93 return ((kbd->ledflagstate >> flag) & 1);
96 static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag)
98 kbd->modeflags |= 1 << flag;
101 static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag)
103 kbd->ledflagstate |= 1 << flag;
106 static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag)
108 kbd->modeflags &= ~(1 << flag);
111 static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag)
113 kbd->ledflagstate &= ~(1 << flag);
116 static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag)
118 kbd->lockstate ^= 1 << flag;
121 static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag)
123 kbd->slockstate ^= 1 << flag;
126 static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag)
128 kbd->modeflags ^= 1 << flag;
131 static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
133 kbd->ledflagstate ^= 1 << flag;
136 #define U(x) ((x) ^ 0xf000)
138 #define BRL_UC_ROW 0x2800
140 /* keyboard.c */
142 struct console;
144 int getkeycode(unsigned int scancode);
145 int setkeycode(unsigned int scancode, unsigned int keycode);
146 void compute_shiftstate(void);
148 /* defkeymap.c */
150 extern unsigned int keymap_count;
152 /* console.c */
154 static inline void con_schedule_flip(struct tty_struct *t)
156 unsigned long flags;
157 spin_lock_irqsave(&t->buf.lock, flags);
158 if (t->buf.tail != NULL)
159 t->buf.tail->commit = t->buf.tail->used;
160 spin_unlock_irqrestore(&t->buf.lock, flags);
161 schedule_delayed_work(&t->buf.work, 0);
164 /* mac_hid.c */
165 extern int mac_hid_mouse_emulate_buttons(int, unsigned int, int);
167 #endif