From 47dabf17aa210d2659c311884baed34889b15f59 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 14 Oct 2017 12:25:41 -0600 Subject: [PATCH] graphics/traveler: Restore most of what was removed in the previous commit. That non-standard logic is currently needed by the simulation. It should be replaced with use of a framebuffer driver. --- graphics/traveler/Kconfig | 2 +- graphics/traveler/src/trv_graphics.c | 85 +++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/graphics/traveler/Kconfig b/graphics/traveler/Kconfig index 806f3b260..656a085d5 100644 --- a/graphics/traveler/Kconfig +++ b/graphics/traveler/Kconfig @@ -7,7 +7,7 @@ config GRAPHICS_TRAVELER bool "Traveler game" default n select FSUTILS_INIFILE - depends on NX_MULTIUSER + depends on !NX || NX_MULTIUSER ---help--- Enable or disable the graphic Traveler game diff --git a/graphics/traveler/src/trv_graphics.c b/graphics/traveler/src/trv_graphics.c index c0adc76de..133371b71 100644 --- a/graphics/traveler/src/trv_graphics.c +++ b/graphics/traveler/src/trv_graphics.c @@ -98,6 +98,89 @@ static void trv_use_bgwindow(FAR struct trv_graphics_info_s *ginfo) } #endif +/**************************************************************************** + * Name: trv_get_fbdev + * + * Description: + * Get the system framebuffer device + * + ****************************************************************************/ + +#ifndef CONFIG_NX +static FAR struct fb_vtable_s *trv_get_fbdev(void) +{ + FAR struct fb_vtable_s *fbdev; + int ret; + + /* Initialize the frame buffer device */ + + ret = up_fbinitialize(0); + if (ret < 0) + { + trv_abort("ERROR: up_fbinitialize() failed: %d\n", -ret); + } + + /* Set up to use video plane 0. There is no support for anything but + * video plane 0. + */ + + fbdev = up_fbgetvplane(0,0); + if (!fbdev) + { + trv_abort("ERROR: up_fbgetvplane() failed\n"); + } + + return fbdev; +} +#endif + +/**************************************************************************** + * Name: trv_fb_initialize + * + * Description: + * Get the system framebuffer device (only used on simulator) + * + ****************************************************************************/ + +#ifndef CONFIG_NX +static void trv_fb_initialize(FAR struct trv_graphics_info_s *ginfo) +{ + struct fb_videoinfo_s vinfo; + struct fb_planeinfo_s pinfo; + FAR struct fb_vtable_s *fbdev; + int ret; + + /* Get the framebuffer device */ + + fbdev = trv_get_fbdev(); + + /* Get information about video plane 0 */ + + ret = fbdev->getvideoinfo(fbdev, &vinfo); + if (ret < 0) + { + trv_abort("ERROR: getvideoinfo() failed\n"); + } + + ginfo->xres = vinfo.xres; + ginfo->yres = vinfo.yres; + + ret = fbdev->getplaneinfo(fbdev, 0, &pinfo); + if (ret < 0) + { + trv_abort("ERROR: getplaneinfo() failed\n"); + } + + ginfo->stride = pinfo.stride; + ginfo->hwbuffer = pinfo.fbmem; + + if (vinfo.fmt != TRV_COLOR_FMT || pinfo.bpp != TRV_BPP) + { + trv_abort("ERROR: Bad color format(%d)/bpp(%d)\n", vinfo.fmt, pinfo.bpp); + } +} +#endif + /**************************************************************************** * Name: trv_nx_initialize ****************************************************************************/ @@ -257,7 +340,7 @@ int trv_graphics_initialize(FAR struct trv_graphics_info_s *ginfo) /* Initialize the graphics device and get information about the display */ -#if !defined(CONFIG_NX) +#ifndef CONFIG_NX trv_fb_initialize(ginfo); #else trv_nx_initialize(ginfo);