diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-03-30 22:49:08 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-03-30 22:49:08 +0000 |
commit | d14549a7db7f1449763ccb40f676860e414ecd36 (patch) | |
tree | 5cba9b70ef679b51a066c54102b96ee40f87126c /nuttx/graphics/nxconsole | |
parent | 7b4b14ec2acf251ba72ef2929011037bfc26e714 (diff) | |
download | px4-nuttx-d14549a7db7f1449763ccb40f676860e414ecd36.tar.gz px4-nuttx-d14549a7db7f1449763ccb40f676860e414ecd36.tar.bz2 px4-nuttx-d14549a7db7f1449763ccb40f676860e414ecd36.zip |
More fixes for NxConsole driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4543 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxconsole')
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_font.c | 29 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_internal.h | 10 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_register.c | 20 | ||||
-rwxr-xr-x | nuttx/graphics/nxconsole/nxcon_scroll.c | 4 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_unregister.c | 14 |
5 files changed, 19 insertions, 58 deletions
diff --git a/nuttx/graphics/nxconsole/nxcon_font.c b/nuttx/graphics/nxconsole/nxcon_font.c index cb5320d25..2677b9c15 100644 --- a/nuttx/graphics/nxconsole/nxcon_font.c +++ b/nuttx/graphics/nxconsole/nxcon_font.c @@ -39,9 +39,12 @@ #include <nuttx/config.h> +#include <string.h> #include <assert.h> #include <debug.h> +#include <nuttx/kmalloc.h> + #include "nxcon_internal.h" /**************************************************************************** @@ -94,7 +97,6 @@ * Name: nxcon_freeglyph ****************************************************************************/ -#ifdef CONFIG_NXCONSOLE_FONTCACHE static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) { if (glyph->bitmap) @@ -103,7 +105,6 @@ static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) } memset(glyph, 0, sizeof(struct nxcon_glyph_s)); } -#endif /**************************************************************************** * Name: nxcon_allocglyph @@ -112,7 +113,6 @@ static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) static inline FAR struct nxcon_glyph_s * nxcon_allocglyph(FAR struct nxcon_state_s *priv) { -#ifdef CONFIG_NXCONSOLE_FONTCACHE FAR struct nxcon_glyph_s *glyph = NULL; FAR struct nxcon_glyph_s *luglyph = NULL; uint8_t luusecnt; @@ -175,16 +175,12 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv) luglyph->usecnt = 1; return luglyph; -#else - return &priv->glyph; -#endif } /**************************************************************************** * Name: nxcon_findglyph ****************************************************************************/ -#ifdef CONFIG_NXCONSOLE_FONTCACHE static FAR struct nxcon_glyph_s * nxcon_findglyph(FAR struct nxcon_state_s *priv, uint8_t ch) { @@ -211,7 +207,6 @@ nxcon_findglyph(FAR struct nxcon_state_s *priv, uint8_t ch) } return NULL; } -#endif /**************************************************************************** * Name: nxcon_renderglyph @@ -226,6 +221,7 @@ 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; @@ -246,15 +242,8 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, /* 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 + bmsize = glyph->stride * glyph->height; + glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize); if (glyph->bitmap) { @@ -329,9 +318,7 @@ 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; } } @@ -374,7 +361,6 @@ nxcon_getglyph(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch) /* First, try to find the glyph in the cache of pre-rendered glyphs */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE glyph = nxcon_findglyph(priv, ch); if (glyph) { @@ -382,9 +368,6 @@ nxcon_getglyph(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch) return glyph; } -#else - glyph = NULL; -#endif /* No, it is not cached... Does the code map to a font? */ diff --git a/nuttx/graphics/nxconsole/nxcon_internal.h b/nuttx/graphics/nxconsole/nxcon_internal.h index 996ea9d5d..ebcab909b 100644 --- a/nuttx/graphics/nxconsole/nxcon_internal.h +++ b/nuttx/graphics/nxconsole/nxcon_internal.h @@ -119,9 +119,7 @@ struct nxcon_glyph_s uint8_t height; /* Height of this glyph (in rows) */ uint8_t width; /* Width of this glyph (in pixels) */ uint8_t stride; /* Width of the glyph row (in bytes) */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE uint8_t usecnt; /* Use count */ -#endif FAR uint8_t *bitmap; /* Allocated bitmap memory */ }; @@ -155,9 +153,7 @@ struct nxcon_state_s uint8_t fheight; /* Max height of a font in pixels */ uint8_t fwidth; /* Max width of a font in pixels */ uint8_t spwidth; /* The width of a space */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE uint8_t maxglyphs; /* Size of the glyph[] array */ -#endif /* VT100 escape sequence processing */ @@ -170,13 +166,7 @@ struct nxcon_state_s /* Glyph cache data storage */ -#ifdef CONFIG_NXCONSOLE_FONTCACHE struct nxcon_glyph_s glyph[CONFIG_NXCONSOLE_CACHESIZE]; -#else - /* A glyph cache of size one -- all fonts will be re-rendered on each use */ - - struct nxcon_glyph_s glyph; -#endif }; /**************************************************************************** diff --git a/nuttx/graphics/nxconsole/nxcon_register.c b/nuttx/graphics/nxconsole/nxcon_register.c index 78f6a1051..663764dce 100644 --- a/nuttx/graphics/nxconsole/nxcon_register.c +++ b/nuttx/graphics/nxconsole/nxcon_register.c @@ -124,27 +124,9 @@ FAR struct nxcon_state_s * priv->maxchars = CONFIG_NXCONSOLE_MXCHARS; - /* Set up the font glyph bitmap cache (if enabled) */ + /* Set up the font glyph bitmap cache */ -#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 */ diff --git a/nuttx/graphics/nxconsole/nxcon_scroll.c b/nuttx/graphics/nxconsole/nxcon_scroll.c index b0a1a2335..882c99ed8 100755 --- a/nuttx/graphics/nxconsole/nxcon_scroll.c +++ b/nuttx/graphics/nxconsole/nxcon_scroll.c @@ -87,7 +87,7 @@ * only. ****************************************************************************/ -#ifndef CONFIG_NXCONSOLE_NOGETRUN +#ifdef CONFIG_NXCONSOLE_NOGETRUN static inline void nxcon_movedisplay(FAR struct nxcon_state_s *priv, int bottom, int scrollheight) { @@ -170,7 +170,7 @@ static inline void nxcon_movedisplay(FAR struct nxcon_state_s *priv, /* Move the source rectangle */ - ret = priv->move(priv, &rect, &offset); + ret = priv->ops->move(priv, &rect, &offset); if (ret < 0) { gdbg("move failed: %d\n", errno); diff --git a/nuttx/graphics/nxconsole/nxcon_unregister.c b/nuttx/graphics/nxconsole/nxcon_unregister.c index 25dbd40c6..e516ef64a 100644 --- a/nuttx/graphics/nxconsole/nxcon_unregister.c +++ b/nuttx/graphics/nxconsole/nxcon_unregister.c @@ -89,6 +89,7 @@ void nxcon_unregister(NXCONSOLE handle) { FAR struct nxcon_state_s *priv; char devname[NX_DEVNAME_SIZE]; + int i; DEBUGASSERT(handle); @@ -97,11 +98,16 @@ void nxcon_unregister(NXCONSOLE handle) priv = (FAR struct nxcon_state_s *)handle; sem_destroy(&priv->exclsem); - /* Free the pre-allocated glyph bitmap */ + /* Free all allocated glyph bitmap */ -#ifndef CONFIG_NXCONSOLE_FONTCACHE - kfree(priv->glyph.bitmap); -#endif + for (i = 0; i < CONFIG_NXCONSOLE_CACHESIZE; i++) + { + FAR struct nxcon_glyph_s *glyph = &priv->glyph[i]; + if (glyph->bitmap) + { + kfree(glyph->bitmap); + } + } /* Unregister the driver */ |