Skip to content

Commit 1526097

Browse files
sthibaulhdeller
authored andcommitted
fbcon: Increase maximum font width x height to 64 x 128
By using bitmaps we actually support whatever size we would want, but the console currently limits fonts to 64x128 (which gives 60x16 text on 4k screens), so we don't need more for now, and we can easily increase later. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent bc87bb3 commit 1526097

File tree

12 files changed

+89
-45
lines changed

12 files changed

+89
-45
lines changed

drivers/firmware/efi/earlycon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
252252
if (si->lfb_depth != 32)
253253
return -ENODEV;
254254

255-
font = get_default_font(xres, yres, -1, -1);
255+
font = get_default_font(xres, yres, NULL, NULL);
256256
if (!font)
257257
return -ENODEV;
258258

drivers/video/fbdev/arkfb.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,13 @@ static int arkfb_set_par(struct fb_info *info)
622622
info->tileops = NULL;
623623

624624
/* in 4bpp supports 8p wide tiles only, any tiles otherwise */
625-
info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
626-
info->pixmap.blit_y = ~(u32)0;
625+
if (bpp == 4) {
626+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
627+
set_bit(8 - 1, info->pixmap.blit_x);
628+
} else {
629+
bitmap_fill(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
630+
}
631+
bitmap_fill(info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
627632

628633
offset_value = (info->var.xres_virtual * bpp) / 64;
629634
screen_size = info->var.yres_virtual * info->fix.line_length;
@@ -635,8 +640,10 @@ static int arkfb_set_par(struct fb_info *info)
635640
info->tileops = &arkfb_tile_ops;
636641

637642
/* supports 8x16 tiles only */
638-
info->pixmap.blit_x = 1 << (8 - 1);
639-
info->pixmap.blit_y = 1 << (16 - 1);
643+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
644+
set_bit(8 - 1, info->pixmap.blit_x);
645+
bitmap_zero(info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
646+
set_bit(16 - 1, info->pixmap.blit_y);
640647

641648
offset_value = info->var.xres_virtual / 16;
642649
screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;

drivers/video/fbdev/core/fbcon.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,12 +2485,12 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
24852485
h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))
24862486
return -EINVAL;
24872487

2488-
if (font->width > 32 || font->height > 32)
2488+
if (font->width > FB_MAX_BLIT_WIDTH || font->height > FB_MAX_BLIT_HEIGHT)
24892489
return -EINVAL;
24902490

24912491
/* Make sure drawing engine can handle the font */
2492-
if (!(info->pixmap.blit_x & BIT(font->width - 1)) ||
2493-
!(info->pixmap.blit_y & BIT(font->height - 1)))
2492+
if (!test_bit(font->width - 1, info->pixmap.blit_x) ||
2493+
!test_bit(font->height - 1, info->pixmap.blit_y))
24942494
return -EINVAL;
24952495

24962496
/* Make sure driver can handle the font length */
@@ -3084,8 +3084,8 @@ void fbcon_get_requirement(struct fb_info *info,
30843084
vc = vc_cons[i].d;
30853085
if (vc && vc->vc_mode == KD_TEXT &&
30863086
info->node == con2fb_map[i]) {
3087-
caps->x |= 1 << (vc->vc_font.width - 1);
3088-
caps->y |= 1 << (vc->vc_font.height - 1);
3087+
set_bit(vc->vc_font.width - 1, caps->x);
3088+
set_bit(vc->vc_font.height - 1, caps->y);
30893089
charcnt = vc->vc_font.charcount;
30903090
if (caps->len < charcnt)
30913091
caps->len = charcnt;
@@ -3096,8 +3096,10 @@ void fbcon_get_requirement(struct fb_info *info,
30963096

30973097
if (vc && vc->vc_mode == KD_TEXT &&
30983098
info->node == con2fb_map[fg_console]) {
3099-
caps->x = 1 << (vc->vc_font.width - 1);
3100-
caps->y = 1 << (vc->vc_font.height - 1);
3099+
bitmap_zero(caps->x, FB_MAX_BLIT_WIDTH);
3100+
set_bit(vc->vc_font.width - 1, caps->x);
3101+
bitmap_zero(caps->y, FB_MAX_BLIT_HEIGHT);
3102+
set_bit(vc->vc_font.height - 1, caps->y);
31013103
caps->len = vc->vc_font.charcount;
31023104
}
31033105
}

drivers/video/fbdev/core/fbmem.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var,
212212
fbcon_get_requirement(info, &caps);
213213
info->fbops->fb_get_caps(info, &fbcaps, var);
214214

215-
if (((fbcaps.x ^ caps.x) & caps.x) ||
216-
((fbcaps.y ^ caps.y) & caps.y) ||
215+
if (!bitmap_subset(caps.x, fbcaps.x, FB_MAX_BLIT_WIDTH) ||
216+
!bitmap_subset(caps.y, fbcaps.y, FB_MAX_BLIT_HEIGHT) ||
217217
(fbcaps.len < caps.len))
218218
err = -EINVAL;
219219

@@ -420,11 +420,11 @@ static int do_register_framebuffer(struct fb_info *fb_info)
420420
}
421421
fb_info->pixmap.offset = 0;
422422

423-
if (!fb_info->pixmap.blit_x)
424-
fb_info->pixmap.blit_x = ~(u32)0;
423+
if (bitmap_empty(fb_info->pixmap.blit_x, FB_MAX_BLIT_WIDTH))
424+
bitmap_fill(fb_info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
425425

426-
if (!fb_info->pixmap.blit_y)
427-
fb_info->pixmap.blit_y = ~(u32)0;
426+
if (bitmap_empty(fb_info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT))
427+
bitmap_fill(fb_info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
428428

429429
if (!fb_info->modelist.prev || !fb_info->modelist.next)
430430
INIT_LIST_HEAD(&fb_info->modelist);

drivers/video/fbdev/core/svgalib.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,19 @@ void svga_get_caps(struct fb_info *info, struct fb_blit_caps *caps,
354354
{
355355
if (var->bits_per_pixel == 0) {
356356
/* can only support 256 8x16 bitmap */
357-
caps->x = 1 << (8 - 1);
358-
caps->y = 1 << (16 - 1);
357+
bitmap_zero(caps->x, FB_MAX_BLIT_WIDTH);
358+
set_bit(8 - 1, caps->x);
359+
bitmap_zero(caps->y, FB_MAX_BLIT_HEIGHT);
360+
set_bit(16 - 1, caps->y);
359361
caps->len = 256;
360362
} else {
361-
caps->x = (var->bits_per_pixel == 4) ? 1 << (8 - 1) : ~(u32)0;
362-
caps->y = ~(u32)0;
363+
if (var->bits_per_pixel == 4) {
364+
bitmap_zero(caps->x, FB_MAX_BLIT_WIDTH);
365+
set_bit(8 - 1, caps->x);
366+
} else {
367+
bitmap_fill(caps->x, FB_MAX_BLIT_WIDTH);
368+
}
369+
bitmap_fill(caps->y, FB_MAX_BLIT_HEIGHT);
363370
caps->len = ~(u32)0;
364371
}
365372
}

drivers/video/fbdev/s3fb.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,13 @@ static int s3fb_set_par(struct fb_info *info)
617617
info->tileops = NULL;
618618

619619
/* in 4bpp supports 8p wide tiles only, any tiles otherwise */
620-
info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
621-
info->pixmap.blit_y = ~(u32)0;
620+
if (bpp == 4) {
621+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
622+
set_bit(8 - 1, info->pixmap.blit_x);
623+
} else {
624+
bitmap_fill(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
625+
}
626+
bitmap_fill(info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
622627

623628
offset_value = (info->var.xres_virtual * bpp) / 64;
624629
screen_size = info->var.yres_virtual * info->fix.line_length;
@@ -630,8 +635,10 @@ static int s3fb_set_par(struct fb_info *info)
630635
info->tileops = fasttext ? &s3fb_fast_tile_ops : &s3fb_tile_ops;
631636

632637
/* supports 8x16 tiles only */
633-
info->pixmap.blit_x = 1 << (8 - 1);
634-
info->pixmap.blit_y = 1 << (16 - 1);
638+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
639+
set_bit(8 - 1, info->pixmap.blit_x);
640+
bitmap_zero(info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
641+
set_bit(16 - 1, info->pixmap.blit_y);
635642

636643
offset_value = info->var.xres_virtual / 16;
637644
screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;

drivers/video/fbdev/vga16fb.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,11 @@ static int vga16fb_probe(struct platform_device *dev)
13531353
info->var = vga16fb_defined;
13541354
info->fix = vga16fb_fix;
13551355
/* supports rectangles with widths of multiples of 8 */
1356-
info->pixmap.blit_x = 1 << 7 | 1 << 15 | 1 << 23 | 1 << 31;
1356+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
1357+
set_bit(8 - 1, info->pixmap.blit_x);
1358+
set_bit(16 - 1, info->pixmap.blit_x);
1359+
set_bit(24 - 1, info->pixmap.blit_x);
1360+
set_bit(32 - 1, info->pixmap.blit_x);
13571361
info->flags = FBINFO_HWACCEL_YPAN;
13581362

13591363
i = (info->var.bits_per_pixel == 8) ? 256 : 16;

drivers/video/fbdev/vt8623fb.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,13 @@ static int vt8623fb_set_par(struct fb_info *info)
390390
info->tileops = NULL;
391391

392392
/* in 4bpp supports 8p wide tiles only, any tiles otherwise */
393-
info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
394-
info->pixmap.blit_y = ~(u32)0;
393+
if (bpp == 4) {
394+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
395+
set_bit(8 - 1, info->pixmap.blit_x);
396+
} else {
397+
bitmap_fill(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
398+
}
399+
bitmap_fill(info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
395400

396401
offset_value = (info->var.xres_virtual * bpp) / 64;
397402
fetch_value = ((info->var.xres * bpp) / 128) + 4;
@@ -408,8 +413,10 @@ static int vt8623fb_set_par(struct fb_info *info)
408413
info->tileops = &vt8623fb_tile_ops;
409414

410415
/* supports 8x16 tiles only */
411-
info->pixmap.blit_x = 1 << (8 - 1);
412-
info->pixmap.blit_y = 1 << (16 - 1);
416+
bitmap_zero(info->pixmap.blit_x, FB_MAX_BLIT_WIDTH);
417+
set_bit(8 - 1, info->pixmap.blit_x);
418+
bitmap_zero(info->pixmap.blit_y, FB_MAX_BLIT_HEIGHT);
419+
set_bit(16 - 1, info->pixmap.blit_y);
413420

414421
offset_value = info->var.xres_virtual / 16;
415422
fetch_value = (info->var.xres / 8) + 8;

drivers/video/sticore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
529529
if (fbfont_name && strlen(fbfont_name))
530530
fbfont = find_font(fbfont_name);
531531
if (!fbfont)
532-
fbfont = get_default_font(1024,768, ~(u32)0, ~(u32)0);
532+
fbfont = get_default_font(1024, 768, NULL, NULL);
533533
if (!fbfont)
534534
return NULL;
535535

include/linux/fb.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,13 @@ struct fb_event {
143143
void *data;
144144
};
145145

146+
/* Enough for the VT console needs, see its max_font_width/height */
147+
#define FB_MAX_BLIT_WIDTH 64
148+
#define FB_MAX_BLIT_HEIGHT 128
149+
146150
struct fb_blit_caps {
147-
u32 x;
148-
u32 y;
151+
DECLARE_BITMAP(x, FB_MAX_BLIT_WIDTH);
152+
DECLARE_BITMAP(y, FB_MAX_BLIT_HEIGHT);
149153
u32 len;
150154
u32 flags;
151155
};
@@ -192,10 +196,12 @@ struct fb_pixmap {
192196
u32 scan_align; /* alignment per scanline */
193197
u32 access_align; /* alignment per read/write (bits) */
194198
u32 flags; /* see FB_PIXMAP_* */
195-
u32 blit_x; /* supported bit block dimensions (1-32)*/
196-
u32 blit_y; /* Format: blit_x = 1 << (width - 1) */
197-
/* blit_y = 1 << (height - 1) */
198-
/* if 0, will be set to 0xffffffff (all)*/
199+
/* supported bit block dimensions */
200+
/* Format: test_bit(width - 1, blit_x) */
201+
/* test_bit(height - 1, blit_y) */
202+
/* if zero, will be set to full (all) */
203+
DECLARE_BITMAP(blit_x, FB_MAX_BLIT_WIDTH);
204+
DECLARE_BITMAP(blit_y, FB_MAX_BLIT_HEIGHT);
199205
/* access methods */
200206
void (*writeio)(struct fb_info *info, void __iomem *dst, void *src, unsigned int size);
201207
void (*readio) (struct fb_info *info, void *dst, void __iomem *src, unsigned int size);

0 commit comments

Comments
 (0)