History

VT: Add height parameter to con_font_get/set consw operations

The current con_font_get/set API currently hardcodes a 32-pixel-tall limitation, which only dates from the old VGA hardware which could not handle taller fonts than that. This change just adds a vpitch parameter to release this constraint. Drivers which do not support vpitch != 32 can just return EINVAL when it is not 32, font loading tools will revert to trying 32 and succeed. This change makes the fbcon driver consider vpitch appropriately, thus making it able to load large fonts.

Samuel Thibault committed 3 years ago

Commit ffc1e081 parent e34a79d6 files · +32 −36Browse files

Unified · Split

6 files
  1. drivers/tty/vt/vt.c +2 −2
  2. drivers/video/console/newport_con.c +5 −4
  3. drivers/video/console/sticon.c +5 −4
  4. drivers/video/console/vgacon.c +4 −4
  5. drivers/video/fbdev/core/fbcon.c +13 −20
  6. include/linux/console.h +3 −2
drivers/tty/vt/vt.c+2−2
@@ -4552,7 +4552,7 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op) · 4551 unmodified lines
4552 if (vc->vc_mode != KD_TEXT)4552 if (vc->vc_mode != KD_TEXT)
4553 rc = -EINVAL;4553 rc = -EINVAL;
4554 else if (vc->vc_sw->con_font_get)4554 else if (vc->vc_sw->con_font_get)
4555 rc = vc->vc_sw->con_font_get(vc, &font);4555 rc = vc->vc_sw->con_font_get(vc, &font, 32);
4556 else4556 else
4557 rc = -ENOSYS;4557 rc = -ENOSYS;
4558 console_unlock();4558 console_unlock();
@@ -4613,7 +4613,7 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op) · 54 unmodified lines
4613 else if (vc->vc_sw->con_font_set) {4613 else if (vc->vc_sw->con_font_set) {
4614 if (vc_is_sel(vc))4614 if (vc_is_sel(vc))
4615 clear_selection();4615 clear_selection();
4616 rc = vc->vc_sw->con_font_set(vc, &font, op->flags);4616 rc = vc->vc_sw->con_font_set(vc, &font, 32, op->flags);
4617 } else4617 } else
4618 rc = -ENOSYS;4618 rc = -ENOSYS;
4619 console_unlock();4619 console_unlock();
drivers/video/console/newport_con.c+5−4
@@ -497,7 +497,7 @@ static int newport_blank(struct vc_data *c, int blank, int mode_switch) · 496 unmodified lines
497 return 1;497 return 1;
498}498}
499 499
500static int newport_set_font(int unit, struct console_font *op)500static int newport_set_font(int unit, struct console_font *op, unsigned int vpitch)
501{501{
502 int w = op->width;502 int w = op->width;
503 int h = op->height;503 int h = op->height;
@@ -507,7 +507,7 @@ static int newport_set_font(int unit, struct console_font *op) · 3 unmodified lines
507 507
508 /* ladis: when I grow up, there will be a day... and more sizes will508 /* ladis: when I grow up, there will be a day... and more sizes will
509 * be supported ;-) */509 * be supported ;-) */
510 if ((w != 8) || (h != 16)510 if ((w != 8) || (h != 16) || (vpitch != 32)
511 || (op->charcount != 256 && op->charcount != 512))511 || (op->charcount != 256 && op->charcount != 512))
512 return -EINVAL;512 return -EINVAL;
513 513
@@ -569,9 +569,10 @@ static int newport_font_default(struct vc_data *vc, struct console_font *op, cha · 55 unmodified lines
569 return newport_set_def_font(vc->vc_num, op);569 return newport_set_def_font(vc->vc_num, op);
570}570}
571 571
572static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags)572static int newport_font_set(struct vc_data *vc, struct console_font *font,
573 unsigned int vpitch, unsigned int flags)
573{574{
574 return newport_set_font(vc->vc_num, font);575 return newport_set_font(vc->vc_num, font, vpitch);
575}576}
576 577
577static bool newport_scroll(struct vc_data *vc, unsigned int t, unsigned int b,578static bool newport_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
drivers/video/console/sticon.c+5−4
@@ -169,7 +169,8 @@ static int sticon_set_def_font(int unit, struct console_font *op) · 168 unmodified lines
169 return 0;169 return 0;
170}170}
171 171
172static int sticon_set_font(struct vc_data *vc, struct console_font *op)172static int sticon_set_font(struct vc_data *vc, struct console_font *op,
173 unsigned int vpitch)
173{174{
174 struct sti_struct *sti = sticon_sti;175 struct sti_struct *sti = sticon_sti;
175 int vc_cols, vc_rows, vc_old_cols, vc_old_rows;176 int vc_cols, vc_rows, vc_old_cols, vc_old_rows;
@@ -181,7 +182,7 @@ static int sticon_set_font(struct vc_data *vc, struct console_font *op) · 5 unmodified lines
181 struct sti_cooked_font *cooked_font;182 struct sti_cooked_font *cooked_font;
182 unsigned char *data = op->data, *p;183 unsigned char *data = op->data, *p;
183 184
184 if ((w < 6) || (h < 6) || (w > 32) || (h > 32)185 if ((w < 6) || (h < 6) || (w > 32) || (h > 32) || (vpitch != 32)
185 || (op->charcount != 256 && op->charcount != 512))186 || (op->charcount != 256 && op->charcount != 512))
186 return -EINVAL;187 return -EINVAL;
187 pitch = ALIGN(w, 8) / 8;188 pitch = ALIGN(w, 8) / 8;
@@ -267,9 +268,9 @@ static int sticon_font_default(struct vc_data *vc, struct console_font *op, char · 79 unmodified lines
267}268}
268 269
269static int sticon_font_set(struct vc_data *vc, struct console_font *font,270static int sticon_font_set(struct vc_data *vc, struct console_font *font,
270 unsigned int flags)271 unsigned int vpitch, unsigned int flags)
271{272{
272 return sticon_set_font(vc, font);273 return sticon_set_font(vc, font, vpitch);
273}274}
274 275
275static void sticon_init(struct vc_data *c, int init)276static void sticon_init(struct vc_data *c, int init)
drivers/video/console/vgacon.c+4−4
@@ -1029,7 +1029,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight) · 1028 unmodified lines
1029}1029}
1030 1030
1031static int vgacon_font_set(struct vc_data *c, struct console_font *font,1031static int vgacon_font_set(struct vc_data *c, struct console_font *font,
1032 unsigned int flags)1032 unsigned int vpitch, unsigned int flags)
1033{1033{
1034 unsigned charcount = font->charcount;1034 unsigned charcount = font->charcount;
1035 int rc;1035 int rc;
@@ -1037,7 +1037,7 @@ static int vgacon_font_set(struct vc_data *c, struct console_font *font, · 1 unmodified line
1037 if (vga_video_type < VIDEO_TYPE_EGAM)1037 if (vga_video_type < VIDEO_TYPE_EGAM)
1038 return -EINVAL;1038 return -EINVAL;
1039 1039
1040 if (font->width != VGA_FONTWIDTH ||1040 if (font->width != VGA_FONTWIDTH || vpitch != 32 ||
1041 (charcount != 256 && charcount != 512))1041 (charcount != 256 && charcount != 512))
1042 return -EINVAL;1042 return -EINVAL;
1043 1043
@@ -1050,9 +1050,9 @@ static int vgacon_font_set(struct vc_data *c, struct console_font *font, · 6 unmodified lines
1050 return rc;1050 return rc;
1051}1051}
1052 1052
1053static int vgacon_font_get(struct vc_data *c, struct console_font *font)1053static int vgacon_font_get(struct vc_data *c, struct console_font *font, unsigned int vpitch)
1054{1054{
1055 if (vga_video_type < VIDEO_TYPE_EGAM)1055 if (vga_video_type < VIDEO_TYPE_EGAM || vpitch != 32)
1056 return -EINVAL;1056 return -EINVAL;
1057 1057
1058 font->width = VGA_FONTWIDTH;1058 font->width = VGA_FONTWIDTH;
drivers/video/fbdev/core/fbcon.c+13−20
@@ -2271,7 +2271,7 @@ static int fbcon_debug_leave(struct vc_data *vc) · 2270 unmodified lines
2271 return 0;2271 return 0;
2272}2272}
2273 2273
2274static int fbcon_get_font(struct vc_data *vc, struct console_font *font)2274static int fbcon_get_font(struct vc_data *vc, struct console_font *font, unsigned int vpitch)
2275{2275{
2276 u8 *fontdata = vc->vc_font.data;2276 u8 *fontdata = vc->vc_font.data;
2277 u8 *data = font->data;2277 u8 *data = font->data;
@@ -2290,8 +2290,8 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) · 12 unmodified lines
2290 2290
2291 for (i = 0; i < font->charcount; i++) {2291 for (i = 0; i < font->charcount; i++) {
2292 memcpy(data, fontdata, j);2292 memcpy(data, fontdata, j);
2293 memset(data + j, 0, 32 - j);2293 memset(data + j, 0, vpitch - j);
2294 data += 32;2294 data += vpitch;
2295 fontdata += j;2295 fontdata += j;
2296 }2296 }
2297 } else if (font->width <= 16) {2297 } else if (font->width <= 16) {
@@ -2301,8 +2301,8 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) · 3 unmodified lines
2301 2301
2302 for (i = 0; i < font->charcount; i++) {2302 for (i = 0; i < font->charcount; i++) {
2303 memcpy(data, fontdata, j);2303 memcpy(data, fontdata, j);
2304 memset(data + j, 0, 64 - j);2304 memset(data + j, 0, 2*vpitch - j);
2305 data += 64;2305 data += 2*vpitch;
2306 fontdata += j;2306 fontdata += j;
2307 }2307 }
2308 } else if (font->width <= 24) {2308 } else if (font->width <= 24) {
@@ -2316,8 +2316,8 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) · 7 unmodified lines
2316 *data++ = fontdata[2];2316 *data++ = fontdata[2];
2317 fontdata += sizeof(u32);2317 fontdata += sizeof(u32);
2318 }2318 }
2319 memset(data, 0, 3 * (32 - j));2319 memset(data, 0, 3 * (vpitch - j));
2320 data += 3 * (32 - j);2320 data += 3 * (vpitch - j);
2321 }2321 }
2322 } else {2322 } else {
2323 j = vc->vc_font.height * 4;2323 j = vc->vc_font.height * 4;
@@ -2326,8 +2326,8 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) · 2 unmodified lines
2326 2326
2327 for (i = 0; i < font->charcount; i++) {2327 for (i = 0; i < font->charcount; i++) {
2328 memcpy(data, fontdata, j);2328 memcpy(data, fontdata, j);
2329 memset(data + j, 0, 128 - j);2329 memset(data + j, 0, 4 * vpitch - j);
2330 data += 128;2330 data += 4 * vpitch;
2331 fontdata += j;2331 fontdata += j;
2332 }2332 }
2333 }2333 }
@@ -2462,19 +2462,12 @@ err_out: · 128 unmodified lines
2462}2462}
2463 2463
2464/*2464/*
2465 * User asked to set font; we are guaranteed that2465 * User asked to set font; we are guaranteed that charcount does not exceed 512
2466 * a) width and height are in range 1..322466 * but lets not assume that, since charcount of 512 is small for unicode support.
2467 * b) charcount does not exceed 512
2468 * but lets not assume that, since someone might someday want to use larger
2469 * fonts. And charcount of 512 is small for unicode support.
2470 *
2471 * However, user space gives the font in 32 rows , regardless of
2472 * actual font height. So a new API is needed if support for larger fonts
2473 * is ever implemented.
2474 */2467 */
2475 2468
2476static int fbcon_set_font(struct vc_data *vc, struct console_font *font,2469static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
2477 unsigned int flags)2470 unsigned int vpitch, unsigned int flags)
2478{2471{
2479 struct fb_info *info = fbcon_info_from_console(vc->vc_num);2472 struct fb_info *info = fbcon_info_from_console(vc->vc_num);
2480 unsigned charcount = font->charcount;2473 unsigned charcount = font->charcount;
@@ -2517,7 +2510,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, · 36 unmodified lines
2517 FNTSIZE(new_data) = size;2510 FNTSIZE(new_data) = size;
2518 REFCOUNT(new_data) = 0; /* usage counter */2511 REFCOUNT(new_data) = 0; /* usage counter */
2519 for (i=0; i< charcount; i++) {2512 for (i=0; i< charcount; i++) {
2520 memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch);2513 memcpy(new_data + i*h*pitch, data + i*vpitch*pitch, h*pitch);
2521 }2514 }
2522 2515
2523 /* Since linux has a nice crc32 function use it for counting font2516 /* Since linux has a nice crc32 function use it for counting font
include/linux/console.h+3−2
@@ -59,8 +59,9 @@ struct consw { · 58 unmodified lines
59 int (*con_switch)(struct vc_data *vc);59 int (*con_switch)(struct vc_data *vc);
60 int (*con_blank)(struct vc_data *vc, int blank, int mode_switch);60 int (*con_blank)(struct vc_data *vc, int blank, int mode_switch);
61 int (*con_font_set)(struct vc_data *vc, struct console_font *font,61 int (*con_font_set)(struct vc_data *vc, struct console_font *font,
62 unsigned int flags);62 unsigned int vpitch, unsigned int flags);
63 int (*con_font_get)(struct vc_data *vc, struct console_font *font);63 int (*con_font_get)(struct vc_data *vc, struct console_font *font,
64 unsigned int vpitch);
64 int (*con_font_default)(struct vc_data *vc,65 int (*con_font_default)(struct vc_data *vc,
65 struct console_font *font, char *name);66 struct console_font *font, char *name);
66 int (*con_resize)(struct vc_data *vc, unsigned int width,67 int (*con_resize)(struct vc_data *vc, unsigned int width,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t