Skip to contentSkip to conversation

30bpp framebuffer support

PATCH Superseded Mark Kettenis 4 participants 12 messages Sep 16, 2021 – Sep 25, 2021 Framebuffer layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover 30bpp framebuffer support

Apple M1 machines come up with a framebuffer that in 30bpp mode. This series adds basic support for this mode.

Mark Kettenis (3):
video: Add 30bpp support
efi_loader: GOP: Add 30bpp support
video: simplefb: Add 30bpp support

 drivers/video/console_normal.c    |  2 ++
 drivers/video/console_rotate.c    |  6 ++++++
 drivers/video/console_truetype.c  |  3 +++
 drivers/video/simplefb.c          |  3 +++
 drivers/video/vidconsole-uclass.c |  7 +++++++
 drivers/video/video-uclass.c      |  1 +
 include/video.h                   |  1 +
 lib/efi_loader/efi_gop.c          | 10 ++++++++++
 8 files changed, 33 insertions(+)
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/3 video: Add 30bpp support

Add support for 30bpp mode where pixels are picked in 32-bit integers but use 10 bits instead of 8 bits for each component.

---
 drivers/video/console_normal.c    | 2 ++
 drivers/video/console_rotate.c    | 6 ++++++
 drivers/video/console_truetype.c  | 3 +++
 drivers/video/vidconsole-uclass.c | 7 +++++++
 drivers/video/video-uclass.c      | 1 +
 include/video.h                   | 1 +
 6 files changed, 20 insertions(+)
drivers/video/console_normal.c +2 -0
index 04f022491e..e0b89cbb93 100644
@@ -41,6 +41,7 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr)
 			end = dst;
 			break;
 		}
+	case VIDEO_BPP30:
 	case VIDEO_BPP32:
 		if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 			uint32_t *dst = line;
@@ -126,6 +127,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
 				}
 				break;
 			}
+		case VIDEO_BPP30:
 		case VIDEO_BPP32:
 			if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 				uint32_t *dst = line;
drivers/video/console_rotate.c +6 -0
index 36c8d0609d..bf81b80a39 100644
@@ -40,6 +40,7 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
 					*dst++ = clr;
 				break;
 			}
+		case VIDEO_BPP30:
 		case VIDEO_BPP32:
 			if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 				uint32_t *dst = line;
@@ -128,6 +129,7 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
 				}
 				break;
 			}
+		case VIDEO_BPP30:
 		case VIDEO_BPP32:
 			if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 				uint32_t *dst = line;
@@ -183,6 +185,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
 			end = dst;
 			break;
 		}
+	case VIDEO_BPP30:
 	case VIDEO_BPP32:
 		if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 			uint32_t *dst = line;
@@ -266,6 +269,7 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
 				}
 				break;
 			}
+		case VIDEO_BPP30:
 		case VIDEO_BPP32:
 			if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 				uint32_t *dst = line;
@@ -318,6 +322,7 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
 					*dst++ = clr;
 				break;
 			}
+		case VIDEO_BPP30:
 		case VIDEO_BPP32:
 			if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 				uint32_t *dst = line;
@@ -402,6 +407,7 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
 				}
 				break;
 			}
+		case VIDEO_BPP30:
 		case VIDEO_BPP32:
 			if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 				uint32_t *dst = line;
drivers/video/console_truetype.c +3 -0
index 98427f4c61..0195d996de 100644
@@ -153,6 +153,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 	}
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+	case VIDEO_BPP30:
 	case VIDEO_BPP32: {
 		u32 *dst = line;
 
@@ -299,6 +300,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 		}
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP30:
 		case VIDEO_BPP32: {
 			u32 *dst = (u32 *)line + xoff;
 			int i;
@@ -381,6 +383,7 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
 		}
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP30:
 		case VIDEO_BPP32: {
 			uint32_t *dst = line;
 
drivers/video/vidconsole-uclass.c +7 -0
index 8132efa55a..cc274b45fe 100644
@@ -153,6 +153,13 @@ u32 vid_console_color(struct video_priv *priv, unsigned int idx)
 			       ((colors[idx].b >> 3) <<  0);
 		}
 		break;
+	case VIDEO_BPP30:
+		if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
+			return (colors[idx].r << 22) |
+			       (colors[idx].g << 12) |
+			       (colors[idx].b <<  2);
+		}
+		break;
 	case VIDEO_BPP32:
 		if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
 			return (colors[idx].r << 16) |
