Add support for a driver private area (as well as a board private area)

ugfx_release_2.6
inmarket 2013-10-21 15:13:10 +10:00
parent 0b9db701a1
commit 0535c67eab
25 changed files with 90 additions and 49 deletions

View File

@ -66,8 +66,8 @@ static const SPIConfig spi1cfg_16bit = {
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -62,7 +62,10 @@ static inline void set_viewport(GDisplay* g) {
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset

View File

@ -19,8 +19,8 @@
static void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -20,8 +20,8 @@
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -98,7 +98,10 @@ static void set_viewport(GDisplay *g) {
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t cver;
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
/* Hardware reset */

View File

@ -33,8 +33,8 @@
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -99,7 +99,10 @@ static void set_viewport(GDisplay* g) {
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
uint16_t cver;
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
/* Hardware reset */

View File

@ -27,8 +27,8 @@
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -71,7 +71,10 @@ static void set_viewport(GDisplay* g) {
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
/* Hardware reset */

View File

@ -59,8 +59,8 @@ static bool_t pwmRunning = FALSE;
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -69,7 +69,9 @@
/* Driver local variables. */
/*===========================================================================*/
static color_t savecolor[GDISP_TOTAL_DISPLAYS];
// Use the priv pointer itself to save our color. This save allocating ram for it
// and works provided sizeof(color_t) <= sizeof(void *)
#define savecolor(g) ((color_t)g->priv)
#define GDISP_FLG_ODDBYTE (GDISP_FLG_DRIVER<<0)
@ -96,7 +98,10 @@ static inline void set_viewport(GDisplay* g) {
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset
@ -140,18 +145,18 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
if ((g->flags & GDISP_FLG_ODDBYTE)) {
// Write the pair of pixels to the display
write_data3(g, ((savecolor[g->controllerdisplay] >> 4) & 0xFF),
(((savecolor[g->controllerdisplay] << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)),
write_data3(g, ((savecolor(g) >> 4) & 0xFF),
(((savecolor(g) << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)),
(g->p.color & 0xFF));
g->flags &= ~GDISP_FLG_ODDBYTE;
} else {
savecolor[g->controllerdisplay] = g->p.color;
savecolor(g) = g->p.color;
g->flags |= GDISP_FLG_ODDBYTE;
}
}
LLDSPEC void gdisp_lld_write_stop(GDisplay *g) {
if ((g->flags & GDISP_FLG_ODDBYTE)) {
write_data2(g, ((savecolor[g->controllerdisplay] >> 4) & 0xFF), ((savecolor[g->controllerdisplay] << 4) & 0xF0));
write_data2(g, ((savecolor(g) >> 4) & 0xFF), ((savecolor(g) << 4) & 0xF0));
write_index(g, NOP);
}
release_bus(g);

View File

@ -71,8 +71,8 @@ static bool_t pwmRunning = FALSE;
*/
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -110,10 +110,13 @@
/*===========================================================================*/
#if GDISP_HARDWARE_STREAM_WRITE
static color_t savecolor[GDISP_TOTAL_DISPLAYS];
#if GDISP_GE8_BROKEN_CONTROLLER
static color_t firstcolor[GDISP_TOTAL_DISPLAYS];
#endif
typedef struct dvrPriv {
color_t savecolor;
#if GDISP_GE8_BROKEN_CONTROLLER
color_t firstcolor;
#endif
} dvrPriv;
#define PRIV ((dvrPriv *)g->priv)
#endif
#define GDISP_FLG_ODDBYTE (GDISP_FLG_DRIVER<<0)
@ -164,7 +167,13 @@ static inline void set_viewport(GDisplay* g) {
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* Initialise your display */
#if GDISP_HARDWARE_STREAM_WRITE
g->priv = gfxAlloc(sizeof(dvrPriv));
#else
g->priv = 0;
#endif
// Initialise the board interface
init_board(g);
// Hardware reset
@ -224,18 +233,18 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
LLDSPEC void gdisp_lld_write_color(GDisplay *g) {
#if GDISP_GE8_BROKEN_CONTROLLER
if (!(g->flags & GDISP_FLG_RUNBYTE)) {
firstcolor[g->controllerdisplay] = g->p.color;
PRIV->firstcolor = g->p.color;
g->flags |= GDISP_FLG_RUNBYTE;
}
#endif
if ((g->flags & GDISP_FLG_ODDBYTE)) {
// Write the pair of pixels to the display
write_data3(g, ((savecolor[g->controllerdisplay] >> 4) & 0xFF),
(((savecolor[g->controllerdisplay] << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)),
write_data3(g, ((PRIV->savecolor >> 4) & 0xFF),
(((PRIV->savecolor << 4) & 0xF0)|((g->p.color >> 8) & 0x0F)),
(g->p.color & 0xFF));
g->flags &= ~GDISP_FLG_ODDBYTE;
} else {
savecolor[g->controllerdisplay] = g->p.color;
PRIV->savecolor = g->p.color;
g->flags |= GDISP_FLG_ODDBYTE;
}
}
@ -260,11 +269,11 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
* user application uses the streaming calls and then terminates the stream early or after buffer wrap.
* Since this is such an unlikely situation we just don't handle it.
*/
write_data3(g, ((savecolor[g->controllerdisplay] >> 4) & 0xFF),
(((savecolor[g->controllerdisplay] << 4) & 0xF0)|((firstcolor[g->controllerdisplay] >> 8) & 0x0F)),
(firstcolor[g->controllerdisplay] & 0xFF));
write_data3(g, ((PRIV->savecolor >> 4) & 0xFF),
(((PRIV->savecolor << 4) & 0xF0)|((PRIV->firstcolor >> 8) & 0x0F)),
(PRIV->firstcolor & 0xFF));
#else
write_data2(g, ((savecolor[g->controllerdisplay] >> 4) & 0xFF), ((savecolor[g->controllerdisplay] << 4) & 0xF0));
write_data2(g, ((PRIV->savecolor >> 4) & 0xFF), ((PRIV->savecolor << 4) & 0xF0));
write_index(g, NOP);
#endif
}

View File

@ -22,8 +22,8 @@
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -107,7 +107,10 @@ static inline void set_backlight(GDisplay* g, uint8_t percent) {
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset

View File

@ -20,8 +20,8 @@
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -117,7 +117,10 @@ static inline void set_viewport(GDisplay *g) {
}
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* initialize the hardware */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
/* Hardware reset */

View File

@ -26,8 +26,8 @@
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -36,8 +36,8 @@ static const PWMConfig pwmcfg = {
static inline void init_board(GDisplay *g) {
// As we are not using multiple displays we set g->priv to NULL as we don't use it.
g->priv = 0;
// As we are not using multiple displays we set g->board to NULL as we don't use it.
g->board = 0;
switch(g->controllerdisplay) {
case 0: // Set up for Display 0

View File

@ -115,7 +115,10 @@ static void set_viewport(GDisplay* g) {
/*===========================================================================*/
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* Initialise your display */
// No private area for this controller
g->priv = 0;
// Initialise the board interface
init_board(g);
// Hardware reset

View File

@ -32,6 +32,9 @@
#endif
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
/* No board interface and no private driver area */
g->priv = g->board = 0;
/* Initialise the GDISP structure */
g->g.Width = GDISP_SCREEN_WIDTH;
g->g.Height = GDISP_SCREEN_HEIGHT;

View File

@ -441,6 +441,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
assert(priv != NULL);
memset(priv, 0, sizeof(winPriv));
g->priv = priv;
g->board = 0; // no board interface for this controller
// Create the window in the message thread
PostThreadMessage(winThreadId, WM_USER, (WPARAM)g->controllerdisplay, (LPARAM)g);

View File

@ -193,6 +193,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
g->priv = gfxAlloc(sizeof(xPriv));
priv = (xPriv *)g->priv;
g->board = 0; // No board interface for this driver
xa.colormap = cmap;
xa.border_pixel = 0xFFFFFF;

View File

@ -271,7 +271,7 @@ extern GDisplay *GDISP;
#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_MONO
typedef uint8_t color_t;
#define COLOR(c) ((color_t)(c))
#define MASKCOLOR FALSE
#define MASKCOLOR TRUE
#define RGB2COLOR(r,g,b) ((r|g|b) ? 1 : 0)
#define HTML2COLOR(h) (h ? 1 : 0)
#define RED_OF(c) (c ? 255 : 0)

View File

@ -191,6 +191,7 @@ struct GDisplay {
#endif
void * priv; // A private area just for the drivers use.
void * board; // A private area just for the board interfaces use.
uint8_t systemdisplay;
uint8_t controllerdisplay;