2002-03-07 Oliver Rauch <Oliver.Rauch@rauch-domain.de>

* updated umax backend to version 1.0.7-build-33
          new file: umax-usb.c (by Frank Zago)
DEVEL_2_0_BRANCH-1
Oliver Rauch 2002-03-07 19:47:15 +00:00
rodzic a764f02edb
commit 31d39a110b
15 zmienionych plików z 760 dodań i 228 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-scanner.c: scanner-definiton file for UMAX scanner driver.
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-scanner.h: scanner-definiton header-file for UMAX scanner driver.
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -3,7 +3,7 @@
/* umax-scsidef.h: scsi-definiton header file for UMAX scanner driver.
Copyright (C) 1996-1997 Michael K. Johnson
Copyright (C) 1997-2001 Oliver Rauch
Copyright (C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -3,7 +3,7 @@
/* umax-uc1200s.c: inquiry for UMAX scanner uc1200s
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -3,7 +3,7 @@
/* umax-uc1200se.c: inquiry for UMAX scanner uc1200se
(C) 1998-2001 Oliver Rauch
(C) 1998-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-uc1260.c: inquiry for UMAX scanner uc1260
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-uc630.c: inquiry for UMAX scanner uc630
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-uc840.c: inquiry for UMAX scanner uc840
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-ug630.c: inquiry for UMAX scanner ug630
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as

Wyświetl plik

@ -2,7 +2,7 @@
/* umax-ug80.c: inquiry for UMAX scanner ug80
(C) 1998-2001 Oliver Rauch
(C) 1998-2002 Oliver Rauch
Thanks to Andreas Hofmeister <hofmeist@informatik.uni-freiburg.de>
for his help!

327
backend/umax-usb.c 100644
Wyświetl plik

@ -0,0 +1,327 @@
/* ---------------------------------------------------------------------- */
/* sane - Scanner Access Now Easy.
umax-usb.c
(C) 2001-2002 Frank Zago
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 USB flatbed scanners. */
/* ---------------------------------------------------------------------- */
#include "../include/sane/sanei_usb.h"
#include "sane/sanei_pv8630.h"
/* USB specific parts */
/* Apparently this will recover from some errors. */
static void pv8630_mini_init_scanner(int fd)
{
DBG(DBG_info, "mini_init_scanner\n");
/* (re-)init the device (?) */
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04 );
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02 );
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02 );
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000);
}
/* Length of the CDB given the SCSI command. The last two are not
correct (vendor reserved). */
static u_char cdb_sizes[8] = {
6, 10, 10, 6, 16, 12, 0, 0
};
#define CDB_SIZE(opcode) cdb_sizes[(((opcode) >> 5) & 7)]
/* Sends a CDB to the scanner. Also sends the parameters and receives
* the data, if necessary. When this function returns with a
* SANE_STATUS_GOOD, the SCSI command has been completed.
*
* Note: I don't know about deferred commands.
*/
static SANE_Status sanei_umaxusb_cmd(int fd, const void *src, size_t src_size, void *dst, size_t * dst_size)
{
unsigned char result;
size_t cmd_size = CDB_SIZE (*(char *) src);
size_t param_size = src_size - cmd_size;
char * param_ptr = ((char *) src) + cmd_size;
size_t tmp_len;
DBG(DBG_info, "Sending SCSI cmd 0x%02x cdb len %d, param len %d, result len %d\n", ((unsigned char *)src)[0], cmd_size, param_size, dst_size? *dst_size:0);
/* This looks like some kinf of pre-initialization. */
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04);
/* Send the CDB and check it's been received OK. */
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x16);
sanei_pv8630_flush_buffer(fd);
sanei_pv8630_prep_bulkwrite(fd, cmd_size);
tmp_len = cmd_size;
sanei_pv8630_bulkwrite(fd, src, &tmp_len);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000);
sanei_pv8630_flush_buffer(fd);
sanei_pv8630_prep_bulkread(fd, 1);
result = 0xA5; /* to be sure */
tmp_len = 1;
sanei_pv8630_bulkread(fd, &result, &tmp_len);
if (result != 0) {
DBG(DBG_info, "error in sanei_pv8630_bulkread (got %02x)\n", result);
if (result == 8) {
pv8630_mini_init_scanner(fd);
}
return(SANE_STATUS_IO_ERROR);
}
/* Send the parameters and check they've been received OK. */
if (param_size) {
sanei_pv8630_flush_buffer(fd);
sanei_pv8630_prep_bulkwrite(fd, param_size);
tmp_len = param_size;
sanei_pv8630_bulkwrite(fd, param_ptr, &tmp_len);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000);
sanei_pv8630_flush_buffer(fd);
sanei_pv8630_prep_bulkread(fd, 1);
result = 0xA5; /* to be sure */
tmp_len = 1;
sanei_pv8630_bulkread(fd, &result, &tmp_len);
if (result != 0) {
DBG(DBG_info, "error in sanei_pv8630_bulkread (got %02x)\n", result);
if (result == 8) {
pv8630_mini_init_scanner(fd);
}
return(SANE_STATUS_IO_ERROR);
}
}
/* If the SCSI command expect a return, get it. */
if (dst_size != NULL && *dst_size != 0 && dst != NULL) {
sanei_pv8630_flush_buffer(fd);
sanei_pv8630_prep_bulkread(fd, *dst_size);
sanei_pv8630_bulkread(fd, dst, dst_size);
DBG(DBG_info, " SCSI cmd returned %d bytes\n", *dst_size);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000);
sanei_pv8630_flush_buffer(fd);
sanei_pv8630_prep_bulkread(fd, 1);
result = 0x5A; /* just to be sure */
tmp_len = 1;
sanei_pv8630_bulkread(fd, &result, &tmp_len);
if (result != 0) {
DBG(DBG_info, "error in sanei_pv8630_bulkread (got %02x)\n", result);
if (result == 8) {
pv8630_mini_init_scanner(fd);
}
return(SANE_STATUS_IO_ERROR);
}
}
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000);
DBG(DBG_info, " SCSI command successfully executed\n");
return(SANE_STATUS_GOOD);
}
/* Initialize the PowerVision 8630. */
static SANE_Status pv8630_init_umaxusb_scanner(int fd)
{
DBG(DBG_info, "Initializing the PV8630\n");
/* Init the device */
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c);
sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000);
sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04);
sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x16);
DBG(DBG_info, "PV8630 initialized\n");
return(SANE_STATUS_GOOD);
}
/*
* SCSI functions for the emulation.
*
* The following functions emulate their sanei_scsi_* counterpart.
*
*/
/*
* sanei_umaxusb_req_wait() and sanei_umaxusb_req_enter()
*
* I don't know if it is possible to queue the reads to the
* scanner. So The queing is disabled. The performance does not seems
* to be bad anyway.
*/
static void *umaxusb_req_buffer; /* keep the buffer ptr as an ID */
static SANE_Status sanei_umaxusb_req_enter (int fd,
const void *src, size_t src_size,
void *dst, size_t * dst_size, void **idp)
{
umaxusb_req_buffer = *idp = dst;
return(sanei_umaxusb_cmd(fd, src, src_size, dst, dst_size));
}
static SANE_Status
sanei_umaxusb_req_wait (void *id)
{
if (id != umaxusb_req_buffer) {
DBG(DBG_info, "sanei_umaxusb_req_wait: AIE, invalid id\n");
return(SANE_STATUS_IO_ERROR);
}
return(SANE_STATUS_GOOD);
}
/* Open the device.
*/
static SANE_Status
sanei_umaxusb_open (const char *dev, int *fdp,
SANEI_SCSI_Sense_Handler handler, void *handler_arg)
{
handler = handler; /* silence gcc */
handler_arg = handler_arg; /* silence gcc */
*fdp = open (dev, O_RDWR | O_EXCL);
if (*fdp == -1) {
SANE_Status status = SANE_STATUS_INVAL;
if (errno == EACCES)
status = SANE_STATUS_ACCESS_DENIED;
DBG (1, "sanei_umaxusb_open: open of `%s' failed: %s\n",
dev, strerror (errno));
return status;
} else {
SANE_Word vendor;
SANE_Word product;
/* We have openned the device. Check that it is a USB scanner. */
if (sanei_usb_get_vendor_product (*fdp, &vendor, &product) != SANE_STATUS_GOOD) {
/* This is not a USB scanner, or SANE or the OS doesn't support it. */
close(*fdp);
*fdp = -1;
return SANE_STATUS_UNSUPPORTED;
}
/* So it's a scanner. Does this backend support it?
* Only the UMAX 2200 USB is currently supported. */
if ((vendor != 0x1606) || (product != 0x0230)) {
close(*fdp);
*fdp = -1;
return SANE_STATUS_UNSUPPORTED;
}
/* It's a good scanner. Initialize it.
*
* Note: pv8630_init_umaxusb_scanner() is for the UMAX
* 2200. Other UMAX scanner might need a different
* initialization routine. */
pv8630_init_umaxusb_scanner(*fdp);
}
return(SANE_STATUS_GOOD);
}
/* sanei_umaxusb_open_extended() is just a passthrough for sanei_umaxusb_open(). */
static SANE_Status
sanei_umaxusb_open_extended (const char *dev, int *fdp,
SANEI_SCSI_Sense_Handler handler, void *handler_arg, int *buffersize)
{
buffersize = buffersize;
return(sanei_umaxusb_open(dev, fdp, handler, handler_arg));
}
/* Close the scanner. */
static void
sanei_umaxusb_close (int fd)
{
close(fd);
}

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1,16 +1,84 @@
#
# Options for the umax backend
#
# define scsi queueing depth
#option scsi-maxqueue 2
# define scsi buffer size in bytes
#option scsi-buffer-size-min 65536
#option scsi-buffer-size-max 262144
# define scan lines that shall be read in one block
#option scan-lines 100
#option preview-lines 20
# define how to handle bad sense codes
# 0 = handle as device busy
# 1 = handle as ok
# 2 = handle as i/o error
# 3 = ignore bad error code - continue sense handler,
#option handle-bad-sense-error 0
# define if a request sense command shall be executed
#option execute-request-sense 0
# define if the preview bit shall be set when scanning in rgb mode
#option force-preview-bit-rgb 0
# define if slow speed flag shall be set
# BE CAREFUL WITH THIS OPTION, IT MAY DESTROY YOUR SCANNER WHEN SET FALSE
# -1 = automatically set by driver - if known
# 0 = disabled
# 1 = enabled
#option slow-speed 0
# define if care-about-smeraring flag shall be set
# BE CAREFUL WITH THIS OPTION, IT MAY DESTROY YOUR SCANNER WHEN SET FALSE
# -1 = automatically set by driver - if known
# 0 = disabled
# 1 = enabled
#option care-about-smearing 0
# define if the calibration shall be done for selected scanarea or for each ccd pixel
# -1 = automatically set by driver - if known
# 0 = disabled
# 1 = enabled
#option calibration-full-ccd 1
# define if an offset of the calculate calibration with has to be used
# -99999 = auto
#option calibration-width-offset -99999
# define the number of pixels that is used for calibration
# -1 = disabled
# 0 = not set
# 1 = 1 byte/pixel,
# 2 = 2 bytes/pixel
#option calibration-bytes-pixel -1
# define if shading data shall be inverted befor sending it back to the scanner
# -1 = automatically set by driver - if known
# 0 = disabled
# 1 = enabled
#option invert-shading-data
# define if the scanner supports lamp control commands
# 0 = automatically set by driver - if known
# 1 = enabled
#option lamp-control-available 0
# define how 16 bit gamma data is padded
# -1 = automatically set by driver - if known
# 0 = gamma data is msb padded
# 1 = gamma data is lsb padded
#option gamma-lsb-padded 0
#
# define connection type of following devices
# 1 = scsi
# 2 = usb
#option connection-type 1
# linux device identification:
#scsi vendor model type bus channel id lun
scsi UMAX * Scanner
@ -25,7 +93,15 @@ scsi KYE ColorPage-HR5
scsi EPSON Perfection600
scsi ESCORT "Galleria 600S"
#
# device list for non-linux-systems:
# Umax Astra 2200 via USB:
# usb vendor product
usb 0x1606 0x0230
# scsi device list
option connection-type 1
/dev/scanner
# usb device list
option connection-type 2
/dev/usbscanner

