From 4d33eea3914e59030eba6cff7c97c8848fb115b5 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 17 Apr 2010 03:08:30 +0000 Subject: [PATCH] Generalize graphics driver type git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2597 42af7a65-404d-4744-a932-0658087f49c3 --- graphics/nxbe/Make.defs | 2 +- graphics/nxbe/nxbe.h | 15 +++++----- graphics/nxbe/nxbe_colormap.c | 6 ++-- .../{nxbe_fbconfigure.c => nxbe_configure.c} | 8 ++--- graphics/nxmu/nxfe.h | 3 +- graphics/nxmu/nxmu_server.c | 27 ++++++++--------- graphics/nxsu/nx_open.c | 18 +++++------ graphics/nxsu/nxfe.h | 3 +- include/nuttx/lcd.h | 1 + include/nuttx/nx.h | 30 ++++++++++++++----- 10 files changed, 63 insertions(+), 50 deletions(-) rename graphics/nxbe/{nxbe_fbconfigure.c => nxbe_configure.c} (97%) diff --git a/graphics/nxbe/Make.defs b/graphics/nxbe/Make.defs index 98aaf20971..2f9388fc0f 100644 --- a/graphics/nxbe/Make.defs +++ b/graphics/nxbe/Make.defs @@ -34,7 +34,7 @@ ############################################################################ NXBE_ASRCS = -NXBE_CSRCS = nxbe_fbconfigure.c nxbe_colormap.c nxbe_clipper.c \ +NXBE_CSRCS = nxbe_configure.c nxbe_colormap.c nxbe_clipper.c \ nxbe_closewindow.c \ nxbe_setposition.c nxbe_setsize.c nxbe_raise.c nxbe_lower.c \ nxbe_fill.c nxbe_filltrapezoid.c nxbe_move.c nxbe_bitmap.c \ diff --git a/graphics/nxbe/nxbe.h b/graphics/nxbe/nxbe.h index f9b36c0a3c..3dec64b02d 100644 --- a/graphics/nxbe/nxbe.h +++ b/graphics/nxbe/nxbe.h @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxbe/nxbe.h * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,8 @@ #include #include -#include + +#include #include /**************************************************************************** @@ -211,20 +212,20 @@ extern "C" { ****************************************************************************/ #if CONFIG_FB_CMAP -EXTERN int nxbe_colormap(FAR struct fb_vtable_s *fb); +EXTERN int nxbe_colormap(FAR struct NX_DRIVERTYPE *dev); #endif /**************************************************************************** - * Name: nx_fbconfigure + * Name: nx_configure * * Description: * Configure the back end state structure based on information from the - * framebuffer driver + * framebuffer or LCD driver * ****************************************************************************/ -EXTERN int nxbe_fbconfigure(FAR struct fb_vtable_s *fb, - FAR struct nxbe_state_s *be); +EXTERN int nxbe_configure(FAR NX_DRIVERTYPE *dev, + FAR struct nxbe_state_s *be); /**************************************************************************** * Name: nxbe_closewindow diff --git a/graphics/nxbe/nxbe_colormap.c b/graphics/nxbe/nxbe_colormap.c index 25a493d1d1..f35393b20a 100644 --- a/graphics/nxbe/nxbe_colormap.c +++ b/graphics/nxbe/nxbe_colormap.c @@ -45,8 +45,6 @@ #include #include -#include - #include "nxbe.h" /**************************************************************************** @@ -82,7 +80,7 @@ ****************************************************************************/ #if CONFIG_FB_CMAP -int nxbe_colormap(FAR struct fb_vtable_s *fb) +int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be) { struct fb_cmap_s cmap; uint8_t *alloc; @@ -143,7 +141,7 @@ int nxbe_colormap(FAR struct fb_vtable_s *fb) /* Then set the color map */ - ret =fb->putcmap(fb, &cmap); + ret = dev->putcmap(dev, &cmap); free(alloc); return ret; diff --git a/graphics/nxbe/nxbe_fbconfigure.c b/graphics/nxbe/nxbe_configure.c similarity index 97% rename from graphics/nxbe/nxbe_fbconfigure.c rename to graphics/nxbe/nxbe_configure.c index df6dbe0d9c..0d5aeefdca 100644 --- a/graphics/nxbe/nxbe_fbconfigure.c +++ b/graphics/nxbe/nxbe_configure.c @@ -1,7 +1,7 @@ /**************************************************************************** - * graphics/nxbe/nxbe_fbconfigure.c + * graphics/nxbe/nxbe_configure.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -70,7 +70,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: nxbe_fbconfigure + * Name: nxbe_configure * * Description: * Configure the back end state structure based on information from the @@ -78,7 +78,7 @@ * ****************************************************************************/ -int nxbe_fbconfigure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be) +int nxbe_configure(FAR struct fb_vtable_s *fb, FAR struct nxbe_state_s *be) { int ret; int i; diff --git a/graphics/nxmu/nxfe.h b/graphics/nxmu/nxfe.h index e449dc10e2..f228c90299 100644 --- a/graphics/nxmu/nxfe.h +++ b/graphics/nxmu/nxfe.h @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nxfe.h * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,6 @@ #include #include -#include #include #include "nxbe.h" diff --git a/graphics/nxmu/nxmu_server.c b/graphics/nxmu/nxmu_server.c index d9ff975347..24132a17f6 100644 --- a/graphics/nxmu/nxmu_server.c +++ b/graphics/nxmu/nxmu_server.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nxmu_server.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,6 @@ #include #include -#include #include #include "nxfe.h" @@ -181,34 +180,34 @@ static inline void nxmu_shutdown(FAR struct nxfe_state_s *fe) * Name: nxmu_setup ****************************************************************************/ -static inline int nxmu_setup(FAR const char *mqname, - FAR struct fb_vtable_s *fb, - FAR struct nxfe_state_s *fe) +static inline int nxmu_lcdsetup(FAR const char *mqname, + FAR NX_DRIVERTYPE *dev, + FAR struct nxfe_state_s *fe) { struct mq_attr attr; int ret; memset(fe, 0, sizeof(struct nxfe_state_s)); - /* Configure the framebuffer device */ + /* Configure the framebuffer/LCD device */ - ret = nxbe_fbconfigure(fb, &fe->be); + ret = nxbe_configure(dev, &fe->be); if (ret < 0) { - gdbg("nxbe_fbconfigure failed: %d\n", -ret); + gdbg("nxbe_configure failed: %d\n", -ret); errno = -ret; return ERROR; } #if CONFIG_FB_CMAP - ret = nxbe_colormap(fb); + ret = nxbe_colormap(dev); if (ret < 0) { gdbg("nxbe_colormap failed: %d\n", -ret); errno = -ret; return ERROR; } -#endif +#endif /* CONFIG_FB_CMAP */ /* Initialize the non-NULL elements of the server connection structure. * Oddly, this strcture represents the connection between the server and @@ -289,7 +288,7 @@ static inline int nxmu_setup(FAR const char *mqname, * * Input Parameters: * mqname - The name for the server incoming message queue - * fb - Vtable "object" of the framebuffer "driver" to use + * dev - Vtable "object" of the framebuffer/LCD "driver" to use * * Return: * This function usually does not return. If it does return, it will @@ -297,7 +296,7 @@ static inline int nxmu_setup(FAR const char *mqname, * ****************************************************************************/ -int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb) +int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) { struct nxfe_state_s fe; FAR struct nxsvrmsg_s *msg; @@ -310,7 +309,7 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb) /* Sanity checking */ #ifdef CONFIG_DEBUG - if (!mqname || !fb) + if (!mqname || !dev) { errno = EINVAL; return ERROR; @@ -319,7 +318,7 @@ int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb) /* Initialize and configure the server */ - ret = nxmu_setup(mqname, fb, &fe); + ret = nxmu_setup(mqname, dev, &fe); if (ret < 0) { return ret; /* nxmu_setup sets errno */ diff --git a/graphics/nxsu/nx_open.c b/graphics/nxsu/nx_open.c index cde501f151..3ba3e60299 100644 --- a/graphics/nxsu/nx_open.c +++ b/graphics/nxsu/nx_open.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxsu/nx_open.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -108,23 +108,23 @@ static void nxsu_bkgdredraw(NXWINDOW hwnd, * Name: nxsu_setup ****************************************************************************/ -static inline int nxsu_setup(FAR struct fb_vtable_s *fb, +static inline int nxsu_setup(FAR NX_DRIVERTYPE *dev, FAR struct nxfe_state_s *fe) { int ret; /* Configure the framebuffer device */ - ret = nxbe_fbconfigure(fb, &fe->be); + ret = nxbe_configure(dev, &fe->be); if (ret < 0) { - gdbg("nxbe_fbconfigure failed: %d\n", -ret); + gdbg("nxbe_configure failed: %d\n", -ret); errno = -ret; return ERROR; } #if CONFIG_FB_CMAP - ret = nxbe_colormap(fb); + ret = nxbe_colormap(dev); if (ret < 0) { gdbg("nxbe_colormap failed: %d\n", -ret); @@ -170,7 +170,7 @@ static inline int nxsu_setup(FAR struct fb_vtable_s *fb, * plus nx_run. * * Input Parameters: - * fb - Vtable "object" of the framebuffer "driver" to use + * dev - Vtable "object" of the framebuffer/LCD "driver" to use * * Return: * Success: A non-NULL handle used with subsequent NX accesses @@ -178,7 +178,7 @@ static inline int nxsu_setup(FAR struct fb_vtable_s *fb, * ****************************************************************************/ -NXHANDLE nx_open(FAR struct fb_vtable_s *fb) +NXHANDLE nx_open(FAR NX_DRIVERTYPE *dev) { FAR struct nxfe_state_s *fe; int ret; @@ -186,7 +186,7 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb) /* Sanity checking */ #ifdef CONFIG_DEBUG - if (!fb) + if (!dev) { errno = EINVAL; return NULL; @@ -204,7 +204,7 @@ NXHANDLE nx_open(FAR struct fb_vtable_s *fb) /* Initialize and configure the server */ - ret = nxsu_setup(fb, fe); + ret = nxsu_setup(dev, fe); if (ret < 0) { return NULL; /* nxsu_setup sets errno */ diff --git a/graphics/nxsu/nxfe.h b/graphics/nxsu/nxfe.h index acfa5e122b..aa9fb49a95 100644 --- a/graphics/nxsu/nxfe.h +++ b/graphics/nxsu/nxfe.h @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxsu/nxfe.h * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ #include #include -#include #include #include "nxbe.h" diff --git a/include/nuttx/lcd.h b/include/nuttx/lcd.h index aee8d1dd23..dbb3fdf75b 100755 --- a/include/nuttx/lcd.h +++ b/include/nuttx/lcd.h @@ -65,6 +65,7 @@ struct lcd_planeinfo_s int (*putrun)(struct lcd_dev_s *dev, unsigned int planeno, fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, size_t npixels); + int (*getrun)(struct lcd_dev_s *dev, unsigned int planeno, fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, size_t npixels); diff --git a/include/nuttx/nx.h b/include/nuttx/nx.h index edc30c0d43..20e0c517d4 100644 --- a/include/nuttx/nx.h +++ b/include/nuttx/nx.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/nx.h * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,13 @@ #include #include -#include + +#ifdef CONFIG_NX_LCDDRIVER +# include +#else +# include +#endif + #include /**************************************************************************** @@ -62,6 +68,16 @@ #define NX_MOUSE_CENTERBUTTON 0x02 #define NX_MOUSE_RIGHTBUTTON 0x04 +/* NX_DRIVERTYPE selects either the framebuffer or LCD driver. A define is + * used instead of a typedef to avoid type mismatches. + */ + +#ifdef CONFIG_NX_LCDDRIVER +# define NX_DRIVERTYPE struct lcd_dev_s +#else +# define NX_DRIVERTYPE struct fb_vtable_s +#endif + /**************************************************************************** * Public Types ****************************************************************************/ @@ -215,7 +231,7 @@ extern "C" { * * Input Parameters: * mqname - The name for the server incoming message queue - * fb - Vtable "object" of the framebuffer "driver" to use + * dev - Vtable "object" of the framebuffer "driver" to use * * Return: * This function usually does not return. If it does return, it will @@ -224,8 +240,8 @@ extern "C" { ****************************************************************************/ #ifdef CONFIG_NX_MULTIUSER -EXTERN int nx_runinstance(FAR const char *mqname, FAR struct fb_vtable_s *fb); -# define nx_run(fb) nx_runinstance(NX_DEFAULT_SERVER_MQNAME, fb) +EXTERN int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev); +# define nx_run(dev) nx_runinstance(NX_DEFAULT_SERVER_MQNAME, dev) #endif /**************************************************************************** @@ -273,7 +289,7 @@ EXTERN NXHANDLE nx_connectinstance(FAR const char *svrmqname); * Single user mode only! * * Input Parameters: - * fb - Vtable "object" of the framebuffer "driver" to use + * dev - Vtable "object" of the framebuffer/LCD "driver" to use * cb - Callbacks used to process received NX server messages * * Return: @@ -283,7 +299,7 @@ EXTERN NXHANDLE nx_connectinstance(FAR const char *svrmqname); ****************************************************************************/ #ifndef CONFIG_NX_MULTIUSER -EXTERN NXHANDLE nx_open(FAR struct fb_vtable_s *fb); +EXTERN NXHANDLE nx_open(FAR NX_DRIVERTYPE *dev); #endif /****************************************************************************