Merge tag 'video-20220314' of https://source.denx.de/u-boot/custodians/u-boot-video
authorTom Rini <trini@konsulko.com>
Mon, 14 Mar 2022 22:39:26 +0000 (18:39 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 14 Mar 2022 22:39:26 +0000 (18:39 -0400)
 - fix display of the u-boot logo on Apple devices
 - convert Nokia RX-51 to CONFIG_DM_VIDEO

board/nokia/rx51/rx51.c
configs/nokia_rx51_defconfig
drivers/video/video-uclass.c
drivers/video/video_bmp.c
include/configs/nokia_rx51.h

index a526915..621cff0 100644 (file)
@@ -30,7 +30,7 @@
 #include <malloc.h>
 #include <twl4030.h>
 #include <i2c.h>
-#include <video_fb.h>
+#include <video.h>
 #include <keyboard.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
@@ -62,8 +62,6 @@ struct emu_hal_params_rx51 {
 
 DECLARE_GLOBAL_DATA_PTR;
 
-GraphicDevice gdev;
-
 const omap3_sysinfo sysinfo = {
        DDR_STACKED,
        "Nokia RX-51",
@@ -342,22 +340,28 @@ void setup_board_tags(struct tag **in_params)
        *in_params = params;
 }
 
-/*
- * Routine: video_hw_init
- * Description: Set up the GraphicDevice depending on sys_boot.
- */
-void *video_hw_init(void)
+static int rx51_video_probe(struct udevice *dev)
 {
-       /* fill in Graphic Device */
-       gdev.frameAdrs = 0x8f9c0000;
-       gdev.winSizeX = 800;
-       gdev.winSizeY = 480;
-       gdev.gdfBytesPP = 2;
-       gdev.gdfIndex = GDF_16BIT_565RGB;
-       memset((void *)gdev.frameAdrs, 0, 0xbb800);
-       return (void *) &gdev;
+       struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+       struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+
+       uc_plat->base = 0x8f9c0000;
+       uc_plat->size = 800 * 480 * sizeof(u16);
+       uc_priv->xsize = 800;
+       uc_priv->ysize = 480;
+       uc_priv->bpix = VIDEO_BPP16;
+
+       video_set_flush_dcache(dev, true);
+
+       return 0;
 }
 
+U_BOOT_DRIVER(rx51_video) = {
+       .name = "rx51_video",
+       .id = UCLASS_VIDEO,
+       .probe = rx51_video_probe,
+};
+
 /*
  * Routine: twl4030_regulator_set_mode
  * Description: Set twl4030 regulator mode over i2c powerbus.
@@ -777,6 +781,10 @@ U_BOOT_DRVINFOS(rx51_watchdog) = {
        { "rx51_watchdog" },
 };
 
+U_BOOT_DRVINFOS(rx51_video) = {
+       { "rx51_video" },
+};
+
 U_BOOT_DRVINFOS(rx51_kp) = {
        { "rx51_kp" },
 };
index 47b7bc3..1d64981 100644 (file)
@@ -77,8 +77,11 @@ CONFIG_SPI=y
 CONFIG_USB=y
 CONFIG_USB_MUSB_UDC=y
 CONFIG_USB_OMAP3=y
-CONFIG_CFB_CONSOLE=y
-CONFIG_CFB_CONSOLE_ANSI=y
+CONFIG_DM_VIDEO=y
+CONFIG_VIDEO_LOGO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP32 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_SPLASH_SCREEN=y
 CONFIG_WATCHDOG_TIMEOUT_MSECS=31000
 CONFIG_WDT=y
index 7d499bc..88797d4 100644 (file)
@@ -33,7 +33,8 @@
  * information represents the requires size and alignment of the frame buffer
  * for the device. The values can be an over-estimate but cannot be too
  * small. The actual values will be suppled (in the same manner) by the bind()
- * method after relocation.
+ * method after relocation. Additionally driver can allocate frame buffer
+ * itself by setting plat->base.
  *
  * This information is then picked up by video_reserve() which works out how
  * much memory is needed for all devices. This is allocated between
@@ -78,6 +79,10 @@ static ulong alloc_fb(struct udevice *dev, ulong *addrp)
        if (!plat->size)
                return 0;
 
+       /* Allow drivers to allocate the frame buffer themselves */
+       if (plat->base)
+               return 0;
+
        align = plat->align ? plat->align : 1 << 20;
        base = *addrp - plat->size;
        base &= ~(align - 1);
index c8c3fd3..4d2d961 100644 (file)
@@ -31,6 +31,18 @@ static uint get_bmp_col_16bpp(struct bmp_color_table_entry cte)
 }
 
 /**
+ * get_bmp_col_x2r10g10b10() - Convert a colour-table entry into a x2r10g10b10  pixel value
+ *
+ * Return: value to write to the x2r10g10b10 frame buffer for this palette entry
+ */
+static u32 get_bmp_col_x2r10g10b10(struct bmp_color_table_entry *cte)
+{
+       return ((cte->red << 22U) |
+               (cte->green << 12U) |
+               (cte->blue << 2U));
+}
+
+/**
  * write_pix8() - Write a pixel from a BMP image into the framebuffer
  *
  * This handles frame buffers with 8, 16, 24 or 32 bits per pixel
@@ -42,8 +54,8 @@ static uint get_bmp_col_16bpp(struct bmp_color_table_entry cte)
  *     which is either written directly (bpix == 8) or used to look up the
  *     palette to get a colour to write
  */
-static void write_pix8(u8 *fb, uint bpix, struct bmp_color_table_entry *palette,
-                      u8 *bmap)
+static void write_pix8(u8 *fb, uint bpix, enum video_format eformat,
+                      struct bmp_color_table_entry *palette, u8 *bmap)
 {
        if (bpix == 8) {
                *fb++ = *bmap;
@@ -57,6 +69,8 @@ static void write_pix8(u8 *fb, uint bpix, struct bmp_color_table_entry *palette,
                        *fb++ = cte->red;
                        *fb++ = cte->green;
                        *fb++ = cte->blue;
+               } else if (eformat == VIDEO_X2R10G10B10) {
+                       *(u32 *)fb = get_bmp_col_x2r10g10b10(cte);
                } else {
                        *fb++ = cte->blue;
                        *fb++ = cte->green;
@@ -66,28 +80,29 @@ static void write_pix8(u8 *fb, uint bpix, struct bmp_color_table_entry *palette,
        }
 }
 
-static void draw_unencoded_bitmap(u8 **fbp, uint bpix, uchar *bmap,
+static void draw_unencoded_bitmap(u8 **fbp, uint bpix,
+                                 enum video_format eformat, uchar *bmap,
                                  struct bmp_color_table_entry *palette,
                                  int cnt)
 {
        u8 *fb = *fbp;
 
        while (cnt > 0) {
-               write_pix8(fb, bpix, palette, bmap++);
+               write_pix8(fb, bpix, eformat, palette, bmap++);
                fb += bpix / 8;
                cnt--;
        }
        *fbp = fb;
 }
 
-static void draw_encoded_bitmap(u8 **fbp, uint bpix,
+static void draw_encoded_bitmap(u8 **fbp, uint bpix, enum video_format eformat,
                                struct bmp_color_table_entry *palette, u8 *bmap,
                                int cnt)
 {
        u8 *fb = *fbp;
 
        while (cnt > 0) {
-               write_pix8(fb, bpix, palette, bmap);
+               write_pix8(fb, bpix, eformat, palette, bmap);
                fb += bpix / 8;
                cnt--;
        }
@@ -106,6 +121,7 @@ static void video_display_rle8_bitmap(struct udevice *dev,
        int x, y;
        int decode = 1;
        uint bytes_per_pixel = bpix / 8;
+       enum video_format eformat = priv->format;
 
        debug("%s\n", __func__);
        bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
@@ -148,7 +164,7 @@ static void video_display_rle8_bitmap(struct udevice *dev,
                                                else
                                                        cnt = runlen;
                                                draw_unencoded_bitmap(
-                                                       &fb, bpix,
+                                                       &fb, bpix, eformat,
                                                        bmap, palette, cnt);
                                        }
                                        x += runlen;
@@ -173,8 +189,9 @@ static void video_display_rle8_bitmap(struct udevice *dev,
                                                cnt = width - x;
                                        else
                                                cnt = runlen;
-                                       draw_encoded_bitmap(&fb, bpix, palette,
-                                                           &bmap[1], cnt);
+                                       draw_encoded_bitmap(&fb, bpix, eformat,
+                                                           palette, &bmap[1],
+                                                           cnt);
                                }
                                x += runlen;
                        }
@@ -224,6 +241,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
        unsigned long width, height, byte_width;
        unsigned long pwidth = priv->xsize;
        unsigned colours, bpix, bmp_bpix;
+       enum video_format eformat;
        struct bmp_color_table_entry *palette;
        int hdr_size;
        int ret;
@@ -245,6 +263,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
        colours = 1 << bmp_bpix;
 
        bpix = VNBITS(priv->bpix);
+       eformat = priv->format;
 
        if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) {
                printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
@@ -312,7 +331,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                for (i = 0; i < height; ++i) {
                        WATCHDOG_RESET();
                        for (j = 0; j < width; j++) {
-                               write_pix8(fb, bpix, palette, bmap);
+                               write_pix8(fb, bpix, eformat, palette, bmap);
                                bmap++;
                                fb += bpix / 8;
                        }
@@ -345,6 +364,16 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                                                        (bmap[0] >> 3);
                                                bmap += 3;
                                                fb += 2;
+                                       } else if (eformat == VIDEO_X2R10G10B10) {
+                                               u32 pix;
+
+                                               pix = *bmap++ << 2U;
+                                               pix |= *bmap++ << 12U;
+                                               pix |= *bmap++ << 22U;
+                                               *fb++ = pix & 0xff;
+                                               *fb++ = (pix >> 8) & 0xff;
+                                               *fb++ = (pix >> 16) & 0xff;
+                                               *fb++ = pix >> 24;
                                        } else {
                                                *fb++ = *bmap++;
                                                *fb++ = *bmap++;
@@ -361,10 +390,23 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                if (IS_ENABLED(CONFIG_BMP_32BPP)) {
                        for (i = 0; i < height; ++i) {
                                for (j = 0; j < width; j++) {
-                                       *fb++ = *bmap++;
-                                       *fb++ = *bmap++;
-                                       *fb++ = *bmap++;
-                                       *fb++ = *bmap++;
+                                       if (eformat == VIDEO_X2R10G10B10) {
+                                               u32 pix;
+
+                                               pix = *bmap++ << 2U;
+                                               pix |= *bmap++ << 12U;
+                                               pix |= *bmap++ << 22U;
+                                               pix |= (*bmap++ >> 6) << 30U;
+                                               *fb++ = pix & 0xff;
+                                               *fb++ = (pix >> 8) & 0xff;
+                                               *fb++ = (pix >> 16) & 0xff;
+                                               *fb++ = pix >> 24;
+                                       } else {
+                                               *fb++ = *bmap++;
+                                               *fb++ = *bmap++;
+                                               *fb++ = *bmap++;
+                                               *fb++ = *bmap++;
+                                       }
                                }
                                fb -= priv->line_length + width * (bpix / 8);
                        }
index 9be64c3..e837b12 100644 (file)
 
 #define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
 
-/*
- * Framebuffer
- */
-/* Video console */
-#define VIDEO_FB_16BPP_PIXEL_SWAP
-#define VIDEO_FB_16BPP_WORD_SWAP
-
 /* Environment information */
 #define CONFIG_EXTRA_ENV_SETTINGS \
        "usbtty=cdc_acm\0" \
        "stdin=usbtty,serial,keyboard\0" \
-       "stdout=usbtty,serial,vga\0" \
-       "stderr=usbtty,serial,vga\0" \
+       "stdout=usbtty,serial,vidconsole\0" \
+       "stderr=usbtty,serial,vidconsole\0" \
        "slide=gpio input " __stringify(GPIO_SLIDE) "\0" \
        "switchmmc=mmc dev ${mmcnum}\0" \
        "kernaddr=0x82008000\0" \