Wyświetl plik

@ -22,18 +22,18 @@
:mfg "UMAX" ; name a manufacturer
:url "http://www.umax.com/"
:url "http://support.umax.com/"
:url "http://www.umax.de/"
:url "http://www.umax.com.tw/"
:url "http://www.umaxweb.com.tw/"
:url "http://support.umax.co.uk/"
:url "http://www.umax.de/en"
:model "parallel scanners" ; name models for above-specified mfg.
:interface "Parport"
:comment "Not supported - see backend umax_pp"
:model "USB scanners"
:interface "USB"
:comment "Not supported - see backend umax1220u"
:comment "All but Astra2200/MX3 not supported - see backend umax1220u"
:model "firewire scanners"
:interface "Firewire"
:interface "IEEE-1394"
:comment "not tested"
:model "Vista S6"
:interface "SCSI"
@ -77,6 +77,9 @@
:model "Astra 2200 (SU)"
:interface "SCSI"
:comment "OK"
:model "Astra 2200 (SU)"
:interface "USB"
:comment "OK"
:model "Astra 2400S"
:interface "SCSI"
:comment "OK"
@ -89,6 +92,9 @@
:model "Astra MX3"
:interface "SCSI"
:comment "OK"
:model "Astra MX3"
:interface "USB"
:comment "OK"
:model "Mirage D-16L"
:interface "SCSI"
:comment "OK"
@ -117,7 +123,7 @@
:interface "SCSI"
:comment "not tested"
:model "PowerLook 1100"
:interface "IEE-1394"
:interface "IEEE-1394"
:comment "Not tested"
:model "PowerLook 2000"
:interface "SCSI"

