Snapscan backend version 1.4.9

DEVEL_2_0_BRANCH-1
Oliver Schwartz 2002-03-24 12:32:38 +00:00
rodzic c40aeba6b1
commit 3f27a13d77
8 zmienionych plików z 1921 dodań i 1762 usunięć

Wyświetl plik

@ -101,7 +101,7 @@ DISTFILES = abaton.c abaton.conf abaton.h agfafocus.c agfafocus.conf \
sm3600-color.c sm3600-gray.c sm3600.h sm3600-homerun.c sm3600-scanmtek.c \
sm3600-scantool.h sm3600-scanusb.c sm3600-scanutil.c snapscan.c \
snapscan.conf snapscan.h snapscan-scsi.c snapscan-sources.c \
snapscan-sources.h snapscan-usb.c snapscan-usb.h snapscan-utils.c sp15c.c \
snapscan-sources.h snapscan-usb.c snapscan-usb.h snapscan-options.c sp15c.c \
sp15c.conf sp15c.h sp15c-scsi.h st400.c st400.conf st400.h stubs.c \
tamarack.c tamarack.conf tamarack.h umax1220u.c umax1220u-common.c \
umax1220u.conf umax.c umax.conf umax.h umax_pp.c umax_pp.conf umax_pp.h \

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1080,62 +1080,14 @@ static SANE_Status calibrate (SnapScan_Scanner *pss)
return SANE_STATUS_GOOD;
}
static SANE_Status get_firmware_name(char** firmware_path)
{
char line[PATH_MAX];
char found = 0;
FILE *fp;
SANE_Status status = SANE_STATUS_GOOD;
char* me = "get_firmware_name";
fp = sanei_config_open (SNAPSCAN_CONFIG_FILE);
if (!fp)
{
DBG (0,
"%s: configuration file not found.\n",
me);
status = SANE_STATUS_INVAL;
}
else
{
while (sanei_config_read (line, sizeof (line), fp))
{
if (line[0] == '#') /* ignore line comments */
continue;
if (!strlen(line))
continue; /* ignore empty lines */
if (strncasecmp(line, FIRMWARE_KW, strlen(FIRMWARE_KW)) == 0)
{
found = 1;
break;
}
}
fclose (fp);
}
if (found)
{
sanei_config_get_string(line + strlen(FIRMWARE_KW), firmware_path);
if (*firmware_path == NULL)
{
DBG (0, "%s: Illegal firmware entry %s.\n", me, line);
status = SANE_STATUS_INVAL;
}
}
else
{
DBG (0, "%s: No firmware entry found in config file %s.\n", me, SNAPSCAN_CONFIG_FILE);
status = SANE_STATUS_INVAL;
}
return status;
}
static SANE_Status download_firmware(SnapScan_Scanner * pss)
{
static const char *me = "download_firmware";
unsigned char *pFwBuf, *pCDB;
char* firmware_path = NULL;
char* firmware = NULL;
FILE *fd;
size_t bufLength,cdbLength;
SANE_Status status;
SANE_Status status = SANE_STATUS_GOOD;
char cModelName[8], cModel[255];
unsigned char bModelNo;
int readByte;
@ -1144,15 +1096,26 @@ static SANE_Status download_firmware(SnapScan_Scanner * pss)
zero_buf((unsigned char *)cModel, 255);
sprintf(cModelName, "%d", bModelNo);
DBG(DL_INFO, "Looking up %s\n", cModelName);
status = get_firmware_name(&firmware_path);
if (pss->pdev->firmware_filename) {
firmware = pss->pdev->firmware_filename;
} else if (default_firmware_filename) {
firmware = default_firmware_filename;
} else {
DBG (0,
"%s: No firmware entry found in config file %s.\n",
me,
SNAPSCAN_CONFIG_FILE
);
status = SANE_STATUS_INVAL;
}
if (status == SANE_STATUS_GOOD)
{
cdbLength = 10;
DBG(DL_INFO, "Downloading %s\n", firmware_path);
fd = fopen(firmware_path,"r");
DBG(DL_INFO, "Downloading %s\n", firmware);
fd = fopen(firmware,"r");
if(fd == NULL)
{
DBG (0, "Cannot open firmware file %s\n", firmware_path);
DBG (0, "Cannot open firmware file %s\n", firmware);
status = SANE_STATUS_INVAL;
}
else
@ -1206,15 +1169,22 @@ static SANE_Status download_firmware(SnapScan_Scanner * pss)
free(pCDB);
fclose(fd);
}
free(firmware_path);
}
return status;
}
/*
* $Log$
* Revision 1.11 2002/01/23 20:50:32 oliverschwartz
* Fix recognition of Acer 320U
* Revision 1.12 2002/03/24 12:32:26 oliverschwartz
* Snapscan backend version 1.4.9
*
* Revision 1.27 2002/03/24 12:11:20 oliverschwartz
* Get name of firmware file in sane_init
*
* Revision 1.26 2002/01/23 20:42:41 oliverschwartz
* Improve recognition of Acer 320U
* Add sense_handler code for sense code 0x0b
* Fix for spaces in model strings
*
* Revision 1.25 2001/12/12 19:44:59 oliverschwartz
* Clean up CVS log

Wyświetl plik

@ -237,7 +237,12 @@ static SANE_Status usb_read(int fd, void *buf, int n) {
do
{
if((r=read(fd,buf,n)) != n && !(r == -1 && errno == EAGAIN)) {
DBG (DL_MAJOR_ERROR, "%s Only %d bytes read\n",me,r);
if (r == -1) {
DBG (DL_MAJOR_ERROR, "%s Error returned from read: %s (%d)\n",
me,strerror(errno),errno);
} else {
DBG (DL_MAJOR_ERROR, "%s Only %d bytes read\n",me,r);
}
return SANE_STATUS_IO_ERROR;
}
if (r == -1 && errno == EAGAIN)
@ -447,13 +452,15 @@ static SANE_Status usb_request_sense(SnapScan_Scanner *pss) {
/*
* $Log$
* Revision 1.7 2002/01/27 18:24:47 hmg
* Only define union semun if not already defined in <sys/sem.h>. Fixes
* compilation bugs on Irix and FreeBSD.
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.8 2002/03/24 12:32:28 oliverschwartz
* Snapscan backend version 1.4.9
*
* Revision 1.6 2002/01/15 20:16:55 oliverschwartz
* Added workaround for bug in semctl() on PPC; backend version 1.4.5
* Revision 1.18 2002/03/24 12:16:09 oliverschwartz
* Better error report in usb_read
*
* Revision 1.17 2002/02/05 19:32:39 oliverschwartz
* Only define union semun if not already defined in <sys/sem.h>. Fixes
* compilation bugs on Irix and FreeBSD. Fixed by Henning Meier-Geinitz.
*
* Revision 1.16 2002/01/14 21:11:56 oliverschwartz
* Add workaround for bug semctl() call in libc for PPC

Wyświetl plik

@ -1,76 +0,0 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997, 1998 Franck Schnefra, Michel Roelofs,
Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller,
Petter Reinholdtsen, Gary Plewa, and Kevin Charter
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 a component of the implementation of a backend for many
of the the AGFA SnapScan and Acer Vuego/Prisa flatbed scanners. */
/* $Id$
SnapScan backend utility functions */
static inline SnapScan_Mode actual_mode (SnapScan_Scanner *pss)
{
if (pss->preview == SANE_TRUE)
return pss->preview_mode;
return pss->mode;
}
static inline int is_colour_mode (SnapScan_Mode m)
{
return (m == MD_COLOUR) || (m == MD_BILEVELCOLOUR);
}
/*
* $Log$
* Revision 1.3 2000/08/12 15:09:35 pere
* Merge devel (v1.0.3) into head branch.
*
* Revision 1.2.2.1 2000/07/13 04:47:46 pere
* New snapscan backend version dated 20000514 from Steve Underwood.
*
* Revision 1.2.1 2000/05/14 13:30:20 coppice
* Added history log to pre-existing code.Some reformatting.
* Actually, this file hardly seems worth splitting out from the rest!
* */

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1,14 +1,61 @@
# If not automatically found from above, then you may manually specify
# a device name.
# For USB devices, make sure that the name contains 'usb' somewhere, as in
# '/dev/usbscanner' or '/dev/usb/scanner0'. Do not use a link
# from /dev/scanner to your USB device.
# For SCSI, use the generic device (e.g. /dev/sg0 in Linux).
/dev/sg0
#/dev/usbscanner
#------------------------------ General -----------------------------------
# Change to the fully qualified filename of your firmware file, if
# firmware upload is needed by the scanner
firmware /path/to/your/firmware/file
firmware /path/to/your/firmware/file.bin
# If not automatically found you may manually specify a device name.
# For USB scanners also specify bus=usb, e.g.
# /dev/usb/scanner0 bus=usb
# For SCSI scanners specify the generic device, e.g. /dev/sg0 on Linux.
# /dev/sg0
#---------------------------------------------------------------------------
# No changes should be necessary below this line
#---------------------------------------------------------------------------
#-------------------------- SCSI scanners ----------------------------------
# These SCSI devices will be probed automatically
scsi AGFA * Scanner
scsi COLOR * Scanner
scsi Color * Scanner
scsi ACERPERI * Scanner
#--------------------------- USB scanners -----------------------------------
# These USB devices will be probed automatically
# (This will currently work only on Linux)
# Acer 620U / 620UT
usb 0x04a5 0x2040
# Acer 640U
usb 0x04a5 0x2060
# Acer 640BU
usb 0x04a5 0x207e
# Acer 1240U
usb 0x04a5 0x20c0
# Acer 3300 / 4300
usb 0x04a5 0x20b0
# Acer 4300
usb 0x04a5 0x20de
# Agfa 1236U
usb 0x06bd 0x0002
# Agfa 1212U
usb 0x06bd 0x0001
usb 0x06bd 0x2061
# Agfa Snapscan e20
usb 0x06bd 0x2091
# Agfa Snapscan e25
usb 0x06bd 0x2095
# Agfa Snapscan e26
usb 0x06bd 0x2097
# Agfa Snapscan e40
usb 0x06bd 0x208d
# Agfa Snapscan e42
usb 0x06bd 0x20ff
# Agfa Snapscan e50
usb 0x06bd 0x208f
# Agfa Snapscan e52
usb 0x06bd 0x20fd

