From 7db13dcc99dbd2f7f5ba4121bd8e8ea1c87a6b8b Mon Sep 17 00:00:00 2001 From: Sun Haiyong Date: Tue, 26 Mar 2024 12:20:27 +0000 Subject: [PATCH 15/22] UniVT: Fix charcount size to 65536. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将charcount的大小扩展到65536。 Signed-off-by: Shi Pujin --- drivers/tty/vt/vt.c | 4 +--- drivers/video/fbdev/core/fbcon.c | 15 +++++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 31317e0d3e61..187980c1e42e 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4539,7 +4539,7 @@ void reset_palette(struct vc_data *vc) #define max_font_width 64 #define max_font_height 128 #define max_font_glyphs 512 -#define max_font_size (max_font_glyphs*max_font_width*max_font_height) +#define max_font_size (max_font_glyphs*max_font_width*max_font_height >= 65536 * 2 * 8 * 16 ? max_font_glyphs*max_font_width*max_font_height : 65536 * 2 * 8 * 16) static int con_font_get(struct vc_data *vc, struct console_font_op *op) { @@ -4602,8 +4602,6 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op) return -EINVAL; if (!op->data) return -EINVAL; - if (op->charcount > max_font_glyphs) - return -EINVAL; if (op->width <= 0 || op->width > max_font_width || !op->height || op->height > max_font_height) return -EINVAL; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 46823c2e2ba1..eb4ca9adf2ef 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1051,7 +1051,7 @@ static void fbcon_init(struct vc_data *vc, int init) vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; - if (vc->vc_font.charcount == 256) { + if (vc->vc_font.charcount == 256 || vc->vc_font.charcount > 512) { vc->vc_hi_font_mask = 0; } else { vc->vc_hi_font_mask = 0x100; @@ -1372,7 +1372,7 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, ops->var = info->var; vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; - if (vc->vc_font.charcount == 256) { + if (vc->vc_font.charcount == 256 || vc->vc_font.charcount > 512) { vc->vc_hi_font_mask = 0; } else { vc->vc_hi_font_mask = 0x100; @@ -2141,7 +2141,7 @@ static int fbcon_switch(struct vc_data *vc) vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; - if (vc->vc_font.charcount > 256) + if (vc->vc_font.charcount > 256 && vc->vc_font.charcount <= 512) vc->vc_complement_mask <<= 1; updatescrollmode(p, info, vc); @@ -2276,7 +2276,7 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font, unsigne font->height = vc->vc_font.height; if (font->height > vpitch) return -ENOSPC; - font->charcount = vc->vc_hi_font_mask ? 512 : 256; + font->charcount = vc->vc_font.charcount; if (!font->data) return 0; @@ -2414,7 +2414,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, vc->vc_font.width = w; vc->vc_font.height = h; vc->vc_font.charcount = charcount; - if (vc->vc_hi_font_mask && charcount == 256) + if (vc->vc_hi_font_mask && (charcount == 256 || charcount > 512)) set_vc_hi_font(vc, false); else if (!vc->vc_hi_font_mask && charcount == 512) set_vc_hi_font(vc, true); @@ -2473,11 +2473,6 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, u8 *new_data, *data = font->data; int pitch = PITCH(font->width); - /* Is there a reason why fbconsole couldn't handle any charcount >256? - * If not this check should be changed to charcount < 256 */ - if (charcount != 256 && charcount != 512) - return -EINVAL; - /* font bigger than screen resolution ? */ if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) || h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) -- 2.34.3