]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bcm2835: Dynamically calculate bytes per pixel parameter
authorIvan T. Ivanov <iivanov@suse.de>
Tue, 23 Jan 2024 08:07:56 +0000 (10:07 +0200)
committerMatthias Brugger <matthias.bgg@gmail.com>
Tue, 30 Jan 2024 16:39:51 +0000 (17:39 +0100)
brcm,bcm2708-fb device provided by firmware on RPi5 uses
16 bits per pixel, so lets calculate framebuffer bytes
per pixel dynamically based on queried information.

Tested to work for RPi2b v1.2, RPi3b v1.3, RPi4b v1.1,
RPi2 Zero W, RPi5b v1.0.

Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Tested-by: Jens Maus <mail@jens-maus.de>
Tested-by: Darko Alavanja <darko.alavanja@konsulko.com>
Signed-off-by: Ivan T. Ivanov <iivanov@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
drivers/video/bcm2835.c

index 14942526f19db7955ed4b2c40986690e43bbe2cf..63efa762db160abe5e15dcf80b10831b8bd9234c 100644 (file)
@@ -16,7 +16,7 @@ static int bcm2835_video_probe(struct udevice *dev)
        struct video_uc_plat *plat = dev_get_uclass_plat(dev);
        struct video_priv *uc_priv = dev_get_uclass_priv(dev);
        int ret;
-       int w, h, pitch;
+       int w, h, pitch, bpp;
        ulong fb_base, fb_size, fb_start, fb_end;
 
        debug("bcm2835: Query resolution...\n");
@@ -41,9 +41,23 @@ static int bcm2835_video_probe(struct udevice *dev)
                                        DCACHE_WRITEBACK);
        video_set_flush_dcache(dev, true);
 
+       bpp = pitch / w;
+       switch (bpp) {
+       case 2:
+               uc_priv->bpix = VIDEO_BPP16;
+               break;
+       case 4:
+               uc_priv->bpix = VIDEO_BPP32;
+               break;
+       default:
+               printf("bcm2835: unexpected bpp %d, pitch %d, width %d\n",
+                      bpp, pitch, w);
+               uc_priv->bpix = VIDEO_BPP32;
+               break;
+       }
+
        uc_priv->xsize = w;
        uc_priv->ysize = h;
-       uc_priv->bpix = VIDEO_BPP32;
        plat->base = fb_base;
        plat->size = fb_size;