Wyświetl plik

@ -61,6 +61,7 @@
#define TMP_FILE_PREFIX "/var/tmp/snapscan"
#define SNAPSCAN_CONFIG_FILE "snapscan.conf"
#define FIRMWARE_KW "firmware"
#define OPTIONS_KW "options"
/* Define the colour channel order in arrays */
#define R_CHAN 0
@ -95,6 +96,37 @@ typedef enum
PRISA1240, /* Acer ScanPrisa 1240 - 1200 DPI */
PRISA5300 /* Acer ScanPrisa 5300 - 1200 DPI */
} SnapScan_Model;
struct SnapScan_Driver_desc {
SnapScan_Model id;
char *driver_name;
};
static struct SnapScan_Driver_desc drivers[] =
{
/* enum value -> Driver name */
{UNKNOWN, "Unknown"},
{SNAPSCAN300, "SnapScan300"},
{SNAPSCAN310, "SnapScan310"},
{SNAPSCAN600, "SnapScan600"},
{SNAPSCAN1236, "SnapScan1236"},
{SNAPSCAN1212U, "SnapScan1212"},
{SNAPSCANE20, "SnapScanE20"},
{SNAPSCANE50, "SnapScanE50"},
{SNAPSCANE52, "SnapScanE52"},
{ACER300F, "Acer300"},
{VUEGO310S, "Acer310"},
{VUEGO610S, "Acer610"},
{PRISA620S, "Acer620"},
{PRISA640, "Acer640"},
{PRISA4300, "Acer4300"},
{PRISA4300_2, "Acer4300-2"},
{PRISA1240, "Acer1240"},
{PRISA5300, "Acer5300"}
};
#define known_drivers ((int) (sizeof(drivers)/sizeof(drivers[0])))
struct SnapScan_Model_desc
{
char *scsi_name;
@ -168,7 +200,6 @@ static struct SnapScan_USB_Model_desc usb_scanners[] =
};
#define known_usb_scanners ((int) (sizeof(usb_scanners)/sizeof(usb_scanners[0])))
typedef enum
{
OPT_COUNT = 0, /* option count */
@ -248,11 +279,12 @@ typedef enum
typedef struct snapscan_device
{
SANE_Device dev;
SANE_Range x_range; /* x dimension of scan area */
SANE_Range y_range; /* y dimension of scan area */
SnapScan_Model model; /* type of scanner */
SnapScan_Bus bus; /* bus of the device usb/scsi */
u_char *depths; /* bit depth table */
SANE_Range x_range; /* x dimension of scan area */
SANE_Range y_range; /* y dimension of scan area */
SnapScan_Model model; /* type of scanner */
SnapScan_Bus bus; /* bus of the device usb/scsi */
u_char *depths; /* bit depth table */
SANE_Char *firmware_filename; /* The name of the firmware file for USB scanners */
struct snapscan_device *pnext;
}
SnapScan_Device;
@ -266,79 +298,83 @@ typedef struct snapscan_scanner SnapScan_Scanner;
struct snapscan_scanner
{
SANE_String devname; /* the scsi device name */
SnapScan_Device *pdev; /* the device */
int fd; /* scsi file descriptor */
int opens; /* open count */
int rpipe[2]; /* reader pipe descriptors */
int orig_rpipe_flags; /* initial reader pipe flags */
pid_t child; /* child reader process pid */
SnapScan_Mode mode; /* mode */
SnapScan_Mode preview_mode; /* preview mode */
SnapScan_Source source; /* scanning source */
SnapScan_State state; /* scanner state */
u_char cmd[MAX_SCSI_CMD_LEN]; /* scsi command buffer */
SANE_String devname; /* the scsi device name */
SnapScan_Device *pdev; /* the device */
int fd; /* scsi file descriptor */
int opens; /* open count */
int rpipe[2]; /* reader pipe descriptors */
int orig_rpipe_flags; /* initial reader pipe flags */
pid_t child; /* child reader process pid */
SnapScan_Mode mode; /* mode */
SnapScan_Mode preview_mode; /* preview mode */
SnapScan_Source source; /* scanning source */
SnapScan_State state; /* scanner state */
u_char cmd[MAX_SCSI_CMD_LEN]; /* scsi command buffer */
u_char *buf; /* data buffer */
size_t phys_buf_sz; /* physical buffer size */
size_t buf_sz; /* effective buffer size */
size_t expected_read_bytes; /* expected amount of data in a single read */
size_t read_bytes; /* amount of actual data read */
size_t bytes_remaining; /* remaining bytes expected from scanner */
size_t actual_res; /* actual resolution */
size_t lines; /* number of scan lines */
size_t bytes_per_line; /* bytes per scan line */
size_t pixels_per_line; /* pixels per scan line */
u_char hconfig; /* hardware configuration byte */
float ms_per_line; /* speed: milliseconds per scan line */
SANE_Bool nonblocking; /* wait on reads for data? */
char *sense_str; /* sense string */
char *as_str; /* additional sense string */
u_char asi1; /* first additional sense info byte */
u_char asi2; /* second additional sense info byte */
SANE_Byte chroma_offset[3]; /* chroma offsets */
size_t bytes_remaining; /* remaining bytes expected from scanner */
size_t actual_res; /* actual resolution */
size_t lines; /* number of scan lines */
size_t bytes_per_line; /* bytes per scan line */
size_t pixels_per_line; /* pixels per scan line */
u_char hconfig; /* hardware configuration byte */
float ms_per_line; /* speed: milliseconds per scan line */
SANE_Bool nonblocking; /* wait on reads for data? */
char *sense_str; /* sense string */
char *as_str; /* additional sense string */
u_char asi1; /* first additional sense info byte */
u_char asi2; /* second additional sense info byte */
SANE_Byte chroma_offset[3]; /* chroma offsets */
SANE_Int chroma;
Source *psrc; /* data source */
SANE_Option_Descriptor
options[NUM_OPTS]; /* the option descriptors */
Option_Value val[NUM_OPTS];
/* the options themselves... */
SANE_Int res; /* resolution */
SANE_Bool preview; /* preview mode toggle */
SANE_String mode_s; /* scanning mode */
SANE_String source_s; /* scanning source */
SANE_String preview_mode_s; /* scanning mode for preview */
SANE_Fixed tlx; /* window top left x */
SANE_Fixed tly; /* window top left y */
SANE_Fixed brx; /* window bottom right x */
SANE_Fixed bry; /* window bottom right y */
int bright; /* brightness */
int contrast; /* contrast */
SANE_String predef_window; /* predefined window name */
SANE_Fixed gamma_gs; /* gamma correction value (greyscale) */
SANE_Fixed gamma_r; /* gamma correction value (red) */
SANE_Fixed gamma_g; /* gamma correction value (green) */
SANE_Fixed gamma_b; /* gamma correction value (blue) */
SANE_Int *gamma_tables; /* gamma correction vectors */
Source *psrc; /* data source */
SANE_Option_Descriptor options[NUM_OPTS]; /* the option descriptors */
Option_Value val[NUM_OPTS]; /* the options themselves... */
SANE_Int res; /* resolution */
SANE_Bool preview; /* preview mode toggle */
SANE_String mode_s; /* scanning mode */
SANE_String source_s; /* scanning source */
SANE_String preview_mode_s; /* scanning mode for preview */
SANE_Fixed tlx; /* window top left x */
SANE_Fixed tly; /* window top left y */
SANE_Fixed brx; /* window bottom right x */
SANE_Fixed bry; /* window bottom right y */
int bright; /* brightness */
int contrast; /* contrast */
SANE_String predef_window; /* predefined window name */
SANE_Fixed gamma_gs; /* gamma correction value (greyscale) */
SANE_Fixed gamma_r; /* gamma correction value (red) */
SANE_Fixed gamma_g; /* gamma correction value (green) */
SANE_Fixed gamma_b; /* gamma correction value (blue) */
SANE_Int *gamma_tables; /* gamma correction vectors */
SANE_Int *gamma_table_gs; /* gamma correction vector (greyscale) */
SANE_Int *gamma_table_r; /* gamma correction vector (red) */
SANE_Int *gamma_table_g; /* gamma correction vector (green) */
SANE_Int *gamma_table_b; /* gamma correction vector (blue) */
int gamma_length; /* length of gamma vectors */
SANE_Bool halftone; /* halftone toggle */
SANE_String dither_matrix; /* the halftone dither matrix */
SANE_Bool negative; /* swap black and white */
SANE_Int threshold; /* threshold for line art */
SANE_Int rgb_lpr; /* lines per scsi read (RGB) */
SANE_Int gs_lpr; /* lines per scsi read (greyscale) */
SANE_Int *gamma_table_r; /* gamma correction vector (red) */
SANE_Int *gamma_table_g; /* gamma correction vector (green) */
SANE_Int *gamma_table_b; /* gamma correction vector (blue) */
int gamma_length; /* length of gamma vectors */
SANE_Bool halftone; /* halftone toggle */
SANE_String dither_matrix; /* the halftone dither matrix */
SANE_Bool negative; /* swap black and white */
SANE_Int threshold; /* threshold for line art */
SANE_Int rgb_lpr; /* lines per scsi read (RGB) */
SANE_Int gs_lpr; /* lines per scsi read (greyscale) */
};
#endif
/*
* $Log$
* Revision 1.12 2002/01/23 20:50:34 oliverschwartz
* Fix recognition of Acer 320U
* Revision 1.13 2002/03/24 12:32:38 oliverschwartz
* Snapscan backend version 1.4.9
*
* Revision 1.29 2002/03/24 12:14:34 oliverschwartz
* Add Snapcan_Driver_desc
*
* Revision 1.28 2002/01/23 20:38:20 oliverschwartz
* Fix model ID for e42
* Improve recognition of Acer 320U
*
* Revision 1.27 2002/01/06 18:34:02 oliverschwartz
* Added support for Snapscan e42 thanks to Yari Adán Petralanda