diff --git a/ChangeLog b/ChangeLog index 0e53645e7f..45ce3331f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2598,3 +2598,7 @@ DAC. Contriburted by by Lzzy. * graphics/nxconsole: Add a character driver that can be used as a console output device for text output (still under development on initial check-in). + * graphics/nxmu: Fix several compilation errors that have crept into the multi- + user NX server because of lack of use. + * graphics/nxconsole: The NX text console is basically function (in multi- + user NX mode only). diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 58ce7d9ba2..854cf585b9 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -387,6 +387,8 @@ nx11 -#CONFIGURED_APPS += examples/nxconsole +CONFIGURED_APPS += examples/nxconsole + See apps/examples/README.txt for further details. + ostest Description diff --git a/configs/sim/nx/defconfig b/configs/sim/nx/defconfig index 05cfbf5acd..f8139b32ca 100644 --- a/configs/sim/nx/defconfig +++ b/configs/sim/nx/defconfig @@ -457,7 +457,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=8 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/configs/sim/nx11/defconfig b/configs/sim/nx11/defconfig index d3962c49bd..d8b1d6019e 100644 --- a/configs/sim/nx11/defconfig +++ b/configs/sim/nx11/defconfig @@ -458,7 +458,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=32 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/configs/stm3210e-eval/README.txt b/configs/stm3210e-eval/README.txt index 0cf7f5cbd4..ff90b2c15d 100755 --- a/configs/stm3210e-eval/README.txt +++ b/configs/stm3210e-eval/README.txt @@ -17,6 +17,7 @@ Contents - Temperature Sensor - RTC - STM3210E-EVAL-specific Configuration Options + - NxConsole - Configurations Development Environment @@ -350,6 +351,28 @@ RTC overflow interrupt may be lost even if the STM32 is powered down only momentarily. Therefore hi-res solution is only useful in systems where the power is always on. +NxConsole +========= + + Several of the graphic-releted configurations are set to use the + examples/nxconsole test. To enable this configuration, + First, select NX Multi-User mode: + + CONFG_NX_MULTIUSER=y + CONFIG_DISABLE_MQUEUE=n + + Then add the following definition to the defconfig file to enable + the NxConsole driver: + + CONFIG_NXCONSOLE=y + + Make sure the that following is in place the appconfig file (perhaps + eliminating other examples): + + CONFIGURED_APPS += examples/nxconsole + + See apps/examples/README.txt for further details. + STM3210E-EVAL-specific Configuration Options ============================================ diff --git a/configs/stm3210e-eval/nsh2/defconfig b/configs/stm3210e-eval/nsh2/defconfig index 1891c7e21f..228abf2309 100644 --- a/configs/stm3210e-eval/nsh2/defconfig +++ b/configs/stm3210e-eval/nsh2/defconfig @@ -1076,7 +1076,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/configs/stm3210e-eval/nx/defconfig b/configs/stm3210e-eval/nx/defconfig index f1a5d46d32..02cafd33d7 100644 --- a/configs/stm3210e-eval/nx/defconfig +++ b/configs/stm3210e-eval/nx/defconfig @@ -926,7 +926,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/configs/stm3210e-eval/nxlines/defconfig b/configs/stm3210e-eval/nxlines/defconfig index 0175dc9b5a..fa067ae41c 100644 --- a/configs/stm3210e-eval/nxlines/defconfig +++ b/configs/stm3210e-eval/nxlines/defconfig @@ -925,7 +925,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/configs/stm3210e-eval/nxtext/defconfig b/configs/stm3210e-eval/nxtext/defconfig index 0b92dac457..753b69190d 100644 --- a/configs/stm3210e-eval/nxtext/defconfig +++ b/configs/stm3210e-eval/nxtext/defconfig @@ -925,7 +925,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/graphics/nxconsole/nxcon_font.c b/graphics/nxconsole/nxcon_font.c index c8336a289a..436f91477d 100644 --- a/graphics/nxconsole/nxcon_font.c +++ b/graphics/nxconsole/nxcon_font.c @@ -47,6 +47,8 @@ #include #include +#include + #include #include #include @@ -103,14 +105,16 @@ * Name: nxcon_freeglyph ****************************************************************************/ +#ifdef CONFIG_NXCONSOLE_FONTCACHE static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) { if (glyph->bitmap) { - free(glyph->bitmap); + kfree(glyph->bitmap); } memset(glyph, 0, sizeof(struct nxcon_glyph_s)); } +#endif /**************************************************************************** * Name: nxcon_allocglyph @@ -183,9 +187,6 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv) luglyph->usecnt = 1; return luglyph; #else - /* TODO: Instead allocating an freeing, just allocate the max glyph once */ - - nxcon_freeglyph(&priv->glyph); return &priv->glyph; #endif } @@ -236,7 +237,6 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, #if CONFIG_NXCONSOLE_BPP < 8 nxgl_mxpixel_t pixel; #endif - int bmsize; int row; int col; int ret; @@ -255,29 +255,50 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, glyph->width = fbm->metric.width + fbm->metric.xoffset; glyph->height = fbm->metric.height + fbm->metric.yoffset; - /* Allocate memory to hold the glyph with its offsets */ + /* Get the physical width of the glyph in bytes */ glyph->stride = (glyph->width * CONFIG_NXCONSOLE_BPP + 7) / 8; - bmsize = glyph->stride * glyph->height; - glyph->bitmap = (FAR uint8_t *)malloc(bmsize); + + /* Allocate memory to hold the glyph with its offsets */ + +#ifdef CONFIG_NXCONSOLE_FONTCACHE + { + DEBUGASSERT(glyph->bitmap == NULL); + int bmsize = glyph->stride * glyph->height; + glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize); + } +#else + DEBUGASSERT(glyph->bitmap != NULL); +#endif if (glyph->bitmap) { - /* Initialize the glyph memory to the background color */ + /* Initialize the glyph memory to the background color using the + * hard-coded bits-per-pixel (BPP). + * + * TODO: The rest of NX is configured to support multiple devices + * with differing BPP. They logic should be extended to support + * differing BPP's as well. + */ #if CONFIG_NXCONSOLE_BPP < 8 pixel = priv->wcolor[0]; + # if CONFIG_NXCONSOLE_BPP == 1 + /* Pack 1-bit pixels into a 2-bits */ pixel &= 0x01; - pixel = (pixel) << 1 |pixel; + pixel = (pixel) << 1 | pixel; + # endif # if CONFIG_NXCONSOLE_BPP < 4 + /* Pack 2-bit pixels into a nibble */ pixel &= 0x03; - pixel = (pixel) << 2 |pixel; + pixel = (pixel) << 2 | pixel; + # endif /* Pack 4-bit nibbles into a byte */ @@ -323,7 +344,9 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, /* Actually, the RENDERER never returns a failure */ gdbg("nxcon_renderglyph: RENDERER failed\n"); +#ifdef CONFIG_NXCONSOLE_FONTCACHE nxcon_freeglyph(glyph); +#endif glyph = NULL; } } diff --git a/graphics/nxconsole/nxcon_internal.h b/graphics/nxconsole/nxcon_internal.h index f5cbc9c6d5..963511b298 100644 --- a/graphics/nxconsole/nxcon_internal.h +++ b/graphics/nxconsole/nxcon_internal.h @@ -55,53 +55,6 @@ /**************************************************************************** * Definitions ****************************************************************************/ -/* Configuration ************************************************************/ -/* The maximum number of characters that can be remembered */ - -#ifndef CONFIG_NXCONSOLE_MXCHARS -# define CONFIG_NXCONSOLE_MXCHARS 128 -#endif - -/* Font cache -- this is the number or pre-rendered font glyphs that can be - * remembered. - */ - -#ifdef CONFIG_NXCONSOLE_FONTCACHE -# ifndef CONFIG_NXCONSOLE_CACHESIZE -# define CONFIG_NXCONSOLE_CACHESIZE 16 -# endif -#else -# undef CONFIG_NXCONSOLE_CACHESIZE -#endif - -/* Pixel depth */ - -#ifndef CONFIG_NXCONSOLE_BPP -# if !defined(CONFIG_NX_DISABLE_1BPP) -# define CONFIG_NXCONSOLE_BPP 1 -# elif !defined(CONFIG_NX_DISABLE_2BPP) -# define CONFIG_NXCONSOLE_BPP 2 -# elif !defined(CONFIG_NX_DISABLE_4BPP) -# define CONFIG_NXCONSOLE_BPP 4 -# elif !defined(CONFIG_NX_DISABLE_8BPP) -# define CONFIG_NXCONSOLE_BPP 8 -# elif !defined(CONFIG_NX_DISABLE_16BPP) -# define CONFIG_NXCONSOLE_BPP 16 -//#elif !defined(CONFIG_NX_DISABLE_24BPP) -//# define CONFIG_NXCONSOLE_BPP 24 -# elif !defined(CONFIG_NX_DISABLE_32BPP) -# define CONFIG_NXCONSOLE_BPP 32 -# else -# error "No pixel depth provided" -# endif -#endif - -/* Space (in rows) between lines */ - -#ifndef CONFIG_NXCONSOLE_LINESEPARATION -# define CONFIG_NXCONSOLE_LINESEPARATION 2 -#endif - /* NxConsole Definitions ****************************************************/ /* Bitmap flags */ diff --git a/graphics/nxconsole/nxcon_redraw.c b/graphics/nxconsole/nxcon_redraw.c index 23bebd6225..1a40a7ee16 100755 --- a/graphics/nxconsole/nxcon_redraw.c +++ b/graphics/nxconsole/nxcon_redraw.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -112,6 +113,25 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor priv = (FAR struct nxcon_state_s *)handle; + /* Get exclusive access to the state structure */ + + do + { + ret = sem_wait(&priv->exclsem); + + /* Check for errors */ + + if (ret < 0) + { + /* The only expected error is if the wait failed because of it + * was interrupted by a signal. + */ + + DEBUGASSERT(errno == EINTR); + } + } + while (ret < 0); + /* Fill the rectangular region with the window background color */ ret = priv->ops->fill(priv, rect, priv->wndo.wcolor); @@ -128,4 +148,5 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor { nxcon_fillchar(priv, rect, &priv->bm[i]); } + ret = sem_post(&priv->exclsem); } diff --git a/graphics/nxconsole/nxcon_register.c b/graphics/nxconsole/nxcon_register.c index cc878b2399..78f6a10519 100644 --- a/graphics/nxconsole/nxcon_register.c +++ b/graphics/nxconsole/nxcon_register.c @@ -120,13 +120,32 @@ FAR struct nxcon_state_s * priv->fwidth = fontset->mxwidth; priv->spwidth = fontset->spwidth; - /* Set up the text caches */ + /* Set up the text cache */ priv->maxchars = CONFIG_NXCONSOLE_MXCHARS; + + /* Set up the font glyph bitmap cache (if enabled) */ + #ifdef CONFIG_NXCONSOLE_FONTCACHE priv->maxglyphs = CONFIG_NXCONSOLE_CACHESIZE; #endif + /* Pre-allocate maximal sized glyph bitmap memory (only if we are not + * using the glyph cache. + */ + +#ifndef CONFIG_NXCONSOLE_FONTCACHE + { + int allocsize = (priv->fheight * priv->fwidth * CONFIG_NXCONSOLE_BPP + 7) >> 3; + priv->glyph.bitmap = (FAR uint8_t *)kmalloc(allocsize); + if (!priv->glyph.bitmap) + { + gdbg("Failed to allocate glyph memory\n"); + goto errout; + } + } +#endif + /* Set the initial display position */ nxcon_home(priv); diff --git a/graphics/nxconsole/nxcon_unregister.c b/graphics/nxconsole/nxcon_unregister.c index 8a19736edd..25dbd40c66 100644 --- a/graphics/nxconsole/nxcon_unregister.c +++ b/graphics/nxconsole/nxcon_unregister.c @@ -97,6 +97,12 @@ void nxcon_unregister(NXCONSOLE handle) priv = (FAR struct nxcon_state_s *)handle; sem_destroy(&priv->exclsem); + /* Free the pre-allocated glyph bitmap */ + +#ifndef CONFIG_NXCONSOLE_FONTCACHE + kfree(priv->glyph.bitmap); +#endif + /* Unregister the driver */ snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, priv->minor); diff --git a/graphics/nxmu/nx_disconnect.c b/graphics/nxmu/nx_disconnect.c index 24fb114f49..f4711b0053 100644 --- a/graphics/nxmu/nx_disconnect.c +++ b/graphics/nxmu/nx_disconnect.c @@ -94,7 +94,7 @@ void nx_disconnect(NXHANDLE handle) /* Inform the server that this client no longer exists */ - msg.msgid = NX_SVRMSG_CONNECT; + msg.msgid = NX_SVRMSG_DISCONNECT; msg.conn = conn; ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO); diff --git a/graphics/nxmu/nx_releasebkgd.c b/graphics/nxmu/nx_releasebkgd.c index 4e8a756790..99815b1e71 100644 --- a/graphics/nxmu/nx_releasebkgd.c +++ b/graphics/nxmu/nx_releasebkgd.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nx_releasebkgd.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/graphics/nxmu/nxmu_server.c b/graphics/nxmu/nxmu_server.c index 9cd9e578a9..fbd03464fd 100644 --- a/graphics/nxmu/nxmu_server.c +++ b/graphics/nxmu/nxmu_server.c @@ -129,31 +129,6 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn) } } -/**************************************************************************** - * Name: nxmu_release - ****************************************************************************/ - -static int nxmu_release(FAR struct nxfe_state_s *fe) -{ - FAR struct nxbe_window_s *wnd; - struct nxclimsg_s outmsg; - int ret; - - /* Don't want windows to close while we do this */ - - for (wnd = fe->be.topwnd; wnd; wnd = wnd->below) - { - outmsg.msgid = NX_CLIMSG_DISCONNECTED; - ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_s), NX_CLIMSG_PRIO); - if (ret < 0) - { - gdbg("mq_send failed: %d\n", errno); - } - } - - return OK; -} - /**************************************************************************** * Name: nxmu_shutdown ****************************************************************************/ diff --git a/include/nuttx/nx/nxconsole.h b/include/nuttx/nx/nxconsole.h index 0a66e4c032..61d79860c4 100644 --- a/include/nuttx/nx/nxconsole.h +++ b/include/nuttx/nx/nxconsole.h @@ -94,6 +94,52 @@ * that the text is simply truncated until a new line is encountered. */ +/* The maximum number of characters that can be remembered */ + +#ifndef CONFIG_NXCONSOLE_MXCHARS +# define CONFIG_NXCONSOLE_MXCHARS 128 +#endif + +/* Font cache -- this is the number or pre-rendered font glyphs that can be + * remembered. + */ + +#ifdef CONFIG_NXCONSOLE_FONTCACHE +# ifndef CONFIG_NXCONSOLE_CACHESIZE +# define CONFIG_NXCONSOLE_CACHESIZE 16 +# endif +#else +# undef CONFIG_NXCONSOLE_CACHESIZE +#endif + +/* Pixel depth */ + +#ifndef CONFIG_NXCONSOLE_BPP +# if !defined(CONFIG_NX_DISABLE_1BPP) +# define CONFIG_NXCONSOLE_BPP 1 +# elif !defined(CONFIG_NX_DISABLE_2BPP) +# define CONFIG_NXCONSOLE_BPP 2 +# elif !defined(CONFIG_NX_DISABLE_4BPP) +# define CONFIG_NXCONSOLE_BPP 4 +# elif !defined(CONFIG_NX_DISABLE_8BPP) +# define CONFIG_NXCONSOLE_BPP 8 +# elif !defined(CONFIG_NX_DISABLE_16BPP) +# define CONFIG_NXCONSOLE_BPP 16 +//#elif !defined(CONFIG_NX_DISABLE_24BPP) +//# define CONFIG_NXCONSOLE_BPP 24 +# elif !defined(CONFIG_NX_DISABLE_32BPP) +# define CONFIG_NXCONSOLE_BPP 32 +# else +# error "No pixel depth provided" +# endif +#endif + +/* Space (in rows) between lines */ + +#ifndef CONFIG_NXCONSOLE_LINESEPARATION +# define CONFIG_NXCONSOLE_LINESEPARATION 2 +#endif + /**************************************************************************** * Public Types ****************************************************************************/