2001-05-03 19:34:02 +00:00
|
|
|
|
/* sane - Scanner Access Now Easy.
|
|
|
|
|
Copyright (C) 2001 St<EFBFBD>phane Voltz <svoltz@wanadoo.fr>
|
|
|
|
|
This file is part of the SANE package.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
|
|
|
MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
|
As a special exception, the authors of SANE give permission for
|
|
|
|
|
additional uses of the libraries contained in this release of SANE.
|
|
|
|
|
|
|
|
|
|
The exception is that, if you link a SANE library with other files
|
|
|
|
|
to produce an executable, this does not by itself cause the
|
|
|
|
|
resulting executable to be covered by the GNU General Public
|
|
|
|
|
License. Your use of that executable is in no way restricted on
|
|
|
|
|
account of linking the SANE library code into it.
|
|
|
|
|
|
|
|
|
|
This exception does not, however, invalidate any other reasons why
|
|
|
|
|
the executable file might be covered by the GNU General Public
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
If you submit changes to SANE to the maintainers to be included in
|
|
|
|
|
a subsequent release, you agree by submitting the changes that
|
|
|
|
|
those changes may be distributed with this exception intact.
|
|
|
|
|
|
|
|
|
|
If you write modifications of your own for SANE, it is your choice
|
|
|
|
|
whether to permit this exception to apply to your modifications.
|
|
|
|
|
If you do not wish that, delete this exception notice.
|
|
|
|
|
|
|
|
|
|
This file implements a SANE backend for Umax PP flatbed scanners. */
|
|
|
|
|
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#include "../include/sane/config.h"
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#include <stdlib.h>
|
2002-01-06 16:23:02 +00:00
|
|
|
|
#include <string.h>
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2001-09-03 12:43:26 +00:00
|
|
|
|
#include <unistd.h>
|
2002-02-05 07:14:53 +00:00
|
|
|
|
#endif
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "../include/sane/sanei_debug.h"
|
|
|
|
|
|
|
|
|
|
#define __MAIN__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "umax_pp_mid.h"
|
|
|
|
|
|
|
|
|
|
/* this function locks the parallel port so that other devices */
|
|
|
|
|
/* won't interfere. Returns UMAX1220P_BUSY is port cannot be */
|
|
|
|
|
/* lock or UMAX1220P_OK if it is locked */
|
2001-09-16 05:55:35 +00:00
|
|
|
|
static int locked = 0;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-09-16 05:55:35 +00:00
|
|
|
|
static int exmode = IEEE1284_MODE_COMPAT;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
static int exflags = 0;
|
|
|
|
|
#endif
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
lock_parport (void)
|
|
|
|
|
{
|
2001-09-03 12:43:26 +00:00
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-09-16 05:55:35 +00:00
|
|
|
|
int mode, fd;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
DBG_INIT ();
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "lock_parport\n");
|
2001-09-03 12:43:26 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-09-16 05:55:35 +00:00
|
|
|
|
fd = sanei_umax_pp_getparport ();
|
2001-09-03 12:43:26 +00:00
|
|
|
|
if ((fd > 0) && (!locked))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2002-01-06 16:23:02 +00:00
|
|
|
|
if (ioctl (sanei_umax_pp_getparport (), PPCLAIM))
|
|
|
|
|
{
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2002-01-06 16:23:02 +00:00
|
|
|
|
}
|
2001-09-16 05:55:35 +00:00
|
|
|
|
#ifdef PPGETMODE
|
|
|
|
|
if (ioctl (fd, PPGETMODE, &exmode))
|
|
|
|
|
exmode = IEEE1284_MODE_COMPAT;
|
|
|
|
|
if (ioctl (fd, PPGETFLAGS, &exflags))
|
|
|
|
|
exflags = 0;
|
|
|
|
|
#endif
|
|
|
|
|
mode = IEEE1284_MODE_EPP;
|
2001-11-10 16:43:15 +00:00
|
|
|
|
ioctl (fd, PPNEGOT, &mode);
|
2001-09-16 05:55:35 +00:00
|
|
|
|
ioctl (fd, PPSETMODE, &mode);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
locked = 1;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
locked = 1;
|
|
|
|
|
#endif
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* this function release parport */
|
|
|
|
|
static int
|
|
|
|
|
unlock_parport (void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-11-10 16:43:15 +00:00
|
|
|
|
int fd, mode;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
|
2001-09-16 05:55:35 +00:00
|
|
|
|
fd = sanei_umax_pp_getparport ();
|
2001-09-03 12:43:26 +00:00
|
|
|
|
if ((fd > 0) && (locked))
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2001-11-10 16:43:15 +00:00
|
|
|
|
mode = IEEE1284_MODE_COMPAT;
|
|
|
|
|
ioctl (fd, PPNEGOT, &mode);
|
2001-09-16 05:55:35 +00:00
|
|
|
|
ioctl (fd, PPSETMODE, &exmode);
|
|
|
|
|
#ifdef PPSETFLAGS
|
|
|
|
|
ioctl (fd, PPSETFLAGS, &exflags);
|
|
|
|
|
#endif
|
2001-09-03 12:43:26 +00:00
|
|
|
|
ioctl (fd, PPRELEASE);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
locked = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "unlock_parport\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
locked = 0;
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* This function recognize the scanner model by sending an image
|
|
|
|
|
* filter command. 1220P will use it as is, but 2000P will return
|
|
|
|
|
* it back modified.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_model (int port, int *model)
|
|
|
|
|
{
|
|
|
|
|
int recover = 0, rc;
|
|
|
|
|
|
|
|
|
|
/* set up port */
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_model\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
sanei_umax_pp_setport (port);
|
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
/* init transport layer */
|
|
|
|
|
/* 0: failed
|
|
|
|
|
1: success
|
|
|
|
|
2: retry
|
|
|
|
|
3: busy
|
|
|
|
|
*/
|
|
|
|
|
do
|
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
rc = sanei_umax_pp_initTransport (recover);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
while (rc == 2);
|
|
|
|
|
|
|
|
|
|
if (rc == 3)
|
2001-09-16 05:55:35 +00:00
|
|
|
|
{
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
}
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (rc != 1)
|
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
DBG (0, "sanei_umax_pp_initTransport() failed (%s:%d)\n", __FILE__,
|
2001-05-03 19:34:02 +00:00
|
|
|
|
__LINE__);
|
2001-09-16 05:55:35 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_TRANSPORT_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
1994-02-15 08:43:42 +00:00
|
|
|
|
|
|
|
|
|
/* check model only, and if only none given in conf file */
|
|
|
|
|
if (!sanei_umax_pp_getastra ())
|
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
rc = sanei_umax_pp_checkModel ();
|
1994-02-15 08:43:42 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rc = sanei_umax_pp_getastra ();
|
|
|
|
|
}
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_endSession ();
|
2001-05-03 19:34:02 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
if (rc < 600)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
DBG (0, "sanei_umax_pp_CheckModel() failed (%s:%d)\n", __FILE__,
|
|
|
|
|
__LINE__);
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_PROBE_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
*model = rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* OK */
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
1994-02-15 08:43:42 +00:00
|
|
|
|
sanei_umax_pp_attach (int port, char *name)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
int recover = 0;
|
|
|
|
|
|
|
|
|
|
/* set up port */
|
1994-02-15 08:43:42 +00:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "sanei_umax_pp_attach(%d,NULL)\n", port);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG (3, "sanei_umax_pp_attach(%d,%s)\n", port, name);
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
sanei_umax_pp_setport (port);
|
2004-03-09 06:12:27 +00:00
|
|
|
|
if (sanei_umax_pp_initPort (port, name) != 1)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_PROBE_FAILED;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
|
|
|
|
|
/* init port locks the port, so we flag that */
|
|
|
|
|
locked = 1;
|
|
|
|
|
|
2004-03-09 06:12:27 +00:00
|
|
|
|
if (sanei_umax_pp_probeScanner (recover) != 1)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (recover)
|
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_initTransport (recover);
|
|
|
|
|
sanei_umax_pp_endSession ();
|
|
|
|
|
if (sanei_umax_pp_probeScanner (recover) != 1)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
DBG (0, "Recover failed ....\n");
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_PROBE_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_PROBE_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_endSession ();
|
2001-05-03 19:34:02 +00:00
|
|
|
|
unlock_parport ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* OK */
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
1994-02-15 08:43:42 +00:00
|
|
|
|
sanei_umax_pp_open (int port, char *name)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
int recover = 0;
|
|
|
|
|
|
|
|
|
|
/* set up port */
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_open\n");
|
1994-02-15 08:43:42 +00:00
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
sanei_umax_pp_setport (port);
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
/* init transport layer */
|
|
|
|
|
/* 0: failed
|
|
|
|
|
1: success
|
|
|
|
|
2: retry
|
|
|
|
|
3: scanner busy
|
|
|
|
|
*/
|
|
|
|
|
do
|
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
rc = sanei_umax_pp_initTransport (recover);
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
while (rc == 2);
|
|
|
|
|
|
|
|
|
|
if (rc == 3)
|
|
|
|
|
{
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rc != 1)
|
|
|
|
|
{
|
|
|
|
|
|
2004-03-09 06:12:27 +00:00
|
|
|
|
DBG (0, "sanei_umax_pp_initTransport() failed (%s:%d)\n", __FILE__,
|
2001-05-03 19:34:02 +00:00
|
|
|
|
__LINE__);
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_TRANSPORT_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
/* init scanner */
|
2004-03-09 06:12:27 +00:00
|
|
|
|
if (sanei_umax_pp_initScanner (recover) == 0)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
DBG (0, "sanei_umax_pp_initScanner() failed (%s:%d)\n", __FILE__,
|
2001-05-03 19:34:02 +00:00
|
|
|
|
__LINE__);
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_endSession ();
|
2001-05-03 19:34:02 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_SCANNER_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* OK */
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_cancel (void)
|
|
|
|
|
{
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_cancel\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2004-03-09 06:12:27 +00:00
|
|
|
|
/* maybe EPAT reset here if exists */
|
|
|
|
|
sanei_umax_pp_cmdSync (0xC2);
|
|
|
|
|
sanei_umax_pp_cmdSync (0x00);
|
|
|
|
|
sanei_umax_pp_cmdSync (0x00);
|
|
|
|
|
if (sanei_umax_pp_park () == 0)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2004-05-03 05:14:20 +00:00
|
|
|
|
DBG (0, "sanei_umax_pp_park failed !!! (%s:%d)\n", __FILE__, __LINE__);
|
2001-09-16 05:55:35 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_PARK_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2004-03-09 06:12:27 +00:00
|
|
|
|
/* endSession() cancels any pending command */
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* such as parking ...., so we only return */
|
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_start (int x, int y, int width, int height, int dpi, int color,
|
2002-01-06 16:23:02 +00:00
|
|
|
|
int autoset,
|
2003-10-09 05:27:39 +00:00
|
|
|
|
int brightness, int contrast, int *rbpp, int *rtw,
|
|
|
|
|
int *rth)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
int col = BW_MODE;
|
|
|
|
|
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_start\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* end session isn't done by cancel any more */
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_endSession ();
|
2001-05-03 19:34:02 +00:00
|
|
|
|
|
2002-01-06 16:23:02 +00:00
|
|
|
|
if (autoset)
|
|
|
|
|
sanei_umax_pp_setauto (1);
|
|
|
|
|
else
|
|
|
|
|
sanei_umax_pp_setauto (0);
|
|
|
|
|
|
2002-11-05 05:40:03 +00:00
|
|
|
|
switch (color)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
col = BW2_MODE;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
col = BW_MODE;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
col = RGB_MODE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-01-06 16:23:02 +00:00
|
|
|
|
|
2004-03-09 06:12:27 +00:00
|
|
|
|
if (sanei_umax_pp_startScan
|
2004-05-03 05:14:20 +00:00
|
|
|
|
(x + sanei_umax_pp_getLeft (), y, width, height, dpi, col, brightness,
|
|
|
|
|
contrast, rbpp, rtw, rth) != 1)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_endSession ();
|
2001-05-03 19:34:02 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_START_FAILED;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2001-09-16 05:55:35 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_read (long len, int window, int dpi, int last,
|
|
|
|
|
unsigned char *buffer)
|
|
|
|
|
{
|
2004-05-03 05:14:20 +00:00
|
|
|
|
int read = 0;
|
|
|
|
|
int bytes;
|
|
|
|
|
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_read\n");
|
2001-09-03 12:43:26 +00:00
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
|
|
|
|
|
|
|
|
|
/* since 610P may override len and last to meet its */
|
|
|
|
|
/* hardware requirements, we have to loop until we */
|
|
|
|
|
/* have all the data */
|
|
|
|
|
while (read < len)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
2004-05-03 05:14:20 +00:00
|
|
|
|
bytes =
|
|
|
|
|
sanei_umax_pp_readBlock (len - read, window, dpi, last,
|
|
|
|
|
buffer + read);
|
|
|
|
|
if (bytes == 0)
|
|
|
|
|
{
|
|
|
|
|
sanei_umax_pp_endSession ();
|
|
|
|
|
return UMAX1220P_READ_FAILED;
|
|
|
|
|
}
|
|
|
|
|
read += bytes;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
2001-09-16 05:55:35 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_lamp (int on)
|
|
|
|
|
{
|
|
|
|
|
/* init transport layer */
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_lamp\n");
|
2004-05-03 05:14:20 +00:00
|
|
|
|
|
|
|
|
|
/* no lamp support for 610P ... */
|
|
|
|
|
if (sanei_umax_pp_getastra () < 1210)
|
|
|
|
|
return UMAX1220P_OK;
|
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-09-16 05:55:35 +00:00
|
|
|
|
|
2004-03-09 06:12:27 +00:00
|
|
|
|
if (sanei_umax_pp_setLamp (on) == 0)
|
2001-05-03 19:34:02 +00:00
|
|
|
|
{
|
|
|
|
|
DBG (0, "Setting lamp state failed!\n");
|
|
|
|
|
}
|
2001-09-16 05:55:35 +00:00
|
|
|
|
|
2001-05-03 19:34:02 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_status (void)
|
|
|
|
|
{
|
|
|
|
|
int status;
|
|
|
|
|
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_status\n");
|
2001-05-03 19:34:02 +00:00
|
|
|
|
if (lock_parport () == UMAX1220P_BUSY)
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
/* check if head is at home */
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_cmdSync (0x40);
|
|
|
|
|
status = sanei_umax_pp_scannerStatus ();
|
2001-09-03 12:43:26 +00:00
|
|
|
|
unlock_parport ();
|
2004-05-03 05:14:20 +00:00
|
|
|
|
DBG (8, "sanei_umax_pp_status=0x%02X\n", status);
|
2004-06-15 05:45:09 +00:00
|
|
|
|
if (((status & ASIC_BIT) != 0x00)||((status & MOTOR_BIT) == 0x00))
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_BUSY;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
sanei_umax_pp_close ()
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-09-16 05:55:35 +00:00
|
|
|
|
int fd;
|
2001-09-03 12:43:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-16 05:55:35 +00:00
|
|
|
|
DBG (3, "sanei_umax_pp_close\n");
|
2001-09-03 12:43:26 +00:00
|
|
|
|
|
|
|
|
|
lock_parport ();
|
2004-03-09 06:12:27 +00:00
|
|
|
|
sanei_umax_pp_endSession ();
|
2001-05-03 19:34:02 +00:00
|
|
|
|
unlock_parport ();
|
|
|
|
|
|
2001-09-03 12:43:26 +00:00
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-09-16 05:55:35 +00:00
|
|
|
|
fd = sanei_umax_pp_getparport ();
|
|
|
|
|
if (fd > 0)
|
2001-09-03 12:43:26 +00:00
|
|
|
|
{
|
2001-09-16 05:55:35 +00:00
|
|
|
|
close (fd);
|
|
|
|
|
sanei_umax_pp_setparport (0);
|
2001-09-03 12:43:26 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2004-05-03 05:14:20 +00:00
|
|
|
|
return UMAX1220P_OK;
|
2001-05-03 19:34:02 +00:00
|
|
|
|
}
|