linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi/earlycon: fix early printk for wider fonts
@ 2020-04-12  2:49 Dave Young
  2020-04-13 10:30 ` Ard Biesheuvel
  2020-05-22 18:30 ` [tip: efi/urgent] efi/earlycon: Fix " tip-bot2 for Dave Young
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Young @ 2020-04-12  2:49 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: linux-efi, linux-kernel

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 <dyoung@redhat.com>
---
 drivers/firmware/efi/earlycon.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--- linux-x86.orig/drivers/firmware/efi/earlycon.c
+++ linux-x86/drivers/firmware/efi/earlycon.c
@@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32
 	const u32 color_black = 0x00000000;
 	const u32 color_white = 0x00ffffff;
 	const u8 *src;
-	u8 s8;
-	int m;
+	int m, n, bytes;
+	u8 x;
 
-	src = font->data + c * font->height;
-	s8 = *(src + h);
+	bytes = BITS_TO_BYTES(font->width);
+	src = font->data + c * font->height * bytes + h * bytes;
 
-	for (m = 0; m < 8; m++) {
-		if ((s8 >> (7 - m)) & 1)
+	for (m = 0; m < font->width; m++) {
+		n = m % 8;
+		x = *(src + m / 8);
+		if ((x >> (7 - n)) & 1)
 			*dst = color_white;
 		else
 			*dst = color_black;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] efi/earlycon: fix early printk for wider fonts
  2020-04-12  2:49 [PATCH] efi/earlycon: fix early printk for wider fonts Dave Young
@ 2020-04-13 10:30 ` Ard Biesheuvel
  2020-05-22 18:30 ` [tip: efi/urgent] efi/earlycon: Fix " tip-bot2 for Dave Young
  1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2020-04-13 10:30 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-efi, Linux Kernel Mailing List

On Sun, 12 Apr 2020 at 04:49, Dave Young <dyoung@redhat.com> wrote:
>
> 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 <dyoung@redhat.com>

Thanks Dave. I tested this with the 10x18 font, which is utterly
broken for efifb unless I apply this patch.

I'll queue this as a fix.




> ---
>  drivers/firmware/efi/earlycon.c |   14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> --- linux-x86.orig/drivers/firmware/efi/earlycon.c
> +++ linux-x86/drivers/firmware/efi/earlycon.c
> @@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32
>         const u32 color_black = 0x00000000;
>         const u32 color_white = 0x00ffffff;
>         const u8 *src;
> -       u8 s8;
> -       int m;
> +       int m, n, bytes;
> +       u8 x;
>
> -       src = font->data + c * font->height;
> -       s8 = *(src + h);
> +       bytes = BITS_TO_BYTES(font->width);
> +       src = font->data + c * font->height * bytes + h * bytes;
>
> -       for (m = 0; m < 8; m++) {
> -               if ((s8 >> (7 - m)) & 1)
> +       for (m = 0; m < font->width; m++) {
> +               n = m % 8;
> +               x = *(src + m / 8);
> +               if ((x >> (7 - n)) & 1)
>                         *dst = color_white;
>                 else
>                         *dst = color_black;
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: efi/urgent] efi/earlycon: Fix early printk for wider fonts
  2020-04-12  2:49 [PATCH] efi/earlycon: fix early printk for wider fonts Dave Young
  2020-04-13 10:30 ` Ard Biesheuvel
@ 2020-05-22 18:30 ` tip-bot2 for Dave Young
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Dave Young @ 2020-05-22 18:30 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Dave Young, Ard Biesheuvel, x86, LKML

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     8f592ada59b321d248391bae175cd78a12972223
Gitweb:        https://git.kernel.org/tip/8f592ada59b321d248391bae175cd78a12972223
Author:        Dave Young <dyoung@redhat.com>
AuthorDate:    Sun, 12 Apr 2020 10:49:27 +08:00
Committer:     Ard Biesheuvel <ardb@kernel.org>
CommitterDate: Tue, 12 May 2020 12:29:45 +02:00

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 <dyoung@redhat.com>
Link: https://lore.kernel.org/r/20200412024927.GA6884@dhcp-128-65.nay.redhat.com
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/earlycon.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
index 5d4f847..a52236e 100644
--- a/drivers/firmware/efi/earlycon.c
+++ b/drivers/firmware/efi/earlycon.c
@@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
 	const u32 color_black = 0x00000000;
 	const u32 color_white = 0x00ffffff;
 	const u8 *src;
-	u8 s8;
-	int m;
+	int m, n, bytes;
+	u8 x;
 
-	src = font->data + c * font->height;
-	s8 = *(src + h);
+	bytes = BITS_TO_BYTES(font->width);
+	src = font->data + c * font->height * bytes + h * bytes;
 
-	for (m = 0; m < 8; m++) {
-		if ((s8 >> (7 - m)) & 1)
+	for (m = 0; m < font->width; m++) {
+		n = m % 8;
+		x = *(src + m / 8);
+		if ((x >> (7 - n)) & 1)
 			*dst = color_white;
 		else
 			*dst = color_black;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-22 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12  2:49 [PATCH] efi/earlycon: fix early printk for wider fonts Dave Young
2020-04-13 10:30 ` Ard Biesheuvel
2020-05-22 18:30 ` [tip: efi/urgent] efi/earlycon: Fix " tip-bot2 for Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).