From 87a6af81f4edd9f638238d785aae716749a7fc13 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 19 Oct 2013 15:36:05 +1000 Subject: [PATCH] Change to gdisp low level driver API. Display number is now in the GDriver structure (It was required for a Nokia driver). --- .../HX8347D/board_HX8347D_stm32f4discovery.h | 11 +++----- .../gdisp/HX8347D/board_HX8347D_template.h | 4 +-- drivers/gdisp/HX8347D/gdisp_lld.c | 4 +-- .../board_ILI9320_olimex_pic32mx_lcd.h | 11 +++----- .../ILI9320/board_ILI9320_olimex_stm32_lcd.h | 11 +++----- .../gdisp/ILI9320/board_ILI9320_template.h | 4 +-- drivers/gdisp/ILI9320/gdisp_lld.c | 4 +-- .../ILI9325/board_ILI9325_hy_stm32_100p.h | 11 +++----- .../gdisp/ILI9325/board_ILI9325_template.h | 4 +-- drivers/gdisp/ILI9325/gdisp_lld.c | 4 +-- .../ILI9481/board_ILI9481_firebullstm32f103.h | 10 +++----- .../gdisp/ILI9481/board_ILI9481_template.h | 4 +-- drivers/gdisp/ILI9481/gdisp_lld.c | 4 +-- drivers/gdisp/RA8875/board_RA8875_marlin.h | 11 +++----- drivers/gdisp/RA8875/board_RA8875_template.h | 25 +++++++++++-------- drivers/gdisp/RA8875/gdisp_lld.c | 4 +-- .../SSD1289/board_SSD1289_firebullstm32f103.h | 10 +++----- .../SSD1289/board_SSD1289_stm32f4discovery.h | 9 +++---- .../gdisp/SSD1289/board_SSD1289_template.h | 4 +-- drivers/gdisp/SSD1289/gdisp_lld.c | 4 +-- drivers/multiple/Win32/gdisp_lld.c | 10 ++++---- drivers/multiple/X/gdisp_lld.c | 4 +-- include/gdisp/lld/gdisp_lld.h | 13 +++++----- src/gdisp/gdisp.c | 10 +++++--- 24 files changed, 84 insertions(+), 106 deletions(-) diff --git a/drivers/gdisp/HX8347D/board_HX8347D_stm32f4discovery.h b/drivers/gdisp/HX8347D/board_HX8347D_stm32f4discovery.h index 4899baa5..daabe75d 100644 --- a/drivers/gdisp/HX8347D/board_HX8347D_stm32f4discovery.h +++ b/drivers/gdisp/HX8347D/board_HX8347D_stm32f4discovery.h @@ -64,17 +64,13 @@ static const SPIConfig spi1cfg_16bit = { SPI_CR1_DFF //SPI_CR1_BR_0 }; -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ - + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 /* Display backlight control */ /* TIM4 is an alternate function 2 (AF2) */ pwmStart(&PWMD4, &pwmcfg); @@ -96,6 +92,7 @@ static inline void init_board(GDisplay *g, unsigned display) { palSetPadMode(GPIOA, 5, PAL_MODE_ALTERNATE(5)|PAL_STM32_OSPEED_HIGHEST); /* SCK. */ palSetPadMode(GPIOA, 6, PAL_MODE_ALTERNATE(5)); /* MISO. */ palSetPadMode(GPIOA, 7, PAL_MODE_ALTERNATE(5)|PAL_STM32_OSPEED_HIGHEST); /* MOSI. */ + break; } } diff --git a/drivers/gdisp/HX8347D/board_HX8347D_template.h b/drivers/gdisp/HX8347D/board_HX8347D_template.h index 528fb027..58fd9338 100644 --- a/drivers/gdisp/HX8347D/board_HX8347D_template.h +++ b/drivers/gdisp/HX8347D/board_HX8347D_template.h @@ -20,16 +20,14 @@ * @brief Initialise the board for the display. * * @param[in] g The GDisplay structure - * @param[in] display The display number on this controller (0..n) * * @note Set the g->priv member to whatever is appropriate. For multiple * displays this might be a pointer to the appropriate register set. * * @notapi */ -static inline void init_board(GDisplay *g, unsigned display) { +static inline void init_board(GDisplay *g) { (void) g; - (void) display; } /** diff --git a/drivers/gdisp/HX8347D/gdisp_lld.c b/drivers/gdisp/HX8347D/gdisp_lld.c index 19d1b822..8cdbb781 100644 --- a/drivers/gdisp/HX8347D/gdisp_lld.c +++ b/drivers/gdisp/HX8347D/gdisp_lld.c @@ -61,9 +61,9 @@ static inline void set_viewport(GDisplay* g) { /* Driver exported functions. */ /*===========================================================================*/ -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { /* Initialise your display */ - init_board(g, display); + init_board(g); // Hardware reset setpin_reset(g, TRUE); diff --git a/drivers/gdisp/ILI9320/board_ILI9320_olimex_pic32mx_lcd.h b/drivers/gdisp/ILI9320/board_ILI9320_olimex_pic32mx_lcd.h index 81d493ed..cf101aaf 100644 --- a/drivers/gdisp/ILI9320/board_ILI9320_olimex_pic32mx_lcd.h +++ b/drivers/gdisp/ILI9320/board_ILI9320_olimex_pic32mx_lcd.h @@ -17,17 +17,13 @@ #define noinline __attribute__((noinline)) #endif -static void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ - + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 // RST palSetPadMode(IOPORTA, 7, PAL_MODE_OUTPUT); palClearPad(IOPORTA, 7); @@ -59,6 +55,7 @@ static void init_board(GDisplay *g, unsigned display) { PMCONbits.PMPEN = 1; palClearPad(IOPORTA, 9); + break; } } diff --git a/drivers/gdisp/ILI9320/board_ILI9320_olimex_stm32_lcd.h b/drivers/gdisp/ILI9320/board_ILI9320_olimex_stm32_lcd.h index df02a716..4738db61 100644 --- a/drivers/gdisp/ILI9320/board_ILI9320_olimex_stm32_lcd.h +++ b/drivers/gdisp/ILI9320/board_ILI9320_olimex_stm32_lcd.h @@ -18,17 +18,13 @@ #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ #define GDISP_RAM (*((volatile uint16_t *) 0x60100000)) /* RS = 1 */ -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ - + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 /* FSMC setup for F1 */ rccEnableAHB(RCC_AHBENR_FSMCEN, 0); @@ -46,6 +42,7 @@ static inline void init_board(GDisplay *g, unsigned display) { /* Bank1 NOR/SRAM control register configuration * This is actually not needed as already set by default after reset */ FSMC_Bank1->BTCR[0] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + break; } } diff --git a/drivers/gdisp/ILI9320/board_ILI9320_template.h b/drivers/gdisp/ILI9320/board_ILI9320_template.h index ead9aee0..4725e1eb 100644 --- a/drivers/gdisp/ILI9320/board_ILI9320_template.h +++ b/drivers/gdisp/ILI9320/board_ILI9320_template.h @@ -20,16 +20,14 @@ * @brief Initialise the board for the display. * * @param[in] g The GDisplay structure - * @param[in] display The display number on this controller (0..n) * * @note Set the g->priv member to whatever is appropriate. For multiple * displays this might be a pointer to the appropriate register set. * * @notapi */ -static inline void init_board(GDisplay *g, unsigned display) { +static inline void init_board(GDisplay *g) { (void) g; - (void) display; } /** diff --git a/drivers/gdisp/ILI9320/gdisp_lld.c b/drivers/gdisp/ILI9320/gdisp_lld.c index 3747b3d7..d4639617 100644 --- a/drivers/gdisp/ILI9320/gdisp_lld.c +++ b/drivers/gdisp/ILI9320/gdisp_lld.c @@ -95,11 +95,11 @@ static void set_viewport(GDisplay *g) { } } -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { uint16_t cver; /* Initialise your display */ - init_board(g, display); + init_board(g); /* Hardware reset */ setpin_reset(g, TRUE); diff --git a/drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h b/drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h index 166ebc33..ae9e96fc 100644 --- a/drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h +++ b/drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h @@ -31,17 +31,13 @@ #define GDISP_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ #define GDISP_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ - + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 /* FSMC setup for F1 */ rccEnableAHB(RCC_AHBENR_FSMCEN, 0); @@ -61,6 +57,7 @@ static inline void init_board(GDisplay *g, unsigned display) { /* Bank1 NOR/SRAM control register configuration * This is actually not needed as already set by default after reset */ FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + break; } } diff --git a/drivers/gdisp/ILI9325/board_ILI9325_template.h b/drivers/gdisp/ILI9325/board_ILI9325_template.h index 7b067293..65ab5704 100644 --- a/drivers/gdisp/ILI9325/board_ILI9325_template.h +++ b/drivers/gdisp/ILI9325/board_ILI9325_template.h @@ -20,16 +20,14 @@ * @brief Initialise the board for the display. * * @param[in] g The GDisplay structure - * @param[in] display The display number on this controller (0..n) * * @note Set the g->priv member to whatever is appropriate. For multiple * displays this might be a pointer to the appropriate register set. * * @notapi */ -static inline void init_board(GDisplay *g, unsigned display) { +static inline void init_board(GDisplay *g) { (void) g; - (void) display; } /** diff --git a/drivers/gdisp/ILI9325/gdisp_lld.c b/drivers/gdisp/ILI9325/gdisp_lld.c index 42acdc46..8a4b8603 100644 --- a/drivers/gdisp/ILI9325/gdisp_lld.c +++ b/drivers/gdisp/ILI9325/gdisp_lld.c @@ -96,11 +96,11 @@ static void set_viewport(GDisplay* g) { } } -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { uint16_t cver; /* Initialise your display */ - init_board(g, display); + init_board(g); /* Hardware reset */ setpin_reset(g, TRUE); diff --git a/drivers/gdisp/ILI9481/board_ILI9481_firebullstm32f103.h b/drivers/gdisp/ILI9481/board_ILI9481_firebullstm32f103.h index 6614d578..9933d17b 100644 --- a/drivers/gdisp/ILI9481/board_ILI9481_firebullstm32f103.h +++ b/drivers/gdisp/ILI9481/board_ILI9481_firebullstm32f103.h @@ -25,16 +25,13 @@ #define SET_RD palSetPad(GPIOD, 15); #define CLR_RD palClearPad(GPIOD, 15); -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOD, 12, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOD, 13, PAL_MODE_OUTPUT_PUSHPULL); @@ -46,6 +43,7 @@ static inline void init_board(GDisplay *g, unsigned display) { SET_RD; SET_WR; CLR_CS; + break; } } diff --git a/drivers/gdisp/ILI9481/board_ILI9481_template.h b/drivers/gdisp/ILI9481/board_ILI9481_template.h index f3f8bbb7..8dcee19c 100644 --- a/drivers/gdisp/ILI9481/board_ILI9481_template.h +++ b/drivers/gdisp/ILI9481/board_ILI9481_template.h @@ -21,16 +21,14 @@ * @brief Initialise the board for the display. * * @param[in] g The GDisplay structure - * @param[in] display The display number on this controller (0..n) * * @note Set the g->priv member to whatever is appropriate. For multiple * displays this might be a pointer to the appropriate register set. * * @notapi */ -static inline void init_board(GDisplay *g, unsigned display) { +static inline void init_board(GDisplay *g) { (void) g; - (void) display; } /** diff --git a/drivers/gdisp/ILI9481/gdisp_lld.c b/drivers/gdisp/ILI9481/gdisp_lld.c index 06a9e681..fc00be10 100644 --- a/drivers/gdisp/ILI9481/gdisp_lld.c +++ b/drivers/gdisp/ILI9481/gdisp_lld.c @@ -70,9 +70,9 @@ static void set_viewport(GDisplay* g) { /* Driver exported functions. */ /*===========================================================================*/ -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { /* Initialise your display */ - init_board(g, display); + init_board(g); /* Hardware reset */ setpin_reset(g, TRUE); diff --git a/drivers/gdisp/RA8875/board_RA8875_marlin.h b/drivers/gdisp/RA8875/board_RA8875_marlin.h index 95fb7f9d..88523060 100644 --- a/drivers/gdisp/RA8875/board_RA8875_marlin.h +++ b/drivers/gdisp/RA8875/board_RA8875_marlin.h @@ -20,17 +20,13 @@ #define FSMC_BANK 4 -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ - + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 /* set pins to FSMC mode */ IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; @@ -52,6 +48,7 @@ static inline void init_board(GDisplay *g, unsigned display) { /* Bank1 NOR/SRAM control register configuration * This is actually not needed as already set by default after reset */ FSMC_Bank1->BTCR[FSMC_BANK] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + break; } } diff --git a/drivers/gdisp/RA8875/board_RA8875_template.h b/drivers/gdisp/RA8875/board_RA8875_template.h index 564f60c0..32d12de5 100644 --- a/drivers/gdisp/RA8875/board_RA8875_template.h +++ b/drivers/gdisp/RA8875/board_RA8875_template.h @@ -20,14 +20,14 @@ * @brief Initialise the board for the display. * * @param[in] g The GDisplay structure - * @param[in] display The display number on this controller (0..n) * * @note Set the g->priv member to whatever is appropriate. For multiple * displays this might be a pointer to the appropriate register set. * * @notapi */ -static inline void init_board(GDisplay *g, unsigned display) { +static inline void init_board(GDisplay *g) { + (void) g; } /** @@ -38,6 +38,7 @@ static inline void init_board(GDisplay *g, unsigned display) { * @notapi */ static inline void post_init_board(GDisplay *g) { + (void) g; } /** @@ -49,7 +50,8 @@ static inline void post_init_board(GDisplay *g) { * @notapi */ static inline void setpin_reset(GDisplay *g, bool_t state) { - + (void) g; + (void) state; } /** @@ -60,7 +62,7 @@ static inline void setpin_reset(GDisplay *g, bool_t state) { * @notapi */ static inline void acquire_bus(GDisplay *g) { - + (void) g; } /** @@ -71,7 +73,7 @@ static inline void acquire_bus(GDisplay *g) { * @notapi */ static inline void release_bus(GDisplay *g) { - + (void) g; } /** @@ -83,7 +85,8 @@ static inline void release_bus(GDisplay *g) { * @notapi */ static inline void write_index(GDisplay *g, uint16_t index) { - + (void) g; + (void) index; } /** @@ -95,7 +98,8 @@ static inline void write_index(GDisplay *g, uint16_t index) { * @notapi */ static inline void write_data(GDisplay *g, uint16_t data) { - + (void) g; + (void) data; } /** @@ -106,7 +110,7 @@ static inline void write_data(GDisplay *g, uint16_t data) { * @notapi */ static inline void setreadmode(GDisplay *g) { - + (void) g; } /** @@ -117,7 +121,7 @@ static inline void setreadmode(GDisplay *g) { * @notapi */ static inline void setwritemode(GDisplay *g) { - + (void) g; } /** @@ -132,9 +136,8 @@ static inline void setwritemode(GDisplay *g) { * @notapi */ static inline uint16_t read_data(GDisplay *g) { - + (void) g; } #endif /* _GDISP_LLD_BOARD_H */ /** @} */ - diff --git a/drivers/gdisp/RA8875/gdisp_lld.c b/drivers/gdisp/RA8875/gdisp_lld.c index 4c146321..6697d9fd 100644 --- a/drivers/gdisp/RA8875/gdisp_lld.c +++ b/drivers/gdisp/RA8875/gdisp_lld.c @@ -106,9 +106,9 @@ static inline void set_backlight(GDisplay* g, uint8_t percent) { /* Driver exported functions. */ /*===========================================================================*/ -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { /* Initialise your display */ - init_board(g, display); + init_board(g); // Hardware reset setpin_reset(g, TRUE); diff --git a/drivers/gdisp/SSD1289/board_SSD1289_firebullstm32f103.h b/drivers/gdisp/SSD1289/board_SSD1289_firebullstm32f103.h index df7594f8..338d9799 100644 --- a/drivers/gdisp/SSD1289/board_SSD1289_firebullstm32f103.h +++ b/drivers/gdisp/SSD1289/board_SSD1289_firebullstm32f103.h @@ -24,16 +24,13 @@ #define SET_RD palSetPad(GPIOD, 15); #define CLR_RD palClearPad(GPIOD, 15); -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - - /** - * Set up for Display 0 - */ + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOD, 12, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOD, 13, PAL_MODE_OUTPUT_PUSHPULL); @@ -45,6 +42,7 @@ static inline void init_board(GDisplay *g, unsigned display) { SET_RD; SET_WR; CLR_CS; + break; } } diff --git a/drivers/gdisp/SSD1289/board_SSD1289_stm32f4discovery.h b/drivers/gdisp/SSD1289/board_SSD1289_stm32f4discovery.h index 84082089..d1e23c4a 100644 --- a/drivers/gdisp/SSD1289/board_SSD1289_stm32f4discovery.h +++ b/drivers/gdisp/SSD1289/board_SSD1289_stm32f4discovery.h @@ -34,16 +34,14 @@ static const PWMConfig pwmcfg = { 0 }; -static inline void init_board(GDisplay *g, unsigned display) { +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; - if (display == 0) { - + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 /** - * Set up for Display 0 - * * Performs the following functions: * 1. initialise the io port used by the display * 2. initialise the reset pin (initial state not-in-reset) @@ -95,6 +93,7 @@ static inline void init_board(GDisplay *g, unsigned display) { pwmStart(&PWMD3, &pwmcfg); palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATE(2)); pwmEnableChannel(&PWMD3, 2, 100); + break; } } diff --git a/drivers/gdisp/SSD1289/board_SSD1289_template.h b/drivers/gdisp/SSD1289/board_SSD1289_template.h index b24789ea..8bef95b9 100644 --- a/drivers/gdisp/SSD1289/board_SSD1289_template.h +++ b/drivers/gdisp/SSD1289/board_SSD1289_template.h @@ -20,16 +20,14 @@ * @brief Initialise the board for the display. * * @param[in] g The GDisplay structure - * @param[in] display The display number on this controller (0..n) * * @note Set the g->priv member to whatever is appropriate. For multiple * displays this might be a pointer to the appropriate register set. * * @notapi */ -static inline void init_board(GDisplay *g, unsigned display) { +static inline void init_board(GDisplay *g) { (void) g; - (void) display; } /** diff --git a/drivers/gdisp/SSD1289/gdisp_lld.c b/drivers/gdisp/SSD1289/gdisp_lld.c index dca11d5d..b376083c 100644 --- a/drivers/gdisp/SSD1289/gdisp_lld.c +++ b/drivers/gdisp/SSD1289/gdisp_lld.c @@ -114,9 +114,9 @@ static void set_viewport(GDisplay* g) { /* Driver exported functions. */ /*===========================================================================*/ -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { /* Initialise your display */ - init_board(g, display); + init_board(g); // Hardware reset setpin_reset(g, TRUE); diff --git a/drivers/multiple/Win32/gdisp_lld.c b/drivers/multiple/Win32/gdisp_lld.c index dae92821..6c2e7f33 100644 --- a/drivers/multiple/Win32/gdisp_lld.c +++ b/drivers/multiple/Win32/gdisp_lld.c @@ -381,7 +381,7 @@ static DECLARE_THREAD_FUNCTION(WindowThread, param) { /* Driver exported functions. */ /*===========================================================================*/ -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { winPriv * priv; char buf[132]; @@ -426,13 +426,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { // Turn on toggles for the first GINPUT_TOGGLE_CONFIG_ENTRIES windows #if GINPUT_NEED_TOGGLE - if (display < GINPUT_TOGGLE_CONFIG_ENTRIES) + if (g->controllerdisplay < GINPUT_TOGGLE_CONFIG_ENTRIES) g->flags |= GDISP_FLG_HASTOGGLE; #endif // Only turn on mouse on the first window for now #if GINPUT_NEED_MOUSE - if (!display) + if (!g->controllerdisplay) g->flags |= GDISP_FLG_HASMOUSE; #endif @@ -443,13 +443,13 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { g->priv = priv; // Create the window in the message thread - PostThreadMessage(winThreadId, WM_USER, (WPARAM)display, (LPARAM)g); + PostThreadMessage(winThreadId, WM_USER, (WPARAM)g->controllerdisplay, (LPARAM)g); // Wait for the window creation to complete (for safety) while(!(((volatile GDisplay *)g)->flags & GDISP_FLG_READY)) Sleep(1); - sprintf(buf, APP_NAME " - %u", display+1); + sprintf(buf, APP_NAME " - %u", g->systemdisplay+1); SetWindowText(priv->hwnd, buf); ShowWindow(priv->hwnd, SW_SHOW); UpdateWindow(priv->hwnd); diff --git a/drivers/multiple/X/gdisp_lld.c b/drivers/multiple/X/gdisp_lld.c index fc573c87..188724ed 100644 --- a/drivers/multiple/X/gdisp_lld.c +++ b/drivers/multiple/X/gdisp_lld.c @@ -145,7 +145,7 @@ static int FatalXIOError(Display *d) { exit(0); } -LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { +LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { XSizeHints *pSH; XSetWindowAttributes xa; XTextProperty WindowTitle; @@ -208,7 +208,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display) { { char buf[132]; - sprintf(buf, "uGFX - %u", display+1); + sprintf(buf, "uGFX - %u", g->systemdisplay+1); WindowTitleText = buf; XStringListToTextProperty(&WindowTitleText, 1, &WindowTitle); XSetWMName(dis, priv->win, &WindowTitle); diff --git a/include/gdisp/lld/gdisp_lld.h b/include/gdisp/lld/gdisp_lld.h index 1a08b330..442e9b6d 100644 --- a/include/gdisp/lld/gdisp_lld.h +++ b/include/gdisp/lld/gdisp_lld.h @@ -172,7 +172,8 @@ /*===========================================================================*/ struct GDisplay { - GDISPControl g; // The public GDISP stuff - must be the first element + // The public GDISP stuff - must be the first element + GDISPControl g; #if GDISP_TOTAL_CONTROLLERS > 1 const struct GDISPVMT const * vmt; // The Virtual Method Table @@ -180,7 +181,8 @@ struct GDisplay { void * priv; // A private area just for the drivers use. - + uint8_t systemdisplay; + uint8_t controllerdisplay; uint16_t flags; #define GDISP_FLG_INSTREAM 0x0001 // We are in a user based stream operation #define GDISP_FLG_SCRSTREAM 0x0002 // The stream area currently covers the whole screen @@ -241,10 +243,9 @@ struct GDisplay { * @brief Initialize the driver. * @return TRUE if successful. * @param[in] g The driver structure - * @param[in] display The display number for this controller 0..n * @param[out] g->g The driver must fill in the GDISPControl structure */ - LLDSPEC bool_t gdisp_lld_init(GDisplay *g, unsigned display); + LLDSPEC bool_t gdisp_lld_init(GDisplay *g); #if GDISP_HARDWARE_STREAM_WRITE || defined(__DOXYGEN__) /** @@ -477,7 +478,7 @@ struct GDisplay { #if GDISP_TOTAL_CONTROLLERS > 1 typedef struct GDISPVMT { - bool_t (*init)(GDisplay *g, unsigned display); + bool_t (*init)(GDisplay *g); void (*writestart)(GDisplay *g); // Uses p.x,p.y p.cx,p.cy void (*writepos)(GDisplay *g); // Uses p.x,p.y void (*writecolor)(GDisplay *g); // Uses p.color @@ -569,7 +570,7 @@ struct GDisplay { }}; #else - #define gdisp_lld_init(g, display) g->vmt->init(g, display) + #define gdisp_lld_init(g) g->vmt->init(g) #define gdisp_lld_write_start(g) g->vmt->writestart(g) #define gdisp_lld_write_pos(g) g->vmt->writepos(g) #define gdisp_lld_write_color(g) g->vmt->writecolor(g) diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c index ef388df5..66cd59fd 100644 --- a/src/gdisp/gdisp.c +++ b/src/gdisp/gdisp.c @@ -493,9 +493,9 @@ static void line_clip(GDisplay *g) { /* Our module initialiser */ void _gdispInit(void) { GDisplay *g; - unsigned i; + uint16_t i; #if GDISP_TOTAL_CONTROLLERS > 1 - unsigned j; + uint16_t j; #endif @@ -504,13 +504,17 @@ void _gdispInit(void) { for(g = GDisplayArray, j=0; j < GDISP_TOTAL_CONTROLLERS; j++) for(i = 0; i < DisplayCountList[j]; g++, i++) { g->vmt = ControllerList[j]; + g->systemdisplay = j*GDISP_TOTAL_CONTROLLERS+i; + g->controllerdisplay = i; #else for(g = GDisplayArray, i = 0; i < GDISP_TOTAL_DISPLAYS; g++, i++) { + g->systemdisplay = i; + g->controllerdisplay = i; #endif MUTEX_INIT(g); MUTEX_ENTER(g); g->flags = 0; - gdisp_lld_init(g, i); + gdisp_lld_init(g); // Set the initial clipping region #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP