Change to GDriver to support an initialisation parameter
This commit is contained in:
parent
ff28a0aa37
commit
b42a2098eb
4 changed files with 11 additions and 9 deletions
|
@ -620,7 +620,7 @@ typedef struct GDISPVMT {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
bool_t _gdispInitDriver(GDriver *g, unsigned driverinstance, unsigned systeminstance);
|
bool_t _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance);
|
||||||
void _gdispPostInitDriver(GDriver *g);
|
void _gdispPostInitDriver(GDriver *g);
|
||||||
void _gdispDeInitDriver(GDriver *g);
|
void _gdispDeInitDriver(GDriver *g);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -572,7 +572,7 @@ void _gdispInit(void)
|
||||||
static const struct GDriverVMT const * dclist[] = {GDISP_DRIVER_LIST};
|
static const struct GDriverVMT const * dclist[] = {GDISP_DRIVER_LIST};
|
||||||
|
|
||||||
for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++)
|
for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++)
|
||||||
gdriverRegister(dclist[i]);
|
gdriverRegister(dclist[i], 0);
|
||||||
}
|
}
|
||||||
#elif GDISP_TOTAL_DISPLAYS > 1
|
#elif GDISP_TOTAL_DISPLAYS > 1
|
||||||
{
|
{
|
||||||
|
@ -580,13 +580,13 @@ void _gdispInit(void)
|
||||||
extern GDriverVMTList GDISPVMT_OnlyOne;
|
extern GDriverVMTList GDISPVMT_OnlyOne;
|
||||||
|
|
||||||
for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++)
|
for(i = 0; i < GDISP_TOTAL_DISPLAYS; i++)
|
||||||
gdriverRegister(GDISPVMT_OnlyOne);
|
gdriverRegister(GDISPVMT_OnlyOne, 0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
extern GDriverVMTList GDISPVMT_OnlyOne;
|
extern GDriverVMTList GDISPVMT_OnlyOne;
|
||||||
|
|
||||||
gdriverRegister(GDISPVMT_OnlyOne);
|
gdriverRegister(GDISPVMT_OnlyOne, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -620,9 +620,10 @@ void _gdispDeinit(void)
|
||||||
/* ToDo */
|
/* ToDo */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t _gdispInitDriver(GDriver *g, unsigned driverinstance, unsigned systeminstance) {
|
bool_t _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) {
|
||||||
#define gd ((GDisplay *)g)
|
#define gd ((GDisplay *)g)
|
||||||
bool_t ret;
|
bool_t ret;
|
||||||
|
(void) param;
|
||||||
|
|
||||||
// Intialise fields
|
// Intialise fields
|
||||||
gd->systemdisplay = systeminstance;
|
gd->systemdisplay = systeminstance;
|
||||||
|
|
|
@ -27,7 +27,7 @@ void _gdriverDeinit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GDriver *gdriverRegister(const GDriverVMT *vmt) {
|
GDriver *gdriverRegister(const GDriverVMT *vmt, void *param) {
|
||||||
GDriver * pd;
|
GDriver * pd;
|
||||||
GDriver * dtail;
|
GDriver * dtail;
|
||||||
unsigned dinstance, sinstance;
|
unsigned dinstance, sinstance;
|
||||||
|
@ -47,7 +47,7 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) {
|
||||||
return 0;
|
return 0;
|
||||||
memset(pd, 0, vmt->objsize);
|
memset(pd, 0, vmt->objsize);
|
||||||
pd->vmt = vmt;
|
pd->vmt = vmt;
|
||||||
if (vmt->init && !vmt->init(pd, dinstance, sinstance)) {
|
if (vmt->init && !vmt->init(pd, param, dinstance, sinstance)) {
|
||||||
gfxFree(pd);
|
gfxFree(pd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef struct GDriverVMT {
|
||||||
uint16_t type; // @< What type of driver this is
|
uint16_t type; // @< What type of driver this is
|
||||||
uint16_t flags; // @< Flags for the driver. Meaning is specific to each driver type.
|
uint16_t flags; // @< Flags for the driver. Meaning is specific to each driver type.
|
||||||
uint32_t objsize; // @< How big the runtime driver structure is
|
uint32_t objsize; // @< How big the runtime driver structure is
|
||||||
bool_t (*init)(GDriver *driver, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK.
|
bool_t (*init)(GDriver *driver, void *param, unsigned driverinstance, unsigned systeminstance); // @< Initialise the driver. Returns TRUE if OK.
|
||||||
// driverinstance is the instance 0..n of this driver.
|
// driverinstance is the instance 0..n of this driver.
|
||||||
// systeminstance is the instance 0..n of this type of device.
|
// systeminstance is the instance 0..n of this type of device.
|
||||||
// The memory allocated is cleared before this call.
|
// The memory allocated is cleared before this call.
|
||||||
|
@ -102,8 +102,9 @@ extern "C" {
|
||||||
* @return The runtime driver structure or NULL if it fails.
|
* @return The runtime driver structure or NULL if it fails.
|
||||||
*
|
*
|
||||||
* @param[in] vmt The driver's vmt
|
* @param[in] vmt The driver's vmt
|
||||||
|
* @param[in] param An arbitrary paramater passed to the driver init routine.
|
||||||
*/
|
*/
|
||||||
GDriver *gdriverRegister(const GDriverVMT *vmt);
|
GDriver *gdriverRegister(const GDriverVMT *vmt, void *param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UnRegister a driver instance.
|
* @brief UnRegister a driver instance.
|
||||||
|
|
Loading…
Add table
Reference in a new issue