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

Wyświetl plik

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