* added handling of ppdev for kernels prior to 2.4.5

DEVEL_2_0_BRANCH-1
Stéphane Voltz 2001-09-16 05:55:35 +00:00
rodzic a167ab7164
commit a7a2ab7f11
2 zmienionych plików z 145 dodań i 114 usunięć

Wyświetl plik

@ -1535,7 +1535,7 @@ static int
EPPRegisterRead (int reg) EPPRegisterRead (int reg)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc, ex; int fd, mode, rc;
unsigned char breg, bval; unsigned char breg, bval;
#endif #endif
int control; int control;
@ -1549,7 +1549,6 @@ EPPRegisterRead (int reg)
{ {
breg = (unsigned char) (reg); breg = (unsigned char) (reg);
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPGETMODE, &ex);
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &breg, 1); rc = write (fd, &breg, 1);
@ -1563,11 +1562,10 @@ EPPRegisterRead (int reg)
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
rc = ioctl (fd, PPSETMODE, &ex);
return value; return value;
} }
/* if not, direct harware access */ /* if not, direct hardware access */
#endif #endif
Outb (EPPADR, reg); Outb (EPPADR, reg);
@ -1586,7 +1584,7 @@ static void
EPPRegisterWrite (int reg, int value) EPPRegisterWrite (int reg, int value)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc, ex; int fd, mode, rc;
unsigned char breg, bval; unsigned char breg, bval;
#endif #endif
@ -1599,7 +1597,6 @@ EPPRegisterWrite (int reg, int value)
{ {
breg = (unsigned char) (reg); breg = (unsigned char) (reg);
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPGETMODE, &ex);
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &breg, 1); rc = write (fd, &breg, 1);
@ -1610,7 +1607,7 @@ EPPRegisterWrite (int reg, int value)
return; return;
} }
/* if not, direct harware access */ /* if not, direct hardware access */
#endif #endif
Outb (EPPADR, reg); Outb (EPPADR, reg);
Outb (EPPDATA, value); Outb (EPPDATA, value);
@ -1620,7 +1617,7 @@ static void
EPPBlockMode (int flag) EPPBlockMode (int flag)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc, ex; int fd, mode, rc;
unsigned char bval; unsigned char bval;
/* check we have ppdev working */ /* check we have ppdev working */
@ -1629,14 +1626,10 @@ EPPBlockMode (int flag)
{ {
bval = (unsigned char) (flag); bval = (unsigned char) (flag);
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPGETMODE, &ex);
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1); rc = write (fd, &bval, 1);
rc = ioctl (fd, PPSETMODE, &ex);
return; return;
} }
/* if not, direct harware access */
#endif #endif
Outb (EPPADR, flag); Outb (EPPADR, flag);
} }
@ -1645,7 +1638,8 @@ static void
EPPReadBuffer (int size, unsigned char *dest) EPPReadBuffer (int size, unsigned char *dest)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc, ex, exf; int fd, mode, rc;
unsigned char bval;
#endif #endif
int control; int control;
@ -1654,20 +1648,28 @@ EPPReadBuffer (int size, unsigned char *dest)
fd = sanei_umax_pp_getparport (); fd = sanei_umax_pp_getparport ();
if (fd > 0) if (fd > 0)
{ {
EPPBlockMode (0x80);
rc = ioctl (fd, PPGETMODE, &ex); bval = 0x80;
rc = ioctl (fd, PPGETFLAGS, &exf); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
mode = 1; /* data_reverse */ mode = 1; /* data_reverse */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
#ifdef PPSETFLAGS
mode = PP_FASTREAD; mode = PP_FASTREAD;
rc = ioctl (fd, PPSETFLAGS, &mode); rc = ioctl (fd, PPSETFLAGS, &mode);
#endif
mode = IEEE1284_MODE_EPP | IEEE1284_DATA; mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = read (fd, dest, size - 1); rc = read (fd, dest, size - 1);
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
EPPBlockMode (0xA0); bval = 0xA0;
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
mode = 1; /* data_reverse */ mode = 1; /* data_reverse */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
@ -1677,12 +1679,10 @@ EPPReadBuffer (int size, unsigned char *dest)
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
rc = ioctl (fd, PPSETMODE, &ex);
rc = ioctl (fd, PPSETFLAGS, &exf);
return; return;
} }
/* if not, direct harware access */ /* if not, direct hardware access */
#endif #endif
EPPBlockMode (0x80); EPPBlockMode (0x80);
@ -1708,22 +1708,28 @@ EPPWriteBuffer (int size, unsigned char *source)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc; int fd, mode, rc;
unsigned char bval;
#endif #endif
EPPBlockMode (0xC0);
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
/* check we have ppdev working */ /* check we have ppdev working */
fd = sanei_umax_pp_getparport (); fd = sanei_umax_pp_getparport ();
if (fd > 0) if (fd > 0)
{ {
bval = 0xC0;
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
mode = IEEE1284_MODE_EPP | IEEE1284_DATA; mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, source, size); rc = write (fd, source, size);
return; return;
} }
/* if not, direct harware access */ /* if not, direct hardware access */
#endif #endif
EPPBlockMode (0xC0);
Outsb (EPPDATA, source, size); Outsb (EPPDATA, source, size);
} }
@ -1821,7 +1827,8 @@ static void
EPPRead32Buffer (int size, unsigned char *dest) EPPRead32Buffer (int size, unsigned char *dest)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc, ex, exf; int fd, mode, rc;
unsigned char bval;
#endif #endif
int control; int control;
@ -1830,13 +1837,18 @@ EPPRead32Buffer (int size, unsigned char *dest)
fd = sanei_umax_pp_getparport (); fd = sanei_umax_pp_getparport ();
if (fd > 0) if (fd > 0)
{ {
EPPBlockMode (0x80);
rc = ioctl (fd, PPGETMODE, &ex); bval = 0x80;
rc = ioctl (fd, PPGETFLAGS, &exf); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
mode = 1; /* data_reverse */ mode = 1; /* data_reverse */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
#ifdef PPSETFLAGS
mode = PP_FASTREAD; mode = PP_FASTREAD;
rc = ioctl (fd, PPSETFLAGS, &mode); rc = ioctl (fd, PPSETFLAGS, &mode);
#endif
mode = IEEE1284_MODE_EPP | IEEE1284_DATA; mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = read (fd, dest, size - 4); rc = read (fd, dest, size - 4);
@ -1845,7 +1857,10 @@ EPPRead32Buffer (int size, unsigned char *dest)
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
EPPBlockMode (0xA0); bval = 0xA0;
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
mode = 1; /* data_reverse */ mode = 1; /* data_reverse */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
@ -1855,12 +1870,10 @@ EPPRead32Buffer (int size, unsigned char *dest)
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
rc = ioctl (fd, PPSETMODE, &ex);
rc = ioctl (fd, PPSETFLAGS, &exf);
return; return;
} }
/* if not, direct harware access */ /* if not, direct hardware access */
#endif #endif
EPPBlockMode (0x80); EPPBlockMode (0x80);
@ -1886,30 +1899,38 @@ static void
EPPWrite32Buffer (int size, unsigned char *source) EPPWrite32Buffer (int size, unsigned char *source)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
int fd, mode, rc, ex; int fd, mode, rc;
unsigned char bval;
#endif #endif
if ((size % 4) != 0) if ((size % 4) != 0)
{ {
DBG (0, "EPPWrite32Buffer: size %% 4 != 0!! (%s:%d)\n", __FILE__, DBG (0, "EPPWrite32Buffer: size %% 4 != 0!! (%s:%d)\n", __FILE__,
__LINE__); __LINE__);
} }
EPPBlockMode (0xC0);
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
/* check we have ppdev working */ /* check we have ppdev working */
fd = sanei_umax_pp_getparport (); fd = sanei_umax_pp_getparport ();
if (fd > 0) if (fd > 0)
{ {
bval = 0xC0;
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
#ifdef PPSETFLAGS
mode = PP_FASTWRITE; mode = PP_FASTWRITE;
rc = ioctl (fd, PPGETFLAGS, &ex);
rc = ioctl (fd, PPSETFLAGS, &mode); rc = ioctl (fd, PPSETFLAGS, &mode);
#endif
mode = IEEE1284_MODE_EPP | IEEE1284_DATA; mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode); rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, source, size); rc = write (fd, source, size);
rc = ioctl (fd, PPSETFLAGS, &ex);
return; return;
} }
/* if not, direct harware access */ /* if not, direct hardware access */
#endif #endif
EPPBlockMode (0xC0);
Outsw (EPPDATA, source, size / 4); Outsw (EPPDATA, source, size / 4);
} }
@ -1957,31 +1978,31 @@ WaitOnError (void)
static int static int
ParportPausedReadBuffer (int size, unsigned char *dest) ParportPausedReadBuffer (int size, unsigned char *dest)
{ {
unsigned char status; unsigned char status, bval;
int error; int error;
int word; int word;
int bread; int bread;
int c; int c;
int fd,rc,mode,ex,exf; int fd, rc, mode;
/* init */ /* init */
bread = 0; bread = 0;
error = 0; error = 0;
fd = sanei_umax_pp_getparport (); fd = sanei_umax_pp_getparport ();
rc = ioctl (fd, PPGETMODE, &ex);
rc = ioctl (fd, PPGETFLAGS, &exf);
mode = 1; /* data_reverse */ mode = 1; /* data_reverse */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
#ifdef PPSETFLAGS
mode = PP_FASTREAD;
rc = ioctl (fd, PPSETFLAGS, &mode);
#endif
mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode);
if ((size & 0x03) != 0) if ((size & 0x03) != 0)
{ {
while ((!error) && ((size & 0x03) != 0)) while ((!error) && ((size & 0x03) != 0))
{ {
mode = PP_FASTREAD;
rc = ioctl (fd, PPSETFLAGS, &mode);
mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode);
rc = read (fd, dest, 1); rc = read (fd, dest, 1);
size--; size--;
dest++; dest++;
@ -2089,17 +2110,20 @@ ParportPausedReadBuffer (int size, unsigned char *dest)
/* end reading */ /* end reading */
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
EPPBlockMode (0xA0); bval = 0xA0;
mode = IEEE1284_MODE_EPP | IEEE1284_ADDR;
rc = ioctl (fd, PPSETMODE, &mode);
rc = write (fd, &bval, 1);
mode = 1; /* data_reverse */ mode = 1; /* data_reverse */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
rc = ioctl (fd, PPSETMODE, &mode);
rc = read (fd, dest, 1); rc = read (fd, dest, 1);
bread++; bread++;
mode = 0; /* forward */ mode = 0; /* forward */
rc = ioctl (fd, PPDATADIR, &mode); rc = ioctl (fd, PPDATADIR, &mode);
rc = ioctl (fd, PPSETMODE, &ex);
rc = ioctl (fd, PPSETFLAGS, &exf);
return (bread); return (bread);
} }
#endif #endif
@ -2242,7 +2266,8 @@ DirectPausedReadBuffer (int size, unsigned char *dest)
} }
int PausedReadBuffer (int size, unsigned char *dest) int
PausedReadBuffer (int size, unsigned char *dest)
{ {
#ifdef HAVE_LINUX_PPDEV_H #ifdef HAVE_LINUX_PPDEV_H
if (sanei_umax_pp_getparport () > 0) if (sanei_umax_pp_getparport () > 0)

Wyświetl plik

@ -74,8 +74,12 @@ lock_parport (void)
fd = sanei_umax_pp_getparport (); fd = sanei_umax_pp_getparport ();
if ((fd > 0) && (!locked)) if ((fd > 0) && (!locked))
{ {
ioctl (fd, PPGETMODE,&exmode); #ifdef PPGETMODE
ioctl (fd, PPGETFLAGS,&exflags); if (ioctl (fd, PPGETMODE, &exmode))
exmode = IEEE1284_MODE_COMPAT;
if (ioctl (fd, PPGETFLAGS, &exflags))
exflags = 0;
#endif
mode = IEEE1284_MODE_EPP; mode = IEEE1284_MODE_EPP;
ioctl (fd, PPSETMODE, &mode); ioctl (fd, PPSETMODE, &mode);
if (ioctl (sanei_umax_pp_getparport (), PPCLAIM)) if (ioctl (sanei_umax_pp_getparport (), PPCLAIM))
@ -102,7 +106,9 @@ int fd;
if ((fd > 0) && (locked)) if ((fd > 0) && (locked))
{ {
ioctl (fd, PPSETMODE, &exmode); ioctl (fd, PPSETMODE, &exmode);
#ifdef PPSETFLAGS
ioctl (fd, PPSETFLAGS, &exflags); ioctl (fd, PPSETFLAGS, &exflags);
#endif
ioctl (fd, PPRELEASE); ioctl (fd, PPRELEASE);
locked = 1; locked = 1;
} }