From 179212d2ab73b866d39113dc36d11b5869122a96 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 18 Apr 2010 02:56:15 +0000 Subject: [PATCH] Code complete for NX for LCD git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2610 42af7a65-404d-4744-a932-0658087f49c3 --- configs/sam3u-ek/nsh/defconfig | 13 +-- graphics/nxbe/nxbe_configure.c | 6 +- graphics/nxglib/lcd/nxglib_copyrectangle.c | 98 ++++++++-------------- graphics/nxglib/nxglib_copyrun.h | 18 ++-- include/nuttx/lcd.h | 4 + 5 files changed, 58 insertions(+), 81 deletions(-) diff --git a/configs/sam3u-ek/nsh/defconfig b/configs/sam3u-ek/nsh/defconfig index 48f89c5541..7c36d45ab0 100755 --- a/configs/sam3u-ek/nsh/defconfig +++ b/configs/sam3u-ek/nsh/defconfig @@ -87,7 +87,7 @@ CONFIG_ARCH_BOOTLOADER=n CONFIG_ARCH_LEDS=y CONFIG_ARCH_BUTTONS=y CONFIG_ARCH_CALIBRATION=n -CONFIG_ARCH_DMA=n +CONFIG_ARCH_DMA=y # # Identify toolchain and linker options @@ -100,9 +100,9 @@ CONFIG_SAM3U_BUILDROOT=y # # Individual subsystems can be enabled: # -CONFIG_SAM3U_DMA=n +CONFIG_SAM3U_DMA=y CONFIG_SAM3U_NAND=n -CONFIG_SAM3U_HSMCI=n +CONFIG_SAM3U_HSMCI=y CONFIG_SAM3U_UART=y CONFIG_SAM3U_USART0=n CONFIG_SAM3U_USART1=n @@ -316,7 +316,7 @@ CONFIG_FDCLONE_DISABLE=n CONFIG_FDCLONE_STDIO=n CONFIG_SDCLONE_DISABLE=y CONFIG_NXFLAT=n -CONFIG_SCHED_WORKQUEUE=n +CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_WORKPRIORITY=50 CONFIG_SCHED_WORKPERIOD=(50*1000) CONFIG_SCHED_WORKSTACKSIZE=1024 @@ -461,12 +461,15 @@ CONFIG_FS_WRITEBUFFER=n # # CONFIG_SDIO_DMA # SDIO driver supports DMA +# CONFIG_SDIO_BLOCKSETUP +# Support block setup methods # CONFIG_MMCSD_MMCSUPPORT # Enable support for MMC cards # CONFIG_MMCSD_HAVECARDDETECT # SDIO driver card detection is 100% accurate # CONFIG_SDIO_DMA=n +CONFIG_SDIO_BLOCKSETUP=y CONFIG_MMCSD_MMCSUPPORT=n CONFIG_MMCSD_HAVECARDDETECT=n @@ -697,7 +700,7 @@ CONFIG_EXAMPLES_NSH_DISABLEBG=n CONFIG_EXAMPLES_NSH_ROMFSETC=n CONFIG_EXAMPLES_NSH_CONSOLE=y CONFIG_EXAMPLES_NSH_TELNET=n -CONFIG_EXAMPLES_NSH_ARCHINIT=n +CONFIG_EXAMPLES_NSH_ARCHINIT=y CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512 CONFIG_EXAMPLES_NSH_DHCPC=n CONFIG_EXAMPLES_NSH_NOMAC=n diff --git a/graphics/nxbe/nxbe_configure.c b/graphics/nxbe/nxbe_configure.c index 527c469758..881bcd99e0 100644 --- a/graphics/nxbe/nxbe_configure.c +++ b/graphics/nxbe/nxbe_configure.c @@ -78,14 +78,14 @@ * ****************************************************************************/ -int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be) +int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be) { int ret; int i; /* Get the video controller configuration */ - ret = fb->getvideoinfo(fb, &be->vinfo); + ret = dev->getvideoinfo(dev, &be->vinfo); if (ret < 0) { gdbg("Failed to get vinfo\n"); @@ -112,7 +112,7 @@ int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be) for (i = 0; i < be->vinfo.nplanes; i++) { - ret = fb->getplaneinfo(fb, i, &be->plane[i].pinfo); + ret = dev->getplaneinfo(dev, i, &be->plane[i].pinfo); if (ret < 0) { gdbg("Failed to get pinfo[%d]\n", i); diff --git a/graphics/nxglib/lcd/nxglib_copyrectangle.c b/graphics/nxglib/lcd/nxglib_copyrectangle.c index 8d73dcb739..8930305678 100755 --- a/graphics/nxglib/lcd/nxglib_copyrectangle.c +++ b/graphics/nxglib/lcd/nxglib_copyrectangle.c @@ -40,11 +40,13 @@ #include #include +#include #include #include #include "nxglib_bitblit.h" +#include "nxglib_copyrun.h" /**************************************************************************** * Pre-Processor Definitions @@ -85,89 +87,55 @@ void NXGL_FUNCNAME(nxgl_copyrectangle,NXGLIB_SUFFIX) unsigned int srcstride) { FAR const uint8_t *sline; - unsigned int width; - unsigned int rows; - + unsigned int ncols; + unsigned int row; + unsigned int xoffset; #if NXGLIB_BITSPERPIXEL < 8 - FAR const uint8_t *sptr; - FAR uint8_t *dptr; - uint8_t leadmask; - uint8_t tailmask; - uint8_t mask; - int lnlen; + unsigned int remainder; #endif /* Get the dimensions of the rectange to fill: width in pixels, * height in rows */ - width = dest->pt2.x - dest->pt1.x + 1; - rows = dest->pt2.y - dest->pt1.y + 1; + ncols = dest->pt2.x - dest->pt1.x + 1; + /* Set up to copy the image */ + + xoffset = dest->pt1.x - origin->x; + sline = (const uint8_t*)src + NXGL_SCALEX(xoffset) + (dest->pt1.y - origin->y) * srcstride; #if NXGLIB_BITSPERPIXEL < 8 -# ifdef CONFIG_NX_PACKEDMSFIRST - - /* Get the mask for pixels that are ordered so that they pack from the - * MS byte down. - */ - - leadmask = (uint8_t)(0xff >> (8 - NXGL_REMAINDERX(dest->pt1.x))); - tailmask = (uint8_t)(0xff << (8 - NXGL_REMAINDERX(dest->pt2.x-1))); -# else - /* Get the mask for pixels that are ordered so that they pack from the - * LS byte up. - */ - - leadmask = (uint8_t)(0xff << (8 - NXGL_REMAINDERX(dest->pt1.x))); - tailmask = (uint8_t)(0xff >> (8 - NXGL_REMAINDERX(dest->pt1.x-1))); -# endif + remainder = NXGL_REMAINDERX(xoffset); #endif - /* Then copy the image */ + /* Copy the image, one row at a time */ - sline = (const uint8_t*)src + NXGL_SCALEX(dest->pt1.x - origin->x) + (dest->pt1.y - origin->y) * srcstride; - dline = pinfo->fbmem + dest->pt1.y * deststride + NXGL_SCALEX(dest->pt1.x); - - while (rows--) + for (row = dest->pt1.y; row < dest->pt2.y; row++) { #if NXGLIB_BITSPERPIXEL < 8 - /* Handle masking of the fractional initial byte */ + /* if the source pixel is not aligned with a byte boundary, then we will + * need to copy the image data to the run buffer first. + */ - mask = leadmask; - sptr = sline; - dptr = dline; - lnlen = width; - - if (lnlen > 1 && mask) + if (remainder != 0) { - dptr[0] = (dptr[0] & ~mask) | (sptr[0] & mask); - mask = 0xff; - dptr++; - sptr++; - lnlen--; + NXGL_FUNCNAME(nxgl_copyrun,NXGLIB_SUFFIX)(sline, pinfo->buffer, remainder, ncols); + (void)pinfo->putrun(row, dest->pt1.x, pinfo->buffer, ncols); } - - /* Handle masking of the fractional final byte */ - - mask &= tailmask; - if (lnlen > 0 && mask) - { - dptr[lnlen-1] = (dptr[lnlen-1] & ~mask) | (sptr[lnlen-1] & mask); - lnlen--; - } - - /* Handle all of the unmasked bytes in-between */ - - if (lnlen > 0) - { - NXGL_MEMCPY(dptr, sptr, lnlen); - } -#else - /* Copy the whole line */ - - NXGL_MEMCPY((NXGL_PIXEL_T*)dline, (NXGL_PIXEL_T*)sline, width); + else #endif - dline += deststride; + { + /* The pixel data is byte aligned. Copy the image data directly from + * the image memory. + */ + + (void)pinfo->putrun(row, dest->pt1.x, sline, ncols); + } + + /* Then adjust the source pointer to refer to the next line in the source + * image. + */ + sline += srcstride; } } diff --git a/graphics/nxglib/nxglib_copyrun.h b/graphics/nxglib/nxglib_copyrun.h index 500d2fb759..b97372bf77 100644 --- a/graphics/nxglib/nxglib_copyrun.h +++ b/graphics/nxglib/nxglib_copyrun.h @@ -79,10 +79,11 @@ #if NXGLIB_BITSPERPIXEL == 1 static inline void nxgl_copyrun_1bpp(FAR const uint8_t *src, FAR uint8_t *dest, - unsigned int inbit, size_t npixels) + unsigned int remainder, size_t npixels) { uint8_t indata; uint8_t outdata; + uint8_t nextdata; unsigned int outpixels = 0; DEBUGASSERT(remainder > 0 && remainder < 8); @@ -166,10 +167,11 @@ nxgl_copyrun_1bpp(FAR const uint8_t *src, FAR uint8_t *dest, #elif NXGLIB_BITSPERPIXEL == 2 static inline void nxgl_copyrun_2bpp(FAR const uint8_t *src, FAR uint8_t *dest, - unsigned int inbit, size_t npixels) + unsigned int remainder, size_t npixels) { uint8_t indata; uint8_t outdata; + uint8_t nextdata; unsigned int outpixels = 0; unsigned int shift; @@ -255,10 +257,11 @@ nxgl_copyrun_2bpp(FAR const uint8_t *src, FAR uint8_t *dest, #elif NXGLIB_BITSPERPIXEL == 4 static inline void nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, - unsigned int inbit, size_t npixels) + unsigned int remainder, size_t npixels) { uint8_t indata; uint8_t outdata; + uint8_t nextdata; unsigned int outpixels = 0; DEBUGASSERT(remainder == 1); @@ -269,7 +272,6 @@ nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, */ indata = *src++; - shift = (remainder << 1); #ifdef CONFIG_NX_PACKEDMSFIRST /* If CONFIG_NX_PACKEDMSFIRST is defined, then bits 0-3 @@ -317,8 +319,8 @@ nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, * src = BBBB CCCC - nextdata = CCCC xxxx */ - outdata |= (indata >> 4); - nextdata = (indata << 4); + outdata |= (indata >> 4); + nextdata = (indata << 4); #else /* If CONFIG_NX_PACKEDMSFIRST is NOT defined, then bits 0-(remainder-1) * are carried over from that last pass through the loop (or are @@ -328,8 +330,8 @@ nxgl_copyrun_4bpp(FAR const uint8_t *src, FAR uint8_t *dest, * src = CCCC CCBB - nextdata = xxCC CCCC */ - outdata |= (indata << 4); - nextdata = (indata >> 4); + outdata |= (indata << 4); + nextdata = (indata >> 4); #endif /* Transfer the byte to the run buffer */ diff --git a/include/nuttx/lcd.h b/include/nuttx/lcd.h index ab93511eee..29059c6ea8 100755 --- a/include/nuttx/lcd.h +++ b/include/nuttx/lcd.h @@ -93,6 +93,10 @@ struct lcd_planeinfo_s * The size of the allocated run buffer must therefor be at least * (bpp * xres / 8). Actual alignment of the buffer must conform to the * bitwidth of the underlying pixel type. + * + * If there are multiple planes, they may share the same working buffer + * because different planes will not be operate on concurrently. However, + * if there are multiple LCD devices, they must each have unique run buffers. */ uint8_t *buffer;