From 69ef693d6f964404ef5d278f2f29ab7d26022f04 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 30 Nov 2008 18:52:14 +0000 Subject: There is at least some X11 output now git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1361 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/sim/src/Makefile | 2 +- nuttx/arch/sim/src/up_framebuffer.c | 31 +++++++------- nuttx/arch/sim/src/up_x11framebuffer.c | 77 +++++++++++++++++++++------------- 3 files changed, 63 insertions(+), 47 deletions(-) (limited to 'nuttx/arch') diff --git a/nuttx/arch/sim/src/Makefile b/nuttx/arch/sim/src/Makefile index 6897f2f63..eace0a903 100644 --- a/nuttx/arch/sim/src/Makefile +++ b/nuttx/arch/sim/src/Makefile @@ -45,7 +45,7 @@ CSRCS = up_initialize.c up_idle.c up_interruptcontext.c \ up_releasepending.c up_reprioritizertr.c \ up_exit.c up_schedulesigaction.c up_allocateheap.c \ up_devconsole.c up_framebuffer.c -HOSTSRCS = up_stdio.c up_x11framebuffer.c +HOSTSRCS = up_stdio.c up_hostusleep.c up_x11framebuffer.c ifeq ($(CONFIG_FS_FAT),y) CSRCS += up_blockdevice.c up_deviceimage.c endif diff --git a/nuttx/arch/sim/src/up_framebuffer.c b/nuttx/arch/sim/src/up_framebuffer.c index f81a5512b..c7c9ee216 100644 --- a/nuttx/arch/sim/src/up_framebuffer.c +++ b/nuttx/arch/sim/src/up_framebuffer.c @@ -124,7 +124,7 @@ extern int up_x11initialize(unsigned short width, unsigned short height, #ifdef CONFIG_FB_CMAP extern int up_x11cmap(unsigned short first, unsigned short len, unsigned char *red, unsigned char *green, - unsigned char *blue, unsigned char *transp) + unsigned char *blue, unsigned char *transp); #endif #endif @@ -132,7 +132,11 @@ extern int up_x11cmap(unsigned short first, unsigned short len, * Private Data ****************************************************************************/ +/* The simulated framebuffer memory */ + +#ifndef CONFIG_SIM_X11FB static ubyte g_fb[FB_SIZE]; +#endif /* This structure describes the simulated video controller */ @@ -160,12 +164,6 @@ static const struct fb_planeinfo_s g_planeinfo = static struct fb_planeinfo_s g_planeinfo; #endif -/* Simulated RGB mapping */ - -#ifdef CONFIG_FB_CMAP -static struct fb_cmap_s g_cmap; -#endif - /* Current cursor position */ #ifdef CONFIG_FB_HWCURSOR @@ -245,16 +243,13 @@ static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno, #ifdef CONFIG_FB_CMAP static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap) { -#ifdef CONFIG_SIM_X11FB - return up_x11cmap(cmap->start, cmap->len, cmap->red, cmap->green, cmap->blue, cmap->transp); -#else - int len + int len; int i; - dbg("vtable=%p cmap=%p cmap->len\n", vtable, cmap, cmap->len); + dbg("vtable=%p cmap=%p len=%d\n", vtable, cmap, cmap->len); if (vtable && cmap) { - for (i = cmap.first, len = 0; i < 256 && len < cmap.len, i++, len++) + for (i = cmap->first, len = 0; i < 256 && len < cmap->len; i++, len++) { cmap->red[i] = i; cmap->green[i] = i; @@ -263,12 +258,12 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap cmap->transp[i] = i; #endif } - cmap.len = len; + + cmap->len = len; return OK; } dbg("Returning EINVAL\n"); return -EINVAL; -#endif } #endif @@ -279,13 +274,17 @@ static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap #ifdef CONFIG_FB_CMAP static int up_putcmap(FAR struct fb_vtable_s *vtable, FAR const struct fb_cmap_s *cmap) { - dbg("vtable=%p cmap=%p cmap->len\n", vtable, cmap, cmap->len); +#ifdef CONFIG_SIM_X11FB + return up_x11cmap(cmap->first, cmap->len, cmap->red, cmap->green, cmap->blue, NULL); +#else + dbg("vtable=%p cmap=%p len=%d\n", vtable, cmap, cmap->len); if (vtable && cmap) { return OK; } dbg("Returning EINVAL\n"); return -EINVAL; +#endif } #endif diff --git a/nuttx/arch/sim/src/up_x11framebuffer.c b/nuttx/arch/sim/src/up_x11framebuffer.c index d19a56f80..346f1380f 100644 --- a/nuttx/arch/sim/src/up_x11framebuffer.c +++ b/nuttx/arch/sim/src/up_x11framebuffer.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/sim/src/up_framebuffer.c + * arch/sim/src/up_x11framebuffer.c * * Copyright (C) 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -170,12 +170,12 @@ static int up_x11untraperrors(void) #endif /**************************************************************************** - * Name: up_x11uninitialize + * Name: up_x11uninitX ***************************************************************************/ -void up_x11uninitialize(void) +static void up_x11uninitX(void) { - fprintf(stderr, "Uninitalizing\n"); + fprintf(stderr, "Uninitalizing X\n"); #ifndef CONFIG_SIM_X11NOSHM if (g_shmcheckpoint > 4) { @@ -196,9 +196,24 @@ void up_x11uninitialize(void) if (g_shmcheckpoint > 1) { XDestroyImage(g_image); - if (!b_useshm) + } + XCloseDisplay(g_display); +} + +/**************************************************************************** + * Name: up_x11uninitialize + ***************************************************************************/ + +#ifndef CONFIG_SIM_X11NOSHM +static void up_x11uninitialize(void) +{ + fprintf(stderr, "Uninitalizing\n"); + if (g_shmcheckpoint > 1) + { + if (!b_useshm && g_framebuffer) { free(g_framebuffer); + g_framebuffer = 0; } } @@ -206,8 +221,8 @@ void up_x11uninitialize(void) { g_shmcheckpoint = 1; } - XCloseDisplay(g_display); } +#endif /**************************************************************************** * Name: up_x11mapsharedmem @@ -219,7 +234,7 @@ static inline int up_x11mapsharedmem(int bpp, unsigned int fblen) Status result; #endif - atexit(up_x11uninitialize); + atexit(up_x11uninitX); g_shmcheckpoint = 1; b_useshm = 0; @@ -289,7 +304,7 @@ shmerror: g_framebuffer = (unsigned char*)malloc(fblen); g_image = XCreateImage(g_display, DefaultVisual(g_display,g_screen), bpp, - ZPixmap, 0, (char *) g_framebuffer, g_fbpixelwidth, g_fbpixelheight, + ZPixmap, 0, (char*)g_framebuffer, g_fbpixelwidth, g_fbpixelheight, 8, 0); if (g_image == NULL) @@ -303,27 +318,6 @@ shmerror: return 0; } -/**************************************************************************** - * Name: up_x11update - ***************************************************************************/ - -static void up_x11update(void) -{ -#ifndef CONFIG_SIM_X11NOSHM - if (b_useshm) - { - XShmPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0, - g_fbpixelwidth, g_fbpixelheight, 0); - } - else -#endif - { - XPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0, - g_fbpixelwidth, g_fbpixelheight); - } - XSync(g_display, 0); -} - /**************************************************************************** * Public Functions ***************************************************************************/ @@ -363,12 +357,13 @@ int up_x11initialize(unsigned short width, unsigned short height, *bpp = windowAttributes.depth; *stride = (windowAttributes.depth * width / 8); - *fbmem = (void*)g_framebuffer; *fblen = (*stride * height); /* Map the window to shared memory */ up_x11mapsharedmem(windowAttributes.depth, *fblen); + + *fbmem = (void*)g_framebuffer; return 0; } @@ -411,3 +406,25 @@ int up_x11cmap(unsigned short first, unsigned short len, return 0; } + +/**************************************************************************** + * Name: up_x11update + ***************************************************************************/ + +void up_x11update(void) +{ +#ifndef CONFIG_SIM_X11NOSHM + if (b_useshm) + { + XShmPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0, + g_fbpixelwidth, g_fbpixelheight, 0); + } + else +#endif + { + XPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0, + g_fbpixelwidth, g_fbpixelheight); + } + XSync(g_display, 0); +} + -- cgit v1.2.3