mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH] handle 10-bpc framebuffer layouts
Date: Sat, 5 Jun 2021 20:15:02 +0000	[thread overview]
Message-ID: <CAOqdjBd=5z0yqK57NMPL+yDKd4duy-AXcqBY2J=zg76oUAabYw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

I'm playing with barebox on an Apple M1-based MacBook Pro that uses
the (new-ish) x2r10g10b10 framebuffer layout. The attached patch is
sufficient to get a white-on-black prompt rather than black-on-black
text.

(I can't actually use the prompt yet, as there's no keyboard driver,
but it's a start.)

I'm aware that this code isn't as accurate as it could be (the LSBs of
the 10-bit color are always 00), but I think it's worth it to keep
this code (relatively) simple, and the difference is unlikely to ever
be apparent to anyone. Please let me know if you'd prefer a version
which does the (r * 0x101) >> (16 - length) thing or any other
version.

Thanks!
Pip

[-- Attachment #2: 0001-graphic_utils.c-handle-10-bpc-framebuffer-layouts.patch --]
[-- Type: text/x-patch, Size: 1137 bytes --]

From eac9610833b747aa3d1685dbc665cf13d863eaa6 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Sat, 5 Jun 2021 19:59:09 +0000
Subject: [PATCH] graphic_utils.c: handle 10-bpc framebuffer layouts

Signed-off-by: Pip Cet <pipcet@gmail.com>
---
 lib/gui/graphic_utils.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/gui/graphic_utils.c b/lib/gui/graphic_utils.c
index 0bed93221..3cb791050 100644
--- a/lib/gui/graphic_utils.c
+++ b/lib/gui/graphic_utils.c
@@ -24,10 +24,10 @@ u32 gu_rgb_to_pixel(struct fb_info *info, u8 r, u8 g, u8 b, u8 t)
 {
 	u32 px;
 
-	px = (t >> (8 - info->transp.length)) << info->transp.offset |
-		 (r >> (8 - info->red.length)) << info->red.offset |
-		 (g >> (8 - info->green.length)) << info->green.offset |
-		 (b >> (8 - info->blue.length)) << info->blue.offset;
+	px = ((t << 2) >> (10 - info->transp.length)) << info->transp.offset |
+		((r << 2) >> (10 - info->red.length)) << info->red.offset |
+		((g << 2) >> (10 - info->green.length)) << info->green.offset |
+		((b << 2) >> (10 - info->blue.length)) << info->blue.offset;
 
 	return px;
 }
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2021-06-05 20:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOqdjBd=5z0yqK57NMPL+yDKd4duy-AXcqBY2J=zg76oUAabYw@mail.gmail.com' \
    --to=pipcet@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox