kopia lustrzana https://gitlab.com/sane-project/backends
Added new canon_pp backend for the CanoScan FB330P, FB630P, N340P, and N640P
scanners. Patch from "Matthew Duggan" <stauff@guarana.org>. Henning Meier-Geinitz <henning@meier-geinitz.de>DEVEL_2_0_BRANCH-1
rodzic
15d3c1c4e3
commit
42f9acfefd
|
@ -60,10 +60,10 @@ DISTCLEAN_FILES = @DISTCLEAN_FILES@
|
|||
@SET_MAKE@
|
||||
|
||||
PRELOADABLE_BACKENDS = abaton agfafocus apple artec as6e avision bh canon \
|
||||
coolscan dc25 @DC210@ @DC240@ dmc epson @GPHOTO2@ hp m3096g \
|
||||
matsushita microtek microtek2 mustek mustek_pp mustek_usb nec @NET@ \
|
||||
pie @PINT@ plustek @PNM@ @QCAM@ ricoh s9036 sceptre sharp @SM3600@ \
|
||||
@SNAPSCAN@ sp15c st400 tamarack umax umax_pp umax1220u @V4L@
|
||||
@CANON_PP@ coolscan dc25 @DC210@ @DC240@ dmc epson @GPHOTO2@ hp \
|
||||
m3096g matsushita microtek microtek2 mustek mustek_pp mustek_usb nec \
|
||||
@NET@ pie @PINT@ plustek @PNM@ @QCAM@ ricoh s9036 sceptre sharp \
|
||||
@SM3600@ @SNAPSCAN@ sp15c st400 tamarack umax umax_pp umax1220u @V4L@
|
||||
ALL_BACKENDS = $(PRELOADABLE_BACKENDS) dll
|
||||
|
||||
LIBS = $(addprefix libsane-,$(addsuffix .la,$(ALL_BACKENDS)))
|
||||
|
@ -79,6 +79,8 @@ DISTFILES = abaton.c abaton.conf abaton.h agfafocus.c agfafocus.conf \
|
|||
agfafocus.h apple.c apple.conf apple.h artec.c artec.conf artec.h as6e.c \
|
||||
as6e.h avision.c avision.conf avision.h bh.c bh.conf bh.h canon.c \
|
||||
canon.conf canon.h canon-sane.c canon-scsi.c cderror.h cdjpeg.h coolscan.c \
|
||||
canon_pp.conf canon_pp.h canon_pp.c canon_pp-dev.c canon_pp-dev.h \
|
||||
canon_pp-io.c canon_pp-io.h \
|
||||
coolscan.conf coolscan.h coolscan-scsidef.h CVS dc210.c dc210.conf dc210.h \
|
||||
dc240.c dc240.conf dc240.h dc25.c dc25.conf dc25.h djpeg.c djpeg.README \
|
||||
dll.aliases dll.c dll.conf dmc.c dmc.conf dmc.h epson.c epson.conf epson.h \
|
||||
|
@ -205,6 +207,7 @@ libsane.la: dll.lo dll-s.lo $(EXTRA) $(addsuffix .lo,$(DLL_PRELOAD)) $(LIBOBJS)
|
|||
|
||||
# additional dependencies
|
||||
|
||||
EXTRA_canon_pp = canon_pp-io canon_pp-dev
|
||||
EXTRA_hp = hp-accessor hp-device hp-handle hp-hpmem hp-option hp-scl
|
||||
EXTRA_umax_pp = umax_pp_low umax_pp_mid
|
||||
# EXTRA_dc210 = djpeg
|
||||
|
@ -241,6 +244,8 @@ libsane-bh.la: ../sanei/sanei_scsi.lo
|
|||
libsane-canon.la: ../sanei/sanei_config2.lo
|
||||
libsane-canon.la: ../sanei/sanei_constrain_value.lo
|
||||
libsane-canon.la: ../sanei/sanei_scsi.lo
|
||||
libsane-canon_pp.la: ../sanei/sanei_config2.lo
|
||||
libsane-canon_pp.la: $(addsuffix .lo,$(EXTRA_canon_pp))
|
||||
libsane-coolscan.la: ../sanei/sanei_config2.lo
|
||||
libsane-coolscan.la: ../sanei/sanei_constrain_value.lo
|
||||
libsane-coolscan.la: ../sanei/sanei_scsi.lo
|
||||
|
|
|
@ -0,0 +1,569 @@
|
|||
/* sane - Scanner Access Now Easy.
|
||||
Copyright (C) 2001-2002 Matthew C. Duggan and Simon Krix
|
||||
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 is part of the canon_pp backend, supporting Canon FBX30P
|
||||
and NX40P scanners and also distributed as part of the stand-alone
|
||||
driver.
|
||||
|
||||
canon_pp-io.c: $Revision$
|
||||
|
||||
Low Level Function library for Canon FB330/FB630P Scanners by
|
||||
Simon Krix <kinsei@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <ieee1284.h>
|
||||
#include "canon_pp-io.h"
|
||||
#include "canon_pp-dev.h"
|
||||
|
||||
#ifdef NOSANE
|
||||
|
||||
/* No SANE, Things that only apply to stand-alone */
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
static void DBG(int level, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
#else
|
||||
|
||||
/* Definitions which only apply to SANE compiles */
|
||||
#define VERSION "$Revision$"
|
||||
/* Fix problem with DBG macro definition having a - in the name */
|
||||
#define DEBUG_DECLARE_ONLY
|
||||
#include "canon_pp.h"
|
||||
#include "../include/sane/sanei_debug.h"
|
||||
#include "../include/sane/sanei_config.h"
|
||||
|
||||
#endif
|
||||
|
||||
/* 0x00 = Nibble Mode
|
||||
0x10 = ECP Mode
|
||||
The scanner driver seems not to support ECP RLE mode
|
||||
(which is a huge bummer because compression would be
|
||||
ace) nor EPP mode.
|
||||
*/
|
||||
static int ieee_mode = 0x0;
|
||||
|
||||
static const int verbose = 0;
|
||||
static const int dump_packets = 0;
|
||||
/* This is just for the time being. We need a way to turn on
|
||||
and off status messages so that wait loops involving sending
|
||||
commands don't obscure the program's status log. */
|
||||
|
||||
|
||||
/* Unknown command 1 */
|
||||
static unsigned char command_1[10] = { 0xec, 0x20, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
/************* Local Prototypes ******************/
|
||||
|
||||
/* Used by wake_scanner */
|
||||
static int scanner_reset(struct parport *port);
|
||||
static void scanner_chessboard_control(struct parport *port);
|
||||
static void scanner_chessboard_data(struct parport *port);
|
||||
|
||||
/* Used by read_data */
|
||||
static int ieee_negotiation(struct parport *port, int e);
|
||||
static int ieee_transfer(struct parport *port, int length,
|
||||
unsigned char *data);
|
||||
static int scanner_endtransfer(struct parport *port);
|
||||
|
||||
/* Low level functions */
|
||||
static int readstatus(struct parport *port);
|
||||
static int expect(struct parport *port, const char *step, int s,
|
||||
int mask, unsigned int delay);
|
||||
|
||||
/* Port-level functions */
|
||||
static void outdata(struct parport *port, int d);
|
||||
static void outcont(struct parport *port, int d, int mask);
|
||||
static void outboth(struct parport *port, int d, int c);
|
||||
|
||||
/************************************/
|
||||
|
||||
void sanei_canon_pp_set_ieee1284_mode(int m)
|
||||
{
|
||||
ieee_mode = m;
|
||||
}
|
||||
|
||||
int sanei_canon_pp_wake_scanner(struct parport *port)
|
||||
{
|
||||
/* The scanner tristates the printer's control lines
|
||||
(essentially disabling the passthrough port) and exits
|
||||
from Transparent Mode ready for communication. */
|
||||
int count1 = 0;
|
||||
|
||||
if (readstatus(port) != READY)
|
||||
{
|
||||
DBG(40, "Scanner not ready. Attempting to reset...\n");
|
||||
if (scanner_reset(port))
|
||||
{
|
||||
DBG(10, "Could not gracefully reset scanner.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
count1++;
|
||||
/* Initial line check? */
|
||||
scanner_chessboard_control(port);
|
||||
scanner_chessboard_data(port);
|
||||
expect(port, "Exit Transparent Mode", 0x03, 0x1f, 1000000);
|
||||
|
||||
if (expect(port, "Scanner wakeup reply 1", 0x03, 0x1f, 50000))
|
||||
{
|
||||
outboth(port, 0x04, 0x0d);
|
||||
usleep(100000);
|
||||
outcont(port, 0x07, 0x0f);
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
} while ((count1 < 3) && (!expect(port, "Scanner wakeup reply 2",
|
||||
0x03, 0x1f, 100000) == 0));
|
||||
|
||||
/* Block just after chessboarding
|
||||
Reply 1 (S3 and S4 on, S5 and S7 off) */
|
||||
outcont(port, 0, HOSTBUSY); /* C1 off */
|
||||
/* Reply 2 */
|
||||
if (expect(port, "Reply 2", 12, 0x1f, 1000000))
|
||||
return 1;
|
||||
outcont(port, HOSTBUSY, HOSTBUSY); /* C1 on */
|
||||
if (expect(port, "Reply 3", 0x0b, 0x1f, 1000000))
|
||||
return 1;
|
||||
outboth(port, 0, NSELECTIN | NINIT | HOSTCLK); /* Clear D, C3+, C1- */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sanei_canon_pp_write(struct parport *port, int length, unsigned char *data)
|
||||
{
|
||||
ssize_t count;
|
||||
|
||||
if (dump_packets)
|
||||
{
|
||||
DBG(10,"Sent: ");
|
||||
for (count = 0; count < length; count++)
|
||||
{
|
||||
DBG(10,"%02x ", data[count]);
|
||||
if (count % 20 == 19)
|
||||
DBG(10,"\n ");
|
||||
}
|
||||
if (count % 20 != 19) DBG(10,"\n");
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
DBG(10, "NEW Send Command (length %i):\n", length);
|
||||
if (ieee_mode == 0x10)
|
||||
ieee_negotiation(port, ieee_mode);
|
||||
|
||||
switch (ieee_mode)
|
||||
{
|
||||
case 0:
|
||||
count = ieee1284_compat_write(port, (char *)data,
|
||||
length);
|
||||
if (count != length)
|
||||
return -1;
|
||||
break;
|
||||
case 0x10:
|
||||
if (ieee1284_ecp_write_data(port, 0, (char *)data,
|
||||
length) != length)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (ieee1284_compat_write(port, (char *)data,
|
||||
length) != length)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sanei_canon_pp_read(struct parport *port, int length, unsigned char *data)
|
||||
{
|
||||
int count;
|
||||
|
||||
if (verbose)
|
||||
DBG(10, "NEW read_data (%i bytes):\n", length);
|
||||
ieee_negotiation(port, ieee_mode);
|
||||
|
||||
/* This is special; Nibble mode needs a little
|
||||
extra help from us. */
|
||||
if (ieee_mode == 0)
|
||||
{
|
||||
/* Interrupt phase */
|
||||
outcont(port, NSELECTIN, HOSTBUSY | NSELECTIN);
|
||||
if (expect(port, "Read Data 1", 0, NDATAAVAIL, 6000000))
|
||||
{
|
||||
DBG(10,"Error 1\n");
|
||||
scanner_endtransfer(port);
|
||||
return 1;
|
||||
}
|
||||
outcont(port, HOSTBUSY, HOSTBUSY);
|
||||
|
||||
if (expect(port, "Read Data 2", NACK, NACK, 1000000))
|
||||
{
|
||||
DBG(1,"Error 2\n");
|
||||
scanner_endtransfer(port);
|
||||
return 1;
|
||||
}
|
||||
if (expect(port, "Read Data 3 (Ready?)", 0, PERROR, 1000000))
|
||||
{
|
||||
DBG(1,"Error 3\n");
|
||||
scanner_endtransfer(port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Host-Busy Data Available phase */
|
||||
|
||||
if ((readstatus(port) & NDATAAVAIL) == NDATAAVAIL)
|
||||
{
|
||||
DBG(1,"No data to read.\n");
|
||||
scanner_endtransfer(port);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
count = ieee_transfer(port, length, data);
|
||||
|
||||
if (count != length)
|
||||
{
|
||||
/* If 0 bytes were transferred, it's a legal
|
||||
"No data" condition (I think). Otherwise,
|
||||
print a message. */
|
||||
if (count != 0)
|
||||
DBG(1,"Data read error at byte %i\n", count);
|
||||
|
||||
scanner_endtransfer(port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (dump_packets)
|
||||
{
|
||||
if (length <= 60)
|
||||
{
|
||||
DBG(10,"Read: ");
|
||||
for (count = 0; count < length; count++)
|
||||
{
|
||||
DBG(10,"%02x ", data[count]);
|
||||
if (count % 20 == 19)
|
||||
DBG(10,"\n ");
|
||||
}
|
||||
|
||||
if (count % 20 != 19) DBG(10,"\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG(10,"Read: %i bytes\n", length);
|
||||
}
|
||||
}
|
||||
|
||||
scanner_endtransfer(port);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* IEEE 1284 defines many values for e,
|
||||
but the FB630P only supports 2: nibble and ECP modes.
|
||||
And no data compression either (argh!)
|
||||
0 = Nibble-mode reverse channel transfer
|
||||
16 = ECP-mode
|
||||
*/
|
||||
static int ieee_negotiation(struct parport *port, int e)
|
||||
{
|
||||
int temp;
|
||||
|
||||
if (verbose)
|
||||
DBG(10, "IEEE Negotiation (mode %i)\n", e);
|
||||
|
||||
temp = ieee1284_negotiate(port, e);
|
||||
|
||||
if (verbose)
|
||||
DBG(10, "result: %i)\n", temp);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int ieee_transfer(struct parport *port, int length, unsigned char *data)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (verbose)
|
||||
DBG(10, "IEEE transfer (%i bytes)\n", length);
|
||||
|
||||
switch (ieee_mode)
|
||||
{
|
||||
case 16:
|
||||
result = ieee1284_ecp_read_data(port, 0, (char *)data,
|
||||
length);
|
||||
break;
|
||||
default:
|
||||
result = ieee1284_nibble_read(port, (char *)data,
|
||||
length);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int sanei_canon_pp_check_status(struct parport *port)
|
||||
{
|
||||
int status;
|
||||
unsigned char data[2];
|
||||
|
||||
if (verbose)
|
||||
DBG(10, "* Check Status:\n");
|
||||
|
||||
sanei_canon_pp_read(port, 2, data);
|
||||
|
||||
status = data[0] | (data[1] << 8);
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case 0x0606:
|
||||
if (verbose)
|
||||
DBG(10, "Ready - 0x0606\n");
|
||||
return 0;
|
||||
break;
|
||||
case 0x1414:
|
||||
if (verbose)
|
||||
DBG(10, "Busy - 0x1414\n");
|
||||
return 1;
|
||||
break;
|
||||
case 0x1515:
|
||||
DBG(1, "!! Invalid Command - 0x1515\n");
|
||||
return 2;
|
||||
break;
|
||||
default:
|
||||
DBG(1, "!! Unknown status - %04x\n", status);
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is a subfunction of scanner_readdata() */
|
||||
static int scanner_endtransfer(struct parport *port)
|
||||
{
|
||||
if (verbose)
|
||||
DBG(40, ">> IEEE Terminate\n");
|
||||
ieee1284_terminate(port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Send a raw byte to the printer port */
|
||||
static void outdata(struct parport *port, int d)
|
||||
{
|
||||
ieee1284_write_data(port, d & 0xff);
|
||||
}
|
||||
|
||||
/* Send the low nibble of d to the control port.
|
||||
The mask affects which bits are changed. */
|
||||
static void outcont(struct parport *port, int d, int mask)
|
||||
{
|
||||
static int control_port_status = 0;
|
||||
control_port_status = (control_port_status & ~mask) | (d & mask);
|
||||
ieee1284_write_control(port, (control_port_status & 0x0f));
|
||||
}
|
||||
|
||||
/* Send a byte to both ports */
|
||||
static void outboth(struct parport *port, int d, int c)
|
||||
{
|
||||
ieee1284_write_data(port, d & 0xff);
|
||||
outcont(port, c, 0x0f);
|
||||
}
|
||||
|
||||
/* readstatus():
|
||||
Returns the LOGIC value of the S register (ie: all input lines)
|
||||
shifted right to to make it easier to read. Note: S5 is inverted
|
||||
by ieee1284_read_status so we don't need to */
|
||||
static int readstatus(struct parport *port)
|
||||
{
|
||||
return (ieee1284_read_status(port) & 0xf8) >> 3;
|
||||
}
|
||||
|
||||
static void scanner_chessboard_control(struct parport *port)
|
||||
{
|
||||
/* Wiggle C1 and C3 (twice) */
|
||||
outboth(port, 0x0, 13);
|
||||
usleep(10);
|
||||
outcont(port, 7, 0xf);
|
||||
usleep(10);
|
||||
outcont(port, 13, 0xf);
|
||||
usleep(10);
|
||||
outcont(port, 7, 0xf);
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
static void scanner_chessboard_data(struct parport *port)
|
||||
{
|
||||
int count;
|
||||
for (count = 0; count < 2; count++)
|
||||
{
|
||||
/* Wiggle data lines (4 times) while strobing C1 */
|
||||
outdata(port, 0x33);
|
||||
outcont(port, HOSTBUSY, HOSTBUSY);
|
||||
usleep(10);
|
||||
outcont(port, 0, HOSTBUSY);
|
||||
usleep(10);
|
||||
outcont(port, HOSTBUSY, HOSTBUSY);
|
||||
usleep(10);
|
||||
|
||||
outdata(port, 0xcc);
|
||||
outcont(port, HOSTBUSY, HOSTBUSY);
|
||||
usleep(10);
|
||||
outcont(port, 0, HOSTBUSY);
|
||||
usleep(10);
|
||||
outcont(port, HOSTBUSY, HOSTBUSY);
|
||||
usleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the scanner. At least, it works 50% of the time. */
|
||||
static int scanner_reset(struct parport *port)
|
||||
{
|
||||
|
||||
if (readstatus(port) == 0x0b)
|
||||
{
|
||||
/* Init Block 1 - composed of a 0-byte IEEE read */
|
||||
ieee_negotiation(port, 0x0);
|
||||
ieee1284_terminate(port);
|
||||
ieee_negotiation(port, 0x0);
|
||||
ieee1284_terminate(port);
|
||||
scanner_chessboard_data(port);
|
||||
scanner_chessboard_data(port);
|
||||
scanner_chessboard_data(port);
|
||||
scanner_chessboard_data(port);
|
||||
scanner_chessboard_data(port);
|
||||
|
||||
/* Reset Block 2 =============== */
|
||||
outboth(port, 0x04, 0x0d);
|
||||
|
||||
/* Specifically, we want this: 00111 on S */
|
||||
if (expect(port, "Reset 2 response 1", 0x7, 0x1f, 100000))
|
||||
return 1;
|
||||
|
||||
outcont(port, 0, HOSTCLK);
|
||||
usleep(5);
|
||||
outcont(port, 0x0f, 0xf); /* All lines must be 1. */
|
||||
|
||||
/* All lines 1 */
|
||||
if (expect(port, "Reset 2 response 2 (READY)",
|
||||
0x1f, 0x1f, 100000))
|
||||
return 1;
|
||||
|
||||
outcont(port, 0, HOSTBUSY);
|
||||
usleep(100000); /* a short pause */
|
||||
outcont(port, HOSTBUSY, HOSTBUSY | NSELECTIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
outboth(port, 0x04, 0x0d);
|
||||
|
||||
/* Specifically, we want this: 00111 on S */
|
||||
if (expect(port, "Reset 2 response 1", 0x7, 0x1f, 100000))
|
||||
return 1;
|
||||
|
||||
outcont(port, 0, HOSTCLK);
|
||||
usleep(5);
|
||||
outcont(port, 0x0f, 0xf); /* All lines must be 1. */
|
||||
|
||||
/* All lines 1 */
|
||||
if (expect(port, "Reset 2 response 2 (READY)",
|
||||
0x1f, 0x1f, 1000000))
|
||||
return 1;
|
||||
|
||||
outcont(port, 0, HOSTBUSY);
|
||||
usleep(100000); /* a short pause */
|
||||
outcont(port, HOSTBUSY, HOSTBUSY | NSELECTIN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* A timed version of expect, which will wait for delay before erroring
|
||||
This is the one and only one we should be using */
|
||||
static int expect(struct parport *port, const char *step, int s,
|
||||
int mask, unsigned int delay)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
/*remove warnings*/
|
||||
step=step;
|
||||
|
||||
tv.tv_sec = delay / 1000000;
|
||||
tv.tv_usec = delay % 1000000;
|
||||
|
||||
if (ieee1284_wait_status(port, mask << 3, s << 3, &tv))
|
||||
{
|
||||
DBG(10, "Timeout: %s (0x%02x in 0x%02x) - Status = "
|
||||
"0x%02x\n", step, s, mask, readstatus(port));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sanei_canon_pp_scanner_init(struct parport *port)
|
||||
{
|
||||
|
||||
/* Put the scanner in nibble mode */
|
||||
ieee_negotiation(port, 0x0);
|
||||
|
||||
/* No data to read yet - return to idle mode */
|
||||
scanner_endtransfer(port);
|
||||
|
||||
/* Send Command 1 (unknown purpose) */
|
||||
sanei_canon_pp_write(port, 10, command_1);
|
||||
|
||||
/* In Windows, this is always ECP (or an attempt at it) */
|
||||
sanei_canon_pp_check_status(port);
|
||||
|
||||
/* Scanner status check */
|
||||
sanei_canon_pp_write(port, 10, command_1);
|
||||
sanei_canon_pp_check_status(port);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/* sane - Scanner Access Now Easy.
|
||||
Copyright (C) 2001-2002 Matthew C. Duggan and Simon Krix
|
||||
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.
|
||||
|
||||
-----
|
||||
|
||||
canon_pp-io.h: $Revision$
|
||||
|
||||
This file is part of the canon_pp backend, supporting Canon FBX30P
|
||||
and NX40P scanners and also distributed as part of the stand-alone
|
||||
driver.
|
||||
|
||||
Low-level scanner interface
|
||||
*/
|
||||
|
||||
#ifndef CANON_PP_IO_H
|
||||
#define CANON_PP_IO_H
|
||||
|
||||
/* Actual Interface */
|
||||
void sanei_canon_pp_set_ieee1284_mode(int m);
|
||||
int sanei_canon_pp_wake_scanner(struct parport *port);
|
||||
int sanei_canon_pp_write(struct parport *port, int length,
|
||||
unsigned char *data);
|
||||
int sanei_canon_pp_read(struct parport *port, int length,
|
||||
unsigned char *data);
|
||||
int sanei_canon_pp_check_status(struct parport *port);
|
||||
int sanei_canon_pp_scanner_init(struct parport *port);
|
||||
|
||||
#endif
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,28 @@
|
|||
# Define which port to use if one isn't specified - you should only have
|
||||
# one of these lines!
|
||||
# This is the default port to be used - others will be detected
|
||||
ieee1284 parport0
|
||||
|
||||
|
||||
# Define the location of our pixel weight file, can begin with ~/ if needed.
|
||||
# You can have as many of these as you like - lines with ports that don't exist
|
||||
# will be ignored.
|
||||
#
|
||||
# Parameters are:
|
||||
# calibrate /path/to/calibration-file port-name
|
||||
#
|
||||
# The format of port-name is dependant on your OS version.
|
||||
#
|
||||
# If a file isn't speficied, the default name will be
|
||||
# ~/.sane/canon_pp-calibration-[port-name]
|
||||
|
||||
calibrate ~/.sane/canon_pp-calibration-pp0 parport0
|
||||
|
||||
# calibrate /etc/sane/my_calibration parport1
|
||||
|
||||
|
||||
# Enable the next line if you're having trouble with ECP mode such as I/O
|
||||
# errors. Nibble mode is slower, but more reliable.
|
||||
|
||||
#force_nibble
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
/* sane - Scanner Access Now Easy.
|
||||
Copyright (C) 2001-2002 Matthew C. Duggan and Simon Krix
|
||||
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.
|
||||
|
||||
-----
|
||||
|
||||
canon_pp.h: $Revision$
|
||||
|
||||
This file is part of the canon_pp backend, supporting Canon FBX30P
|
||||
and NX40P scanners
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CANON_PARALLEL_H
|
||||
|
||||
#define CANON_PARALLEL_H
|
||||
|
||||
#ifdef BACKEND_NAME
|
||||
#undef BACKEND_NAME
|
||||
#define BACKEND_NAME canon_pp
|
||||
#endif
|
||||
|
||||
#define DEBUG_NOT_STATIC
|
||||
#include "../include/sane/sanei_debug.h"
|
||||
|
||||
#define PACKAGE "Canon Parallel SANE Backend"
|
||||
#define CMODE_COLOUR "Colour"
|
||||
#define CMODE_MONO "Mono"
|
||||
#define CANONP_CONFIG_FILE "canon_pp.conf"
|
||||
/* options: num,res,colour,depth,tl-x,tl-y,br-x,br-y,cal */
|
||||
/* preview option disabled */
|
||||
#define NUM_OPTIONS 9
|
||||
#define BUF_MAX 64000
|
||||
|
||||
/* Indexes into options array */
|
||||
#define OPT_NUM_OPTIONS 0
|
||||
#define OPT_RESOLUTION 1
|
||||
#define OPT_COLOUR_MODE 2
|
||||
#define OPT_DEPTH 3
|
||||
#define OPT_TL_X 4
|
||||
#define OPT_TL_Y 5
|
||||
#define OPT_BR_X 6
|
||||
#define OPT_BR_Y 7
|
||||
#define OPT_CAL 8
|
||||
#define OPT_PREVIEW 9
|
||||
#if 0
|
||||
#define OPT_GAMMA_R 10
|
||||
#define OPT_GAMMA_G 11
|
||||
#define OPT_GAMMA_B 12
|
||||
#endif
|
||||
/*#define OPT_GAMMA 13*/
|
||||
|
||||
typedef struct CANONP_Scanner_Struct CANONP_Scanner;
|
||||
|
||||
struct CANONP_Scanner_Struct
|
||||
{
|
||||
CANONP_Scanner *next;
|
||||
SANE_Device hw;
|
||||
SANE_Option_Descriptor opt[NUM_OPTIONS];
|
||||
SANE_Int vals[NUM_OPTIONS];
|
||||
SANE_Bool opened;
|
||||
SANE_Bool scanning;
|
||||
SANE_Bool sent_eof;
|
||||
SANE_Bool cancelled;
|
||||
SANE_Bool setup;
|
||||
SANE_Int lines_scanned;
|
||||
|
||||
char *weights_file;
|
||||
SANE_Bool cal_readonly;
|
||||
SANE_Bool cal_valid;
|
||||
|
||||
scanner_parameters params;
|
||||
scan_parameters scan;
|
||||
|
||||
int ieee1284_mode;
|
||||
|
||||
SANE_Bool scanner_present;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -8,6 +8,7 @@ artec
|
|||
as6e
|
||||
bh
|
||||
canon
|
||||
#canon_pp
|
||||
coolscan
|
||||
#dc25
|
||||
#dc210
|
||||
|
|
Ładowanie…
Reference in New Issue