blob: cbfb171bbcbaaf169726b00a2013683e3ec94a1b [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070010extern char *func_table[MAX_NR_FUNC];
11extern char func_buf[];
12extern char *funcbufptr;
13extern 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 */
24struct 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
Andreas Platschekcf940eb2013-07-26 06:46:37 +020039 unsigned char ledmode:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#define LED_SHOW_FLAGS 0 /* traditional state */
41#define LED_SHOW_IOCTL 1 /* only change leds upon ioctl */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43 unsigned char ledflagstate:4; /* flags, not lights */
44 unsigned char default_ledflagstate:4;
45#define VC_SCROLLOCK 0 /* scroll-lock mode */
46#define VC_NUMLOCK 1 /* numeric lock mode */
47#define VC_CAPSLOCK 2 /* capslock mode */
48#define VC_KANALOCK 3 /* kanalock mode */
49
Arthur Taylor9fc3de92011-02-04 13:55:50 -080050 unsigned char kbdmode:3; /* one 3-bit value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define VC_XLATE 0 /* translate keycodes using keymap */
52#define VC_MEDIUMRAW 1 /* medium raw (keycode) mode */
53#define VC_RAW 2 /* raw (scancode) mode */
54#define VC_UNICODE 3 /* Unicode mode */
Arthur Taylor9fc3de92011-02-04 13:55:50 -080055#define VC_OFF 4 /* disabled mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57 unsigned char modeflags:5;
58#define VC_APPLIC 0 /* application key mode */
59#define VC_CKMODE 1 /* cursor key mode */
60#define VC_REPEAT 2 /* keyboard repeat */
61#define VC_CRLF 3 /* 0 - enter sends CR, 1 - enter sends CRLF */
62#define VC_META 4 /* 0 - meta, 1 - meta=prefix with ESC */
63};
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065extern int kbd_init(void);
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067extern void setledstate(struct kbd_struct *kbd, unsigned int led);
68
69extern int do_poke_blanked_console;
70
71extern void (*kbd_ledfunc)(unsigned int led);
72
Andrew Johnsonb257bc02007-03-16 13:38:24 -080073extern int set_console(int nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern void schedule_console_callback(void);
75
Alan Cox079c9532012-02-28 14:49:23 +000076/* FIXME: review locking for vt.c callers */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077static inline void set_leds(void)
78{
79 tasklet_schedule(&keyboard_tasklet);
80}
81
82static inline int vc_kbd_mode(struct kbd_struct * kbd, int flag)
83{
84 return ((kbd->modeflags >> flag) & 1);
85}
86
87static inline int vc_kbd_led(struct kbd_struct * kbd, int flag)
88{
89 return ((kbd->ledflagstate >> flag) & 1);
90}
91
92static inline void set_vc_kbd_mode(struct kbd_struct * kbd, int flag)
93{
94 kbd->modeflags |= 1 << flag;
95}
96
97static inline void set_vc_kbd_led(struct kbd_struct * kbd, int flag)
98{
99 kbd->ledflagstate |= 1 << flag;
100}
101
102static inline void clr_vc_kbd_mode(struct kbd_struct * kbd, int flag)
103{
104 kbd->modeflags &= ~(1 << flag);
105}
106
107static inline void clr_vc_kbd_led(struct kbd_struct * kbd, int flag)
108{
109 kbd->ledflagstate &= ~(1 << flag);
110}
111
112static inline void chg_vc_kbd_lock(struct kbd_struct * kbd, int flag)
113{
114 kbd->lockstate ^= 1 << flag;
115}
116
117static inline void chg_vc_kbd_slock(struct kbd_struct * kbd, int flag)
118{
119 kbd->slockstate ^= 1 << flag;
120}
121
122static inline void chg_vc_kbd_mode(struct kbd_struct * kbd, int flag)
123{
124 kbd->modeflags ^= 1 << flag;
125}
126
127static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
128{
129 kbd->ledflagstate ^= 1 << flag;
130}
131
132#define U(x) ((x) ^ 0xf000)
133
Samuel Thibaultb9ec4e12006-04-02 00:10:28 -0500134#define BRL_UC_ROW 0x2800
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136/* keyboard.c */
137
138struct console;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140void compute_shiftstate(void);
141
142/* defkeymap.c */
143
144extern unsigned int keymap_count;
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif