aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2007-05-08 03:39:11 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:31 -0400
commit2d2699d984924890f6dac8cf51c3b6311f56816c (patch)
treebd8f50392ac6918589c6069177b89172f2263916
parentbf26ad72a60c0009a99179b449a43daa6bf4b4f6 (diff)
fbcon: font setting should check limitation of driver
fbcon_set_font() will now check if the new font dimensions can be drawn by the driver (by checking pixmap.blit_x and blit_y). Similarly, add 2 new parameters to get_default_font(), font_w and font_h, to further aid in the font selection process. Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/video/console/fbcon.c17
-rw-r--r--drivers/video/console/fonts.c10
-rw-r--r--drivers/video/console/sticore.c2
-rw-r--r--include/linux/font.h3
4 files changed, 26 insertions, 6 deletions
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 19dfdfbd4341..c71a88d531cd 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -988,7 +988,9 @@ static const char *fbcon_startup(void)
988 if (!p->fontdata) { 988 if (!p->fontdata) {
989 if (!fontname[0] || !(font = find_font(fontname))) 989 if (!fontname[0] || !(font = find_font(fontname)))
990 font = get_default_font(info->var.xres, 990 font = get_default_font(info->var.xres,
991 info->var.yres); 991 info->var.yres,
992 info->pixmap.blit_x,
993 info->pixmap.blit_y);
992 vc->vc_font.width = font->width; 994 vc->vc_font.width = font->width;
993 vc->vc_font.height = font->height; 995 vc->vc_font.height = font->height;
994 vc->vc_font.data = (void *)(p->fontdata = font->data); 996 vc->vc_font.data = (void *)(p->fontdata = font->data);
@@ -1108,7 +1110,9 @@ static void fbcon_init(struct vc_data *vc, int init)
1108 1110
1109 if (!fontname[0] || !(font = find_font(fontname))) 1111 if (!fontname[0] || !(font = find_font(fontname)))
1110 font = get_default_font(info->var.xres, 1112 font = get_default_font(info->var.xres,
1111 info->var.yres); 1113 info->var.yres,
1114 info->pixmap.blit_x,
1115 info->pixmap.blit_y);
1112 vc->vc_font.width = font->width; 1116 vc->vc_font.width = font->width;
1113 vc->vc_font.height = font->height; 1117 vc->vc_font.height = font->height;
1114 vc->vc_font.data = (void *)(p->fontdata = font->data); 1118 vc->vc_font.data = (void *)(p->fontdata = font->data);
@@ -2495,6 +2499,7 @@ static int fbcon_copy_font(struct vc_data *vc, int con)
2495 2499
2496static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags) 2500static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigned flags)
2497{ 2501{
2502 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
2498 unsigned charcount = font->charcount; 2503 unsigned charcount = font->charcount;
2499 int w = font->width; 2504 int w = font->width;
2500 int h = font->height; 2505 int h = font->height;
@@ -2508,6 +2513,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
2508 if (charcount != 256 && charcount != 512) 2513 if (charcount != 256 && charcount != 512)
2509 return -EINVAL; 2514 return -EINVAL;
2510 2515
2516 /* Make sure drawing engine can handle the font */
2517 if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
2518 !(info->pixmap.blit_y & (1 << (font->height - 1))))
2519 return -EINVAL;
2520
2511 size = h * pitch * charcount; 2521 size = h * pitch * charcount;
2512 2522
2513 new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER); 2523 new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
@@ -2552,7 +2562,8 @@ static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, cha
2552 const struct font_desc *f; 2562 const struct font_desc *f;
2553 2563
2554 if (!name) 2564 if (!name)
2555 f = get_default_font(info->var.xres, info->var.yres); 2565 f = get_default_font(info->var.xres, info->var.yres,
2566 info->pixmap.blit_x, info->pixmap.blit_y);
2556 else if (!(f = find_font(name))) 2567 else if (!(f = find_font(name)))
2557 return -ENOENT; 2568 return -ENOENT;
2558 2569
diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c
index c960728b7e82..a6828d0a4c56 100644
--- a/drivers/video/console/fonts.c
+++ b/drivers/video/console/fonts.c
@@ -98,6 +98,8 @@ const struct font_desc *find_font(const char *name)
98 * get_default_font - get default font 98 * get_default_font - get default font
99 * @xres: screen size of X 99 * @xres: screen size of X
100 * @yres: screen size of Y 100 * @yres: screen size of Y
101 * @font_w: bit array of supported widths (1 - 32)
102 * @font_h: bit array of supported heights (1 - 32)
101 * 103 *
102 * Get the default font for a specified screen size. 104 * Get the default font for a specified screen size.
103 * Dimensions are in pixels. 105 * Dimensions are in pixels.
@@ -107,7 +109,8 @@ const struct font_desc *find_font(const char *name)
107 * 109 *
108 */ 110 */
109 111
110const struct font_desc *get_default_font(int xres, int yres) 112const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
113 u32 font_h)
111{ 114{
112 int i, c, cc; 115 int i, c, cc;
113 const struct font_desc *f, *g; 116 const struct font_desc *f, *g;
@@ -129,6 +132,11 @@ const struct font_desc *get_default_font(int xres, int yres)
129#endif 132#endif
130 if ((yres < 400) == (f->height <= 8)) 133 if ((yres < 400) == (f->height <= 8))
131 c += 1000; 134 c += 1000;
135
136 if (!(font_w & (1 << (f->width - 1))) ||
137 !(font_w & (1 << (f->height - 1))))
138 c += 1000;
139
132 if (c > cc) { 140 if (c > cc) {
133 cc = c; 141 cc = c;
134 g = f; 142 g = f;
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index 88e7038eab88..717b360d0415 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -495,7 +495,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
495 return NULL; 495 return NULL;
496 fbfont = find_font(fbfont_name); 496 fbfont = find_font(fbfont_name);
497 if (!fbfont) 497 if (!fbfont)
498 fbfont = get_default_font(1024,768); 498 fbfont = get_default_font(1024,768, ~(u32)0, ~(u32)0);
499 if (!fbfont) 499 if (!fbfont)
500 return NULL; 500 return NULL;
501 501
diff --git a/include/linux/font.h b/include/linux/font.h
index 53b129f07f6f..40a24ab41b36 100644
--- a/include/linux/font.h
+++ b/include/linux/font.h
@@ -49,7 +49,8 @@ extern const struct font_desc *find_font(const char *name);
49 49
50/* Get the default font for a specific screen size */ 50/* Get the default font for a specific screen size */
51 51
52extern const struct font_desc *get_default_font(int xres, int yres); 52extern const struct font_desc *get_default_font(int xres, int yres,
53 u32 font_w, u32 font_h);
53 54
54/* Max. length for the name of a predefined font */ 55/* Max. length for the name of a predefined font */
55#define MAX_FONT_NAME 32 56#define MAX_FONT_NAME 32