kopia lustrzana https://gitlab.com/sane-project/backends
* added handling of ppdev for kernels prior to 2.4.5
rodzic
a167ab7164
commit
a7a2ab7f11
|
@ -503,7 +503,7 @@ sanei_umax_pp_InitPort (int port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* release port */
|
/* release port */
|
||||||
if(!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
mode = IEEE1284_MODE_COMPAT;
|
mode = IEEE1284_MODE_COMPAT;
|
||||||
ioctl (fd, PPSETMODE, &mode);
|
ioctl (fd, PPSETMODE, &mode);
|
||||||
|
@ -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,35 +1648,41 @@ 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);
|
||||||
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,1);
|
rc = read (fd, dest + size - 1, 1);
|
||||||
|
|
||||||
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,37 +1837,43 @@ 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);
|
||||||
|
|
||||||
rc = read (fd, dest+size-4, 3);
|
rc = read (fd, dest + size - 4, 3);
|
||||||
|
|
||||||
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;
|
mode = IEEE1284_MODE_EPP | IEEE1284_DATA;
|
||||||
rc = ioctl (fd, PPSETMODE, &mode);
|
rc = ioctl (fd, PPSETMODE, &mode);
|
||||||
rc = read (fd, dest+ size-1,1);
|
rc = read (fd, dest + size - 1, 1);
|
||||||
|
|
||||||
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,13 +2266,14 @@ 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)
|
||||||
return(ParportPausedReadBuffer(size,dest));
|
return (ParportPausedReadBuffer (size, dest));
|
||||||
#endif
|
#endif
|
||||||
return(DirectPausedReadBuffer(size,dest));
|
return (DirectPausedReadBuffer (size, dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,20 +64,24 @@ static int
|
||||||
lock_parport (void)
|
lock_parport (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
int mode,fd;
|
int mode, fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBG_INIT ();
|
DBG_INIT ();
|
||||||
DBG(3,"lock_parport\n");
|
DBG (3, "lock_parport\n");
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
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))
|
||||||
mode=IEEE1284_MODE_EPP;
|
exmode = IEEE1284_MODE_COMPAT;
|
||||||
ioctl (fd, PPSETMODE,&mode);
|
if (ioctl (fd, PPGETFLAGS, &exflags))
|
||||||
|
exflags = 0;
|
||||||
|
#endif
|
||||||
|
mode = IEEE1284_MODE_EPP;
|
||||||
|
ioctl (fd, PPSETMODE, &mode);
|
||||||
if (ioctl (sanei_umax_pp_getparport (), PPCLAIM))
|
if (ioctl (sanei_umax_pp_getparport (), PPCLAIM))
|
||||||
{
|
{
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
|
@ -96,18 +100,20 @@ static int
|
||||||
unlock_parport (void)
|
unlock_parport (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd=sanei_umax_pp_getparport ();
|
fd = sanei_umax_pp_getparport ();
|
||||||
if ((fd > 0) && (locked))
|
if ((fd > 0) && (locked))
|
||||||
{
|
{
|
||||||
ioctl (fd, PPSETMODE,&exmode);
|
ioctl (fd, PPSETMODE, &exmode);
|
||||||
ioctl (fd, PPSETFLAGS,&exflags);
|
#ifdef PPSETFLAGS
|
||||||
|
ioctl (fd, PPSETFLAGS, &exflags);
|
||||||
|
#endif
|
||||||
ioctl (fd, PPRELEASE);
|
ioctl (fd, PPRELEASE);
|
||||||
locked = 1;
|
locked = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
DBG(3,"unlock_parport\n");
|
DBG (3, "unlock_parport\n");
|
||||||
locked = 0;
|
locked = 0;
|
||||||
return (UMAX1220P_OK);
|
return (UMAX1220P_OK);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +134,7 @@ sanei_umax_pp_model (int port, int *model)
|
||||||
int recover = 0, rc;
|
int recover = 0, rc;
|
||||||
|
|
||||||
/* set up port */
|
/* set up port */
|
||||||
DBG(3,"sanei_umax_pp_model\n");
|
DBG (3, "sanei_umax_pp_model\n");
|
||||||
sanei_umax_pp_setport (port);
|
sanei_umax_pp_setport (port);
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
|
@ -179,7 +185,7 @@ sanei_umax_pp_attach (int port)
|
||||||
int recover = 0;
|
int recover = 0;
|
||||||
|
|
||||||
/* set up port */
|
/* set up port */
|
||||||
DBG(3,"sanei_umax_pp_attach\n");
|
DBG (3, "sanei_umax_pp_attach\n");
|
||||||
sanei_umax_pp_setport (port);
|
sanei_umax_pp_setport (port);
|
||||||
if (sanei_umax_pp_InitPort (port) != 1)
|
if (sanei_umax_pp_InitPort (port) != 1)
|
||||||
return (UMAX1220P_PROBE_FAILED);
|
return (UMAX1220P_PROBE_FAILED);
|
||||||
|
@ -222,7 +228,7 @@ sanei_umax_pp_open (int port)
|
||||||
int recover = 0;
|
int recover = 0;
|
||||||
|
|
||||||
/* set up port */
|
/* set up port */
|
||||||
DBG(3,"sanei_umax_pp_open\n");
|
DBG (3, "sanei_umax_pp_open\n");
|
||||||
sanei_umax_pp_setport (port);
|
sanei_umax_pp_setport (port);
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
|
@ -272,7 +278,7 @@ sanei_umax_pp_open (int port)
|
||||||
int
|
int
|
||||||
sanei_umax_pp_cancel (void)
|
sanei_umax_pp_cancel (void)
|
||||||
{
|
{
|
||||||
DBG(3,"sanei_umax_pp_cancel\n");
|
DBG (3, "sanei_umax_pp_cancel\n");
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
|
|
||||||
|
@ -283,7 +289,7 @@ sanei_umax_pp_cancel (void)
|
||||||
if (sanei_umax_pp_Park () == 0)
|
if (sanei_umax_pp_Park () == 0)
|
||||||
{
|
{
|
||||||
DBG (0, "Park failed !!! (%s:%d)\n", __FILE__, __LINE__);
|
DBG (0, "Park failed !!! (%s:%d)\n", __FILE__, __LINE__);
|
||||||
unlock_parport();
|
unlock_parport ();
|
||||||
return (UMAX1220P_PARK_FAILED);
|
return (UMAX1220P_PARK_FAILED);
|
||||||
}
|
}
|
||||||
/* EndSession() cancels any pending command */
|
/* EndSession() cancels any pending command */
|
||||||
|
@ -301,7 +307,7 @@ sanei_umax_pp_start (int x, int y, int width, int height, int dpi, int color,
|
||||||
{
|
{
|
||||||
int col = BW_MODE;
|
int col = BW_MODE;
|
||||||
|
|
||||||
DBG(3,"sanei_umax_pp_start\n");
|
DBG (3, "sanei_umax_pp_start\n");
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
/* end session isn't done by cancel any more */
|
/* end session isn't done by cancel any more */
|
||||||
|
@ -317,7 +323,7 @@ sanei_umax_pp_start (int x, int y, int width, int height, int dpi, int color,
|
||||||
unlock_parport ();
|
unlock_parport ();
|
||||||
return (UMAX1220P_START_FAILED);
|
return (UMAX1220P_START_FAILED);
|
||||||
}
|
}
|
||||||
unlock_parport();
|
unlock_parport ();
|
||||||
return (UMAX1220P_OK);
|
return (UMAX1220P_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +331,7 @@ int
|
||||||
sanei_umax_pp_read (long len, int window, int dpi, int last,
|
sanei_umax_pp_read (long len, int window, int dpi, int last,
|
||||||
unsigned char *buffer)
|
unsigned char *buffer)
|
||||||
{
|
{
|
||||||
DBG(3,"sanei_umax_pp_read\n");
|
DBG (3, "sanei_umax_pp_read\n");
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
if (sanei_umax_pp_ReadBlock (len, window, dpi, last, buffer) == 0)
|
if (sanei_umax_pp_ReadBlock (len, window, dpi, last, buffer) == 0)
|
||||||
|
@ -333,7 +339,7 @@ sanei_umax_pp_read (long len, int window, int dpi, int last,
|
||||||
sanei_umax_pp_EndSession ();
|
sanei_umax_pp_EndSession ();
|
||||||
return (UMAX1220P_READ_FAILED);
|
return (UMAX1220P_READ_FAILED);
|
||||||
}
|
}
|
||||||
unlock_parport();
|
unlock_parport ();
|
||||||
return (UMAX1220P_OK);
|
return (UMAX1220P_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +349,7 @@ int
|
||||||
sanei_umax_pp_lamp (int on)
|
sanei_umax_pp_lamp (int on)
|
||||||
{
|
{
|
||||||
/* init transport layer */
|
/* init transport layer */
|
||||||
DBG(3,"sanei_umax_pp_lamp\n");
|
DBG (3, "sanei_umax_pp_lamp\n");
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
|
|
||||||
|
@ -364,7 +370,7 @@ sanei_umax_pp_status (void)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
DBG(3,"sanei_umax_pp_status\n");
|
DBG (3, "sanei_umax_pp_status\n");
|
||||||
if (lock_parport () == UMAX1220P_BUSY)
|
if (lock_parport () == UMAX1220P_BUSY)
|
||||||
return (UMAX1220P_BUSY);
|
return (UMAX1220P_BUSY);
|
||||||
/* check if head is at home */
|
/* check if head is at home */
|
||||||
|
@ -384,21 +390,21 @@ int
|
||||||
sanei_umax_pp_close ()
|
sanei_umax_pp_close ()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
int fd;
|
int fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DBG(3,"sanei_umax_pp_close\n");
|
DBG (3, "sanei_umax_pp_close\n");
|
||||||
|
|
||||||
lock_parport ();
|
lock_parport ();
|
||||||
sanei_umax_pp_EndSession ();
|
sanei_umax_pp_EndSession ();
|
||||||
unlock_parport ();
|
unlock_parport ();
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
fd=sanei_umax_pp_getparport ();
|
fd = sanei_umax_pp_getparport ();
|
||||||
if (fd>0)
|
if (fd > 0)
|
||||||
{
|
{
|
||||||
close(fd);
|
close (fd);
|
||||||
sanei_umax_pp_setparport(0);
|
sanei_umax_pp_setparport (0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return (UMAX1220P_OK);
|
return (UMAX1220P_OK);
|
||||||
|
|
Ładowanie…
Reference in New Issue