diff options
Diffstat (limited to 'src/byteblaster.c')
-rw-r--r-- | src/byteblaster.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/byteblaster.c b/src/byteblaster.c index 838c828..0fd9edb 100644 --- a/src/byteblaster.c +++ b/src/byteblaster.c @@ -24,10 +24,34 @@ #include <stdio.h> #include <fcntl.h> #include <unistd.h> -#include <linux/ppdev.h> -#include <linux/parport.h> #include <sys/ioctl.h> +#ifdef HAVE_LINUX_PPDEV_H +# include <linux/ppdev.h> +#endif +#ifdef HAVE_LINUX_PARPORT_H +# include <linux/parport.h> +#endif +#ifdef HAVE_DEV_PPBUS_PPI_H +# include <dev/ppbus/ppi.h> +#endif +#ifdef HAVE_DEV_PPBUS_PPBCONF_H +# include <dev/ppbus/ppbconf.h> +# define PPRDATA PPIGDATA +# define PPWDATA PPISDATA + +# define PPRSTATUS PPIGSTATUS +# define PPWSTATUS PPISSTATUS + +# define PPRCONTROL PPIGCTRL +# define PPWCONTROL PPISCTRL + +# define PARPORT_CONTROL_AUTOFD AUTOFEED +# define PARPORT_STATUS_ACK nACK +# define PARPORT_STATUS_SELECT SELECT +# define PARPORT_STATUS_BUSY nBUSY +#endif + /*************************************************************************** * * * Private functions * @@ -44,11 +68,13 @@ static void out_data(int device, unsigned char mask, unsigned char val) static void set_AUTOFEED(int device, int value) { - struct ppdev_frob_struct frob; + unsigned char control; - frob.mask = PARPORT_CONTROL_AUTOFD; - frob.val = (value != 0) ? PARPORT_CONTROL_AUTOFD : 0; - ioctl(device, PPFCONTROL, &frob); + ioctl(device, PPRCONTROL, &control); + control &= ~PARPORT_CONTROL_AUTOFD; + if (value != 0) + control |= PARPORT_CONTROL_AUTOFD; + ioctl(device, PPWCONTROL, &control); usleep(100000); } @@ -74,6 +100,7 @@ static int open_parport(char *device_name) printf("Opening %s\n", device_name); dev = open(device_name, O_RDWR); +#ifdef PPCLAIM if (dev < 0) { if (!quiet) @@ -88,6 +115,7 @@ static int open_parport(char *device_name) close(dev); return -1; } +#endif return dev; } @@ -95,7 +123,9 @@ static void close_parport(int device) { if (device) { +#ifdef PPRELEASE ioctl(device, PPRELEASE); +#endif close(device); } } |