blob: ec2d17bc1f1eaeccc4d7971d0643fba6d380b737 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
8extern struct tasklet_struct keyboard_tasklet;
9
10extern int shift_state;
11
12extern char *func_table[MAX_NR_FUNC];
13extern char func_buf[];
14extern char *funcbufptr;
15extern int funcbufsize, funcbufleft;
16
17/*
18 * kbd->xxx contains the VC-local things (flag settings etc..)
19 *
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.
23 *
24 * Note: lockstate is used as index in the array key_map.
25 */
26struct kbd_struct {
27
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. */
40
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 */
45
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 */
52
Arthur Taylor9fc3de92011-02-04 13:55:50 -080053 unsigned char kbdmode:3; /* one 3-bit value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#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 */
Arthur Taylor9fc3de92011-02-04 13:55:50 -080058#define VC_OFF 4 /* disabled mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60 unsigned char modeflags:5;
61#define VC_APPLIC 0 /* application key mode */
62#define VC_CKMODE 1 /* cursor key mode */
63#define VC_REPEAT 2 /* keyboard repeat */
64#define VC_CRLF 3 /* 0 - enter sends CR, 1 - enter sends CRLF */
65#define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */
66};
67
68extern struct kbd_struct kbd_table[];
69
70extern int kbd_init(void);
71
72extern unsigned char getledstate(void);
73extern void setledstate(struct kbd_struct *kbd, unsigned int led);
74
75extern int do_poke_blanked_console;
76
77extern void (*kbd_ledfunc)(unsigned int led);
78
Andrew Johnsonb257bc02007-03-16 13:38:24 -080079extern int set_console(int nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080extern void schedule_console_callback(void);
81
82static inline void set_leds(void)
83{
84 tasklet_schedule(&keyboard_tasklet);
85}
86
87static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag)
88{
89 return ((kbd->modeflags >> flag) & 1);
90}
91
92static inline int vc_kbd_led(struct kbd_struct * kbd, int flag)
93{
94 return ((kbd->ledflagstate >> flag) & 1);
95}
96
97static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag)
98{
99 kbd->modeflags |= 1 << flag;
100}
101
102static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag)
103{
104 kbd->ledflagstate |= 1 << flag;
105}
106
107static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag)
108{
109 kbd->modeflags &= ~(1 << flag);
110}
111
112static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag)
113{
114 kbd->ledflagstate &= ~(1 << flag);
115}
116
117static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag)
118{
119 kbd->lockstate ^= 1 << flag;
120}
121
122static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag)
123{
124 kbd->slockstate ^= 1 << flag;
125}
126
127static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag)
128{
129 kbd->modeflags ^= 1 << flag;
130}
131
132static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
133{
134 kbd->ledflagstate ^= 1 << flag;
135}
136
137#define U(x) ((x) ^ 0xf000)
138
Samuel Thibaultb9ec4e12006-04-02 00:10:28 -0500139#define BRL_UC_ROW 0x2800
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141/* keyboard.c */
142
143struct console;
144
145int getkeycode(unsigned int scancode);
146int setkeycode(unsigned int scancode, unsigned int keycode);
147void compute_shiftstate(void);
148
149/* defkeymap.c */
150
151extern unsigned int keymap_count;
152
153/* console.c */
154
155static inline void con_schedule_flip(struct tty_struct *t)
156{
Paul Fulghum808249c2006-02-03 03:04:41 -0800157 unsigned long flags;
158 spin_lock_irqsave(&t->buf.lock, flags);
Paul Fulghum33b37a32006-06-28 04:26:49 -0700159 if (t->buf.tail != NULL)
Paul Fulghum8977d922006-02-10 01:51:14 -0800160 t->buf.tail->commit = t->buf.tail->used;
Paul Fulghum808249c2006-02-03 03:04:41 -0800161 spin_unlock_irqrestore(&t->buf.lock, flags);
Linus Torvaldsf23eb2b2011-03-22 16:17:32 -0700162 schedule_work(&t->buf.work);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163}
164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165#endif