diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 95d4b9f63..b170601ef 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -591,4 +591,6 @@ 0.3.20 2008-xx-xx Gregory Nutt * Initial release of a tiny windowing system for NuttX (not well tested at initial check-in) * Add fixed precision sin() and cos() (not well tested at initial check-in) - + * Add an X11-based simulated framebuffer driver + * The simulated target now has an option (CONFIG_SIM_WALLTIME) that will let the simulation + run in more-or-less realtime. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 6dcce8b58..ecf01aa7c 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -1207,6 +1207,9 @@ buildroot-0.1.2 2007-11-06 <spudmonkey@racsa.co.cr> nuttx-0.3.20 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * Initial release of a tiny windowing system for NuttX (not well tested at initial check-in) * Add fixed precision sin() and cos() (not well tested at initial check-in) + * Add an X11-based simulated framebuffer driver + * The simulated target now has an option (CONFIG_SIM_WALLTIME) that will let the simulation + run in more-or-less realtime. pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/TODO b/nuttx/TODO index e69cc20e6..5a2a00fad 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -16,7 +16,7 @@ NuttX TODO List (Last updated November 20, 2008) (3) Build system (2) NuttShell (NSH) (examples/nsh) (1) Other Applications & Tests (examples/) - (2) Linux/Cywgin simulation (arch/sim) + (1) Linux/Cywgin simulation (arch/sim) (2) ARM (arch/arm/) (1) ARM/C5471 (arch/arm/src/c5471/) (3) ARM/DM320 (arch/arm/src/dm320/) @@ -383,14 +383,7 @@ o Other Applications & Tests (examples/) o Linux/Cywgin simulation (arch/sim) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Description: Need to implement timing. Use system timing resources to fake - a NuttX real time clock. At present, the timer is driven in - non-realtime (like 1000x realtime) and causes some behavior - differences from real platforms. - Status: Open - Priority: Low (because the simulator is only a test/development platform) - - Description: The simulated serial driver also has some odd behavior. It + Description: The simulated serial driver has some odd behavior. It will stall for a long time on reads when the C stdio buffers are being refilled. This only effects the behavior of things like fgetc(). Workaround: Set CONFIG_STDIO_BUFFER_SIZE=0, suppressing 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); +} + diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 8e8fe42f1..aed86deff 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -50,6 +50,11 @@ nx - The default in defconfig is to use a generic memory buffer for the framebuffer. defconfig-x11 is an example with X11 support enabled. + - The default is the single-user NX implementation. To select + the multi-user NX implementation: + + CONFG_NX_MULTIUSER=y + CONFIG_DISABLE_MQUEUE=n ostest diff --git a/nuttx/configs/sim/nx/defconfig b/nuttx/configs/sim/nx/defconfig index 1eaa2ca54..33e7732bb 100644 --- a/nuttx/configs/sim/nx/defconfig +++ b/nuttx/configs/sim/nx/defconfig @@ -124,7 +124,7 @@ CONFIG_DEV_LOWCONSOLE=n CONFIG_DISABLE_CLOCK=n CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_DISABLE_PTHREAD=y -CONFIG_DISABLE_SIGNALS=y +CONFIG_DISABLE_SIGNALS=n CONFIG_DISABLE_MQUEUE=y CONFIG_DISABLE_MOUNTPOINT=y CONFIG_DISABLE_ENVIRON=y diff --git a/nuttx/configs/sim/nx/defconfig-x11 b/nuttx/configs/sim/nx/defconfig-x11 index 58ae6a81d..be2feabbc 100644 --- a/nuttx/configs/sim/nx/defconfig-x11 +++ b/nuttx/configs/sim/nx/defconfig-x11 @@ -124,7 +124,7 @@ CONFIG_DEV_LOWCONSOLE=n CONFIG_DISABLE_CLOCK=n CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_DISABLE_PTHREAD=y -CONFIG_DISABLE_SIGNALS=y +CONFIG_DISABLE_SIGNALS=n CONFIG_DISABLE_MQUEUE=y CONFIG_DISABLE_MOUNTPOINT=y CONFIG_DISABLE_ENVIRON=y diff --git a/nuttx/examples/nx/nx_internal.h b/nuttx/examples/nx/nx_internal.h index fa3120906..40bf62059 100644 --- a/nuttx/examples/nx/nx_internal.h +++ b/nuttx/examples/nx/nx_internal.h @@ -54,19 +54,37 @@ #endif #ifndef CONFIG_EXAMPLES_NX_VPLANE -# define CONFIG_EXAMPLES_NX_VPLANE 0 +# define CONFIG_EXAMPLES_NX_VPLANE 0 #endif #ifndef CONFIG_EXAMPLES_NX_BGCOLOR -# define CONFIG_EXAMPLES_NX_BGCOLOR ' ' +# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32 +# define CONFIG_EXAMPLES_NX_BGCOLOR 0x00602020 +# elif CONFIG_SIM_FBBPP = 16 +# define CONFIG_EXAMPLES_NX_BGCOLOR 0x3088 +# else +# define CONFIG_EXAMPLES_NX_BGCOLOR ' ' +# endif #endif #ifndef CONFIG_EXAMPLES_NX_COLOR1 -# define CONFIG_EXAMPLES_NX_COLOR1 '1' +# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32 +# define CONFIG_EXAMPLES_NX_COLOR1 0x00606020 +# elif CONFIG_SIM_FBBPP = 16 +# define CONFIG_EXAMPLES_NX_COLOR1 0x30c8 +# else +# define CONFIG_EXAMPLES_NX_COLOR1 '1' +# endif #endif #ifndef CONFIG_EXAMPLES_NX_COLOR2 -# define CONFIG_EXAMPLES_NX_COLOR2 '2' +# if CONFIG_SIM_FBBPP == 24 || CONFIG_SIM_FBBPP == 32 +# define CONFIG_EXAMPLES_NX_COLOR2 0x00606060 +# elif CONFIG_SIM_FBBPP = 16 +# define CONFIG_EXAMPLES_NX_COLOR2 0x30cc +# else +# define CONFIG_EXAMPLES_NX_COLOR2 '2' +# endif #endif #ifdef CONFIG_NX_MULTIUSER diff --git a/nuttx/graphics/nxbe/nxbe.h b/nuttx/graphics/nxbe/nxbe.h index 393a06075..5f5e14b76 100644 --- a/nuttx/graphics/nxbe/nxbe.h +++ b/nuttx/graphics/nxbe/nxbe.h @@ -55,6 +55,10 @@ # define CONFIG_NX_NPLANES 1 /* Max number of color planes supported */ #endif +#ifndef CONFIG_NX_NCOLORS +# define CONFIG_NX_NCOLORS 256 +#endif + /* These are the values for the clipping order provided to nx_clipper */ #define NX_CLIPORDER_TLRB (0) /* Top-left-right-bottom */ @@ -199,7 +203,7 @@ extern "C" { ****************************************************************************/ #if CONFIG_FB_CMAP -EXTERN int nxbe_colormap(FAR const fb_vtable_s *fb); +EXTERN int nxbe_colormap(FAR struct fb_vtable_s *fb); #endif /**************************************************************************** diff --git a/nuttx/graphics/nxbe/nxbe_colormap.c b/nuttx/graphics/nxbe/nxbe_colormap.c index 2d4b34b7f..509cf4f45 100644 --- a/nuttx/graphics/nxbe/nxbe_colormap.c +++ b/nuttx/graphics/nxbe/nxbe_colormap.c @@ -40,9 +40,13 @@ #include #include +#include +#include #include #include +#include + #include "nxbe.h" /**************************************************************************** @@ -78,9 +82,9 @@ ****************************************************************************/ #if CONFIG_FB_CMAP -int nxbe_colormap(FAR const fb_vtable_s *fb) +int nxbe_colormap(FAR struct fb_vtable_s *fb) { - struct fb_cmap cmap; + struct fb_cmap_s cmap; ubyte *alloc; ubyte *red; ubyte *green; @@ -94,7 +98,7 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) /* Allocate the color map tables */ - size = 3 * NX_NCOLORS * sizeof(uint16); + size = 3 * CONFIG_NX_NCOLORS * sizeof(uint16); alloc = (ubyte*)malloc(size); if (alloc < 0) { @@ -103,8 +107,8 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) memset(alloc, 0xff, size); red = alloc; - green = &alloc[NX_NCOLORS]; - blue = &alloc[2*NX_NCOLORS]; + green = &alloc[CONFIG_NX_NCOLORS]; + blue = &alloc[2*CONFIG_NX_NCOLORS]; /* Initialize the color map tables. 6*6*6 = 216, the rest * are (0xffff, 0xffff, 0xffff) @@ -113,15 +117,15 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) ndx = 0; for (i = 0; i < 6; i++) { - rval = (i * (NX_NCOLORS-1) / 5) << 8; + rval = (i * (CONFIG_NX_NCOLORS-1) / 5) << 8; for (j = 0; j < 6; j++) { - gval = (j * (NX_NCOLORS-1) / 5) << 8; + gval = (j * (CONFIG_NX_NCOLORS-1) / 5) << 8; for (k = 0; k < 6; k++) { red[ndx] = rval; green[ndx] = gval; - blue[ndx] = k * (NX_NCOLORS-1) / 5; + blue[ndx] = k * (CONFIG_NX_NCOLORS-1) / 5; ndx++; } } @@ -129,7 +133,7 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) /* Now configure the cmap structure */ - cmap.len = NX_NCOLORS; + cmap.len = CONFIG_NX_NCOLORS; cmap.red = red; cmap.green = green; cmap.blue = blue; @@ -141,7 +145,7 @@ int nxbe_colormap(FAR const fb_vtable_s *fb) ret =fb->putcmap(fb, &cmap); - free(cmap); + free(alloc); return ret; } #endif diff --git a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c index 35ded6139..b20b46570 100644 --- a/nuttx/graphics/nxglib/nxglib_filltrapezoid.c +++ b/nuttx/graphics/nxglib/nxglib_filltrapezoid.c @@ -117,6 +117,12 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)( x1 = trap->top.x1; x2 = trap->top.x2; + /* Calculate the number of rows to render */ + + y1 = trap->top.y; + y2 = trap->bot.y; + nrows = y2 - y1 + 1; + /* Calculate the slope of the left and right side of the trapezoid */ dx1dy = b16divi((trap->bot.x1 - x1), nrows); @@ -124,28 +130,31 @@ void NXGL_FUNCNAME(nxgl_filltrapezoid,NXGLIB_SUFFIX)( /* Perform vertical clipping */ - y1 = trap->top.y; if (y1 < bounds->pt1.y) { + /* Calculate the x values for the new top run */ + int dy = bounds->pt1.y - y1; x1 += dy * dx1dy; x2 += dy * dx2dy; + + /* Clip and re-calculate the number of rows to render */ + y1 = bounds->pt1.y; + nrows = y2 - y1 + 1; } - y2 = trap->bot.y; if (y2 > bounds->pt2.y) { - y2 = bounds->pt2.y; + /* Clip and re-calculate the number of rows to render */ + + y2 = bounds->pt2.y; + nrows = y2 - y1 + 1; } - /* Then calculate the number of rows to render */ - - nrows = y2 - y1 + 1; - /* Get the address of the first byte on the first line */ - line = pinfo->fbmem + y1 * stride ; + line = pinfo->fbmem + y1 * stride ; /* Then fill the trapezoid line-by-line */ diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index c193dc7cb..186a22ea8 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -56,8 +56,6 @@ * Pre-Processor Definitions ****************************************************************************/ -#define NX_NCOLORS 256 - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/nuttx/include/nuttx/nxglib.h b/nuttx/include/nuttx/nxglib.h index 18284a2d4..5edd639aa 100644 --- a/nuttx/include/nuttx/nxglib.h +++ b/nuttx/include/nuttx/nxglib.h @@ -75,7 +75,7 @@ * the smallest common pixel representation: */ -#if !defined(CONFIG_NXGLIB_DISABLE_32BPP) || defined(CONFIG_NXGLIB_DISABLE_24BPP) +#if !defined(CONFIG_NXGLIB_DISABLE_32BPP) || !defined(CONFIG_NXGLIB_DISABLE_24BPP) typedef uint32 nxgl_mxpixel_t; #elif !defined(CONFIG_NXGLIB_DISABLE_16BPP) typedef uint16 nxgl_mxpixel_t;