diff options
-rw-r--r-- | drv_LCDLinux.c | 38 | ||||
-rw-r--r-- | drv_LCDLinux.h | 13 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 8 |
3 files changed, 44 insertions, 15 deletions
diff --git a/drv_LCDLinux.c b/drv_LCDLinux.c index 503a01d..fbd8401 100644 --- a/drv_LCDLinux.c +++ b/drv_LCDLinux.c @@ -1,4 +1,4 @@ -/* $Id: drv_LCDLinux.c,v 1.5 2005/04/09 07:36:42 reinelt Exp $ +/* $Id: drv_LCDLinux.c,v 1.6 2005/04/30 06:02:09 reinelt Exp $ * * driver for the LCD-Linux HD44780 kernel driver * http://lcd-linux.sourceforge.net @@ -24,6 +24,9 @@ * * * $Log: drv_LCDLinux.c,v $ + * Revision 1.6 2005/04/30 06:02:09 reinelt + * LCD-Linux display size set up from lcd4linux.conf + * * Revision 1.5 2005/04/09 07:36:42 reinelt * updated LCD-Linux driver to version 0.8.8 * @@ -142,10 +145,23 @@ static void drv_LL_defchar (const int ascii, const unsigned char *matrix) } -static int drv_LL_start (const int quiet) +static int drv_LL_start (const char *section, const int quiet) { + char *s; + int rows=-1, cols=-1; struct lcd_driver buf; + /* get size from config file */ + s=cfg_get(section, "Size", NULL); + if (s != NULL || *s != '\0') { + if (sscanf(s, "%dx%d",&cols,&rows) != 2 || rows < 1 || cols < 1) { + error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source()); + free (s); + return -1; + } + } + free (s); + /* open device */ lcdlinux_fd = open(Device, O_WRONLY); if (lcdlinux_fd == -1) { @@ -156,11 +172,23 @@ static int drv_LL_start (const int quiet) /* get display size */ memset(&buf, 0, sizeof(buf)); if (ioctl(lcdlinux_fd, IOCTL_GET_PARAM, &buf) != 0) { - error ("%s: ioctl() failed: %s", Name, strerror(errno)); + error ("%s: ioctl(IOCTL_GET_PARAM) failed: %s", Name, strerror(errno)); error ("%s: Could not get display geometry!", Name); return -1; } - info("%s: %dx%d display, %d controllers", Name, buf.disp_cols, buf.cntr_rows, buf.num_cntr); + info("%s: %dx%d display (%d controllers)", Name, buf.disp_cols, buf.cntr_rows, buf.num_cntr); + + /* overwrite with size from lcd4linux.conf */ + if ((rows > 0 && rows != buf.cntr_rows) || (cols > 0 && cols != buf.disp_cols)) { + buf.cntr_rows = rows; + buf.disp_cols = cols; + if (ioctl(lcdlinux_fd, IOCTL_SET_PARAM, &buf) != 0) { + error ("%s: ioctl(IOCTL_SET_PARAM) failed: %s", Name, strerror(errno)); + error ("%s: Could not set display geometry!", Name); + return -1; + } + info("%s: size changed to %dx%d", Name, buf.disp_cols, buf.cntr_rows); + } DROWS = buf.cntr_rows; DCOLS = buf.disp_cols; @@ -231,7 +259,7 @@ int drv_LL_init (const char *section, const int quiet) /* start display */ - if ((ret=drv_LL_start (quiet))!=0) + if ((ret=drv_LL_start (section, quiet))!=0) return ret; /* initialize generic text driver */ diff --git a/drv_LCDLinux.h b/drv_LCDLinux.h index 6bdf1f1..2063a04 100644 --- a/drv_LCDLinux.h +++ b/drv_LCDLinux.h @@ -1,6 +1,6 @@ /* lcd.h * - * $Id: drv_LCDLinux.h,v 1.1 2005/04/09 07:36:42 reinelt Exp $ + * $Id: drv_LCDLinux.h,v 1.2 2005/04/30 06:02:09 reinelt Exp $ * * LCD driver for HD44780 compatible displays connected to the parallel port. * @@ -27,7 +27,7 @@ #ifndef LCD_H #define LCD_H -#define LCD_LINUX_VERSION "0.8.8" /* Version number */ +#define LCD_LINUX_VERSION "0.8.9-CVS" /* Version number */ #define LCD_MAJOR 120 /* Major number for this device * Set this to 0 for dynamic allocation @@ -55,11 +55,10 @@ struct lcd_driver { #define IOCTL_GET_PARAM _IOR(LCD_MAJOR, 1, struct lcd_driver *) #define LCD_PROC_ON 0x0001 /* Enable the /proc filesystem support */ -#define LCD_READ_ON 0x0002 /* Enable the read functions */ -#define LCD_ETTY_ON 0x0004 /* Enable the tty support */ -#define LCD_CONSOLE 0x0008 /* Enable the console support */ -#define LCD_4BITS_BUS 0x0010 /* Set the bus length to 4 bits */ -#define LCD_5X10_FONT 0x0020 /* Use 5x10 dots fonts */ +#define LCD_ETTY_ON 0x0002 /* Enable the tty support */ +#define LCD_CONSOLE 0x0004 /* Enable the console support */ +#define LCD_4BITS_BUS 0x0008 /* Set the bus length to 4 bits */ +#define LCD_5X10_FONT 0x0010 /* Use 5x10 dots fonts */ diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 57465f1..f8fa773 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -8,6 +8,7 @@ Display Trefon { Display LCD-Linux { Driver 'LCD-Linux' + Size '20x2' } Display LK204 { @@ -75,8 +76,9 @@ Display Curses { Display HD44780-generic { Driver 'HD44780' Model 'generic' - Port '/dev/parport0' + Port '/dev/parports/0' Size '20x4' + asc255bug 1 Wire { RW 'GND' RS 'AUTOFD' @@ -737,7 +739,7 @@ Layout testMySQL { } -#Display 'LCD-Linux' +Display 'LCD-Linux' #Display 'LK204' #Display 'MI240' #Display 'CW12232' @@ -756,7 +758,7 @@ Layout testMySQL { #Display 'USBLCD' #Display 'BWCT' #Display 'Image' -Display 'Trefon' +#Display 'Trefon' #Layout 'Default' Layout 'L16x2' |