u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: "Ivan T. Ivanov" <iivanov@suse.de>
To: Matthias Brugger <mbrugger@suse.com>,
	Peter Robinson <pbrobinson@gmail.com>
Cc: Dmitry Malkin <dmitry@bedrocksystems.com>,
	Thomas Fitzsimmons <fitzsim@fitzsim.org>,
	Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Anatolij Gustschin <agust@denx.de>,
	wahrenst@gmx.net, florian.fainelli@broadcom.com,
	u-boot@lists.denx.de, "Ivan T. Ivanov" <iivanov@suse.de>
Subject: [PATCH v5 4/7] bcm2835: Dynamically calculate bytes per pixel parameter
Date: Tue, 23 Jan 2024 10:07:56 +0200	[thread overview]
Message-ID: <20240123080819.13625-5-iivanov@suse.de> (raw)
In-Reply-To: <20240123080819.13625-1-iivanov@suse.de>

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>
Signed-off-by: Ivan T. Ivanov <iivanov@suse.de>
---
 drivers/video/bcm2835.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c
index 14942526f1..63efa762db 100644
--- a/drivers/video/bcm2835.c
+++ b/drivers/video/bcm2835.c
@@ -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;
 
-- 
2.43.0


  parent reply	other threads:[~2024-01-23  8:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23  8:07 [PATCH v5 0/7] rpi5: initial support Ivan T. Ivanov
2024-01-23  8:07 ` [PATCH v5 1/7] rpi5: add initial memory map for bcm2712 Ivan T. Ivanov
2024-01-23  8:07 ` [PATCH v5 2/7] rpi5: Use devicetree as alternative way to read IO base addresses Ivan T. Ivanov
2024-01-23  8:07 ` [PATCH v5 3/7] rpi5: Use devicetree to retrieve board revision Ivan T. Ivanov
2024-01-23  8:07 ` Ivan T. Ivanov [this message]
2024-01-23  8:07 ` [PATCH v5 5/7] mmc: bcmstb: Add support for bcm2712 SD controller Ivan T. Ivanov
2024-01-23  8:07 ` [PATCH v5 6/7] configs: rpi_arm64: enable SDHCI BCMSTB driver Ivan T. Ivanov
2024-01-23  8:07 ` [PATCH v5 7/7] configs: rpi_arm64: build position independent code Ivan T. Ivanov
2024-01-23 12:27 ` [PATCH v5 0/7] rpi5: initial support Jens Maus
2024-01-29 14:57   ` Darko Alavanja

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=20240123080819.13625-5-iivanov@suse.de \
    --to=iivanov@suse.de \
    --cc=agust@denx.de \
    --cc=dmitry@bedrocksystems.com \
    --cc=fitzsim@fitzsim.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=jh80.chung@samsung.com \
    --cc=mbrugger@suse.com \
    --cc=pbrobinson@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    --cc=wahrenst@gmx.net \
    /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;
as well as URLs for NNTP newsgroup(s).