From d0c7529cb9833ede3595051df5599a11fe03be48 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 5 Apr 2007 15:25:19 +0200 Subject: import new upstream --- drv_LCDLinux.c | 98 ++++++++++++++++------------------------------------------ 1 file changed, 27 insertions(+), 71 deletions(-) (limited to 'drv_LCDLinux.c') diff --git a/drv_LCDLinux.c b/drv_LCDLinux.c index 63199c2..26d12f5 100644 --- a/drv_LCDLinux.c +++ b/drv_LCDLinux.c @@ -1,4 +1,5 @@ -/* $Id: drv_LCDLinux.c,v 1.14 2006/07/12 20:47:51 reinelt Exp $ +/* $Id: drv_LCDLinux.c 736 2007-01-16 06:15:15Z michael $ + * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/drv_LCDLinux.c $ * * driver for the LCD-Linux HD44780 kernel driver * http://lcd-linux.sourceforge.net @@ -22,50 +23,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * - * $Log: drv_LCDLinux.c,v $ - * Revision 1.14 2006/07/12 20:47:51 reinelt - * indent - * - * Revision 1.13 2006/04/17 08:10:42 reinelt - * LCDLinux patch from Mattia; widget_image moved to EXTRA_SOURCE - * - * Revision 1.12 2006/01/30 06:25:52 reinelt - * added CVS Revision - * - * Revision 1.11 2006/01/18 11:49:48 reinelt - * adopted to lcd-linux-0.9.2 - * - * Revision 1.10 2005/08/27 07:02:25 reinelt - * LCD-Linux updated to 0.9.0 - * - * Revision 1.9 2005/06/15 05:24:35 reinelt - * updated LCD-Linux driver to version 0.8.9 - * - * Revision 1.8 2005/05/08 04:32:44 reinelt - * CodingStyle added and applied - * - * Revision 1.7 2005/05/02 05:15:46 reinelt - * make busy-flag checking configurable for LCD-Linux driver - * - * 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 - * - * Revision 1.4 2005/02/24 07:06:48 reinelt - * SimpleLCD driver added - * - * Revision 1.3 2005/02/24 06:51:40 reinelt - * LCD-Linux driver GOTO_COST corrected - * - * Revision 1.2 2005/01/30 06:43:22 reinelt - * driver for LCD-Linux finished - * - * Revision 1.1 2005/01/22 22:57:57 reinelt - * LCD-Linux driver added - * */ /* @@ -106,7 +63,6 @@ static char Name[] = "LCD-Linux"; static char Device[] = "/dev/lcd"; static int lcdlinux_fd = -1; -static int raw_mode = 0; /****************************************/ @@ -139,7 +95,7 @@ static void drv_LL_send(const char *string, const int len) static void drv_LL_clear(void) { /* No return value check since this ioctl cannot fail */ - ioctl(lcdlinux_fd, IOCTL_CLEAR_DISP); + ioctl(lcdlinux_fd, LCDL_CLEAR_DISP); } @@ -156,20 +112,17 @@ static void drv_LL_write(const int row, const int col, const char *data, int len static void drv_LL_defchar(const int ascii, const unsigned char *matrix) { - char buffer[8]; - int pos = 1024 + ascii; + char buf[9]; int i; - for (i = 0; i < 8; i++) { - buffer[i] = *matrix++ & 0x1f; + buf[0] = ascii; + for (i = 1; i < 9; i++) { + buf[i] = *matrix++ & 0x1f; } - if (lseek(lcdlinux_fd, pos, SEEK_SET) == (off_t) - 1) { - error("%s: lseek(%s) failed: %s", Name, Device, strerror(errno)); + if (ioctl(lcdlinux_fd, LCDL_SET_CGRAM_CHAR, &buf) != 0) { + error("%s: ioctl(LCDL_SET_CGRAM_CHAR) failed: %s", Name, strerror(errno)); } - - drv_LL_send(buffer, 8); - } @@ -203,20 +156,25 @@ static int drv_LL_start(const char *section, const int quiet) /* get display size */ memset(&buf, 0, sizeof(buf)); - if (ioctl(lcdlinux_fd, IOCTL_GET_PARAM, &buf) != 0) { - error("%s: ioctl(IOCTL_GET_PARAM) failed: %s", Name, strerror(errno)); + if (ioctl(lcdlinux_fd, LCDL_GET_PARAM, &buf) != 0) { + error("%s: ioctl(LCDL_GET_PARAM) failed: %s", Name, strerror(errno)); error("%s: Could not query display information!", Name); return -1; } - info("%s: %dx%d display with %d controllers, flags=0x%02x:", + info("%s: %dx%d display with %d controllers, flags=0x%02lx:", Name, buf.cntr_cols, buf.cntr_rows, buf.num_cntr, buf.flags); - info("%s: busy-flag checking %sabled", Name, buf.flags & HD44780_CHECK_BF ? "en" : "dis"); - info("%s: bus width %d bits", Name, buf.flags & HD44780_4BITS_BUS ? 4 : 8); - info("%s: font size %s", Name, buf.flags & HD44780_5X10_FONT ? "5x10" : "5x8"); - - + info("%s: busy-flag checking %sabled", Name, (buf.flags & HD44780_CHECK_BF) ? "en" : "dis"); + info("%s: bus width %d bits", Name, (buf.flags & HD44780_4BITS_BUS) ? 4 : 8); + info("%s: font size %s", Name, (buf.flags & HD44780_5X10_FONT) ? "5x10" : "5x8"); /* overwrite width size from lcd4linux.conf */ + if (buf.vs_rows || buf.vs_cols) { + info("%s: disabling virtual screen", Name); + buf.vs_rows = 0; + buf.vs_cols = 0; + commit = 1; + } + if ((rows > 0 && rows != buf.cntr_rows) || (cols > 0 && cols != buf.cntr_cols)) { info("%s: changing size to %dx%d", Name, cols, rows); buf.cntr_rows = rows; @@ -251,8 +209,8 @@ static int drv_LL_start(const char *section, const int quiet) commit = 1; } - if (commit && ioctl(lcdlinux_fd, IOCTL_SET_PARAM, &buf) != 0) { - error("%s: ioctl(IOCTL_SET_PARAM) failed: %s", Name, strerror(errno)); + if (commit && ioctl(lcdlinux_fd, LCDL_SET_PARAM, &buf) != 0) { + error("%s: ioctl(LCDL_SET_PARAM) failed: %s", Name, strerror(errno)); return -1; } @@ -261,8 +219,7 @@ static int drv_LL_start(const char *section, const int quiet) /* Disable control characters interpretation. */ /* No return value check since this ioctl cannot fail */ - raw_mode = 1; - ioctl(lcdlinux_fd, IOCTL_RAW_MODE, &raw_mode); + ioctl(lcdlinux_fd, LCDL_RAW_MODE, 1); if (!quiet) { char buffer[40]; @@ -314,7 +271,7 @@ int drv_LL_init(const char *section, const int quiet) int asc255bug; int ret; - info("%s: %s", Name, "$Revision: 1.14 $"); + info("%s: %s", Name, "$Rev: 736 $"); /* display preferences */ XRES = 5; /* pixel width of one char */ @@ -393,8 +350,7 @@ int drv_LL_quit(const int quiet) /* Enable control characters interpretation. */ /* No return value check since this ioctl cannot fail */ - raw_mode = 0; - ioctl(lcdlinux_fd, IOCTL_RAW_MODE, &raw_mode); + ioctl(lcdlinux_fd, LCDL_RAW_MODE, 0); /* close device */ close(lcdlinux_fd); -- cgit v1.2.3