--- /dev/null
+This patch fixes compilation errors with hardware that does not have a parallel
+port. It was proposed by serialVFD driver author Stefan Herdler and accepted
+upstream for the next release.
+
+See Gentoo bug #151308 and
+ http://thread.gmane.org/gmane.comp.sysutils.lcdproc/11184/focus=11184
+
+--- ../cvs/lcdproc/server/drivers/serialVFD.c 2006-11-11 18:03:47.000000000 +0100
++++ ./server/drivers/serialVFD.c 2006-11-11 17:07:38.000000000 +0100
+@@ -126,7 +126,7 @@ serialVFD_init (Driver *drvthis)
+ p->cellheight = DEFAULT_CELL_HEIGHT;
+ p->ccmode = CCMODE_STANDARD;
+ p->ISO_8859_1 = 1;
+- p->refresh_timer = 0;
++ p->refresh_timer = 480;
+ p->hw_brightness = 0;
+
+ debug(RPT_INFO, "%s(%p)", __FUNCTION__, drvthis );
+@@ -134,15 +134,17 @@ serialVFD_init (Driver *drvthis)
+ /* Read config file */
+
+ p->use_parallel = drvthis->config_get_bool( drvthis->name, "use_parallel", 0, 0 );
+- if (p->use_parallel) {
+- p->port = drvthis->config_get_int( drvthis->name, "port", 0, LPTPORT );
+- }
+- else {
++
+ /* Which device should be used */
+ strncpy(p->device, drvthis->config_get_string(drvthis->name, "Device", 0, DEFAULT_DEVICE), sizeof(p->device));
+ p->device[sizeof(p->device)-1] = '\0';
+ report(RPT_INFO, "%s: using Device %s", drvthis->name, p->device);
+
++ if (p->use_parallel) {
++ p->port = drvthis->config_get_int( drvthis->name, "port", 0, LPTPORT );
++ }
++ else {
++
+ /* Which speed */
+ tmp = drvthis->config_get_int (drvthis->name, "Speed", 0, DEFAULT_SPEED);
+ if ((tmp != 1200) && (tmp != 2400) && (tmp != 9600) && (tmp != 19200) && (tmp != 115200)) {
+@@ -236,7 +238,7 @@ serialVFD_init (Driver *drvthis)
+ report(RPT_ERR, "%s: unable to create framebuffer backing store.", drvthis->name);
+ return -1;
+ }
+- memset(p->backingstore, ' ', p->width * p->height);
++ memset(p->backingstore, 0, p->width * p->height);
+
+ //setup displayspecific data
+ serialVFD_load_display_data(drvthis);
+@@ -427,8 +429,7 @@ serialVFD_flush (Driver *drvthis)
+ Port_Function[p->use_parallel].write_fkt (drvthis, &p->hw_cmd[p->hw_brightness][1],\
+ p->hw_cmd[p->hw_brightness][0]); // restore brightness
+
+- for (i = 0; i < (p->height * p->width); i++)
+- p->backingstore[i]=0; // clear Backing-store
++ memset(p->backingstore, 0, p->width * p->height); // clear Backing-store
+
+ for(i=0;i<p->customchars;i++) // refresh all customcharacters
+ custom_char_changed[i]=1;
+@@ -659,8 +660,7 @@ serialVFD_close (Driver *drvthis)
+ {
+ PrivateData *p = drvthis->private_data;
+ if (p != NULL) {
+- if (p->fd >= 0)
+- close(p->fd);
++ Port_Function[p->use_parallel].close_fkt (drvthis);
+ if (p->framebuf)
+ free(p->framebuf);
+ if (p->backingstore)
+--- ../cvs/lcdproc/server/drivers/serialVFD.h 2006-10-02 19:48:08.000000000 +0200
++++ ./server/drivers/serialVFD.h 2006-11-12 17:17:04.000000000 +0100
+@@ -73,7 +73,7 @@ MODULE_EXPORT const char * serialVFD_get
+
+ typedef struct driver_private_data {
+ int use_parallel; // use parallel?
+- unsigned int port; // Port in parallel mode
++ unsigned short port; // Port in parallel mode
+ char device[200]; // Device in serial mode
+ int fd;
+ int speed; // Speed in serial mode
+@@ -96,9 +96,9 @@ typedef struct driver_private_data {
+ unsigned char charmap[128];
+ int display_type; // display type
+ int last_custom; // last custom character written
+- char custom_char[31][7]; // stored custom characters
+- char custom_char_store[31][7]; // custom characters backingstore
+- char hw_cmd[10][4]; // hardwarespecific commands
++ unsigned char custom_char[31][7]; // stored custom characters
++ unsigned char custom_char_store[31][7]; // custom characters backingstore
++ unsigned char hw_cmd[10][4]; // hardwarespecific commands
+ int usr_chr_dot_assignment[57]; // how to setup usercharacters
+ unsigned int usr_chr_mapping[31];// where to place the usercharacters (0..30) in the asciicode
+ int hbar_cc_offset; // character offset of the bars
+--- ../cvs/lcdproc/server/drivers/serialVFD_io.c 2006-10-02 19:48:08.000000000 +0200
++++ ./server/drivers/serialVFD_io.c 2006-11-12 19:34:25.000000000 +0100
+@@ -33,6 +33,7 @@
+ #include "serialVFD_io.h"
+ #include "serialVFD.h"
+ #include "lcd.h"
++
+ #define WR_on 0x10
+ #define WR_off 0x11
+ #define Busy 0x80
+@@ -41,30 +42,32 @@
+ #define MAXBUSY 300
+
+ void
+-serialVFD_write_serial (Driver *drvthis, char *dat, size_t length)
++serialVFD_write_serial (Driver *drvthis, unsigned char *dat, size_t length)
+ {
+ PrivateData *p = drvthis->private_data;
+ write (p->fd,dat,length);
+ }
+
+ void
+-serialVFD_write_parallel (Driver *drvthis, char *dat, size_t length)
++serialVFD_write_parallel (Driver *drvthis, unsigned char *dat, size_t length)
+ {
++#ifdef HAVE_PCSTYLE_LPT_CONTROL
+ PrivateData *p = drvthis->private_data;
+ int i_para, j_para;
+
+ for(i_para = 0; i_para < length; i_para++) {
+ port_out(p->port, dat[i_para]);
+- port_in(p->port+1);
++// port_in(p->port+1);
+ port_out(p->port+2, WR_on);
+ port_in(p->port+1);
+ port_out(p->port+2, WR_off);
+-
++ port_in(p->port+1);
+ for(j_para=0; j_para < MAXBUSY; j_para++) {
+ if((port_in(p->port+1)) & Busy)
+ break;
+ }
+ }
++#endif
+ }
+
+ int
+@@ -110,18 +113,37 @@ serialVFD_init_serial (Driver *drvthis)
+ int
+ serialVFD_init_parallel (Driver *drvthis)
+ {
+- int ret=0;
+ PrivateData *p = drvthis->private_data;
++#ifdef HAVE_PCSTYLE_LPT_CONTROL
+ debug( RPT_DEBUG, "%s: Opening parallelport at: 0x%X", __FUNCTION__, p->port);
+-// if(port_access_multiple(p->port,3)) return -1;
+- if(port_access(p->port) != 0) ret=-1;
+- if(port_access(p->port+1) != 0) ret=-1;
+- if(port_access(p->port+2) != 0) ret=-1;
+- if(ret == -1) {
+- report (RPT_ERR, "%s: port_access() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror (errno));
++ if(port_access_multiple(p->port,3)) {
++ report (RPT_ERR, "%s: port_access_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror (errno));
+ return -1;
+ }
+ return 0;
++#else
++ report (RPT_ERR, "%s: LCDproc was compiled without PCstyle LPT support\n", __FUNCTION__);
++ return -1;
++#endif
++}
++
++void
++serialVFD_close_serial (Driver *drvthis)
++{
++ PrivateData *p = drvthis->private_data;
++ if (p->fd >= 0)
++ close(p->fd);
+ }
+
++void
++serialVFD_close_parallel (Driver *drvthis)
++{
++#ifdef HAVE_PCSTYLE_LPT_CONTROL
++ PrivateData *p = drvthis->private_data;
+
++ debug( RPT_DEBUG, "%s: Closing parallelport at: 0x%X", __FUNCTION__, p->port);
++ if(port_deny_multiple(p->port,3)) {
++ report (RPT_ERR, "%s: port_deny_multiple() of 0x%X failed (%s)\n", __FUNCTION__, p->port, strerror (errno));
++ }
++#endif
++}
+--- ../cvs/lcdproc/server/drivers/serialVFD_io.h 2006-10-02 19:48:08.000000000 +0200
++++ ./server/drivers/serialVFD_io.h 2006-11-11 16:47:29.000000000 +0100
+@@ -44,12 +44,15 @@
+
+ int serialVFD_init_serial (Driver *drvthis);
+ int serialVFD_init_parallel (Driver *drvthis);
+-void serialVFD_write_serial (Driver *drvthis, char *dat, size_t length);
+-void serialVFD_write_parallel (Driver *drvthis, char *dat, size_t length);
++void serialVFD_write_serial (Driver *drvthis, unsigned char *dat, size_t length);
++void serialVFD_write_parallel (Driver *drvthis, unsigned char *dat, size_t length);
++void serialVFD_close_serial (Driver *drvthis);
++void serialVFD_close_parallel (Driver *drvthis);
+
+ typedef struct Port_fkt {
+- void (*write_fkt) (Driver *drvthis, char *dat, size_t length);
++ void (*write_fkt) (Driver *drvthis, unsigned char *dat, size_t length);
+ int (*init_fkt) (Driver *drvthis);
++ void (*close_fkt) (Driver *drvthis);
+ } Port_fkt;
+
+
+@@ -57,8 +60,8 @@ static const Port_fkt Port_Function[] =
+ // initialisation function
+ // write function
+
+- {serialVFD_write_serial, serialVFD_init_serial},
+- {serialVFD_write_parallel, serialVFD_init_parallel}
++ {serialVFD_write_serial, serialVFD_init_serial, serialVFD_close_serial},
++ {serialVFD_write_parallel, serialVFD_init_parallel, serialVFD_close_parallel}
+ };
+
+
+
+--- ../cvs/lcdproc/docs/lcdproc-user/drivers/serialVFD.docbook 2006-11-11 18:03:14.000000000 +0100
++++ ./docs/lcdproc-user/drivers/serialVFD.docbook 2006-10-02 19:48:01.000000000 +0200
+@@ -394,7 +394,7 @@ optional
+ <arg choice="plain"><replaceable>CUSTOM-CHARACTERS</replaceable></arg>
+ </term>
+ <listitem><para>
+- Number of Custom-Characters [default: Display-<command>Type</command> dependent].
++Number of Custom-Characters [default: Display-<command>Type</command> dependent].
+ </para></listitem>
+ </varlistentry>
+
+@@ -420,7 +420,7 @@ optional
+ </term>
+ <listitem>
+ <para>
+- Specifies the display type.[default: <literal>0</literal>]
++ Specifies the display type.[default: 0]
+ The following type codes are available:
+ </para>
+ <informaltable>
+@@ -463,7 +463,7 @@ optional
+ <arg choice="plain"><replaceable>BRIGHTNESS</replaceable></arg>
+ </term>
+ <listitem><para>
+-Set the initial brightness [default: <literal>1000</literal>; legal: <literal>0</literal> - <literal>1000</literal>]
++Set the initial brightness [default: 1000; legal: 0 - 1000]
+ (4 steps 0-250, 251-500, 501-750, 751-1000)
+ </para></listitem>
+ </varlistentry>
+@@ -474,7 +474,7 @@ Set the initial brightness [default: <li
+ <arg choice="plain"><replaceable>OFFBRIGHTNESS</replaceable></arg>
+ </term>
+ <listitem><para>
+-Set the initial off-brightness [default: <literal>0</literal>; legal: <literal>0</literal> - <literal>1000</literal>].
++Set the initial off-brightness [default: 0; legal: 0 - 1000].
+ This value is used when the display is normally
+ switched off in case LCDd is inactive.
+ (4 steps 0-250, 251-500, 501-750, 751-1000)
--- /dev/null
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-misc/lcdproc/lcdproc-0.5.1-r1.ebuild,v 1.1 2006/12/20 12:00:00 jokey Exp $
+
+WANT_AUTOCONF="latest"
+WANT_AUTOMAKE="latest"
+inherit eutils flag-o-matic autotools
+
+DESCRIPTION="Client/Server suite to drive all kinds of LCD (-like) devices"
+HOMEPAGE="http://lcdproc.org/"
+SRC_URI="mirror://sourceforge/lcdproc/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+# general use keywords in first line, drivers in line 2
+IUSE="doc debug ldap nfs samba seamless-hbars usb
+ g15 graphlcd irman lirc ncurses svga ula200 xosd"
+
+DEPEND="
+ doc? ( app-text/xmlto )
+ ldap? ( net-nds/openldap )
+ usb? ( dev-libs/libusb )
+
+ graphlcd? ( app-misc/graphlcd-base app-misc/glcdprocdriver )
+ g15? ( app-misc/g15daemon dev-libs/libg15 >=dev-libs/libg15render-1.1.1 )
+ irman? ( media-libs/libirman )
+ lirc? ( app-misc/lirc )
+ ncurses? ( sys-libs/ncurses )
+ svga? ( media-libs/svgalib )
+ ula200? ( dev-embedded/libftdi dev-libs/libusb )
+ xosd? ( x11-libs/xosd x11-libs/libX11 x11-libs/libXext ) "
+RDEPEND=${DEPEND}
+
+USE_DRIVERS="curses g15 glcdlib irman lirc svga ula200 xosd"
+EXTRA_DRIVERS="bayrad CFontz CFontz633 CFontzPacket CwLnx EyeboxOne \
+ glk hd44780 icp_a106 imon IOWarrior joy lb216 lcdm001 \
+ lcterm MD8800 ms6931 mtc_s16209x MtxOrb NoritakeVFD pyramid sed1330 \
+ sed1520 serialVFD sli stv5730 t6963 text tyan "
+ALL_DRIVERS="${USE_DRIVERS} ${EXTRA_DRIVERS}"
+
+
+# compatibility with 1.4-ebuild format
+LCDPROC_DRIVERS=${LCDPROC_DRIVERS//,/ }
+
+# if no drivers or all are set, select the defaults
+has all ${LCDPROC_DRIVERS} \
+ && LCDPROC_DRIVERS="${EXTRA_DRIVERS}"
+[ -z "${LCDPROC_DRIVERS}" ] \
+ && LCDPROC_DRIVERS="${EXTRA_DRIVERS}"
+has none ${LCDPROC_DRIVERS} \
+ && LCDPROC_DRIVERS=""
+
+
+pkg_setup() {
+ echo
+ einfo "If you are updating from lcdproc-0.4, note that the setup of drivers has changed:"
+ einfo "The drivers ${USE_DRIVERS// /, } are controlled by use flags."
+ einfo "All other drivers are built by default, or in respect to the env variable"
+ einfo "LCDPROC_DRIVERS which can be a space separated list. Example:"
+ einfo " LCDPROC_DRIVERS=\"text CFontz\" emerge lcdproc"
+ einfo "You can also set this variable in your make.conf."
+ echo
+ einfo "Possible choices for LCDPROC_DRIVERS are:"
+
+ # Nice Output of EXTRA_DRIVERS
+ local LINE=" "
+ local ELEM=0
+ for driver in ${EXTRA_DRIVERS}; do
+ ELEM=$((${ELEM}+1))
+ LINE="${LINE} ${driver}"
+ if [ "${ELEM}" = 8 ]; then
+ einfo "${LINE}"
+ ELEM=0
+ LINE=" "
+ fi
+ done
+ if [ ! "${ELEM}" = 0 ]; then
+ einfo "${LINE}"
+ fi
+
+ einfo " 'all' if you want to include all drivers (default)."
+ einfo " 'none' will not include any extra drivers."
+ echo
+
+ local FILTERED_DRIVERS
+ for driver in ${LCDPROC_DRIVERS}; do
+ if has ${driver} ${EXTRA_DRIVERS} ; then
+ FILTERED_DRIVERS="${FILTERED_DRIVERS} ${driver}"
+ else
+ eerror "The extra driver '${driver}' is not available or has to be enabled by a USE flag."
+ eerror "Please check your LCDPROC_DRIVERS variable!"
+ echo
+ fi
+ done
+ LCDPROC_DRIVERS="${FILTERED_DRIVERS}"
+
+ # add use-flag specific drivers to LCDPROC_DRIVERS
+ use graphlcd && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} glcdlib"
+ use g15 && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} g15"
+ use irman && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} irman"
+ use lirc && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} lirc"
+ use ncurses && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} curses"
+ use svga && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} svga"
+ use ula200 && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} ula200"
+ use xosd && LCDPROC_DRIVERS="${LCDPROC_DRIVERS} xosd"
+
+ einfo "The following drivers will be built: "
+ echo
+
+ for driver in ${ALL_DRIVERS}; do
+ has ${driver} ${LCDPROC_DRIVERS} && einfo $driver
+ if (! use usb) && (has ${driver} "CFontzPacket CwLnx pyramid"); then
+ ewarn "${driver} might not compile if you do not enable USE=\"usb\""
+ fi
+ done
+}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ epatch "${FILESDIR}/${PV}-LCDd-conf-driver-path.patch"
+ epatch "${FILESDIR}/${PV}-as-needed.patch"
+ epatch "${FILESDIR}/${PV}-serialvfd-parallel.patch"
+ eautoreconf
+}
+
+src_compile() {
+ # avoid executable stack as mentioned
+ # in http://www.gentoo.org/proj/en/hardened/gnu-stack.xml
+ append-ldflags -Wl,-z,noexecstack
+
+ # convert space separated LCDPROC_DRIVERS to comma separated COMMA_DRIVERS
+ local COMMA_DRIVERS
+ for driver in ${LCDPROC_DRIVERS}; do
+ if [ -z "${COMMA_DRIVERS}" ] ; then
+ COMMA_DRIVERS="${driver}"
+ else
+ COMMA_DRIVERS="${COMMA_DRIVERS},${driver}"
+ fi
+ done
+
+ econf \
+ $(use_enable debug) \
+ $(use_enable ldap) \
+ $(use_enable nfs stat-nfs) \
+ $(use_enable samba stat-smbfs ) \
+ $(use_enable seamless-hbars) \
+ $(use_enable usb libusb) \
+ "--enable-drivers=${COMMA_DRIVERS}" \
+ || die "configure failed"
+
+ emake || die "make failed"
+
+ if use doc; then
+ ebegin "Creating user documentation"
+ cd ${S}/docs/lcdproc-user
+ xmlto html lcdproc-user.docbook
+ eend 0
+ ebegin "Creating dev documentation"
+ cd ${S}/docs/lcdproc-dev
+ xmlto html lcdproc-dev.docbook
+ eend 0
+ fi
+}
+
+src_install() {
+ dosbin server/LCDd
+ dobin clients/lcdexec/lcdexec
+ dobin clients/lcdproc/lcdproc
+ dobin clients/lcdvc/lcdvc
+
+ insinto /usr/share/lcdproc/drivers
+ doins server/drivers/*.so
+
+ insinto /usr/share/lcdproc/clients
+ doins clients/examples/*.pl
+ doins clients/metar/lcdmetar.pl
+
+ insinto /etc
+ doins LCDd.conf
+ doins clients/lcdexec/lcdexec.conf
+ doins clients/lcdproc/lcdproc.conf
+ doins clients/lcdvc/lcdvc.conf
+
+ newinitd "${FILESDIR}/${PV}-LCDd.initd" LCDd
+ newinitd "${FILESDIR}/${PV}-lcdproc.initd" lcdproc
+
+ doman docs/*.1 docs/*.5 docs/*.8
+ dodoc README CREDITS ChangeLog INSTALL TODO
+ dodoc docs/README.* docs/*.txt
+
+ if use doc; then
+ insinto /usr/share/doc/${PF}/lcdproc-user
+ doins docs/lcdproc-user/*.html
+ insinto /usr/share/doc/${PF}/lcdproc-dev
+ doins docs/lcdproc-dev/*.html
+ fi
+}