aboutsummaryrefslogtreecommitdiffstats
path: root/src/gdriver
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-09-13 14:50:32 +1000
committerinmarket <andrewh@inmarket.com.au>2014-09-13 14:50:32 +1000
commit683ac0ab7fc5c379cec605257edac00b562bea86 (patch)
treeafd6baa420ff537bfe8a91f7ec5ea8ff737c4859 /src/gdriver
parent0c7c74112e07f612ea5a2da00a5962728225d41f (diff)
downloaduGFX-683ac0ab7fc5c379cec605257edac00b562bea86.tar.gz
uGFX-683ac0ab7fc5c379cec605257edac00b562bea86.tar.bz2
uGFX-683ac0ab7fc5c379cec605257edac00b562bea86.zip
Fixes to gdriver to make uGFXnet displays work
Diffstat (limited to 'src/gdriver')
-rw-r--r--src/gdriver/gdriver_gdriver.c47
-rw-r--r--src/gdriver/sys_defs.h17
2 files changed, 20 insertions, 44 deletions
diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c
index 2c73719e..90a1d932 100644
--- a/src/gdriver/gdriver_gdriver.c
+++ b/src/gdriver/gdriver_gdriver.c
@@ -14,51 +14,8 @@
// Define the tables to hold the driver instances.
static GDriver *dhead;
-// Definition that allows getting addresses of structures
-typedef const struct GDriverVMT const VMT_EL[1];
-
// The system initialization.
void _gdriverInit(void) {
- #if GFX_USE_GDISP
- {
- // Both GDISP_CONTROLLER_LIST and GDISP_CONTROLLER_DISPLAYS are defined - create the required numbers of each controller
- #if defined(GDISP_CONTROLLER_LIST) && defined(GDISP_CONTROLLER_DISPLAYS)
- int i, cnt;
-
-
- extern VMT_EL GDISP_CONTROLLER_LIST;
- static const struct GDriverVMT const * dclist[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_LIST};
- static const unsigned dnlist[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_DISPLAYS};
- for(i = 0; i < GDISP_TOTAL_CONTROLLERS; i++) {
- for(cnt = dnlist[i]; cnt; cnt--)
- gdriverRegister(dclist[i]);
- }
-
- // Only GDISP_CONTROLLER_LIST is defined - create one of each controller
- #elif defined(GDISP_CONTROLLER_LIST)
- int i;
-
-
- extern VMT_EL GDISP_CONTROLLER_LIST;
- static const struct GDriverVMT const * dclist[GDISP_TOTAL_CONTROLLERS] = {GDISP_CONTROLLER_LIST};
- for(i = 0; i < GDISP_TOTAL_CONTROLLERS; i++)
- gdriverRegister(dclist[i]);
-
- // Only GDISP_TOTAL_DISPLAYS is defined - create the required number of the one controller
- #elif GDISP_TOTAL_DISPLAYS > 1
- int cnt;
-
- extern VMT_EL GDISPVMT_OnlyOne;
- for(cnt = 0; cnt < GDISP_TOTAL_DISPLAYS; cnt++)
- gdriverRegister(GDISPVMT_OnlyOne);
-
- // One and only one display
- #else
- extern VMT_EL GDISPVMT_OnlyOne;
- gdriverRegister(GDISPVMT_OnlyOne);
- #endif
- }
- #endif
// Drivers not loaded yet
// GINPUT_NEED_MOUSE
@@ -107,6 +64,10 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) {
else
dhead = pd;
+ // Do the post init
+ if (vmt->postinit)
+ vmt->postinit(pd);
+
return pd;
}
diff --git a/src/gdriver/sys_defs.h b/src/gdriver/sys_defs.h
index c5ab9862..7f50fc6d 100644
--- a/src/gdriver/sys_defs.h
+++ b/src/gdriver/sys_defs.h
@@ -67,12 +67,27 @@ typedef struct GDriverVMT {
uint16_t type; // @< What type of driver this is
uint16_t flags; // @< Flags for the driver. Meaning is specific to each driver type.
uint32_t objsize; // @< How big the runtime driver structure is
- bool_t (*init)(GDriver *driver, int driverinstance, int systeminstance); // @< Initialise the driver.
+ bool_t (*init)(GDriver *driver, int driverinstance, int systeminstance); // @< Initialise the driver. Returns TRUE if OK.
// driverinstance is the instance 0..n of this driver.
// systeminstance is the instance 0..n of this type of device.
+ void (*postinit)(GDriver *driver); // @< Called once the driver is registered.
void (*deinit)(GDriver *driver); // @< De-initialise the driver
} GDriverVMT;
+/**
+ * @brief A definition that allows getting addresses of GDriverVMT structures to put into a list.
+ * @note eg. <code>
+ * const MyDriverVMTtype a[1] = {{...}};
+ * const MyDriverVMTtype b[1] = {{...}};
+ * ...
+ * #define DRIVER_LIST a, b
+ * extern GDriverVMTList DRIVER_LIST; // Now treated as single element arrays of GDriverVMT
+ * const GDriverVMT const * mylist = { DRIVER_LIST };
+ * </code>
+ *
+ */
+typedef const struct GDriverVMT const GDriverVMTList[1];
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/