Skip to content

Commit 8f592ad

Browse files
daveyoungardbiesheuvel
authored andcommitted
efi/earlycon: Fix early printk for wider fonts
When I play with terminus fonts I noticed the efi early printk does not work because the earlycon code assumes font width is 8. Here add the code to adapt with larger fonts. Tested with all kinds of kernel built-in fonts on my laptop. Also tested with a local draft patch for 14x28 !bold terminus font. Signed-off-by: Dave Young <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 081d515 commit 8f592ad

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/firmware/efi/earlycon.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
114114
const u32 color_black = 0x00000000;
115115
const u32 color_white = 0x00ffffff;
116116
const u8 *src;
117-
u8 s8;
118-
int m;
117+
int m, n, bytes;
118+
u8 x;
119119

120-
src = font->data + c * font->height;
121-
s8 = *(src + h);
120+
bytes = BITS_TO_BYTES(font->width);
121+
src = font->data + c * font->height * bytes + h * bytes;
122122

123-
for (m = 0; m < 8; m++) {
124-
if ((s8 >> (7 - m)) & 1)
123+
for (m = 0; m < font->width; m++) {
124+
n = m % 8;
125+
x = *(src + m / 8);
126+
if ((x >> (7 - n)) & 1)
125127
*dst = color_white;
126128
else
127129
*dst = color_black;

0 commit comments

Comments
 (0)