drivers/video/video-uclass.c +1 -0
index 9f8cf6ef2a..28bf701f41 100644
@@ -129,6 +129,7 @@ int video_clear(struct udevice *dev)
 				*ppix++ = priv->colour_bg;
 			break;
 		}
+	case VIDEO_BPP30:
 	case VIDEO_BPP32:
 		if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
 			u32 *ppix = priv->fb;
include/video.h +1 -0
index 827733305e..04c636b317 100644
@@ -53,6 +53,7 @@ enum video_log2_bpp {
 	VIDEO_BPP4,
 	VIDEO_BPP8,
 	VIDEO_BPP16,
+	VIDEO_BPP30,
 	VIDEO_BPP32,
 };
 
Signature · 1 line
2.33.0
Tested-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] video: Add 30bpp support

Quoted 149 lines · Mark Kettenis

Add support for 30bpp mode where pixels are picked in 32-bit integers but use 10 bits instead of 8 bits for each component.

---
 drivers/video/console_normal.c    | 2 ++
 drivers/video/console_rotate.c    | 6 ++++++
 drivers/video/console_truetype.c  | 3 +++
 drivers/video/vidconsole-uclass.c | 7 +++++++
 drivers/video/video-uclass.c      | 1 +
 include/video.h                   | 1 +
 6 files changed, 20 insertions(+)
drivers/video/console_normal.c +2 -0
index 04f022491e..e0b89cbb93 100644
@@ -41,6 +41,7 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr)
                        end = dst;
                        break;
                }
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
                if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                        uint32_t *dst = line;
@@ -126,6 +127,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
drivers/video/console_rotate.c +6 -0
index 36c8d0609d..bf81b80a39 100644
@@ -40,6 +40,7 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
                                        *dst++ = clr;
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -128,6 +129,7 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -183,6 +185,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
                        end = dst;
                        break;
                }
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
                if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                        uint32_t *dst = line;
@@ -266,6 +269,7 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -318,6 +322,7 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
                                        *dst++ = clr;
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -402,6 +407,7 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
drivers/video/console_truetype.c +3 -0
index 98427f4c61..0195d996de 100644
@@ -153,6 +153,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
        }
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+       case VIDEO_BPP30:
        case VIDEO_BPP32: {
                u32 *dst = line;
 
@@ -299,6 +300,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
                }
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+               case VIDEO_BPP30:
                case VIDEO_BPP32: {
                        u32 *dst = (u32 *)line + xoff;
                        int i;
@@ -381,6 +383,7 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
                }
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+               case VIDEO_BPP30:
                case VIDEO_BPP32: {
                        uint32_t *dst = line;
 
drivers/video/vidconsole-uclass.c +7 -0
index 8132efa55a..cc274b45fe 100644
@@ -153,6 +153,13 @@ u32 vid_console_color(struct video_priv *priv, unsigned int idx)
                               ((colors[idx].b >> 3) <<  0);
                }
                break;
+       case VIDEO_BPP30:
+               if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
+                       return (colors[idx].r << 22) |
+                              (colors[idx].g << 12) |
+                              (colors[idx].b <<  2);
+               }
+               break;
        case VIDEO_BPP32:
                if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
                        return (colors[idx].r << 16) |
drivers/video/video-uclass.c +1 -0
index 9f8cf6ef2a..28bf701f41 100644
@@ -129,6 +129,7 @@ int video_clear(struct udevice *dev)
                                *ppix++ = priv->colour_bg;
                        break;
                }
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
                if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                        u32 *ppix = priv->fb;
include/video. renamed from include/video.h +0 -0
index 827733305e..04c636b317 100644

