Fixed major bug: drivers that accepted size arguments could wind
up with more than 80 characters (20x4) in their display, and thus overwrite memory outside of the allocated 80 characterwframebuffer. For example, using a 20x6 screen would do this. All drivers now either ignore a missing framebuffer, or allocate it themselves - the latter is prefered.
This commit is contained in:
@@ -187,11 +187,6 @@ CFontz_init (lcd_logical_driver * driver, char *args)
|
|||||||
CFontz_autoscroll (0);
|
CFontz_autoscroll (0);
|
||||||
CFontz_backlight (backlight_brightness);
|
CFontz_backlight (backlight_brightness);
|
||||||
|
|
||||||
if (!driver->framebuf) {
|
|
||||||
syslog(LOG_ERR, "cfontz_init: no frame buffer!");
|
|
||||||
CFontz_close ();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// Set the functions the driver supports...
|
// Set the functions the driver supports...
|
||||||
|
|
||||||
driver->clear = CFontz_clear;
|
driver->clear = CFontz_clear;
|
||||||
|
|||||||
@@ -361,12 +361,6 @@ MtxOrb_init (lcd_logical_driver * driver, char *args)
|
|||||||
MtxOrb_cursorblink (DEFAULT_CURSORBLINK);
|
MtxOrb_cursorblink (DEFAULT_CURSORBLINK);
|
||||||
MtxOrb_contrast (contrast);
|
MtxOrb_contrast (contrast);
|
||||||
|
|
||||||
if (!driver->framebuf) {
|
|
||||||
syslog(LOG_ERR, "no frame buffer! exiting driver init...");
|
|
||||||
MtxOrb_close ();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure the display functions
|
* Configure the display functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -26,13 +26,6 @@ debug_init (struct lcd_logical_driver *driver, char *args)
|
|||||||
|
|
||||||
debug_drv = driver;
|
debug_drv = driver;
|
||||||
|
|
||||||
if (driver->framebuf)
|
|
||||||
syslog(LOG_INFO, "frame buffer at: %010X", (int) driver->framebuf);
|
|
||||||
else {
|
|
||||||
syslog(LOG_ERR, "no frame buffer!");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug_clear ();
|
debug_clear ();
|
||||||
|
|
||||||
driver->daemonize = 0;
|
driver->daemonize = 0;
|
||||||
|
|||||||
@@ -196,15 +196,6 @@ int LB216_init(lcd_logical_driver *driver, char *args)
|
|||||||
LB216_hidecursor();
|
LB216_hidecursor();
|
||||||
LB216_backlight(backlight_brightness);
|
LB216_backlight(backlight_brightness);
|
||||||
|
|
||||||
|
|
||||||
if(!driver->framebuf)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "LB216_init: No frame buffer.\n");
|
|
||||||
driver->close();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Set the functions the driver supports...
|
// Set the functions the driver supports...
|
||||||
|
|
||||||
driver->clear = LB216_clear;
|
driver->clear = LB216_clear;
|
||||||
|
|||||||
@@ -445,19 +445,17 @@ lcd_add_driver (char *driver, char *args)
|
|||||||
// Default settings for the driver...
|
// Default settings for the driver...
|
||||||
lcd_drv_init(add, NULL);
|
lcd_drv_init(add, NULL);
|
||||||
|
|
||||||
memset(buf, '\0', sizeof(buf));
|
|
||||||
add->framebuf = buf; // *** HACK: makes drivers think framebuffer is allocated!
|
|
||||||
|
|
||||||
i = init_driver (add, args);
|
i = init_driver (add, args);
|
||||||
|
|
||||||
// Allocate space for a framebuffer... *AFTER* the driver
|
if (!add->framebuf) {
|
||||||
// has a chance to initialize height and width!!
|
|
||||||
if ((add->framebuf = malloc (add->wid * add->hgt)) == NULL) {
|
if ((add->framebuf = malloc (add->wid * add->hgt)) == NULL) {
|
||||||
snprintf (buf, sizeof(buf), "couldn't allocate framebuffer for driver \"%s\"", driver);
|
snprintf (buf, sizeof(buf), "couldn't allocate framebuffer of %d chars for driver \"%s\"",
|
||||||
|
(add->wid * add->hgt), driver);
|
||||||
syslog (LOG_ERR, buf);
|
syslog (LOG_ERR, buf);
|
||||||
// free (add);
|
// free (add);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
memset (add->framebuf, ' ', (add->wid * add->hgt));
|
memset (add->framebuf, ' ', (add->wid * add->hgt));
|
||||||
|
|
||||||
// Now patch up the returned driver structure
|
// Now patch up the returned driver structure
|
||||||
|
|||||||
@@ -217,12 +217,16 @@ sed1520_init (struct lcd_logical_driver *driver, char *args)
|
|||||||
writecommand (0xAF, CS1 + CS2);
|
writecommand (0xAF, CS1 + CS2);
|
||||||
writecommand (0xC0, CS1 + CS2);
|
writecommand (0xC0, CS1 + CS2);
|
||||||
selectpage (3);
|
selectpage (3);
|
||||||
|
|
||||||
|
driver->cellwid = 6;
|
||||||
|
driver->cellhgt = 8;
|
||||||
|
|
||||||
// The Framebuffer LCDproc allocates by default is too small,
|
// The Framebuffer LCDproc allocates by default is too small,
|
||||||
// so we free() it and allocate one of adequate size.
|
// so we free() it (if it exists) and allocate one of adequate size.
|
||||||
if (!driver->framebuf)
|
if (!driver->framebuf)
|
||||||
free (driver->framebuf);
|
free (driver->framebuf);
|
||||||
|
|
||||||
driver->framebuf = malloc (488);
|
driver->framebuf = malloc (122 * 4);
|
||||||
if (!driver->framebuf)
|
if (!driver->framebuf)
|
||||||
{
|
{
|
||||||
sed1520_close ();
|
sed1520_close ();
|
||||||
@@ -232,10 +236,6 @@ sed1520_init (struct lcd_logical_driver *driver, char *args)
|
|||||||
// clear screen
|
// clear screen
|
||||||
memset (driver->framebuf, 0, 122 * 4);
|
memset (driver->framebuf, 0, 122 * 4);
|
||||||
|
|
||||||
driver->cellwid = 6;
|
|
||||||
driver->cellhgt = 8; // FIXME: sed1520->cellwid always stays 5
|
|
||||||
// regardless what it is set to here. This is
|
|
||||||
// a bug but not inside this driver.
|
|
||||||
driver->clear = sed1520_clear;
|
driver->clear = sed1520_clear;
|
||||||
driver->string = sed1520_string;
|
driver->string = sed1520_string;
|
||||||
driver->chr = sed1520_chr;
|
driver->chr = sed1520_chr;
|
||||||
|
|||||||
@@ -447,9 +447,8 @@ stv5730_init (struct lcd_logical_driver *driver, char *args)
|
|||||||
memset (driver->framebuf, 0, STV5730_WID * STV5730_HGT);
|
memset (driver->framebuf, 0, STV5730_WID * STV5730_HGT);
|
||||||
|
|
||||||
driver->cellwid = 4;
|
driver->cellwid = 4;
|
||||||
driver->cellhgt = 6; // FIXME: stv5730->cellwid always stays 5
|
driver->cellhgt = 6;
|
||||||
// regardless what it is set to here. This is
|
|
||||||
// a bug but not inside this driver.
|
|
||||||
driver->clear = stv5730_clear;
|
driver->clear = stv5730_clear;
|
||||||
driver->string = stv5730_string;
|
driver->string = stv5730_string;
|
||||||
driver->chr = stv5730_chr;
|
driver->chr = stv5730_chr;
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ text_init (lcd_logical_driver * driver, char *args)
|
|||||||
{
|
{
|
||||||
text = driver;
|
text = driver;
|
||||||
|
|
||||||
if (!text->framebuf) {
|
|
||||||
syslog(LOG_ERR, "text: no frame buffer!");
|
|
||||||
text_close ();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
text->wid = LCD_DEFAULT_WIDTH;
|
text->wid = LCD_DEFAULT_WIDTH;
|
||||||
text->hgt = LCD_DEFAULT_HEIGHT;
|
text->hgt = LCD_DEFAULT_HEIGHT;
|
||||||
text->cellwid = LCD_DEFAULT_CELL_WIDTH;
|
text->cellwid = LCD_DEFAULT_CELL_WIDTH;
|
||||||
|
|||||||
@@ -148,11 +148,6 @@ sli_init (lcd_logical_driver * driver, char *args)
|
|||||||
out[1] = 0x001; /* Clear LCD, not sure if this belongs here */
|
out[1] = 0x001; /* Clear LCD, not sure if this belongs here */
|
||||||
write (fd, out, 2);
|
write (fd, out, 2);
|
||||||
|
|
||||||
if (!driver->framebuf) {
|
|
||||||
fprintf (stderr, "sli_init: No frame buffer.\n");
|
|
||||||
sli_close ();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// Set LCD parameters (I use a 16x2 LCD) -- small but still useful
|
// Set LCD parameters (I use a 16x2 LCD) -- small but still useful
|
||||||
// Its also much cheaper than the higher quality Matrix Orbital modules
|
// Its also much cheaper than the higher quality Matrix Orbital modules
|
||||||
// Currently, $30 for interface kit and 16x2 non-backlit LCD...
|
// Currently, $30 for interface kit and 16x2 non-backlit LCD...
|
||||||
|
|||||||
Reference in New Issue
Block a user