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