include/video. enum video_log2_bpp { · line 58

Quoted 6 lines
include/video. renamed from include/video.h +1 -0
@@ -53,6 +53,7 @@ enum video_log2_bpp {
        VIDEO_BPP4,
        VIDEO_BPP8,
        VIDEO_BPP16,
+       VIDEO_BPP30,
        VIDEO_BPP32,
 };

This breaks the enuam here. See the comment above:

/*
* Bits per pixel selector. Each value n is such that the bits-per-pixel is
* 2 ^ n
*/

Quite a few things rely on this, so there will need to be some changes. See for example VBNBYTE() immediately below.

Also don't you need a CONFIG_VIDEO_BPP30 ?

Tested on: Macbook Air M1

Fails on sandbox (display turns blue)

Regards,
Simon

#3 lore raw

Re: [PATCH 1/3] video: Add 30bpp support

Quoted 162 lines

From: Simon Glass <[email protected]>
Date: Sat, 25 Sep 2021 07:40:54 -0600

Quoted 149 lines · Mark Kettenis

Add support for 30bpp mode where pixels are picked in 32-bit integers but use 10 bits instead of 8 bits for each component.

---
 drivers/video/console_normal.c    | 2 ++
 drivers/video/console_rotate.c    | 6 ++++++
 drivers/video/console_truetype.c  | 3 +++
 drivers/video/vidconsole-uclass.c | 7 +++++++
 drivers/video/video-uclass.c      | 1 +
 include/video.h                   | 1 +
 6 files changed, 20 insertions(+)
drivers/video/console_normal.c +2 -0
index 04f022491e..e0b89cbb93 100644
@@ -41,6 +41,7 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr)
                        end = dst;
                        break;
                }
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
                if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                        uint32_t *dst = line;
@@ -126,6 +127,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
drivers/video/console_rotate.c +6 -0
index 36c8d0609d..bf81b80a39 100644
@@ -40,6 +40,7 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
                                        *dst++ = clr;
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -128,6 +129,7 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -183,6 +185,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
                        end = dst;
                        break;
                }
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
                if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                        uint32_t *dst = line;
@@ -266,6 +269,7 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -318,6 +322,7 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
                                        *dst++ = clr;
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
@@ -402,6 +407,7 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
                                }
                                break;
                        }
+               case VIDEO_BPP30:
                case VIDEO_BPP32:
                        if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                                uint32_t *dst = line;
drivers/video/console_truetype.c +3 -0
index 98427f4c61..0195d996de 100644
@@ -153,6 +153,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
        }
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+       case VIDEO_BPP30:
        case VIDEO_BPP32: {
                u32 *dst = line;
 
@@ -299,6 +300,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
                }
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+               case VIDEO_BPP30:
                case VIDEO_BPP32: {
                        u32 *dst = (u32 *)line + xoff;
                        int i;
@@ -381,6 +383,7 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
                }
 #endif
 #ifdef CONFIG_VIDEO_BPP32
+               case VIDEO_BPP30:
                case VIDEO_BPP32: {
                        uint32_t *dst = line;
 
drivers/video/vidconsole-uclass.c +7 -0
index 8132efa55a..cc274b45fe 100644
@@ -153,6 +153,13 @@ u32 vid_console_color(struct video_priv *priv, unsigned int idx)
                               ((colors[idx].b >> 3) <<  0);
                }
                break;
+       case VIDEO_BPP30:
+               if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
+                       return (colors[idx].r << 22) |
+                              (colors[idx].g << 12) |
+                              (colors[idx].b <<  2);
+               }
+               break;
        case VIDEO_BPP32:
                if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
                        return (colors[idx].r << 16) |
drivers/video/video-uclass.c +1 -0
index 9f8cf6ef2a..28bf701f41 100644
@@ -129,6 +129,7 @@ int video_clear(struct udevice *dev)
                                *ppix++ = priv->colour_bg;
                        break;
                }
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
                if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
                        u32 *ppix = priv->fb;
include/video. renamed from include/video.h +0 -0
index 827733305e..04c636b317 100644

