diff options
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 162 | ||||
-rw-r--r-- | configure.in | 3 | ||||
-rw-r--r-- | drivers.m4 | 10 | ||||
-rw-r--r-- | drv_LCDLinux.c | 82 | ||||
-rw-r--r-- | drv_LCDLinux.h | 118 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 4 |
7 files changed, 268 insertions, 114 deletions
diff --git a/config.h.in b/config.h.in index 63afa45..580654e 100644 --- a/config.h.in +++ b/config.h.in @@ -55,6 +55,9 @@ /* Define to 1 if you have the <linux/isdn.h> header file. */ #undef HAVE_LINUX_ISDN_H +/* Define to 1 if you have the <linux/lcd-linux.h> header file. */ +#undef HAVE_LINUX_LCD_LINUX_H + /* Define to 1 if you have the <linux/parport.h> header file. */ #undef HAVE_LINUX_PARPORT_H @@ -5766,6 +5766,159 @@ fi done +# check for LCD-Linux + +for ac_header in linux/lcd-linux.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ---------------------------------------------------- ## +## Report this to lcd4linux-users@lists.sourceforge.net ## +## ---------------------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + has_lcd_linux="true" +else + has_lcd_linux="false" +fi + +done + + # check for python echo "$as_me:$LINENO: checking if python support is wanted" >&5 echo $ECHO_N "checking if python support is wanted... $ECHO_C" >&6 @@ -6072,13 +6225,18 @@ _ACEOF fi if test "$LCDLINUX" = "yes"; then - TEXT="yes" - DRIVERS="$DRIVERS drv_LCDLinux.o" + if test "$has_lcd_linux" = true; then + TEXT="yes" + DRIVERS="$DRIVERS drv_LCDLinux.o" cat >>confdefs.h <<\_ACEOF #define WITH_LCDLINUX 1 _ACEOF + else + { echo "$as_me:$LINENO: WARNING: lcd-linux.h not found: LCD-Linux driver disabled" >&5 +echo "$as_me: WARNING: lcd-linux.h not found: LCD-Linux driver disabled" >&2;} + fi fi if test "$LCDTERM" = "yes"; then diff --git a/configure.in b/configure.in index 60a4e14..87a0981 100644 --- a/configure.in +++ b/configure.in @@ -65,6 +65,9 @@ AC_CHECK_HEADERS(usb.h, [has_usb="true"], [has_usb="false"]) # check for serdisplib AC_CHECK_HEADERS(serdisplib/serdisp.h, [has_serdisplib="true"], [has_serdisplib="false"]) +# check for LCD-Linux +AC_CHECK_HEADERS(linux/lcd-linux.h, [has_lcd_linux="true"], [has_lcd_linux="false"]) + # check for python AC_MSG_CHECKING(if python support is wanted) AC_ARG_WITH(python, @@ -218,9 +218,13 @@ if test "$HD44780" = "yes"; then fi if test "$LCDLINUX" = "yes"; then - TEXT="yes" - DRIVERS="$DRIVERS drv_LCDLinux.o" - AC_DEFINE(WITH_LCDLINUX,1,[LCD-Linux driver]) + if test "$has_lcd_linux" = true; then + TEXT="yes" + DRIVERS="$DRIVERS drv_LCDLinux.o" + AC_DEFINE(WITH_LCDLINUX,1,[LCD-Linux driver]) + else + AC_MSG_WARN(lcd-linux.h not found: LCD-Linux driver disabled) + fi fi if test "$LCDTERM" = "yes"; then diff --git a/drv_LCDLinux.c b/drv_LCDLinux.c index 526c82d..1703cee 100644 --- a/drv_LCDLinux.c +++ b/drv_LCDLinux.c @@ -1,4 +1,4 @@ -/* $Id: drv_LCDLinux.c,v 1.9 2005/06/15 05:24:35 reinelt Exp $ +/* $Id: drv_LCDLinux.c,v 1.10 2005/08/27 07:02:25 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.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 * @@ -84,13 +87,14 @@ #include "drv.h" #include "drv_generic_text.h" -#define HD44780_MAIN +#define LCD_LINUX_MAIN #include "drv_LCDLinux.h" static char Name[] = "LCD-Linux"; static char Device[] = "/dev/lcd"; static int lcdlinux_fd = -1; +static int raw_mode = 0; /****************************************/ @@ -122,8 +126,8 @@ static void drv_LL_send(const char *string, const int len) static void drv_LL_clear(void) { - /* Fixme: is there no otherway to clear the display? */ - drv_LL_send("\14", 1); /* Form Feed */ + /* No return value check since this ioctl cannot fail */ + ioctl(lcdlinux_fd, IOCTL_CLEAR_DISP); } @@ -161,8 +165,8 @@ static int drv_LL_start(const char *section, const int quiet) { char *s; int rows = -1, cols = -1; - int use_busy = 0; - struct lcd_driver buf; + int use_busy = 0, commit = 0; + struct lcd_parameters buf; /* emit version information */ info("%s: Version %s", Name, LCD_LINUX_VERSION); @@ -192,58 +196,51 @@ static int drv_LL_start(const char *section, const int quiet) error("%s: Could not query display information!", Name); return -1; } - info("%s: %dx%d display at 0x%x, %d controllers, flags=0x%02x:", Name, buf.disp_cols, buf.cntr_rows, buf.io, buf.num_cntr, buf.flags); - + info("%s: %dx%d display with %d controllers, flags=0x%02x:", + Name, buf.cntr_cols, buf.cntr_rows, buf.num_cntr, buf.flags); -#if 0 - /* these two flags vanished with release 0.8.9 */ - info("%s: /proc support %sabled", Name, buf.flags & LCD_PROC_ON ? "en" : "dis"); - info("%s: tty support %sabled", Name, buf.flags & LCD_ETTY_ON ? "en" : "dis"); -#endif - info("%s: console support %sabled", Name, buf.flags & LCD_CONSOLE ? "en" : "dis"); - info("%s: bus width %d bits", Name, buf.flags & LCD_4BITS_BUS ? 4 : 8); - info("%s: font size %s", Name, buf.flags & LCD_5X10_FONT ? "5x10" : "5x8"); - info("%s: busy-flag checking %sabled", Name, buf.flags & LCD_CHECK_BF ? "en" : "dis"); + 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 with size from lcd4linux.conf */ - if ((rows > 0 && rows != buf.cntr_rows) || (cols > 0 && cols != buf.disp_cols)) { + 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; - 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; - } + buf.cntr_cols = cols; + commit = 1; } DROWS = buf.cntr_rows; - DCOLS = buf.disp_cols; + DCOLS = buf.cntr_cols; /* overwrite busy-flag checking from lcd4linux.conf */ cfg_number(section, "UseBusy", 0, 0, 1, &use_busy); - if (use_busy && !(buf.flags & LCD_CHECK_BF)) { + if (use_busy && !(buf.flags & HD44780_CHECK_BF)) { info("%s: activating busy-flag checking", Name); - buf.flags |= LCD_CHECK_BF; - if (ioctl(lcdlinux_fd, IOCTL_SET_PARAM, &buf) != 0) { - error("%s: ioctl(IOCTL_SET_PARAM) failed: %s", Name, strerror(errno)); - error("%s: Could not activate busy-flag checking!", Name); - return -1; - } - } else if (!use_busy && (buf.flags & LCD_CHECK_BF)) { + buf.flags |= HD44780_CHECK_BF; + commit = 1; + } else if (!use_busy && (buf.flags & HD44780_CHECK_BF)) { info("%s: deactivating busy-flag checking", Name); - buf.flags &= ~LCD_CHECK_BF; - if (ioctl(lcdlinux_fd, IOCTL_SET_PARAM, &buf) != 0) { - error("%s: ioctl(IOCTL_SET_PARAM) failed: %s", Name, strerror(errno)); - error("%s: Could not deactivate busy-flag checking!", Name); - return -1; - } + buf.flags &= ~HD44780_CHECK_BF; + commit = 1; } + if (commit && ioctl(lcdlinux_fd, IOCTL_SET_PARAM, &buf) != 0) { + error("%s: ioctl(IOCTL_SET_PARAM) failed: %s", Name, strerror(errno)); + return -1; + } + /* initialize display */ drv_LL_clear(); /* clear display */ + /* Disable control characters interpretation. */ + /* No return value check since this ioctl cannot fail */ + raw_mode = 1; + ioctl(lcdlinux_fd, IOCTL_RAW_MODE, &raw_mode); + if (!quiet) { char buffer[40]; qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS); @@ -368,7 +365,12 @@ int drv_LL_quit(const int quiet) if (!quiet) { drv_generic_text_greet("goodbye!", NULL); } - + + /* Enable control characters interpretation. */ + /* No return value check since this ioctl cannot fail */ + raw_mode = 0; + ioctl(lcdlinux_fd, IOCTL_RAW_MODE, &raw_mode); + /* close device */ close(lcdlinux_fd); diff --git a/drv_LCDLinux.h b/drv_LCDLinux.h index 1a36454..c7c7e71 100644 --- a/drv_LCDLinux.h +++ b/drv_LCDLinux.h @@ -1,10 +1,11 @@ -/* lcd.h +/* hd44780.h * - * $Id: drv_LCDLinux.h,v 1.5 2005/06/15 05:24:35 reinelt Exp $ + * $Id: drv_LCDLinux.h,v 1.6 2005/08/27 07:02:25 reinelt Exp $ * - * LCD driver for HD44780 compatible displays connected to the parallel port. + * LCD-Linux: + * Driver for HD44780 compatible displays connected to the parallel port. * - * External interface header file. + * HD44780 header file. * * Copyright (C) 2004, 2005 Mattia Jona-Lasinio (mjona@users.sourceforge.net) * @@ -24,83 +25,66 @@ * */ -#ifndef LCD_LINUX_H -#define LCD_LINUX_H +#ifndef HD44780_H +#define HD44780_H -#ifndef HD44780_MAIN -#warning -#warning LCD-Linux is still in development stage and -#warning aims at speed and optimization. For these -#warning reasons there is no guarantee of backward -#warning compatibility between different LCD-Linux -#warning versions. Be sure to use the lcd-linux.h -#warning file of the same version as the module. -#warning -#endif +#include <linux/lcd-linux.h> -#define LCD_LINUX_VERSION "0.8.9-CVS" /* Version number */ +#define HD44780_VERSION "0.9.0" /* Version number */ +#define HD44780_STRING "hd44780" -#define LCD_MAJOR 120 /* Major number for this device - * Set this to 0 for dynamic allocation - */ -#include <linux/types.h> - -struct lcd_driver { - /* Hardware */ - unsigned short io; /* Parport base address */ - unsigned short flags; /* Flags (see Documentation) */ +/* IOCTLs */ +#include <asm/ioctl.h> +#define IOCTL_RAW_CMD _IOW(LCD_MAJOR, 0, unsigned char *) - /* Display geometry */ - unsigned short num_cntr; /* Number of available controllers */ - unsigned short cntr_rows; /* Rows per controller */ - unsigned short disp_cols; /* Columns */ - unsigned short frames; /* Framebuffer frames */ +/* flags */ +#define HD44780_CHECK_BF 0x0001 /* Do busy flag checking */ +#define HD44780_4BITS_BUS 0x0002 /* Set the bus length to 4 bits */ +#define HD44780_5X10_FONT 0x0004 /* Use 5x10 dots fonts */ - unsigned short tabstop; /* Length of tab character */ -}; -/* IOCTLs */ -#include <asm/ioctl.h> -#define IOCTL_SET_PARAM _IOW(LCD_MAJOR, 0, struct lcd_driver *) -#define IOCTL_GET_PARAM _IOR(LCD_MAJOR, 1, struct lcd_driver *) -#define IOCTL_RAW_CMD _IOW(LCD_MAJOR, 2, unsigned char *) -#define IOCTL_RESET_CHARMAP _IOW(LCD_MAJOR, 3, void *) -#define IOCTL_SAVE_CHARMAP _IOW(LCD_MAJOR, 4, void *) -#define IOCTL_RESTORE_CHARMAP _IOW(LCD_MAJOR, 5, void *) -#define IOCTL_SWAP_CHARMAP _IOW(LCD_MAJOR, 6, void *) -#define LCD_CHECK_BF 0x0001 /* Do busy flag checking */ -#define LCD_CONSOLE 0x0002 /* Enable the console support */ -#define LCD_4BITS_BUS 0x0004 /* Set the bus length to 4 bits */ -#define LCD_5X10_FONT 0x0008 /* Use 5x10 dots fonts */ +/*** HD44780 Command Set ***/ +/* Clear Display*/ +#define CLR_DISP 0x01 /* Clear entire display; cursor at row 0, column 0 */ +/* Return Home */ +#define RET_HOME 0x02 /* Cursor at row 0, column 0; display content doesn't change */ -#ifdef __KERNEL__ /* The rest is for kernel only */ +/* Entry Mode Set */ +#define DISP_SHIFT_ON 0x05 /* Shift display, not cursor after data write */ +#define DISP_SHIFT_OFF 0x04 /* Shift cursor, not display after data write */ +#define CURS_INC 0x06 /* Shift on the right after data read/write */ +#define CURS_DEC 0x04 /* Shift on the left after data read/write */ -#include <linux/version.h> +/* Display on/off Control */ +#define BLINK_ON 0x09 /* Cursor blinking on */ +#define BLINK_OFF 0x08 /* Cursor blinking off */ +#define CURS_ON 0x0a /* Display Cursor */ +#define CURS_OFF 0x08 /* Hide Cursor */ +#define DISP_ON 0x0c /* Turn on display updating */ +#define DISP_OFF 0x08 /* Freeze display content */ -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#endif +/* Cursor or Display Shift */ +#define SHIFT_RIGHT 0x14 /* Shift on the right */ +#define SHIFT_LEFT 0x10 /* Shift on the left */ +#define SHIFT_DISP 0x18 /* Shift display */ +#define SHIFT_CURS 0x10 /* Shift cursor */ -#ifndef LINUX_VERSION_CODE -#error - LINUX_VERSION_CODE undefined. -#endif +/* Function Set */ +#define FONT_5X10 0x24 /* Select 5x10 dots font */ +#define FONT_5X8 0x20 /* Select 5x8 dots font */ +#define DISP_2_LINES 0x28 /* Select 2 lines display (only 5x8 font allowed) */ +#define DISP_1_LINE 0x20 /* Select 1 line display */ +#define BUS_8_BITS 0x30 /* Set 8 data bits */ +#define BUS_4_BITS 0x20 /* Set 4 data bits */ -/* External interface */ -int lcd_init(struct lcd_driver *); -void lcd_exit(void); -int lcd_ioctl(unsigned int, void *); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) -ssize_t lcd_write(const char *, size_t, unsigned int); -ssize_t lcd_read(char *, size_t, unsigned int); -#else -int lcd_write(const char *, int, unsigned int); -int lcd_read(char *, int, unsigned int); -#endif +/* Set CGRAM Address */ +#define CGRAM_IO 0x40 /* Access the CGRAM */ -#endif /* __KERNEL__ */ +/* Set DDRAM Address */ +#define DDRAM_IO 0x80 /* Access the DDRAM */ -#endif /* External interface included */ +#endif /* HD44780 included */ diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index d303f63..47cff2d 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -803,7 +803,7 @@ Layout testMySQL { #Display 'SerDispLib' -#Display 'LCD-Linux' +Display 'LCD-Linux' #Display 'LK204' #Display 'MI240' #Display 'CW12232' @@ -819,7 +819,7 @@ Layout testMySQL { #Display 'M50530-24x8' #Display 'LCDTerm' #Display 'SimpleLCD' -Display 'BA63' +#Display 'BA63' #Display 'CT20x4' #Display 'T6963-240x64' #Display 'XWindow' |