Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vt: Store font in struct vc_font

Replace struct console_font with struct vc_font for the type of the
vc_font field of struct vc_data. Struct console_font is UAPI, which
prevents further changes. Hence a new data type is required.

Struct console_font has a documented vertical pitch of 32 bytes. This
is not the case after the font data has been loaded into the kernel.
Changing the type of vc_font addresses this inconsistency.

The font data is now declared as constant, as it might come from the
kernel's read-only section. There's some fallout throughout the console
code where non-const variables refer to it. Fix them. A later update
will declare the font data to a dedicated data type.

v3:
- fix typos

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Thomas Zimmermann and committed by
Helge Deller
61912c60 982f8b00

+36 -12
+5 -6
drivers/video/fbdev/core/bitblit.c
··· 22 22 /* 23 23 * Accelerated handlers. 24 24 */ 25 - static void update_attr(u8 *dst, u8 *src, int attribute, 26 - struct vc_data *vc) 25 + static void update_attr(u8 *dst, const u8 *src, int attribute, struct vc_data *vc) 27 26 { 28 27 int i, offset = (vc->vc_font.height < 10) ? 1 : 2; 29 28 int width = DIV_ROUND_UP(vc->vc_font.width, 8); ··· 80 81 u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; 81 82 unsigned int charcnt = vc->vc_font.charcount; 82 83 u32 idx = vc->vc_font.width >> 3; 83 - u8 *src; 84 + const u8 *src; 84 85 85 86 while (cnt--) { 86 87 u16 ch = scr_readw(s++) & charmask; ··· 119 120 u32 shift_low = 0, mod = vc->vc_font.width % 8; 120 121 u32 shift_high = 8; 121 122 u32 idx = vc->vc_font.width >> 3; 122 - u8 *src; 123 + const u8 *src; 123 124 124 125 while (cnt--) { 125 126 u16 ch = scr_readw(s++) & charmask; ··· 266 267 int y = real_y(par->p, vc->state.y); 267 268 int attribute, use_sw = vc->vc_cursor_type & CUR_SW; 268 269 int err = 1; 269 - char *src; 270 + const u8 *src; 270 271 271 272 cursor.set = 0; 272 273 ··· 277 278 attribute = get_attribute(info, c); 278 279 src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height)); 279 280 280 - if (par->cursor_state.image.data != src || 281 + if (par->cursor_state.image.data != (const char *)src || 281 282 par->cursor_reset) { 282 283 par->cursor_state.image.data = src; 283 284 cursor.set |= FB_CUR_SETIMAGE;
+2 -2
drivers/video/fbdev/core/fbcon.c
··· 2286 2286 2287 2287 static int fbcon_get_font(struct vc_data *vc, struct console_font *font, unsigned int vpitch) 2288 2288 { 2289 - u8 *fontdata = vc->vc_font.data; 2289 + const u8 *fontdata = vc->vc_font.data; 2290 2290 u8 *data = font->data; 2291 2291 int i, j; 2292 2292 ··· 2417 2417 struct fbcon_par *par = info->fbcon_par; 2418 2418 struct fbcon_display *p = &fb_display[vc->vc_num]; 2419 2419 int resize, ret, old_userfont, old_width, old_height, old_charcount; 2420 - u8 *old_data = vc->vc_font.data; 2420 + const u8 *old_data = vc->vc_font.data; 2421 2421 2422 2422 resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); 2423 2423 vc->vc_font.data = (void *)(p->fontdata = data);
+2 -2
drivers/video/fbdev/core/fbcon.h
··· 82 82 int rotate; 83 83 int cur_rotate; 84 84 char *cursor_data; 85 - u8 *fontbuffer; 86 - u8 *fontdata; 85 + u8 *fontbuffer; 86 + const u8 *fontdata; 87 87 u8 *cursor_src; 88 88 u32 cursor_size; 89 89 u32 fd_size;
+27 -2
include/linux/console_struct.h
··· 13 13 #ifndef _LINUX_CONSOLE_STRUCT_H 14 14 #define _LINUX_CONSOLE_STRUCT_H 15 15 16 - #include <linux/wait.h> 16 + #include <linux/math.h> 17 17 #include <linux/vt.h> 18 + #include <linux/wait.h> 18 19 #include <linux/workqueue.h> 19 20 20 21 struct uni_pagedict; ··· 57 56 bool underline; 58 57 bool blink; 59 58 bool reverse; 59 + }; 60 + 61 + /** 62 + * struct vc_font - Describes a font 63 + * @width: The width of a single glyph in bits 64 + * @height: The height of a single glyph in scanlines 65 + * @charcount: The number of glyphs in the font 66 + * @data: The raw font data 67 + * 68 + * Font data is organized as an array of glyphs. Each glyph is a bitmap with 69 + * set bits indicating the foreground color. Unset bits indicate background 70 + * color. The fields @width and @height store a single glyph's number of 71 + * horizontal bits and vertical scanlines. If width is not a multiple of 8, 72 + * there are trailing bits to fill up the byte. These bits should not be drawn. 73 + * 74 + * The field @data points to the first glyph's first byte. The value @charcount 75 + * gives the number of glyphs in the font. There are no empty scanlines between 76 + * two adjacent glyphs. 77 + */ 78 + struct vc_font { 79 + unsigned int width; 80 + unsigned int height; 81 + unsigned int charcount; 82 + const unsigned char *data; 60 83 }; 61 84 62 85 /* ··· 147 122 unsigned long vc_pos; /* Cursor address */ 148 123 /* fonts */ 149 124 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ 150 - struct console_font vc_font; /* Current VC font set */ 125 + struct vc_font vc_font; /* Current VC font set */ 151 126 unsigned short vc_video_erase_char; /* Background erase character */ 152 127 /* VT terminal data */ 153 128 unsigned int vc_state; /* Escape sequence parser state */