include/video. enum video_log2_bpp { · line 58

Quoted 6 lines
include/video. renamed from include/video.h +1 -0
@@ -53,6 +53,7 @@ enum video_log2_bpp {
        VIDEO_BPP4,
        VIDEO_BPP8,
        VIDEO_BPP16,
+       VIDEO_BPP30,
        VIDEO_BPP32,
 };

This breaks the enuam here. See the comment above:

Quoted 7 lines

/*
* Bits per pixel selector. Each value n is such that the bits-per-pixel is
* 2 ^ n
*/

Quite a few things rely on this, so there will need to be some changes. See for example VBNBYTE() immediately below.

Bleah. I suppose I need a separate field in struct video_priv to keep track of the pixel format then.

Quoted 1 line

Also don't you need a CONFIG_VIDEO_BPP30 ?

The idea was that the code additions were minimal enough for that not to make sense. But I'll need re-evaluate this after I figure out a better way to distinguish between 8-bit and 10-bit color depth.

#4 lore raw

PATCH 2/3 efi_loader: GOP: Add 30bpp support

In reply to Mark Kettenis

Provide correct framebuffer information for 30bpp modes.

---
 lib/efi_loader/efi_gop.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/efi_loader/efi_gop.c +10 -0
index 1206b2d7a2..42bf49b184 100644
@@ -227,6 +227,7 @@ static efi_uintn_t gop_get_bpp(struct efi_gop *this)
 
 	switch (gopobj->bpix) {
 #ifdef CONFIG_DM_VIDEO
+	case VIDEO_BPP30:
 	case VIDEO_BPP32:
 #else
 	case LCD_COLOR32:
@@ -468,6 +469,7 @@ efi_status_t efi_gop_register(void)
 	switch (bpix) {
 #ifdef CONFIG_DM_VIDEO
 	case VIDEO_BPP16:
+	case VIDEO_BPP30:
 	case VIDEO_BPP32:
 #else
 	case LCD_COLOR32:
@@ -518,6 +520,14 @@ efi_status_t efi_gop_register(void)
 #endif
 	{
 		gopobj->info.pixel_format = EFI_GOT_BGRA8;
+#ifdef CONFIG_DM_VIDEO
+	} else if (bpix == VIDEO_BPP30) {
+		gopobj->info.pixel_format = EFI_GOT_BITMASK;
+		gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */
+		gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */
+		gopobj->info.pixel_bitmask[2] = 0x000003ff; /* blue */
+		gopobj->info.pixel_bitmask[3] = 0xc0000000; /* reserved */
+#endif
 	} else {
 		gopobj->info.pixel_format = EFI_GOT_BITMASK;
 		gopobj->info.pixel_bitmask[0] = 0xf800; /* red */
Signature · 1 line
2.33.0
#5 lore raw

Re: [PATCH 2/3] efi_loader: GOP: Add 30bpp support

Quoted 1 line · Mark Kettenis

Provide correct framebuffer information for 30bpp modes.

This is not enough to get a correct GOP implementation for the 30bpp mode.

Have a look at efi_gop_pixel efi_vid16_to_blt_col() and efi_blt_col_to_vid16() and where they are used.

Quoted 27 lines
---
  lib/efi_loader/efi_gop.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
lib/efi_loader/efi_gop.c +2 -0
index 1206b2d7a2..42bf49b184 100644
@@ -227,6 +227,7 @@ static efi_uintn_t gop_get_bpp(struct efi_gop *this)
 
  	switch (gopobj->bpix) {
  #ifdef CONFIG_DM_VIDEO
+	case VIDEO_BPP30:
  	case VIDEO_BPP32:
  #else
  	case LCD_COLOR32:
@@ -468,6 +469,7 @@ efi_status_t efi_gop_register(void)
  	switch (bpix) {
  #ifdef CONFIG_DM_VIDEO
  	case VIDEO_BPP16:
+	case VIDEO_BPP30:
  	case VIDEO_BPP32:
  #else
  	case LCD_COLOR32:

lib/efi_loader/efi_gop.c efi_status_t efi_gop_register(void) · line 523

Quoted 4 lines
lib/efi_loader/efi_gop.c +1 -0
@@ -518,6 +520,14 @@ efi_status_t efi_gop_register(void)
  #endif
  	{
  		gopobj->info.pixel_format = EFI_GOT_BGRA8;
+#ifdef CONFIG_DM_VIDEO

This symbol is not 30bpp specific. Is there a Kconfig variable that we can use to hide 30bpp support where it is not needed?

Which modes does the M1 support?

Best regards

Heinrich

Quoted 11 lines
lib/efi_loader/efi_gop.c +7 -0
+	} else if (bpix == VIDEO_BPP30) {
+		gopobj->info.pixel_format = EFI_GOT_BITMASK;
+		gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */
+		gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */
+		gopobj->info.pixel_bitmask[2] = 0x000003ff; /* blue */
+		gopobj->info.pixel_bitmask[3] = 0xc0000000; /* reserved */
+#endif
  	} else {
  		gopobj->info.pixel_format = EFI_GOT_BITMASK;
  		gopobj->info.pixel_bitmask[0] = 0xf800; /* red */
#6 lore raw

Re: [PATCH 2/3] efi_loader: GOP: Add 30bpp support

Quoted 2 lines

From: Heinrich Schuchardt <[email protected]>
Date: Fri, 17 Sep 2021 04:56:31 +0200

Hi Heinrich,

Quoted 7 lines · Mark Kettenis
Quoted 1 line

Provide correct framebuffer information for 30bpp modes.

This is not enough to get a correct GOP implementation for the 30bpp mode.

Have a look at efi_gop_pixel efi_vid16_to_blt_col() and efi_blt_col_to_vid16() and where they are used.

Ah right. This does indeed not support EFI_GRAPHICS_OUTPUT_PROTOCOL.Blt() correctly. I shouldn't be too hard to translate between XRGB2101010 and XRGB8888. Any ideas how I could test that code?

Quoted 25 lines
Quoted 25 lines
---
  lib/efi_loader/efi_gop.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
lib/efi_loader/efi_gop.c +2 -0
index 1206b2d7a2..42bf49b184 100644
@@ -227,6 +227,7 @@ static efi_uintn_t gop_get_bpp(struct efi_gop *this)
 
  	switch (gopobj->bpix) {
  #ifdef CONFIG_DM_VIDEO
+	case VIDEO_BPP30:
  	case VIDEO_BPP32:
  #else
  	case LCD_COLOR32:
@@ -468,6 +469,7 @@ efi_status_t efi_gop_register(void)
  	switch (bpix) {
  #ifdef CONFIG_DM_VIDEO
  	case VIDEO_BPP16:
+	case VIDEO_BPP30:
  	case VIDEO_BPP32:
  #else
  	case LCD_COLOR32:
Quoted 8 lines

lib/efi_loader/efi_gop.c efi_status_t efi_gop_register(void) · line 523

Quoted 5 lines
lib/efi_loader/efi_gop.c +1 -0
@@ -518,6 +520,14 @@ efi_status_t efi_gop_register(void)
  #endif
  	{
  		gopobj->info.pixel_format = EFI_GOT_BGRA8;
+#ifdef CONFIG_DM_VIDEO

This symbol is not 30bpp specific. Is there a Kconfig variable that we can use to hide 30bpp support where it is not needed?

I quite deliberately didn't add a separate config option for 30bpp as there is very little code that is added to the already existing 32bpp code. In a sense 30bpp is just a different submode of the 32bpp support with just a different color map, so I thought it made sense to group it under CONFIG_VIDEO_32BPP. I did initially consider adding a separate config option for it, but it quickly turns into an #ifdef maze that makes it hard to understand the code.

The CONFIG_DM_VIDEO check is just there to make sure the 30bpp is only offered in the DM model. Based on recent discussions I expect the !CONFIG_DM_VIDEO case to disappear in the near feature so adding 30bpp support for the non-DM case doesn't make sense.

The EFI GOP code currently doesn't check the CONFIG_VIDEO_BPP16 and CONFIG_VIDEO_BPP32 defines to see which of these modes are enabled within U-Boot, so we don't "hide" 16bpp support on platforms that just support 32bpp either.

Quoted 1 line

Which modes does the M1 support?

We're not sure. It does support at least 8-bit (32bpp) and 10-bit (30bpp) color depth modes. But the firmware tends to come up with 10-bit color depth whenever it can and I'm not planning to add support for changing the framebuffer mode on the M1, since the interface to do that is "interesting" [1].

[1] See Alyssa Rozenzweig's talk at XDC 2021,
https://www.youtube.com/watch?v=uTZISTjqy9Q

Quoted 14 lines
Quoted 12 lines
lib/efi_loader/efi_gop.c +7 -0
+	} else if (bpix == VIDEO_BPP30) {
+		gopobj->info.pixel_format = EFI_GOT_BITMASK;
+		gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */
+		gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */
+		gopobj->info.pixel_bitmask[2] = 0x000003ff; /* blue */
+		gopobj->info.pixel_bitmask[3] = 0xc0000000; /* reserved */
+#endif
  	} else {
  		gopobj->info.pixel_format = EFI_GOT_BITMASK;
  		gopobj->info.pixel_bitmask[0] = 0xf800; /* red */
#7 lore raw

Re: [PATCH 2/3] efi_loader: GOP: Add 30bpp support

Quoted 8 lines · Mark Kettenis
Quoted 2 lines

From: Heinrich Schuchardt <[email protected]>
Date: Fri, 17 Sep 2021 04:56:31 +0200

Hi Heinrich,

Quoted 3 lines · Mark Kettenis
Quoted 1 line

Provide correct framebuffer information for 30bpp modes.

Quoted 8 lines
Quoted 4 lines

This is not enough to get a correct GOP implementation for the 30bpp mode.

Have a look at efi_gop_pixel efi_vid16_to_blt_col() and efi_blt_col_to_vid16() and where they are used.

Ah right. This does indeed not support EFI_GRAPHICS_OUTPUT_PROTOCOL.Blt() correctly. I shouldn't be too hard to translate between XRGB2101010 and XRGB8888. Any ideas how I could test that code?

setenv efi_selftest block image transfer
bootefi selftest

should show an animated submarine with yellow portholes similar to

https://gist.github.com/xypron/7e1f73408465da71e3ef946250e76776#file-sub-png

Best regards

Heinrich

Quoted 77 lines
Quoted 26 lines
Quoted 26 lines
---
   lib/efi_loader/efi_gop.c | 10 ++++++++++
   1 file changed, 10 insertions(+)
lib/efi_loader/efi_gop.c +2 -0
index 1206b2d7a2..42bf49b184 100644
@@ -227,6 +227,7 @@ static efi_uintn_t gop_get_bpp(struct efi_gop *this)
 
   	switch (gopobj->bpix) {
   #ifdef CONFIG_DM_VIDEO
+	case VIDEO_BPP30:
   	case VIDEO_BPP32:
   #else
   	case LCD_COLOR32:
@@ -468,6 +469,7 @@ efi_status_t efi_gop_register(void)
   	switch (bpix) {
   #ifdef CONFIG_DM_VIDEO
   	case VIDEO_BPP16:
+	case VIDEO_BPP30:
   	case VIDEO_BPP32:
   #else
   	case LCD_COLOR32:
Quoted 8 lines

lib/efi_loader/efi_gop.c efi_status_t efi_gop_register(void) · line 523

Quoted 5 lines
lib/efi_loader/efi_gop.c +1 -0
@@ -518,6 +520,14 @@ efi_status_t efi_gop_register(void)
   #endif
   	{
   		gopobj->info.pixel_format = EFI_GOT_BGRA8;
+#ifdef CONFIG_DM_VIDEO

This symbol is not 30bpp specific. Is there a Kconfig variable that we can use to hide 30bpp support where it is not needed?

I quite deliberately didn't add a separate config option for 30bpp as there is very little code that is added to the already existing 32bpp code. In a sense 30bpp is just a different submode of the 32bpp support with just a different color map, so I thought it made sense to group it under CONFIG_VIDEO_32BPP. I did initially consider adding a separate config option for it, but it quickly turns into an #ifdef maze that makes it hard to understand the code.

The CONFIG_DM_VIDEO check is just there to make sure the 30bpp is only offered in the DM model. Based on recent discussions I expect the !CONFIG_DM_VIDEO case to disappear in the near feature so adding 30bpp support for the non-DM case doesn't make sense.

The EFI GOP code currently doesn't check the CONFIG_VIDEO_BPP16 and CONFIG_VIDEO_BPP32 defines to see which of these modes are enabled within U-Boot, so we don't "hide" 16bpp support on platforms that just support 32bpp either.

Quoted 1 line

Which modes does the M1 support?

We're not sure. It does support at least 8-bit (32bpp) and 10-bit (30bpp) color depth modes. But the firmware tends to come up with 10-bit color depth whenever it can and I'm not planning to add support for changing the framebuffer mode on the M1, since the interface to do that is "interesting" [1].

[1] See Alyssa Rozenzweig's talk at XDC 2021,
https://www.youtube.com/watch?v=uTZISTjqy9Q

Quoted 14 lines
Quoted 12 lines
lib/efi_loader/efi_gop.c +7 -0
+	} else if (bpix == VIDEO_BPP30) {
+		gopobj->info.pixel_format = EFI_GOT_BITMASK;
+		gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */
+		gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */
+		gopobj->info.pixel_bitmask[2] = 0x000003ff; /* blue */
+		gopobj->info.pixel_bitmask[3] = 0xc0000000; /* reserved */
+#endif
   	} else {
   		gopobj->info.pixel_format = EFI_GOT_BITMASK;
   		gopobj->info.pixel_bitmask[0] = 0xf800; /* red */
#8 lore raw

Re: [PATCH 2/3] efi_loader: GOP: Add 30bpp support

Quoted 21 lines

From: Heinrich Schuchardt <[email protected]>
Date: Fri, 17 Sep 2021 13:29:06 +0200

Quoted 8 lines · Mark Kettenis
Quoted 2 lines

From: Heinrich Schuchardt <[email protected]>
Date: Fri, 17 Sep 2021 04:56:31 +0200

Hi Heinrich,

Quoted 3 lines · Mark Kettenis
Quoted 1 line

Provide correct framebuffer information for 30bpp modes.

Quoted 8 lines
Quoted 4 lines

This is not enough to get a correct GOP implementation for the 30bpp mode.

Have a look at efi_gop_pixel efi_vid16_to_blt_col() and efi_blt_col_to_vid16() and where they are used.

Ah right. This does indeed not support EFI_GRAPHICS_OUTPUT_PROTOCOL.Blt() correctly. I shouldn't be too hard to translate between XRGB2101010 and XRGB8888. Any ideas how I could test that code?

Quoted 8 lines

setenv efi_selftest block image transfer
bootefi selftest

should show an animated submarine with yellow portholes similar to

https://gist.github.com/xypron/7e1f73408465da71e3ef946250e76776#file-sub-png

Best regards

Cool thanks. Looks like my implementation works! I'll wait a bit for feedback on the other diffs in this series before sending a v2 with that.

Cheers,

Mark

Quoted 77 lines
Quoted 76 lines
Quoted 25 lines
Quoted 25 lines
---
   lib/efi_loader/efi_gop.c | 10 ++++++++++
   1 file changed, 10 insertions(+)
lib/efi_loader/efi_gop.c +2 -0
index 1206b2d7a2..42bf49b184 100644
@@ -227,6 +227,7 @@ static efi_uintn_t gop_get_bpp(struct efi_gop *this)
 
   	switch (gopobj->bpix) {
   #ifdef CONFIG_DM_VIDEO
+	case VIDEO_BPP30:
   	case VIDEO_BPP32:
   #else
   	case LCD_COLOR32:
@@ -468,6 +469,7 @@ efi_status_t efi_gop_register(void)
   	switch (bpix) {
   #ifdef CONFIG_DM_VIDEO
   	case VIDEO_BPP16:
+	case VIDEO_BPP30:
   	case VIDEO_BPP32:
   #else
   	case LCD_COLOR32:
Quoted 8 lines

lib/efi_loader/efi_gop.c efi_status_t efi_gop_register(void) · line 523

Quoted 5 lines
lib/efi_loader/efi_gop.c +1 -0
@@ -518,6 +520,14 @@ efi_status_t efi_gop_register(void)
   #endif
   	{
   		gopobj->info.pixel_format = EFI_GOT_BGRA8;
+#ifdef CONFIG_DM_VIDEO

This symbol is not 30bpp specific. Is there a Kconfig variable that we can use to hide 30bpp support where it is not needed?

I quite deliberately didn't add a separate config option for 30bpp as there is very little code that is added to the already existing 32bpp code. In a sense 30bpp is just a different submode of the 32bpp support with just a different color map, so I thought it made sense to group it under CONFIG_VIDEO_32BPP. I did initially consider adding a separate config option for it, but it quickly turns into an #ifdef maze that makes it hard to understand the code.

The CONFIG_DM_VIDEO check is just there to make sure the 30bpp is only offered in the DM model. Based on recent discussions I expect the !CONFIG_DM_VIDEO case to disappear in the near feature so adding 30bpp support for the non-DM case doesn't make sense.

The EFI GOP code currently doesn't check the CONFIG_VIDEO_BPP16 and CONFIG_VIDEO_BPP32 defines to see which of these modes are enabled within U-Boot, so we don't "hide" 16bpp support on platforms that just support 32bpp either.

Quoted 1 line

Which modes does the M1 support?

We're not sure. It does support at least 8-bit (32bpp) and 10-bit (30bpp) color depth modes. But the firmware tends to come up with 10-bit color depth whenever it can and I'm not planning to add support for changing the framebuffer mode on the M1, since the interface to do that is "interesting" [1].

[1] See Alyssa Rozenzweig's talk at XDC 2021,
https://www.youtube.com/watch?v=uTZISTjqy9Q

Quoted 14 lines
Quoted 12 lines
lib/efi_loader/efi_gop.c +7 -0
+	} else if (bpix == VIDEO_BPP30) {
+		gopobj->info.pixel_format = EFI_GOT_BITMASK;
+		gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */
+		gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */
+		gopobj->info.pixel_bitmask[2] = 0x000003ff; /* blue */
+		gopobj->info.pixel_bitmask[3] = 0xc0000000; /* reserved */
+#endif
   	} else {
   		gopobj->info.pixel_format = EFI_GOT_BITMASK;
   		gopobj->info.pixel_bitmask[0] = 0xf800; /* red */
Tested-by on v1 2/3
#9 lore raw

Re: [PATCH 2/3] efi_loader: GOP: Add 30bpp support

In reply to Mark Kettenis

Hi Mark,

Quoted 29 lines · Mark Kettenis

Provide correct framebuffer information for 30bpp modes.

---
 lib/efi_loader/efi_gop.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/efi_loader/efi_gop.c +2 -0
index 1206b2d7a2..42bf49b184 100644
@@ -227,6 +227,7 @@ static efi_uintn_t gop_get_bpp(struct efi_gop *this)
 
        switch (gopobj->bpix) {
 #ifdef CONFIG_DM_VIDEO
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
 #else
        case LCD_COLOR32:
@@ -468,6 +469,7 @@ efi_status_t efi_gop_register(void)
        switch (bpix) {
 #ifdef CONFIG_DM_VIDEO
        case VIDEO_BPP16:
+       case VIDEO_BPP30:
        case VIDEO_BPP32:
 #else
        case LCD_COLOR32:

lib/efi_loader/efi_gop.c efi_status_t efi_gop_register(void) · line 523

Quoted 4 lines
lib/efi_loader/efi_gop.c +1 -0
@@ -518,6 +520,14 @@ efi_status_t efi_gop_register(void)
 #endif
        {
                gopobj->info.pixel_format = EFI_GOT_BGRA8;
+#ifdef CONFIG_DM_VIDEO

Can avoid #ifdefs please? Does this work?

if (IS_ENABLED(CONFIG_DM_VIDEO) && IS_ENABLED(CONFIG_VIDEO_BPP30) && bpix == VIDEO_BPP30)

Heinrich might know if we can just require DM_VIDEO.

Quoted 11 lines
lib/efi_loader/efi_gop.c +7 -1
+       } else if (bpix == VIDEO_BPP30) {
+               gopobj->info.pixel_format = EFI_GOT_BITMASK;
+               gopobj->info.pixel_bitmask[0] = 0x3ff00000; /* red */
+               gopobj->info.pixel_bitmask[1] = 0x000ffc00; /* green */
+               gopobj->info.pixel_bitmask[2] = 0x000003ff; /* blue */
+               gopobj->info.pixel_bitmask[3] = 0xc0000000; /* reserved */
+#endif
        } else {
                gopobj->info.pixel_format = EFI_GOT_BITMASK;
                gopobj->info.pixel_bitmask[0] = 0xf800; /* red */
--
Quoted 2 lines

2.33.0

Tested on: Macbook Air M1

Regards,
Simon

#10 lore raw

PATCH 3/3 video: simplefb: Add 30bpp support

In reply to Mark Kettenis

Recognize the canonical format strings for framebuffers in 30bpp mode.

---
 drivers/video/simplefb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/video/simplefb.c +3 -0
index fd58426cf5..7e1cc4560f 100644
@@ -52,6 +52,9 @@ static int simple_video_probe(struct udevice *dev)
 		uc_priv->bpix = VIDEO_BPP16;
 	} else if (strcmp(format, "a8b8g8r8") == 0) {
 		uc_priv->bpix = VIDEO_BPP32;
+	} else if (strcmp(format, "a2r10g10b10") == 0 ||
+		   strcmp(format, "x2r10g10b10") == 0) {
+		uc_priv->bpix = VIDEO_BPP30;
 	} else {
 		printf("%s: invalid format: %s\n", __func__, format);
 		return -EINVAL;
Signature · 1 line
2.33.0
Reviewed-by Tested-by on v1 3/3
#11 lore raw

Re: [PATCH 3/3] video: simplefb: Add 30bpp support

Quoted 24 lines · Mark Kettenis

Recognize the canonical format strings for framebuffers in 30bpp mode.

---
 drivers/video/simplefb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/video/simplefb.c +3 -1
index fd58426cf5..7e1cc4560f 100644
@@ -52,6 +52,9 @@ static int simple_video_probe(struct udevice *dev)
                uc_priv->bpix = VIDEO_BPP16;
        } else if (strcmp(format, "a8b8g8r8") == 0) {
                uc_priv->bpix = VIDEO_BPP32;
+       } else if (strcmp(format, "a2r10g10b10") == 0 ||
+                  strcmp(format, "x2r10g10b10") == 0) {
+               uc_priv->bpix = VIDEO_BPP30;
        } else {
                printf("%s: invalid format: %s\n", __func__, format);
                return -EINVAL;
--
Quoted 2 lines

2.33.0

Tested on: Macbook Air M1