Wyświetl plik

@ -2,7 +2,7 @@
/* umax.h - headerfile for SANE-backend for umax scanners
(C) 1997-2001 Oliver Rauch
(C) 1997-2002 Oliver Rauch
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@ -50,21 +50,14 @@
#include "sys/types.h"
#ifdef HAVE_SANEI_IPC
# include "sane/sanei_ipc.h"
#endif
/* --------------------------------------------------------------------------------------------------------- */
/* COMPILER OPTIONS: */
#define UMAX_ENABLE_USB
#define UMAX_HIDE_UNUSED
/* #define SANE_UMAX_DEBUG_S12 */
/* #define PREVIEW_FIX_ON */
/* #define UMAX_CALIBRATION_MODE_SELECTABLE */
/* --------------------------------------------------------------------------------------------------------- */
@ -191,13 +184,19 @@ typedef union
/* LIST OF AVAILABLE SCANNERS, THE VALUES LISTED HERE ARE THE SAME FOR DIFFERENT APPLICATIONS
THAT USE THE SAME DEVICE */
/* Umax_Device contains values relevant for the device that are not intersting for the sane interface */
typedef struct Umax_Device
{
struct Umax_Device *next;
SANE_Device sane;
int connection_type;
#define SANE_UMAX_UNKNOWN 0
#define SANE_UMAX_SCSI 1
#define SANE_UMAX_USB 2
SANE_Range x_dpi_range;
SANE_Range y_dpi_range;
SANE_Range x_range;
@ -452,10 +451,6 @@ typedef struct Umax_Device
int pause_for_moving; /* pause for moving scanhead over full scanarea in ms */
int lamp_control_available; /* is set when scanner supportes lamp control */
int gamma_lsb_padded; /* 16 bit gamma data is padded to lsb */
#ifdef HAVE_SANEI_IPC
sanei_ipc *ipc;
#endif
} Umax_Device;
@ -486,9 +481,7 @@ typedef struct Umax_Scanner
SANE_Parameters params;
pid_t reader_pid;
#ifndef HAVE_SANEI_IPC
int pipe;
#endif
} Umax_Scanner;