diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-08-23 17:55:42 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-08-23 17:55:42 +1000 |
commit | 0c7c74112e07f612ea5a2da00a5962728225d41f (patch) | |
tree | 093d8e253f77a87b303db89dacc3e339454347ce /src/gdriver | |
parent | 339150c55f934afccc989c75954a46f16612a777 (diff) | |
download | uGFX-0c7c74112e07f612ea5a2da00a5962728225d41f.tar.gz uGFX-0c7c74112e07f612ea5a2da00a5962728225d41f.tar.bz2 uGFX-0c7c74112e07f612ea5a2da00a5962728225d41f.zip |
GDRIVER now working for GDISP including multiple displays.
Still uses old GDISP driver model for now
Untested with uGFXnet.
Still to come: Input drivers etc
Diffstat (limited to 'src/gdriver')
-rw-r--r-- | src/gdriver/gdriver_gdriver.c | 93 | ||||
-rw-r--r-- | src/gdriver/sys_defs.h | 29 |
2 files changed, 86 insertions, 36 deletions
diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c index a6eb3e98..2c73719e 100644 --- a/src/gdriver/gdriver_gdriver.c +++ b/src/gdriver/gdriver_gdriver.c @@ -7,42 +7,72 @@ #include "gfx.h" -#if GFX_NEED_GDRIVER +#if GFX_USE_GDRIVER -// Some HACKS as these aren't supported yet -#ifndef GINPUT_NEED_STRING - #define GINPUT_NEED_STRING FALSE -#endif -#ifndef GFX_USE_GBLOCK - #define GFX_USE_GBLOCK FALSE -#endif +#include "sys_defs.h" // 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) { - const GDriverAutoStart const *pa; - int cnt; - #if GFX_USE_GDISP - #ifdef GDISP_DRIVER_LIST - { - static const struct { - const struct GDISPVMT const * vmt; - int instances; - } drivers[] = {GDISP_DRIVER_LIST}; - - for(pa = drivers; pa < &drivers[sizeof(drivers)/sizeof(drivers[0])]) { - for(cnt = pa->instances; cnt; cnt--) - gdriverRegister(pa->vmt); - } + { + // 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 struct GDISPVMT GDISP_VMT; - gdriverRegister((GDriver *)&GDISP_VMT); + extern VMT_EL GDISPVMT_OnlyOne; + gdriverRegister(GDISPVMT_OnlyOne); #endif + } #endif + + // Drivers not loaded yet + // GINPUT_NEED_MOUSE + // GINPUT_NEED_DIAL + // GINPUT_NEED_TOGGLE + // GINPUT_NEED_KEYBOARD + // GINPUT_NEED_STRING + // GFX_USE_GBLOCK +} + +// The system de-initialization. +void _gdriverDeinit(void) { + while(dhead) + gdriverUnRegister(dhead); } @@ -76,6 +106,8 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) { dtail->driverchain = pd; else dhead = pd; + + return pd; } void gdriverUnRegister(GDriver *driver) { @@ -99,7 +131,7 @@ void gdriverUnRegister(GDriver *driver) { // Call the deinit() if (driver->vmt->deinit) - driver->vmt->dinit(driver); + driver->vmt->deinit(driver); // Cleanup gfxFree(driver); @@ -134,4 +166,13 @@ int gdriverInstanceCount(uint16_t type) { return sinstance; } -#endif /* GFX_NEED_GDRIVER */ +GDriver *gdriverGetNext(uint16_t type, GDriver *driver) { + driver = driver ? driver->driverchain : dhead; + + while(driver && driver->vmt->type != type) + driver = driver->driverchain; + + return driver; +} + +#endif /* GFX_USE_GDRIVER */ diff --git a/src/gdriver/sys_defs.h b/src/gdriver/sys_defs.h index 3392f73a..c5ab9862 100644 --- a/src/gdriver/sys_defs.h +++ b/src/gdriver/sys_defs.h @@ -34,7 +34,7 @@ #ifndef _GDRIVER_H #define _GDRIVER_H -#if GFX_NEED_GDRIVER || defined(__DOXYGEN__) +#if GFX_USE_GDRIVER || defined(__DOXYGEN__) /*===========================================================================*/ /* Type definitions */ @@ -56,7 +56,7 @@ * dynamically by the system for each driver instance. */ typedef struct GDriver { - GDriver * driverchain; + struct GDriver * driverchain; const struct GDriverVMT * vmt; } GDriver; @@ -64,13 +64,13 @@ typedef struct GDriver { * @brief All driver VMT's start with this structure. */ 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)(void *driver, int driverinstance, int systeminstance); // @< Initialise the driver. - // driverinstance is the instance 0..n of this driver. - // systeminstance is the instance 0..n of this type of device. - void (*deinit)(void *driver); // @< De-initialise the driver + 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. + // driverinstance is the instance 0..n of this driver. + // systeminstance is the instance 0..n of this type of device. + void (*deinit)(GDriver *driver); // @< De-initialise the driver } GDriverVMT; /*===========================================================================*/ @@ -115,11 +115,20 @@ extern "C" { */ int gdriverInstanceCount(uint16_t type); + /** + * @brief Get the next driver for a type of device + * @return The runtime driver structure or NULL if there are no more. + * + * @param[in] type The type of driver to find + * @param[in] driver The last driver returned or NULL to start again + */ + GDriver *gdriverGetNext(uint16_t type, GDriver *driver); + #ifdef __cplusplus } #endif -#endif /* GFX_NEED_GDRIVER */ +#endif /* GFX_USE_GDRIVER */ #endif /* _GDRIVER_H */ /** @} */ |