This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 0f14427658f6fa236af50bb5f453050738b2d9d8 Author: Matteo Golin <[email protected]> AuthorDate: Sat May 30 11:17:17 2026 -0400 bcm2711/fb: Use physical device resolution OR force resolution This change causes the frame buffer allocation to use the connected device's physical resolution by default. The user also has the option to force a request for a different, compile-time selected resolution if the physical display can support something else the user would prefer. Signed-off-by: Matteo Golin <[email protected]> --- arch/arm64/src/bcm2711/Kconfig | 20 ++++++++++++++++++++ arch/arm64/src/bcm2711/bcm2711_fb.c | 33 ++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/arch/arm64/src/bcm2711/Kconfig b/arch/arm64/src/bcm2711/Kconfig index 2228d41ccc3..d4fd57fc985 100644 --- a/arch/arm64/src/bcm2711/Kconfig +++ b/arch/arm64/src/bcm2711/Kconfig @@ -340,6 +340,26 @@ config BCM2711_FRAMEBUFFER ---help--- Support for the VideoCore frame buffer interface. +config BCM2711_FB_WIDTH + int "Default x resolution (width)" + default 1920 + ---help--- + The x resolution (width) of the frame buffer. + +config BCM2711_FB_HEIGHT + int "Default y resolution (height)" + default 1080 + ---help--- + The y resolution (height) of the frame buffer. + +config BCM2711_FB_FORCE_RESOLUTION + bool "Force resolution" + depends on VIDEO_FB + default n + ---help--- + Force the frame buffer allocation to use the default resolution instead + of querying the physical display and using that. + endmenu # Broadcom BCM2711 Peripheral Selection endif # ARCH_CHIP_BCM2711 diff --git a/arch/arm64/src/bcm2711/bcm2711_fb.c b/arch/arm64/src/bcm2711/bcm2711_fb.c index 1ede3c7a1eb..8ee0e4c09e7 100644 --- a/arch/arm64/src/bcm2711/bcm2711_fb.c +++ b/arch/arm64/src/bcm2711/bcm2711_fb.c @@ -46,11 +46,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Screen resolution */ - -#define FB_WIDTH (1920) -#define FB_HEIGHT (1080) - /* Bits per pixel (32 for RGB) */ #define FB_BPP (32) @@ -344,8 +339,8 @@ int up_fbinitialize(int display) { int err; uint8_t tries = 0; - uint32_t xres = FB_WIDTH; - uint32_t yres = FB_HEIGHT; + uint32_t xres = CONFIG_BCM2711_FB_WIDTH; + uint32_t yres = CONFIG_BCM2711_FB_HEIGHT; uint32_t bpp = FB_BPP; struct bcm2711_fb_s *priv; @@ -371,6 +366,24 @@ int up_fbinitialize(int display) priv->fb = NULL; priv->fbsize = 0; +#ifndef CONFIG_BCM2711_FB_FORCE_RESOLUTION + /* Ask for physical resolution to choose the frame buffer resolution */ + + err = bcm2711_mbox_getdisp(&xres, &yres); + if (err < 0) + { + gerr("Couldn't get display dimensions: %d", err); + return err; + } + + err = bcm2711_mbox_getdepth(&bpp); + if (err < 0) + { + gerr("Couldn't get display depth: %d", err); + return err; + } +#endif + /* Initialize the frame-buffer in a bulk request. Doing this piece-wise * never seems to work, always resulting a virtual resolution of 2x2 px. * This attempts the initialization three times since the operation always @@ -391,12 +404,14 @@ int up_fbinitialize(int display) return err; } - if (xres != FB_WIDTH || yres != FB_HEIGHT) +#ifdef CONFIG_BCM2711_FB_FORCE_RESOLUTION + if (xres != CONFIG_BCM2711_FB_WIDTH || yres != CONFIG_BCM2711_FB_HEIGHT) { gerr("Display mismatch: wanted %u x %u px, but got %u x %u px", - FB_WIDTH, FB_HEIGHT, xres, yres); + CONFIG_BCM2711_FB_WIDTH, CONFIG_BCM2711_FB_HEIGHT, xres, yres); return -EIO; } +#endif if (bpp != FB_BPP) {
