Merge tag 'fbdev-for-6.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
[linux-block.git] / include / linux / console_struct.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1da177e4
LT
2/*
3 * console_struct.h
4 *
5 * Data structure describing single virtual console except for data
6 * used by vt.c.
7 *
8 * Fields marked with [#] must be set by the low-level driver.
9 * Fields marked with [!] can be changed by the low-level driver
10 * to achieve effects such as fast scrolling by changing the origin.
11 */
12
217397d7
RD
13#ifndef _LINUX_CONSOLE_STRUCT_H
14#define _LINUX_CONSOLE_STRUCT_H
15
a8f340e3 16#include <linux/wait.h>
e07dea98 17#include <linux/vt.h>
8b6312f4 18#include <linux/workqueue.h>
e07dea98 19
4173f018 20struct uni_pagedict;
1da177e4
LT
21
22#define NPAR 16
dbee4cff 23#define VC_TABSTOPS_COUNT 256U
1da177e4 24
b84ae3dc
JS
25enum vc_intensity {
26 VCI_HALF_BRIGHT,
27 VCI_NORMAL,
28 VCI_BOLD,
29 VCI_MASK = 0x3,
30};
31
28bc24fc
JS
32/**
33 * struct vc_state -- state of a VC
34 * @x: cursor's x-position
35 * @y: cursor's y-position
36 * @color: foreground & background colors
b70ec4d9 37 * @Gx_charset: what's G0/G1 slot set to (like GRAF_MAP, LAT1_MAP)
28bc24fc 38 * @charset: what character set to use (0=G0 or 1=G1)
b84ae3dc 39 * @intensity: see enum vc_intensity for values
28bc24fc
JS
40 * @reverse: reversed foreground/background colors
41 *
42 * These members are defined separately from struct vc_data as we save &
43 * restore them at times.
44 */
45struct vc_state {
46 unsigned int x, y;
47
48 unsigned char color;
49
b70ec4d9 50 unsigned char Gx_charset[2];
28bc24fc
JS
51 unsigned int charset : 1;
52
53 /* attribute flags */
b84ae3dc 54 enum vc_intensity intensity;
77bc14f2
JS
55 bool italic;
56 bool underline;
57 bool blink;
58 bool reverse;
28bc24fc
JS
59};
60
a4bedd01
JS
61/*
62 * Example: vc_data of a console that was scrolled 3 lines down.
63 *
64 * Console buffer
65 * vc_screenbuf ---------> +----------------------+-.
66 * | initializing W | \
67 * | initializing X | |
68 * | initializing Y | > scroll-back area
69 * | initializing Z | |
70 * | | /
71 * vc_visible_origin ---> ^+----------------------+-:
72 * (changes by scroll) || Welcome to linux | \
73 * || | |
74 * vc_rows --->< | login: root | | visible on console
75 * || password: | > (vc_screenbuf_size is
76 * vc_origin -----------> || | | vc_size_row * vc_rows)
77 * (start when no scroll) || Last login: 12:28 | /
78 * v+----------------------+-:
79 * | Have a lot of fun... | \
80 * vc_pos -----------------|--------v | > scroll-front area
81 * | ~ # cat_ | /
82 * vc_scr_end -----------> +----------------------+-:
83 * (vc_origin + | | \ EMPTY, to be filled by
84 * vc_screenbuf_size) | | / vc_video_erase_char
85 * +----------------------+-'
86 * <---- 2 * vc_cols ----->
87 * <---- vc_size_row ----->
88 *
89 * Note that every character in the console buffer is accompanied with an
90 * attribute in the buffer right after the character. This is not depicted
91 * in the figure.
92 */
1da177e4 93struct vc_data {
ff917ba4
AC
94 struct tty_port port; /* Upper level data */
95
28bc24fc
JS
96 struct vc_state state, saved_state;
97
1da177e4
LT
98 unsigned short vc_num; /* Console number */
99 unsigned int vc_cols; /* [#] Console size */
100 unsigned int vc_rows;
101 unsigned int vc_size_row; /* Bytes per row */
102 unsigned int vc_scan_lines; /* # of scan lines */
860dafa9 103 unsigned int vc_cell_height; /* CRTC character cell height */
1da177e4
LT
104 unsigned long vc_origin; /* [!] Start of real screen */
105 unsigned long vc_scr_end; /* [!] End of real screen */
106 unsigned long vc_visible_origin; /* [!] Top of visible window */
107 unsigned int vc_top, vc_bottom; /* Scrolling region */
108 const struct consw *vc_sw;
109 unsigned short *vc_screenbuf; /* In-memory character/attribute buffer */
110 unsigned int vc_screenbuf_size;
111 unsigned char vc_mode; /* KD_TEXT, ... */
112 /* attributes for all characters on screen */
113 unsigned char vc_attr; /* Current attributes */
114 unsigned char vc_def_color; /* Default colors */
1da177e4 115 unsigned char vc_ulcolor; /* Color for underline mode */
fa6ce9ab 116 unsigned char vc_itcolor;
1da177e4
LT
117 unsigned char vc_halfcolor; /* Color for half intensity mode */
118 /* cursor */
119 unsigned int vc_cursor_type;
120 unsigned short vc_complement_mask; /* [#] Xor mask for mouse pointer */
121 unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */
1da177e4
LT
122 unsigned long vc_pos; /* Cursor address */
123 /* fonts */
124 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */
125 struct console_font vc_font; /* Current VC font set */
126 unsigned short vc_video_erase_char; /* Background erase character */
127 /* VT terminal data */
128 unsigned int vc_state; /* Escape sequence parser state */
129 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
1da177e4
LT
130 /* data for manual vt switching */
131 struct vt_mode vt_mode;
bde0d2c9 132 struct pid *vt_pid;
1da177e4
LT
133 int vt_newvt;
134 wait_queue_head_t paste_wait;
135 /* mode flags */
1da177e4
LT
136 unsigned int vc_disp_ctrl : 1; /* Display chars < 32? */
137 unsigned int vc_toggle_meta : 1; /* Toggle high bit? */
138 unsigned int vc_decscnm : 1; /* Screen Mode */
139 unsigned int vc_decom : 1; /* Origin Mode */
140 unsigned int vc_decawm : 1; /* Autowrap Mode */
141 unsigned int vc_deccm : 1; /* Cursor Visible */
142 unsigned int vc_decim : 1; /* Insert Mode */
1da177e4 143 /* misc */
2ff5c5a1 144 unsigned int vc_priv : 3;
1da177e4
LT
145 unsigned int vc_need_wrap : 1;
146 unsigned int vc_can_do_color : 1;
147 unsigned int vc_report_mouse : 2;
1da177e4
LT
148 unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */
149 unsigned char vc_utf_count;
150 int vc_utf_char;
dbee4cff 151 DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */
1da177e4
LT
152 unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */
153 unsigned short * vc_translate;
e400b6ec 154 unsigned int vc_resize_user; /* resize request from user */
1da177e4
LT
155 unsigned int vc_bell_pitch; /* Console bell pitch */
156 unsigned int vc_bell_duration; /* Console bell duration */
bd63364c 157 unsigned short vc_cur_blink_ms; /* Cursor blink duration */
1da177e4 158 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */
8da443b1
JS
159 struct uni_pagedict *uni_pagedict;
160 struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */
feb36abb 161 u32 **vc_uni_lines; /* unicode screen content */
1da177e4
LT
162 /* additional information is in vt_kern.h */
163};
164
165struct vc {
166 struct vc_data *d;
8b6312f4 167 struct work_struct SAK_work;
1da177e4 168
f4c6fbc9 169 /* might add scrmem, kbd at some time,
7d4a3112 170 to have everything in one place */
1da177e4
LT
171};
172
173extern struct vc vc_cons [MAX_NR_CONSOLES];
8b6312f4 174extern void vc_SAK(struct work_struct *work);
1da177e4 175
4dfa3c54
JS
176#define CUR_MAKE(size, change, set) ((size) | ((change) << 8) | \
177 ((set) << 16))
178#define CUR_SIZE(c) ((c) & 0x00000f)
179# define CUR_DEF 0
180# define CUR_NONE 1
181# define CUR_UNDERLINE 2
182# define CUR_LOWER_THIRD 3
183# define CUR_LOWER_HALF 4
184# define CUR_TWO_THIRDS 5
185# define CUR_BLOCK 6
186#define CUR_SW 0x000010
187#define CUR_ALWAYS_BG 0x000020
188#define CUR_INVERT_FG_BG 0x000040
189#define CUR_FG 0x000700
190#define CUR_BG 0x007000
191#define CUR_CHANGE(c) ((c) & 0x00ff00)
192#define CUR_SET(c) (((c) & 0xff0000) >> 8)
1da177e4 193
ddde3c18 194bool con_is_visible(const struct vc_data *vc);
217397d7
RD
195
196#endif /* _LINUX_CONSOLE_STRUCT_H */