update snapscan to snapshot 20011008

DEVEL_2_0_BRANCH-1
Oliver Schwartz 2001-10-09 09:45:21 +00:00
rodzic e4db2d172b
commit 010db1ed52
9 zmienionych plików z 1784 dodań i 1543 usunięć

Wyświetl plik

@ -2,8 +2,8 @@
Copyright (C) 1997, 1998, 2001 Franck Schnefra, Michel Roelofs,
Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller,
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson
and Kevin Charter
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson,
Oliver Schwartz and Kevin Charter
This file is part of the SANE package.
@ -52,6 +52,8 @@
/* scanner scsi commands */
static SANE_Status download_firmware(SnapScan_Scanner * pss);
#include "snapscan-usb.h"
/* a sensible sense handler, courtesy of Franck;
@ -161,8 +163,7 @@ static SANE_Status open_scanner (SnapScan_Scanner *pss)
}
else
{
status = snapscani_usb_open (pss->devname, &(pss->fd),
sense_handler, (void *) pss);
status = snapscani_usb_open (pss->devname, &(pss->fd));
}
}
else
@ -303,6 +304,8 @@ static void check_range (int *v, SANE_Range r)
#define INQUIRY_REV 32 /* Offset in reply data to revision level */
#define INQUIRY_PRL2 36 /* Product Revision Level 2 (AGFA) */
#define INQUIRY_HCFG 37 /* Hardware Configuration (AGFA) */
#define INQUIRY_HWST 40 /* Hardware status */
#define INQUIRY_HWMI 41 /* HARDWARE Model ID */
#define INQUIRY_PIX_PER_LINE 42 /* Pixels per scan line (AGFA) */
#define INQUIRY_BYTE_PER_LINE 44 /* Bytes per scan line (AGFA) */
#define INQUIRY_NUM_LINES 46 /* number of scan lines (AGFA) */
@ -364,8 +367,94 @@ static SANE_Status inquiry (SnapScan_Scanner *pss)
pss->buf,
&pss->read_bytes);
CHECK_STATUS (status, me, "snapscan_cmd");
/* Download Firmware for USB scanners */
if ( (pss->pdev->bus == USB) && (*(pss->buf + INQUIRY_HWST) & 0x02) )
{
char model[17];
int i;
status = download_firmware(pss);
CHECK_STATUS (status, me, "download_firmware");
/* send inquiry command again, wait for scanner to initialize */
do {
status = snapscan_cmd (pss->pdev->bus,
pss->fd,
pss->cmd,
INQUIRY_LEN,
pss->buf,
&pss->read_bytes);
if (status == SANE_STATUS_DEVICE_BUSY) {
DBG (DL_INFO, "%s: Waiting for scanner after firmware upload\n",me);
sleep(1);
}
} while (status == SANE_STATUS_DEVICE_BUSY);
CHECK_STATUS (status, me, "snapscan_cmd");
/* The model identifier will change after firmware upload */
memcpy (model, &pss->buf[INQUIRY_PRODUCT], 16);
model[16] = 0;
DBG (DL_INFO,
"%s (after firmware upload): Checking if \"%s\" is a supported scanner\n",
me,
model);
/* Check if it is one of our supported models */
pss->pdev->model = UNKNOWN;
for (i = 0; i < known_scanners; i++)
{
if (0 == strcasecmp (model, scanners[i].scsi_name))
{
pss->pdev->model = scanners[i].id;
break;
}
}
if (pss->pdev->model == UNKNOWN) {
DBG (DL_MINOR_ERROR,
"%s (after firmware upload): \"%s\" is not a supported scanner\n",
me,
model);
}
}
/* record current parameters */
{
char exptime[4] = {' ', '.', ' ', 0};
exptime[0] = (char) (pss->buf[INQUIRY_EXPTIME1] + '0');
exptime[2] = (char) (pss->buf[INQUIRY_EXPTIME2] + '0');
pss->ms_per_line = atof (exptime)*(float) pss->buf[INQUIRY_SCAN_SPEED];
DBG (DL_DATA_TRACE, "%s: exposure time: %s ms\n", me, exptime);
DBG (DL_DATA_TRACE, "%s: ms per line: %f\n", me, pss->ms_per_line);
}
switch (pss->pdev->model)
{
case SNAPSCAN300:
case ACER300F:
pss->chroma_offset[R_CHAN] =
pss->chroma_offset[G_CHAN] =
pss->chroma_offset[B_CHAN] = 0;
pss->chroma = 0;
break;
default:
{
signed char min_diff;
signed char g = (pss->buf[INQUIRY_G2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_G2R_DIFF] & 0x7F) : pss->buf[INQUIRY_G2R_DIFF];
signed char b = (pss->buf[INQUIRY_B2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_B2R_DIFF] & 0x7F) : pss->buf[INQUIRY_B2R_DIFF];
DBG (DL_DATA_TRACE, "%s: G2R_DIFF: %d\n", me, pss->buf[INQUIRY_G2R_DIFF]);
DBG (DL_DATA_TRACE, "%s: B2R_DIFF: %d\n", me, pss->buf[INQUIRY_B2R_DIFF]);
min_diff = MIN (MIN (b, g), 0);
pss->chroma_offset[R_CHAN] = (u_char) (0 - min_diff);
pss->chroma_offset[G_CHAN] = (u_char) (g - min_diff);
pss->chroma_offset[B_CHAN] = (u_char) (b - min_diff);
pss->chroma = abs(min_diff);
DBG (DL_DATA_TRACE,
"%s: Chroma offsets=%d; Red=%u, Green:=%u, Blue=%u\n",
me, pss->chroma,
pss->chroma_offset[R_CHAN],
pss->chroma_offset[G_CHAN],
pss->chroma_offset[B_CHAN]);
}
break;
}
pss->actual_res =
u_char_to_u_short (pss->buf + INQUIRY_OPT_RES);
@ -374,60 +463,16 @@ static SANE_Status inquiry (SnapScan_Scanner *pss)
pss->bytes_per_line =
u_char_to_u_short (pss->buf + INQUIRY_BYTE_PER_LINE);
pss->lines =
u_char_to_u_short (pss->buf + INQUIRY_NUM_LINES);
u_char_to_u_short (pss->buf + INQUIRY_NUM_LINES) - pss->chroma;
/* effective buffer size must be a whole number of scan lines */
if (pss->lines)
pss->buf_sz = (SCANNER_BUF_SZ/pss->bytes_per_line)*pss->bytes_per_line;
pss->buf_sz = (pss->phys_buf_sz/pss->bytes_per_line)*pss->bytes_per_line;
else
pss->buf_sz = 0;
pss->bytes_remaining = pss->bytes_per_line*pss->lines;
pss->bytes_remaining = pss->bytes_per_line * (pss->lines + pss->chroma);
pss->expected_read_bytes = 0;
pss->read_bytes = 0;
pss->hconfig = pss->buf[INQUIRY_HCFG];
{
char exptime[4] = {' ', '.', ' ', 0};
exptime[0] = (char) (pss->buf[INQUIRY_EXPTIME1] + '0');
exptime[2] = (char) (pss->buf[INQUIRY_EXPTIME2] + '0');
pss->ms_per_line = atof (exptime)*(float) pss->buf[INQUIRY_SCAN_SPEED];
}
switch (pss->pdev->model)
{
case SNAPSCAN310:
case SNAPSCAN600:
case SNAPSCAN1236S:
case SNAPSCAN1212U:
case SNAPSCANE50:
case VUEGO310S: /* WG changed */
case VUEGO610S: /* SJU changed */
case PRISA620S: /* GP added */
{
signed char min_diff;
signed char g = (pss->buf[INQUIRY_G2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_G2R_DIFF] & 0x7F) : pss->buf[INQUIRY_G2R_DIFF];
signed char b = (pss->buf[INQUIRY_B2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_B2R_DIFF] & 0x7F) : pss->buf[INQUIRY_B2R_DIFF];
min_diff = MIN (MIN (b, g), 0);
pss->chroma_offset[R_CHAN] = (u_char) (0 - min_diff);
pss->chroma_offset[G_CHAN] = (u_char) (g - min_diff);
pss->chroma_offset[B_CHAN] = (u_char) (b - min_diff);
DBG (DL_VERBOSE,
"%s: Chroma offsets Red:%u, Green:%u Blue:%u\n",
me,
pss->chroma_offset[R_CHAN],
pss->chroma_offset[G_CHAN],
pss->chroma_offset[B_CHAN]);
}
break;
default:
pss->chroma_offset[R_CHAN] =
pss->chroma_offset[G_CHAN] =
pss->chroma_offset[B_CHAN] = 0;
break;
}
DBG (DL_DATA_TRACE,
"%s: pixels per scan line = %lu\n",
me,
@ -456,8 +501,7 @@ static SANE_Status inquiry (SnapScan_Scanner *pss)
static SANE_Status test_unit_ready (SnapScan_Scanner *pss)
{
static const char *me = "test_unit_ready";
char cmd[] =
{TEST_UNIT_READY, 0, 0, 0, 0, 0};
char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
SANE_Status status;
DBG (DL_CALL_TRACE, "%s\n", me);
@ -657,6 +701,7 @@ static SANE_Status set_window (SnapScan_Scanner *pss)
pc[SET_WINDOW_P_WIN_ID] = 0;
u_short_to_u_charp (pss->res, pc + SET_WINDOW_P_XRES);
u_short_to_u_charp (pss->res, pc + SET_WINDOW_P_YRES);
DBG (DL_CALL_TRACE, "%s Resolution: %d\n", me, pss->res);
/* it's an ugly sound if the scanner drives against the rear
wall, and with changing max values we better be sure */
@ -693,6 +738,8 @@ static SANE_Status set_window (SnapScan_Scanner *pss)
pc + SET_WINDOW_P_WIDTH);
u_int_to_u_char4p (MAX (((unsigned) (bryp - tlyp)), 75),
pc + SET_WINDOW_P_LENGTH);
DBG (DL_CALL_TRACE, "%s Width: %d\n", me, brxp-tlxp);
DBG (DL_CALL_TRACE, "%s Length: %d\n", me, bryp-tlyp);
}
pc[SET_WINDOW_P_BRIGHTNESS] = 128;
pc[SET_WINDOW_P_THRESHOLD] =
@ -706,7 +753,7 @@ static SANE_Status set_window (SnapScan_Scanner *pss)
mode = pss->preview_mode;
bpp = pss->pdev->depths[mode];
DBG (DL_CALL_TRACE, "%s Mode: %d\n", me, mode);
switch (mode)
{
case MD_COLOUR:
@ -750,7 +797,7 @@ static SANE_Status set_window (SnapScan_Scanner *pss)
&&
pss->pdev->model != SNAPSCAN310
&&
pss->pdev->model != SNAPSCAN1236S
pss->pdev->model != SNAPSCAN1236
&&
pss->pdev->model != SNAPSCANE50
&&
@ -761,12 +808,16 @@ static SANE_Status set_window (SnapScan_Scanner *pss)
pc[SET_WINDOW_P_DEBUG_MODE] = 2; /* use full 128k buffer */
pc[SET_WINDOW_P_GAMMA_NO] = 0x01; /* downloaded table */
}
source = 0x20;
if (pss->preview)
source |= 0x40;
if (pss->preview) {
source = 0x20 + 0x40;
} else {
source = 0x20 + 0x80;
}
if (pss->source == SRC_TPO)
source |= 0x08;
pc[SET_WINDOW_P_OPERATION_MODE] = source;
DBG (DL_DATA_TRACE, "%s: operation mode set to %d\n", me, (int) source);
pc[SET_WINDOW_P_RED_UNDER_COLOR] = 0xff; /* defaults */
pc[SET_WINDOW_P_BLUE_UNDER_COLOR] = 0xff;
pc[SET_WINDOW_P_GREEN_UNDER_COLOR] = 0xff;
@ -860,44 +911,6 @@ static SANE_Status send_diagnostic (SnapScan_Scanner *pss)
return status;
}
#if 0
/* get_data_buffer_status: fetch the scanner's current data buffer
status. If wait == 0, the scanner must respond immediately;
otherwise it will wait until there is data available in the buffer
before reporting. */
#define GET_DATA_BUFFER_STATUS_LEN 10
#define DESCRIPTOR_LENGTH 12
static SANE_Status get_data_buffer_status (SnapScan_Scanner *pss, int wait)
{
static const char *me = "get_data_buffer_status";
SANE_Status status;
pss->read_bytes = DESCRIPTOR_LENGTH; /* one status descriptor only */
DBG (DL_CALL_TRACE, "%s\n", me);
zero_buf (pss->cmd, MAX_SCSI_CMD_LEN);
pss->cmd[0] = GET_DATA_BUFFER_STATUS;
if (wait)
pss->cmd[1] = 0x01;
u_short_to_u_charp (DESCRIPTOR_LENGTH, pss->cmd + 7);
status = snapscan_cmd (pss->pdev->bus, pss->fd,
pss->cmd,
GET_DATA_BUFFER_STATUS_LEN,
pss->buf,
&pss->read_bytes);
CHECK_STATUS (status, me, "snapscan_cmd");
return status;
}
#endif
static SANE_Status wait_scanner_ready (SnapScan_Scanner *pss)
{
static char me[] = "wait_scanner_ready";
@ -981,6 +994,7 @@ static SANE_Status calibrate (SnapScan_Scanner *pss)
SANE_Status status;
int line_length = calibration_line_length(pss);
if (pss->hconfig & HCFG_CAL_ALLOWED) {
buf = (u_char *) malloc(NUM_CALIBRATION_LINES * line_length);
if (!buf)
{
@ -992,9 +1006,6 @@ static SANE_Status calibrate (SnapScan_Scanner *pss)
status = read_calibration_data(pss, buf, NUM_CALIBRATION_LINES);
CHECK_STATUS(status, me, "read_calibration_data");
/* status = test_unit_ready (pss);
CHECK_STATUS(status, me, "test unit ready");*/
for(c=0; c < line_length; c++) {
u_int sum = 0;
for(r=0; r < NUM_CALIBRATION_LINES; r++) {
@ -1005,19 +1016,166 @@ static SANE_Status calibrate (SnapScan_Scanner *pss)
status = send (pss, DTC_CALIBRATION, 1);
CHECK_STATUS(status, me, "send calibration");
/* status = test_unit_ready (pss);
CHECK_STATUS(status, me, "test unit ready");*/
}
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)
{
char *pFwBuf, *pCDB;
char* firmware_path = NULL;
FILE *fd;
size_t bufLength,cdbLength;
SANE_Status status;
char cModelName[8], cModel[255];
unsigned char bModelNo;
int readByte;
bModelNo =*(pss->buf + INQUIRY_HWMI);
zero_buf(cModel, 255);
sprintf(cModelName, "%d", bModelNo);
DBG(DL_INFO, "Looking up %s\n", cModelName);
status = get_firmware_name(&firmware_path);
if (status == SANE_STATUS_GOOD)
{
cdbLength = 10;
DBG(DL_INFO, "Downloading %s\n", firmware_path);
fd = fopen(firmware_path,"r");
if(fd == NULL)
{
DBG (0, "Cannot open firmware file %s\n", firmware_path);
status = SANE_STATUS_INVAL;
}
else
{
switch (pss->pdev->model)
{
case VUEGO610S:
case VUEGO310S:
case PRISA620S:
case PRISA1240:
case PRISA640:
case PRISA4300:
case PRISA4300_2:
case PRISA5300:
/* ACER firmware files do not contain an info block */
fseek(fd, 0, SEEK_END);
bufLength = ftell(fd);
fseek(fd, 0, SEEK_SET);
break;
default:
/* AGFA firmware files contain an info block which
specifies the length of the firmware data. The
length information is stored at offset 0x5e from
end of file */
{
unsigned char size_l, size_h;
fseek(fd, -0x5e, SEEK_END);
fread(&size_l, 1, 1, fd);
fread(&size_h, 1, 1, fd);
fseek(fd, 0, SEEK_SET);
bufLength = (size_h << 8) + size_l;
}
break;
}
DBG(DL_INFO, "Size of firmware: %d\n", bufLength);
pCDB = (char *)malloc(bufLength + cdbLength);
pFwBuf = pCDB + cdbLength;
zero_buf (pCDB, cdbLength);
readByte = fread(pFwBuf,1,bufLength,fd);
*pCDB = SEND;
*(pCDB + 2) = 0x87;
*(pCDB + 6) = (bufLength >> 16) & 0xff;
*(pCDB + 7) = (bufLength >> 8) & 0xff;
*(pCDB + 8) = bufLength & 0xff;
status = snapscan_cmd (
pss->pdev->bus, pss->fd, pCDB, bufLength+cdbLength, NULL, NULL);
free(pCDB);
fclose(fd);
}
free(firmware_path);
}
return status;
}
/*
* $Log$
* Revision 1.4 2001/05/26 12:47:30 hmg
* Updated snapscan backend to version 1.2 (from
* Sebastien Sable <Sebastien.Sable@snv.jussieu.fr>).
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.5 2001/10/09 09:45:10 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.17 2001/10/08 19:26:01 oliverschwartz
* - Disable quality calibration for scanners that do not support it
*
* Revision 1.16 2001/10/08 18:22:01 oliverschwartz
* - Disable quality calibration for Acer Vuego 310F
* - Use sanei_scsi_max_request_size as scanner buffer size
* for SCSI devices
* - Added new devices to snapscan.desc
*
* Revision 1.15 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* Revision 1.14 2001/09/17 10:01:08 sable
* Added model AGFA 1236U
*
* Revision 1.13 2001/09/09 18:06:32 oliverschwartz
* add changes from Acer (new models; automatic firmware upload for USB scanners); fix distorted colour scans after greyscale scans (call set_window only in sane_start); code cleanup
*
* Revision 1.12 2001/04/10 13:00:31 sable
* Moving sanei_usb_* to snapscani_usb*

Wyświetl plik

@ -2,7 +2,8 @@
Copyright (C) 1997, 1998 Franck Schnefra, Michel Roelofs,
Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller,
Petter Reinholdtsen, Gary Plewa, Sebastien Sable and Kevin Charter
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Oliver Schwartz
and Kevin Charter
This file is part of the SANE package.
@ -92,7 +93,6 @@ typedef enum
BUF_SRC
} BaseSourceType;
#define SCSISOURCE_BAD_TIME -1
typedef struct
{
@ -100,7 +100,6 @@ typedef struct
SANE_Int scsi_buf_pos; /* current position in scsi buffer */
SANE_Int scsi_buf_max; /* data limit */
SANE_Int absolute_max; /* largest possible data read */
struct timeval time; /* time of last scsi read (usec) */
} SCSISource;
static SANE_Int SCSISource_remaining (Source *pself)
@ -116,64 +115,19 @@ static SANE_Status SCSISource_get (Source *pself,
SCSISource *ps = (SCSISource *) pself;
SANE_Status status = SANE_STATUS_GOOD;
SANE_Int remaining = *plen;
static SANE_Int warned_expected_bytes = 0;
char* me = "SCSISource_get";
DBG (DL_CALL_TRACE, "%s\n", me);
while (remaining > 0
&&
pself->remaining(pself) > 0
&&
status == SANE_STATUS_GOOD)
&& pself->remaining(pself) > 0
&& status == SANE_STATUS_GOOD)
{
SANE_Int ndata = ps->scsi_buf_max - ps->scsi_buf_pos;
DBG (DL_DATA_TRACE, "%s: ndata %d; remaining %d\n", me, ndata, remaining);
if (ndata == 0)
{
/* read more data */
struct timeval oldtime = ps->time;
if (ps->time.tv_sec != SCSISOURCE_BAD_TIME
&&
gettimeofday(&(ps->time), NULL) == 0)
{
/* estimate number of lines to read from the elapsed time
since the last read and the scanner's reported speed */
double msecs = (ps->time.tv_sec - oldtime.tv_sec)*1000.0
+ (ps->time.tv_usec - oldtime.tv_usec)/1000.0;
ps->pss->expected_read_bytes =
((int) (msecs/ps->pss->ms_per_line))*ps->pss->bytes_per_line;
if(ps->pss->pdev->model == ACER300F
||
ps->pss->pdev->model == SNAPSCAN310
||
ps->pss->pdev->model == PRISA620S
||
ps->pss->pdev->model == SNAPSCAN1212U
||
ps->pss->pdev->model == SNAPSCAN1236S
||
ps->pss->pdev->model == SNAPSCANE50
||
ps->pss->pdev->model == VUEGO310S
||
ps->pss->pdev->model == VUEGO610S)
{
ps->pss->expected_read_bytes = (size_t) ps->absolute_max;
}
if (ps->pss->expected_read_bytes == 0)
{
if (!warned_expected_bytes)
{
warned_expected_bytes++;
DBG (DL_MAJOR_ERROR,
"%s: Hung up because expected bytes is 0. Please report!",
__FUNCTION__);
}
}
}
else
{
/* use the "lines_per_read" values */
ps->pss->expected_read_bytes = ps->absolute_max;
/*
SANE_Int lines;
if (is_colour_mode(actual_mode(ps->pss)) == SANE_TRUE)
@ -181,11 +135,9 @@ static SANE_Status SCSISource_get (Source *pself,
else
lines = ps->pss->gs_lpr;
ps->pss->expected_read_bytes = lines * ps->pss->bytes_per_line;
}
*/
ps->pss->expected_read_bytes = MIN(ps->pss->expected_read_bytes,
ps->pss->bytes_remaining);
ps->pss->expected_read_bytes = MIN(ps->pss->expected_read_bytes,
(size_t) ps->absolute_max);
ps->scsi_buf_pos = 0;
ps->scsi_buf_max = 0;
status = scsi_read (ps->pss, READ_IMAGE);
@ -194,6 +146,9 @@ static SANE_Status SCSISource_get (Source *pself,
ps->scsi_buf_max = ps->pss->read_bytes;
ndata = ps->pss->read_bytes;
ps->pss->bytes_remaining -= ps->pss->read_bytes;
DBG (DL_DATA_TRACE, "%s: pos: %d; max: %d; expected: %d; read: %d\n",
me, ps->scsi_buf_pos, ps->scsi_buf_max, ps->pss->expected_read_bytes,
ps->pss->read_bytes);
}
ndata = MIN(ndata, remaining);
memcpy (pbuf, ps->pss->buf + ps->scsi_buf_pos, (size_t)ndata);
@ -207,6 +162,7 @@ static SANE_Status SCSISource_get (Source *pself,
static SANE_Status SCSISource_done (Source *pself)
{
DBG(DL_MINOR_INFO, "SCSISource_done\n");
UNREFERENCED_PARAMETER(pself);
return SANE_STATUS_GOOD;
}
@ -224,16 +180,7 @@ static SANE_Status SCSISource_init (SCSISource *pself, SnapScan_Scanner *pss)
pself->scsi_buf_max = 0;
pself->scsi_buf_pos = 0;
pself->absolute_max =
(SCANNER_BUF_SZ/pss->bytes_per_line)*pss->bytes_per_line;
if (gettimeofday(&(pself->time), NULL) != 0)
{
DBG (DL_MAJOR_ERROR,
"%s: error in gettimeofday(): %s\n",
__FUNCTION__,
strerror(errno));
pself->time.tv_sec = SCSISOURCE_BAD_TIME;
pself->time.tv_usec = SCSISOURCE_BAD_TIME;
}
(pss->phys_buf_sz/pss->bytes_per_line)*pss->bytes_per_line;
}
return status;
}
@ -258,10 +205,8 @@ static SANE_Status FDSource_get (Source *pself, SANE_Byte *pbuf, SANE_Int *plen)
SANE_Int remaining = *plen;
while (remaining > 0
&&
pself->remaining(pself) > 0
&&
status == SANE_STATUS_GOOD)
&& pself->remaining(pself) > 0
&& status == SANE_STATUS_GOOD)
{
SANE_Int bytes_read = read (ps->fd, pbuf, remaining);
if (bytes_read == -1)
@ -272,21 +217,20 @@ static SANE_Status FDSource_get (Source *pself, SANE_Byte *pbuf, SANE_Int *plen)
break;
}
/* It's an IO error */
DBG (DL_MAJOR_ERROR,
"%s: read failed: %s\n",
__FUNCTION__,
strerror(errno));
DBG (DL_MAJOR_ERROR, "%s: read failed: %s\n",
__FUNCTION__, strerror(errno));
status = SANE_STATUS_IO_ERROR;
}
else if (bytes_read == 0)
{
/* EOF of current reading */
DBG(DL_DATA_TRACE, "%s: EOF\n",__FUNCTION__);
break;
}
ps->pss->bytes_remaining -= bytes_read;
remaining -= bytes_read;
pbuf += bytes_read;
}
*plen -= remaining;
return status;
}
@ -339,7 +283,6 @@ static SANE_Status BufSource_get (Source *pself,
BufSource *ps = (BufSource *) pself;
SANE_Status status = SANE_STATUS_GOOD;
SANE_Int to_move = MIN(*plen, pself->remaining(pself));
if (to_move == 0)
{
status = SANE_STATUS_EOF;
@ -371,6 +314,7 @@ static SANE_Status BufSource_init (BufSource *pself,
Source_pixelsPerLine,
BufSource_get,
BufSource_done);
DBG(DL_DATA_TRACE, "BufSource_init: buf_size=%d\n", buf_size);
if (status == SANE_STATUS_GOOD)
{
pself->buf = buf;
@ -441,8 +385,8 @@ static SANE_Status create_base_source (SnapScan_Scanner *pss,
/* The transformer sources */
#define TX_SOURCE_GUTS \
SOURCE_GUTS;\
Source *psub /* sub-source */
SOURCE_GUTS;\
Source *psub /* sub-source */
typedef struct
{
@ -679,39 +623,22 @@ typedef struct
SANE_Byte *xbuf; /* single line buffer */
SANE_Int pos; /* current position in xbuf */
SANE_Int cb_size; /* size of the circular buffer */
SANE_Int cb_line_size; /* size of a line in the circular buffer */
SANE_Int cb_line_size;/* size of a line in the circular buffer */
SANE_Int cb_start; /* start of valid data in the circular buffer */
SANE_Int ch_offset[3]; /* offset in cbuf */
SANE_Int cb_finish; /* finish of valid data, for next read */
SANE_Int ch_offset[3];/* offset in cbuf */
SANE_Int round_req;
SANE_Int round_read;
} RGBRouter;
static SANE_Int RGBRouter_remaining (Source *pself)
{
RGBRouter *ps = (RGBRouter *) pself;
SANE_Int remaining;
if (ps->cb_start < 0)
remaining = (TxSource_remaining(pself) - ps->cb_size + ps->cb_line_size);
if (ps->round_req == ps->cb_size)
remaining = TxSource_remaining(pself) - ps->cb_size + ps->cb_line_size;
else
remaining = (TxSource_remaining(pself) + ps->cb_line_size - ps->pos);
if (remaining < 0)
{
/* We are in big trouble. Someone is using the RBGRouter routines
* to find out how much is remaining. There is a case were not
* enough data has been read yet to fill the circular buffer.
* Until it is filled then no one should be accessing it or
* checking how much is remaining (in current implemntation).
* FIXME: For now, there is some code (measure_transfer_rate) that
* will do this at times and setting remaining = 1 allows some
* scans to squeak by.
*/
remaining = 1;
DBG (DL_MAJOR_ERROR,
"%s: Computed a negative size for circular buffer! Forcing to size of 1 to keep going\n",
__FUNCTION__);
}
remaining = TxSource_remaining(pself) + ps->cb_line_size - ps->pos;
return (remaining);
}
@ -724,39 +651,40 @@ static SANE_Status RGBRouter_get (Source *pself,
SANE_Int remaining = *plen;
SANE_Byte *s;
SANE_Int i;
SANE_Int r;
SANE_Int g;
SANE_Int b;
SANE_Int r, g, b;
SANE_Int run_req;
SANE_Int org_len = *plen;
char *me = "RGBRouter_get";
while (remaining > 0 && pself->remaining(pself) > 0)
{
DBG(DL_DATA_TRACE, "%s: remaining=%d, pself->remaining=%d, round_req=%d, cb_size=%d\n",
me, remaining, pself->remaining(pself), ps->round_req, ps->cb_size);
/* Check if there is no valid data left from previous get */
if (ps->pos >= ps->cb_line_size)
{
/* Try to get more data */
SANE_Int ndata = (ps->cb_start < 0) ? ps->cb_size : (ps->cb_line_size - ps->cb_start%ps->cb_line_size);
SANE_Int start = (ps->cb_start < 0) ? 0 : ps->cb_start;
SANE_Int ndata2;
SANE_Int ndata3;
ndata2 = ndata;
ndata3 = 0;
/* Try to get more data. either one line or
full buffer (first time) */
do
{
status = TxSource_get (pself, ps->cbuf + start + ndata3, &ndata2);
if (status != SANE_STATUS_GOOD || ndata2 == 0)
run_req = ps->round_req - ps->round_read;
status = TxSource_get (pself,
ps->cbuf + ps->cb_start + ps->round_read,
&run_req);
if (status != SANE_STATUS_GOOD || run_req==0)
{
DBG (DL_MINOR_ERROR,
"TxSource_get failed status:%d, ndata:%d, ndata2:%d ndata3:%d\n", status, ndata, ndata2, ndata3);
ps->cb_start = (start + ndata3)%ps->cb_size;
*plen -= remaining;
if ( *plen > 0 )
DBG(DL_DATA_TRACE, "%s: request=%d, read=%d\n",
me, org_len, *plen);
return status;
}
ndata3 += ndata2;
ndata2 = ndata - ndata3;
ps->round_read += run_req;
}
while (ndata3 < ndata);
ps->cb_start = (start + ndata3)%ps->cb_size;
while (ps->round_req > ps->round_read);
/* route RGB */
ps->cb_start = (ps->cb_start + ps->round_read)%ps->cb_size;
s = ps->xbuf;
r = (ps->cb_start + ps->ch_offset[0])%ps->cb_size;
g = (ps->cb_start + ps->ch_offset[1])%ps->cb_size;
@ -767,17 +695,32 @@ static SANE_Status RGBRouter_get (Source *pself,
*s++ = ps->cbuf[g++];
*s++ = ps->cbuf[b++];
}
/* end of reading & offsetiing whole line data;
reset valid position */
ps->pos = 0;
/* prepare for next round */
ps->round_req = ps->cb_line_size;
ps->round_read =0;
}
/* Repack the whole scan line now */
/* Repack the whole scan line and copy to caller's buffer */
while (remaining > 0 && ps->pos < ps->cb_line_size)
{
*pbuf++ = ps->xbuf[ps->pos++];
remaining--;
}
}
*plen -= remaining;
DBG(DL_DATA_TRACE,
"%s: Request=%d, remaining=%d, read=%d, TXSource_rem=%d, bytes_rem=%d\n",
me,
org_len,
pself->remaining(pself),
*plen,
TxSource_remaining(pself),
ps->pss->bytes_remaining);
return status;
}
@ -808,22 +751,18 @@ static SANE_Status RGBRouter_init (RGBRouter *pself,
psub);
if (status == SANE_STATUS_GOOD)
{
SANE_Int lines_in_buffer = 1;
SANE_Int ch;
/* Size the buffer to accomodate the necessary number of scan lines
to cater for the offset between R, G and B */
lines_in_buffer = 0;
for (ch = 0; ch < 3; ch++)
{
if (pss->chroma_offset[ch] > lines_in_buffer)
lines_in_buffer = pss->chroma_offset[ch];
}
lines_in_buffer++;
SANE_Int lines_in_buffer = 0;
/* Size the buffer to accomodate the necessary number of scan
lines to cater for the offset between R, G and B */
lines_in_buffer = pss->chroma + 1;
pself->cb_line_size = pself->bytesPerLine((Source *) pself);
pself->cb_size = pself->cb_line_size*lines_in_buffer;
pself->pos = pself->cb_line_size;
pself->round_req = pself->cb_size;
pself->round_read = 0;
pself->cbuf = (SANE_Byte *) malloc(pself->cb_size);
pself->xbuf = (SANE_Byte *) malloc(pself->cb_line_size);
if (pself->cbuf == NULL || pself->xbuf == NULL)
@ -837,13 +776,18 @@ static SANE_Status RGBRouter_init (RGBRouter *pself,
{
SANE_Int ch;
pself->cb_start = -1;
pself->cb_start = 0;
for (ch = 0; ch < 3; ch++)
{
pself->ch_offset[ch] = pss->chroma_offset[ch]*pself->bytesPerLine((Source *) pself)
+ ch*(pself->bytesPerLine((Source *) pself)/3);
pself->ch_offset[ch] =
pss->chroma_offset[ch] * pself->cb_line_size
+ ch * (pself->cb_line_size / 3);
}
}
DBG(DL_MINOR_INFO, "RGBRouter_init: buf_size: %d x %d = %d\n",
pself->cb_line_size, lines_in_buffer, pself->cb_size);
DBG(DL_MINOR_INFO, "RGBRouter_init: buf offset R:%d G:%d B:%d\n",
pself->ch_offset[0], pself->ch_offset[1],pself->ch_offset[2]);
}
return status;
}
@ -852,12 +796,14 @@ static SANE_Status create_RGBRouter (SnapScan_Scanner *pss,
Source *psub,
Source **pps)
{
static char me[] = "create_RGBRouter";
SANE_Status status = SANE_STATUS_GOOD;
DBG (DL_CALL_TRACE, "%s\n", me);
*pps = (Source *) malloc(sizeof(RGBRouter));
if (*pps == NULL)
{
DBG (DL_MAJOR_ERROR,
"%s: failed to allocate RGBRouter.\n",
DBG (DL_MAJOR_ERROR, "%s: failed to allocate RGBRouter.\n",
__FUNCTION__);
status = SANE_STATUS_NO_MEM;
}
@ -881,7 +827,6 @@ static SANE_Status Inverter_get (Source *pself, SANE_Byte *pbuf, SANE_Int *plen)
if (status == SANE_STATUS_GOOD)
{
int i;
for (i = 0; i < *plen; i++)
pbuf[i] ^= 0xFF;
}
@ -910,8 +855,7 @@ static SANE_Status create_Inverter (SnapScan_Scanner *pss,
*pps = (Source *) malloc(sizeof(Inverter));
if (*pps == NULL)
{
DBG (DL_MAJOR_ERROR,
"%s: failed to allocate Inverter.\n",
DBG (DL_MAJOR_ERROR, "%s: failed to allocate Inverter.\n",
__FUNCTION__);
status = SANE_STATUS_NO_MEM;
}
@ -928,7 +872,10 @@ static SANE_Status create_source_chain (SnapScan_Scanner *pss,
BaseSourceType bst,
Source **pps)
{
static char me[] = "create_source_chain";
SANE_Status status = create_base_source (pss, bst, pps);
DBG (DL_CALL_TRACE, "%s\n", me);
if (status == SANE_STATUS_GOOD)
{
SnapScan_Mode mode = actual_mode(pss);
@ -952,10 +899,8 @@ static SANE_Status create_source_chain (SnapScan_Scanner *pss,
status = create_Inverter (pss, *pps, pps);
break;
default:
DBG (DL_MAJOR_ERROR,
"%s: bad mode value %d (internal error)\n",
__FUNCTION__,
mode);
DBG (DL_MAJOR_ERROR, "%s: bad mode value %d (internal error)\n",
__FUNCTION__, mode);
status = SANE_STATUS_INVAL;
break;
}
@ -965,10 +910,31 @@ static SANE_Status create_source_chain (SnapScan_Scanner *pss,
/*
* $Log$
* Revision 1.4 2001/05/26 12:47:31 hmg
* Updated snapscan backend to version 1.2 (from
* Sebastien Sable <Sebastien.Sable@snv.jussieu.fr>).
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.5 2001/10/09 09:45:12 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.16 2001/10/08 18:22:02 oliverschwartz
* - Disable quality calibration for Acer Vuego 310F
* - Use sanei_scsi_max_request_size as scanner buffer size
* for SCSI devices
* - Added new devices to snapscan.desc
*
* Revision 1.15 2001/09/28 15:56:51 oliverschwartz
* - fix hanging for SNAPSCAN300 / VUEGO 310
*
* Revision 1.14 2001/09/28 13:39:16 oliverschwartz
* - Added "Snapscan 300" ID string
* - cleanup
* - more debugging messages in snapscan-sources.c
*
* Revision 1.13 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* Revision 1.12 2001/09/09 18:06:32 oliverschwartz
* add changes from Acer (new models; automatic firmware upload for USB scanners); fix distorted colour scans after greyscale scans (call set_window only in sane_start); code cleanup
*
* Revision 1.11 2001/04/13 13:12:18 oliverschwartz
* use absolute_max as expected_read_bytes for PRISA620S

Wyświetl plik

@ -2,7 +2,8 @@
Copyright (C) 1997, 1998 Franck Schnefra, Michel Roelofs,
Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller,
Petter Reinholdtsen, Gary Plewa, Sebastien Sable and Kevin Charter
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Oliver Schwartz
and Kevin Charter
This file is part of the SANE package.
@ -87,10 +88,14 @@ static SANE_Status Source_init (Source *pself,
/*
* $Log$
* Revision 1.3 2001/05/26 12:47:31 hmg
* Updated snapscan backend to version 1.2 (from
* Sebastien Sable <Sebastien.Sable@snv.jussieu.fr>).
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.4 2001/10/09 09:45:13 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.4 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* Revision 1.3 2001/03/17 22:53:21 sable
* Applying Mikael Magnusson patch concerning Gamma correction

Wyświetl plik

@ -47,6 +47,9 @@
So far this strategy has worked flawlessly. Thanks Dmitri!
*/
/* $Id$
SnapScan backend scan data sources */
#include <sys/ipc.h>
#include <sys/sem.h>
@ -83,7 +86,7 @@ static SANE_Status snapscani_usb_cmd(int fd, const void *src, size_t src_size,
status = atomic_usb_cmd(fd,src,src_size,dst,dst_size);
if((status == SANE_STATUS_DEVICE_BUSY) && is_queueable(src) ) {
if ((status == SANE_STATUS_DEVICE_BUSY) && is_queueable(src) ) {
enqueue_bq(fd,src,src_size);
return SANE_STATUS_GOOD;
}
@ -120,10 +123,9 @@ static SANE_Status atomic_usb_cmd(int fd, const void *src, size_t src_size,
}
static SANE_Status snapscani_usb_open(const char *dev, int *fdp,
SANEI_SCSI_Sense_Handler handler, void *handler_arg)
static SANE_Status snapscani_usb_open(const char *dev, int *fdp)
{
return usb_open(dev,fdp,handler,handler_arg);
return usb_open(dev,fdp);
}
@ -169,12 +171,11 @@ static char *usb_debug_data(char *str,const char *data, int len) {
}
static SANE_Status usb_open(const char *dev, int *fdp,
SANEI_SCSI_Sense_Handler handler, void *handler_arg)
static SANE_Status usb_open(const char *dev, int *fdp)
{
static const char me[] = "usb_open";
static const char me[] = "usb_open";
DBG (DL_CALL_TRACE, "%s(%s)\n", me, dev);
DBG (DL_CALL_TRACE, "%s(%s)\n", me, dev);
if((sem_id = semget( ftok(dev,0x1234), 1, IPC_CREAT | 0660 )) == -1) {
DBG (DL_MAJOR_ERROR, "%s: Can't get semaphore\n", me);
@ -416,3 +417,15 @@ static void dequeue_bq()
me,bqelements,bqhead,bqtail);
}
/*
* $Log$
* Revision 1.2 2001/10/09 09:45:14 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.12 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* */

Wyświetl plik

@ -1,10 +1,38 @@
/*
Snapscan 1212U modifications for the Snapscan SANE backend
Copyright (C) 2000 Henrik Johansson
Henrik Johansson (henrikjo@post.urfors.se)
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.
This file implements USB equivalents to the SCSI routines used by the Snapscan
backend.
*/
/* $Id$
SnapScan backend scan data sources */
#ifndef snapscan_usb_h
#define snapscan_usb_h
static SANE_Status snapscani_usb_cmd(int fd, const void *src, size_t src_size,
void *dst, size_t * dst_size);
static SANE_Status snapscani_usb_open(const char *dev, int *fdp,
SANEI_SCSI_Sense_Handler handler, void *handler_arg);
static SANE_Status snapscani_usb_open(const char *dev, int *fdp);
static void snapscani_usb_close(int fd);
/*
@ -47,8 +75,7 @@ static int is_queueable(const char *src);
static SANE_Status atomic_usb_cmd(int fd, const void *src, size_t src_size,
void *dst, size_t * dst_size);
static SANE_Status usb_open(const char *dev, int *fdp,
SANEI_SCSI_Sense_Handler handler, void *handler_arg);
static SANE_Status usb_open(const char *dev, int *fdp);
static void usb_close(int fd);
@ -56,3 +83,16 @@ static SANE_Status usb_cmd(int fd, const void *src, size_t src_size,
void *dst, size_t * dst_size);
#endif
/*
* $Log$
* Revision 1.2 2001/10/09 09:45:15 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.8 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* */

Wyświetl plik

@ -2,8 +2,8 @@
Copyright (C) 1997, 1998, 2001 Franck Schnefra, Michel Roelofs,
Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller,
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson
and Kevin Charter
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson,
Oliver Schwartz and Kevin Charter
This file is part of the SANE package.
@ -95,7 +95,6 @@
#endif
#include "../include/sane/sanei_config.h"
#define SNAPSCAN_CONFIG_FILE "snapscan.conf"
/* debug levels */
#define DL_INFO 1
@ -120,6 +119,7 @@ if ((s) != SANE_STATUS_GOOD) { DBG(DL_MAJOR_ERROR, "%s: %s command failed: %s\n"
#define HCFG_HT16 0x08 /* 16x16 halftone matrices */
#define HCFG_HT8 0x04 /* 8x8 halftone matrices */
#define HCFG_SRA 0x02 /* scanline row average (high-speed colour) */
#define HCFG_CAL_ALLOWED 0x01 /* 1 ==> calibration allowed */
#define HCFG_HT 0x0C /* support halftone matrices at all */
@ -154,14 +154,24 @@ static const SANE_Range y_range_fb =
{
SANE_FIX (0.0), SANE_FIX (297.0), SANE_FIX (1.0)
}; /* mm */
static const SANE_Range x_range_tpo =
static const SANE_Range x_range_tpo_default =
{
SANE_FIX (0.0), SANE_FIX (129.0), SANE_FIX (1.0)
}; /* mm */
static const SANE_Range y_range_tpo =
static const SANE_Range y_range_tpo_default =
{
SANE_FIX (0.0), SANE_FIX (180.0), SANE_FIX (1.0)
}; /* mm */
static const SANE_Range x_range_tpo_1236 =
{
SANE_FIX (0.0), SANE_FIX (203.0), SANE_FIX (1.0)
}; /* mm */
static const SANE_Range y_range_tpo_1236 =
{
SANE_FIX (0.0), SANE_FIX (254.0), SANE_FIX (1.0)
}; /* mm */
static SANE_Range x_range_tpo;
static SANE_Range y_range_tpo;
static const SANE_Range gamma_range =
{
SANE_FIX (0.0), SANE_FIX (4.0), SANE_FIX (0.1)
@ -240,6 +250,7 @@ static SANE_Char password[SANE_MAX_PASSWORD_LEN];
static u_char depths8[MD_NUM_MODES] = {8, 1, 8, 1};
static u_char depths10[MD_NUM_MODES] = {10, 1, 10, 1};
static u_char depths12[MD_NUM_MODES] = {12, 1, 12, 1};
static u_char depths14[MD_NUM_MODES] = {14, 1, 14, 1};
static void gamma_n (double gamma, int brightness, int contrast,
u_char *buf, int length);
@ -333,22 +344,18 @@ static SANE_Status init_gamma(SnapScan_Scanner * ps)
static void init_options (SnapScan_Scanner * ps)
{
static SANE_Word resolutions_300[] =
{7, 50, 75, 100, 150, 200, 300, 600};
static SANE_Word resolutions_310[] =
{6, 50, 75, 100, 150, 200, 300};
static SANE_Word resolutions_610[] =
{11, 75, 100, 150, 200, 300, 400, 600, 1200, 2400, 4800, 9600};
static SANE_Word resolutions_620[] =
{12, 75, 100, 150, 200, 300, 400, 600, 1200, 2400, 4800, 9600, 19200};
static SANE_Word resolutions_e50[] =
{9, 75, 100, 150, 200, 300, 400, 600, 1200, 2400}; /* 2400 and above, still not work */
static SANE_String_Const names_300[] =
static SANE_Word resolutions_600[] =
{8, 50, 75, 100, 150, 200, 300, 450, 600};
static SANE_Word resolutions_1200[] =
{10, 50, 75, 100, 150, 200, 300, 450, 600, 900, 1200};
static SANE_String_Const names_all[] =
{md_colour, md_bilevelcolour, md_greyscale, md_lineart, NULL};
static SANE_String_Const names_310[] =
static SANE_String_Const names_basic[] =
{md_colour, md_greyscale, md_lineart, NULL};
static SANE_String_Const preview_names_300[] =
static SANE_String_Const preview_names_all[] =
{md_auto, md_colour, md_bilevelcolour, md_greyscale, md_lineart, NULL};
static SANE_String_Const preview_names_310[] =
static SANE_String_Const preview_names_basic[] =
{md_auto, md_colour, md_greyscale, md_lineart, NULL};
SANE_Option_Descriptor *po = ps->options;
@ -385,27 +392,16 @@ static void init_options (SnapScan_Scanner * ps)
{
case SNAPSCAN310:
case VUEGO310S: /* WG changed */
po[OPT_SCANRES].constraint.word_list = resolutions_310;
break;
case VUEGO610S: /* SJU added */
po[OPT_SCANRES].constraint.word_list = resolutions_610;
break;
case SNAPSCANE50:
po[OPT_SCANRES].constraint.word_list = resolutions_e50;
break;
case PRISA620S: /* GP added */
po[OPT_SCANRES].constraint.word_list = resolutions_620;
break;
case SNAPSCAN600:
DBG (DL_MINOR_INFO,
"600 dpi mode untested on SnapScan 600\nPlease report bugs\n");
default:
po[OPT_SCANRES].constraint.word_list = resolutions_300;
break;
case SNAPSCANE50:
case PRISA5300:
case PRISA1240:
po[OPT_SCANRES].constraint.word_list = resolutions_1200;
break;
default:
po[OPT_SCANRES].constraint.word_list = resolutions_600;
break;
}
ps->res = DEFAULT_RES;
@ -453,18 +449,11 @@ static void init_options (SnapScan_Scanner * ps)
switch (ps->pdev->model)
{
case SNAPSCAN310:
case SNAPSCAN600:
case SNAPSCAN1236S:
case SNAPSCAN1212U:
case SNAPSCANE50:
case VUEGO310S: /* WG changed */
po[OPT_MODE].constraint.string_list = names_310;
case VUEGO310S:
po[OPT_MODE].constraint.string_list = names_basic;
break;
case VUEGO610S: /* SJU added */
case PRISA620S: /* GP added */
default:
po[OPT_MODE].constraint.string_list = names_300;
po[OPT_MODE].constraint.string_list = names_all;
break;
}
ps->mode_s = md_colour;
@ -483,18 +472,11 @@ static void init_options (SnapScan_Scanner * ps)
switch (ps->pdev->model)
{
case SNAPSCAN310:
case SNAPSCAN600:
case SNAPSCAN1236S:
case SNAPSCAN1212U:
case SNAPSCANE50:
case VUEGO310S: /* WG changed */
po[OPT_PREVIEW_MODE].constraint.string_list = preview_names_310;
case VUEGO310S:
po[OPT_PREVIEW_MODE].constraint.string_list = preview_names_basic;
break;
case VUEGO610S: /* SJU added */
case PRISA620S: /* GP added */
default:
po[OPT_PREVIEW_MODE].constraint.string_list = preview_names_300;
po[OPT_PREVIEW_MODE].constraint.string_list = preview_names_all;
break;
}
ps->preview_mode_s = md_auto;
@ -603,9 +585,14 @@ static void init_options (SnapScan_Scanner * ps)
po[OPT_QUALITY_CAL].type = SANE_TYPE_BOOL;
po[OPT_QUALITY_CAL].unit = SANE_UNIT_NONE;
po[OPT_QUALITY_CAL].size = sizeof (SANE_Bool);
po[OPT_QUALITY_CAL].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
po[OPT_QUALITY_CAL].constraint_type = SANE_CONSTRAINT_NONE;
po[OPT_QUALITY_CAL].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
ps->val[OPT_QUALITY_CAL].b = DEFAULT_QUALITY;
/* Disable quality calibration option if not supported */
if (!(ps->hconfig & HCFG_CAL_ALLOWED)) {
po[OPT_QUALITY_CAL].cap |= SANE_CAP_INACTIVE;
ps->val[OPT_QUALITY_CAL].b = SANE_FALSE;
}
po[OPT_GAMMA_BIND].name = SANE_NAME_ANALOG_GAMMA_BIND;
po[OPT_GAMMA_BIND].title = SANE_TITLE_ANALOG_GAMMA_BIND;
@ -1019,13 +1006,17 @@ static SANE_Status add_device (SANE_String_Const name)
vendor[0] = model[0] = '\0';
if(strstr (name, "usb"))
if((strstr (name, "usb")) || (strstr (name, "USB")))
{
DBG (DL_VERBOSE, "%s: Detected (kind of) an USB device\n", me);
bus_type = USB;
status = snapscani_usb_open (name, &fd, sense_handler, NULL);
if (strncasecmp(name, "usb", 3) == 0) {
/* ignore USB keyword */
name += 3;
name = sanei_config_skip_whitespace(name);
}
status = snapscani_usb_open (name, &fd);
if (status != SANE_STATUS_GOOD)
{
DBG (DL_MAJOR_ERROR,
@ -1107,9 +1098,9 @@ static SANE_Status add_device (SANE_String_Const name)
me,
vendor,
model,
"AGFA SnapScan 300, 310, 600 or 1236s, "
"AGFA SnapScan 300, 310, 600 or 1236, "
"Acer VUEGO 300, 310S, 610S, or 610plus, "
"Acer PRISA model 620S");
"Acer PRISA 620, 640, 1240, 3300, 4300 or 5300");
if(bus_type == SCSI)
{
@ -1149,12 +1140,13 @@ static SANE_Status add_device (SANE_String_Const name)
case SNAPSCAN300:
pd->depths = depths8;
break;
case PRISA620S:
pd->depths = depths12;
break;
case VUEGO610S: /* SJU added */
case PRISA4300_2:
case PRISA5300:
pd->depths = depths14;
break;
default:
pd->depths = depths10;
break;
@ -1267,8 +1259,10 @@ SANE_Status sane_init (SANE_Int *version_code,
{
if (dev_name[0] == '#') /* ignore line comments */
continue;
len = strlen (dev_name);
if (strncasecmp(dev_name, FIRMWARE_KW, strlen(FIRMWARE_KW)) == 0)
continue; /* ignore firmware lines */
len = strlen (dev_name);
if (!len)
continue; /* ignore empty lines */
@ -1389,6 +1383,20 @@ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h)
pss->opens = 0;
pss->sense_str = NULL;
pss->as_str = NULL;
pss->phys_buf_sz = DEFAULT_SCANNER_BUF_SZ;
if (psd->bus == SCSI) {
pss->phys_buf_sz = sanei_scsi_max_request_size;
}
DBG (DL_DATA_TRACE,
"%s: Allocating %d bytes as scanner buffer.\n",
me, pss->phys_buf_sz);
pss->buf = (u_char *) malloc(pss->phys_buf_sz);
if (!pss->buf) {
DBG (DL_MAJOR_ERROR,
"%s: out of memory creating scanner buffer.\n",
me);
return SANE_STATUS_NO_MEM;
}
/* temp file name and the temp file */
{
@ -1486,9 +1494,19 @@ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h)
free (pss);
return status;
}
switch (pss->pdev->model)
{
case SNAPSCAN1236:
x_range_tpo = x_range_tpo_1236;
y_range_tpo = y_range_tpo_1236;
break;
default:
x_range_tpo = x_range_tpo_default;
y_range_tpo = y_range_tpo_default;
break;
}
init_options (pss);
pss->state = ST_IDLE;
}
@ -1512,6 +1530,7 @@ void sane_close (SANE_Handle h)
close (pss->tfd);
free (pss->tmpfname);
free (pss->gamma_tables);
free (pss->buf);
free (pss);
}
@ -1889,12 +1908,6 @@ SANE_Status sane_control_option (SANE_Handle h,
pss->source = SRC_FLATBED;
pss->pdev->x_range.max = x_range_fb.max;
pss->pdev->y_range.max = y_range_fb.max;
/*
if (pss->brx > pss->pdev->x_range.max)
pss->brx = pss->pdev->x_range.max;
if (pss->bry > pss->pdev->y_range.max)
pss->bry = pss->pdev->y_range.max;
*/
}
else if (strcmp(v, src_tpo) == 0)
{
@ -2120,6 +2133,7 @@ SANE_Status sane_control_option (SANE_Handle h,
"\tRing buffer: %s\n"
"\t16x16 halftone matrix support: %s\n"
"\t8x8 halftone matrix support: %s\n"
"\tCalibration allowed: %s\n"
"\toptical resolution: %lu\n"
"\tscan resolution: %lu\n"
"\tnumber of lines: %lu\n"
@ -2139,6 +2153,7 @@ SANE_Status sane_control_option (SANE_Handle h,
(pss->hconfig & HCFG_RB) ? "Yes" : "No",
(pss->hconfig & HCFG_HT16) ? "Yes" : "No",
(pss->hconfig & HCFG_HT8) ? "Yes" : "No",
(pss->hconfig & HCFG_CAL_ALLOWED) ? "Yes" : "No",
(u_long) pss->actual_res,
(u_long) pss->res,
(u_long) pss->lines,
@ -2335,13 +2350,6 @@ SANE_Status sane_control_option (SANE_Handle h,
DBG (DL_MAJOR_ERROR, "%s: invalid action code %ld\n", me, (long) a);
return SANE_STATUS_UNSUPPORTED;
}
if (a != SANE_ACTION_GET_VALUE)
{
SANE_Status status = set_window (pss);
CHECK_STATUS (status, me, "set_window");
}
close_scanner (pss);
return SANE_STATUS_GOOD;
}
@ -2357,36 +2365,24 @@ SANE_Status sane_get_parameters (SANE_Handle h,
DBG (DL_CALL_TRACE, "%s (%p, %p)\n", me, (void *) h, (void *) p);
if (pss->state == ST_IDLE)
{
status = open_scanner (pss);
CHECK_STATUS (status, me, "open_scanner");
/* fetch the latest parameters */
status = inquiry (pss);
CHECK_STATUS (status, me, "inquiry");
close_scanner (pss);
}
else
{
DBG (DL_INFO, "NOT doing an inquiry to get scanner parameters\n");
status = SANE_STATUS_GOOD;
}
p->last_frame = SANE_TRUE; /* we always do only one frame */
if ((pss->state == ST_SCAN_INIT) || (pss->state == ST_SCANNING))
{
/* we are in the middle of a scan, so we can use the data
that the scanner has reported */
if (pss->psrc != NULL)
{
DBG(DL_DATA_TRACE, "%s: Using source chain data\n", me);
/* use what the source chain says */
p->pixels_per_line = pss->psrc->pixelsPerLine(pss->psrc);
p->bytes_per_line = pss->psrc->bytesPerLine(pss->psrc);
/* p->lines = pss->psrc->remaining(pss->psrc)/p->bytes_per_line;*/
/* p->lines = pss->psrc->remaining(pss->psrc)/p->bytes_per_line; */
p->lines = pss->lines;
}
else
{
DBG(DL_DATA_TRACE, "%s: Using current data\n", me);
/* estimate based on current data */
p->pixels_per_line = pss->pixels_per_line;
p->bytes_per_line = pss->bytes_per_line;
@ -2394,11 +2390,40 @@ SANE_Status sane_get_parameters (SANE_Handle h,
if (mode == MD_BILEVELCOLOUR)
p->bytes_per_line = p->pixels_per_line*3;
}
}
else
{
/* no scan in progress. The scanner data may not be up to date.
we have to calculate an estimate. */
double width, height;
int dpi;
double dots_per_mm;
DBG(DL_DATA_TRACE, "%s: Using estimated data\n", me);
width = SANE_UNFIX (pss->brx - pss->tlx);
height = SANE_UNFIX (pss->bry - pss->tly);
dpi = pss->res;
dots_per_mm = dpi / MM_PER_IN;
p->pixels_per_line = width * dots_per_mm;
p->lines = height * dots_per_mm;
switch (mode)
{
case MD_COLOUR:
case MD_BILEVELCOLOUR:
p->bytes_per_line = 3 * p->pixels_per_line;
break;
case MD_LINEART:
p->bytes_per_line = (p->pixels_per_line + 7) / 8;
break;
default:
/* greyscale */
p->bytes_per_line = p->pixels_per_line;
break;
}
}
p->format = (is_colour_mode(mode)) ? SANE_FRAME_RGB : SANE_FRAME_GRAY;
p->depth = (mode == MD_LINEART) ? 1 : 8;
DBG (DL_DATA_TRACE, "%s: depth = %ld\n", me, (long) p->depth);
DBG (DL_DATA_TRACE, "%s: lines = %ld\n", me, (long) p->lines);
DBG (DL_DATA_TRACE,
@ -2492,21 +2517,17 @@ static SANE_Status start_reader (SnapScan_Scanner *pss)
pss->rpipe[0] = pss->rpipe[1] = -1;
pss->child = -1;
if (pss->pdev->model == PRISA620S /* GP added - blocking mode only */
if (pss->pdev->model == VUEGO610S
||
pss->pdev->model == VUEGO610S /* SJU added */
pss->pdev->model == ACER300F
||
pss->pdev->model == ACER300F /* Seb added */
pss->pdev->model == SNAPSCAN310
||
pss->pdev->model == SNAPSCAN310 /* Seb added */
||
pss->pdev->model == VUEGO310S /* Seb added */
||
pss->pdev->model == VUEGO610S /* Seb added */
pss->pdev->model == VUEGO310S
||
pss->pdev->model == SNAPSCANE50
||
pss->pdev->model == SNAPSCAN1236S) /* Seb added */
pss->pdev->model == SNAPSCAN1236)
{
status = SANE_STATUS_UNSUPPORTED;
}
@ -2770,69 +2791,8 @@ static SANE_Status measure_transfer_rate (SnapScan_Scanner *pss)
pss->expected_read_bytes =
(pss->buf_sz%128) ? (pss->buf_sz/128 + 1)*128 : pss->buf_sz;
{
u_char *other_buf = (u_char *) malloc (pss->expected_read_bytes);
if (other_buf == NULL)
{
DBG (DL_MAJOR_ERROR,
"%s: failed to allocate second test buffer.\n",
me);
return SANE_STATUS_NO_MEM;
}
status = scsi_read (pss, READ_TRANSTIME);
if (status != SANE_STATUS_GOOD)
{
DBG (DL_MAJOR_ERROR, "%s: test read failed.\n", me);
free (other_buf);
return status;
}
/* process the data through a typical source chain; because
we've rounded the data at a 128-byte boundary, it may
happen that some data is left over */
status = create_source_chain (pss, BUF_SRC, &(pss->psrc));
if (status == SANE_STATUS_GOOD)
{
SANE_Int remaining = pss->read_bytes;
while (remaining > 0)
{
SANE_Int ndata = pss->psrc->bytesPerLine(pss->psrc);
ndata = MIN(ndata, remaining);
status = pss->psrc->get(pss->psrc, other_buf, &ndata);
if (status != SANE_STATUS_GOOD)
break;
remaining -= ndata;
}
pss->read_bytes -= remaining;
}
else
{
DBG (DL_MAJOR_ERROR,
"%s: warning: couldn't allocate source chain.\n",
me);
memcpy (other_buf, pss->buf, pss->read_bytes);
}
/* presumably, after copying, the front-end will be storing the
data in a file */
{
int result = write (pss->tfd, other_buf, pss->read_bytes);
if (result < 0 || result == INT_MAX)
{
DBG (DL_MAJOR_ERROR,
"%s: write of test data to file failed.\n",
me);
perror ("");
return SANE_STATUS_UNSUPPORTED;
}
}
free (other_buf);
}
CHECK_STATUS (status, me, "scsi_read");
pss->expected_read_bytes = 0;
status = scsi_read (pss, READ_TRANSTIME);
CHECK_STATUS (status, me, "scsi_read");
@ -3127,16 +3087,38 @@ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd)
/*
* $Log$
* Revision 1.5 2001/06/01 16:24:46 hmg
* Fixed two bugs: pss->devname must be checked for 0. Return total
* number of lines in sane_get_parameters (patch from Ben Stanley
* <bds02@uow.edu.au>).
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.6 2001/10/09 09:45:16 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.4 2001/05/26 12:47:32 hmg
* Updated snapscan backend to version 1.2 (from
* Sebastien Sable <Sebastien.Sable@snv.jussieu.fr>).
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.22 2001/10/08 19:26:01 oliverschwartz
* - Disable quality calibration for scanners that do not support it
*
* Revision 1.21 2001/10/08 18:22:02 oliverschwartz
* - Disable quality calibration for Acer Vuego 310F
* - Use sanei_scsi_max_request_size as scanner buffer size
* for SCSI devices
* - Added new devices to snapscan.desc
*
* Revision 1.20 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* Revision 1.19 2001/09/17 10:01:08 sable
* Added model AGFA 1236U
*
* Revision 1.18 2001/09/10 10:16:32 oliverschwartz
* better USB / SCSI recognition, correct max scan area for 1236+TPO
*
* Revision 1.17 2001/09/09 18:06:32 oliverschwartz
* add changes from Acer (new models; automatic firmware upload for USB scanners); fix distorted colour scans after greyscale scans (call set_window only in sane_start); code cleanup
*
* Revision 1.16 2001/09/07 09:42:13 oliverschwartz
* Sync with Sane-1.0.5
*
* Revision 1.15 2001/05/15 20:51:14 oliverschwartz
* check for pss->devname instead of name in sane_open()
*
* Revision 1.14 2001/04/10 13:33:06 sable
* Transparency adapter bug and xsane crash corrections thanks to Oliver Schwartz

Wyświetl plik

@ -1,9 +1,14 @@
scsi AGFA
scsi COLOR
scsi ACERPERI
# If not automatically found from above, then you may manually specify
# a device name.
/dev/scanner
#/dev/usbscanner
# 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.
/dev/usbscanner
#/dev/scanner
#/dev/sga
# Change to the fully qualified filename of your firmware file, if
# firmware upload is needed by the scanner
firmware /path/to/your/firmware/file

Wyświetl plik

@ -12,7 +12,7 @@
:backend "SnapScan" ; name of backend
:version "1.2" ; version of backend
:status :alpha ; :alpha, :beta, :stable, :new
:status :beta ; :alpha, :beta, :stable, :new
:manpage "sane-snapscan" ; name of manpage (if it exists)
:url "http://snapscan.sourceforge.net/" ; backend's web page
@ -40,10 +40,18 @@
:interface "SCSI"
:comment "Ditto. Have no specific programming info yet."
:model "SnapScan 1236u"
:interface "USB"
:comment "Ditto. Have no specific programming info yet."
:model "SnapScan 1212u"
:interface "USB"
:comment "Ditto. Have no specific programming info yet."
:model "SnapScan e20"
:interface "USB"
:comment "Have no specific programming info yet."
:model "SnapScan e40"
:interface "USB"
:comment "Have no specific programming info yet."
@ -52,6 +60,10 @@
:interface "USB"
:comment "Have no specific programming info yet."
:model "SnapScan e60"
:interface "USB"
:comment "Have no specific programming info yet."
:mfg "Vuego"
;------------------------------------------------------------------------------
@ -84,6 +96,10 @@
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:model "Prisa 620ut"
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:model "Prisa 640u"
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
@ -92,6 +108,22 @@
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:model "Prisa 1240"
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:model "Prisa 3300"
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:model "Prisa 4300"
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:model "Prisa 5300"
:interface "USB"
:comment "Seems to be a close SnapScan 310/600 compatible."
:mfg "Guillemot International"
;------------------------------------------------------------------------------

Wyświetl plik

@ -2,8 +2,8 @@
Copyright (C) 1997, 1998, 1999, 2001 Franck Schnefra, Michel Roelofs,
Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller,
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson
and Kevin Charter
Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson,
Oliver Schwartz and Kevin Charter
This file is part of the SANE package.
@ -58,8 +58,9 @@
#define DEFAULT_DEVICE "/dev/scanner" /* Check this if config is missing */
#define SNAPSCAN_TYPE "flatbed scanner"
/*#define INOPERATIVE*/
#define TMP_FILE_PREFIX "/var/tmp/snapscan"
#define SNAPSCAN_CONFIG_FILE "snapscan.conf"
#define FIRMWARE_KW "firmware"
/* Define the colour channel order in arrays */
#define R_CHAN 0
@ -79,13 +80,18 @@ typedef enum
SNAPSCAN300, /* the original SnapScan or SnapScan 300 */
SNAPSCAN310, /* the SnapScan 310 */
SNAPSCAN600, /* the SnapScan 600 */
SNAPSCAN1236S, /* the SnapScan 1236s */
SNAPSCAN1236, /* the SnapScan 1236 */
SNAPSCAN1212U,
SNAPSCANE50, /* SnapScan e20/e40/e50 */
ACER300F,
VUEGO310S, /* Vuego-Version of SnapScan 310 WG changed */
VUEGO610S, /* Vuego 610S and 610plus SJU changed */
PRISA620S /* Prisa-Version of SnapScan 600 GP added */
PRISA620S, /* Acer ScanPrisa 620 - 600 DPI */
PRISA640, /* Acer ScanPrisa 640 - 600 DPI */
PRISA4300, /* Acer ScanPrisa 3300/4300 - 600 DPI */
PRISA4300_2, /* Acer ScanPrisa 3300/4300 - 600 DPI */
PRISA1240, /* Acer ScanPrisa 1240 - 1200 DPI */
PRISA5300 /* Acer ScanPrisa 5300 - 1200 DPI */
} SnapScan_Model;
struct SnapScan_Model_desc
{
@ -98,22 +104,29 @@ static struct SnapScan_Model_desc scanners[] =
/* SCSI model name -> enum value */
{"FlatbedScanner_2", VUEGO610S},
{"FlatbedScanner_4", VUEGO310S},
{"FlatbedScanner_5", PRISA620S},
{"FlatbedScanner_9", PRISA620S},
{"FlatbedScanner13", PRISA620S},
{"FlatbedScanner16", PRISA620S},
{"FlatbedScanner17", PRISA620S},
{"FlatbedScanner18", PRISA620S},
{"FlatbedScanner19", PRISA620S}, /* Acer ScanPrisa 1240UT */
{"FlatbedScanner20", PRISA620S},
{"FlatbedScanner19", PRISA1240},
{"FlatbedScanner20", PRISA640},
{"FlatbedScanner21", PRISA4300},
{"FlatbedScanner23", PRISA4300_2},
{"FlatbedScanner24", PRISA5300},
{"SNAPSCAN 1212U", SNAPSCAN1212U},
{"SNAPSCAN 1212U_2", SNAPSCAN1212U},
{"SNAPSCAN e20", SNAPSCANE50},
{"SNAPSCAN e50", SNAPSCANE50},
{"SNAPSCAN e40", SNAPSCANE50},
{"SNAPSCAN 1236", SNAPSCAN1236S},
{"SNAPSCAN 1236", SNAPSCAN1236},
{"SNAPSCAN 1236U", SNAPSCAN1236},
{"SNAPSCAN 300", SNAPSCAN300},
{"SNAPSCAN 310", SNAPSCAN310},
{"SNAPSCAN 600", SNAPSCAN600},
{"SnapScan", SNAPSCAN300},
{"ACERSCAN_A4____1", ACER300F},
{"ACERSCAN_A4____1", ACER300F}
};
#define known_scanners ((int) (sizeof(scanners)/sizeof(scanners[0])))
@ -122,6 +135,7 @@ static char *vendors[] =
/* SCSI Vendor name */
"AGFA",
"COLOR",
"Color",
"ACERPER"
};
#define known_vendors ((int) (sizeof(vendors)/sizeof(vendors[0])))
@ -215,7 +229,7 @@ typedef struct snapscan_device
SnapScan_Device;
#define MAX_SCSI_CMD_LEN 256 /* not that large */
#define SCANNER_BUF_SZ 31744
#define DEFAULT_SCANNER_BUF_SZ 1024*63
typedef struct snapscan_scanner SnapScan_Scanner;
@ -237,7 +251,8 @@ struct snapscan_scanner
SnapScan_Source source; /* scanning source */
SnapScan_State state; /* scanner state */
u_char cmd[MAX_SCSI_CMD_LEN]; /* scsi command buffer */
u_char buf[SCANNER_BUF_SZ]; /* data 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 */
@ -254,6 +269,7 @@ struct snapscan_scanner
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
@ -294,10 +310,34 @@ struct snapscan_scanner
/*
* $Log$
* Revision 1.4 2001/05/26 12:47:34 hmg
* Updated snapscan backend to version 1.2 (from
* Sebastien Sable <Sebastien.Sable@snv.jussieu.fr>).
* Henning Meier-Geinitz <henning@meier-geinitz.de>
* Revision 1.5 2001/10/09 09:45:21 oliverschwartz
* update snapscan to snapshot 20011008
*
* Revision 1.17 2001/10/08 18:22:02 oliverschwartz
* - Disable quality calibration for Acer Vuego 310F
* - Use sanei_scsi_max_request_size as scanner buffer size
* for SCSI devices
* - Added new devices to snapscan.desc
*
* Revision 1.16 2001/09/28 13:39:16 oliverschwartz
* - Added "Snapscan 300" ID string
* - cleanup
* - more debugging messages in snapscan-sources.c
*
* Revision 1.15 2001/09/18 15:01:07 oliverschwartz
* - Read scanner id string again after firmware upload
* to indentify correct model
* - Make firmware upload work for AGFA scanners
* - Change copyright notice
*
* Revision 1.14 2001/09/17 10:01:08 sable
* Added model AGFA 1236U
*
* Revision 1.13 2001/09/09 20:39:52 oliverschwartz
* add identification for 620ST+
*
* Revision 1.12 2001/09/09 18:06:32 oliverschwartz
* add changes from Acer (new models; automatic firmware upload for USB scanners); fix distorted colour scans after greyscale scans (call set_window only in sane_start); code cleanup
*
* Revision 1.11 2001/04/10 12:38:21 sable
* Adding e20 support thanks to Steffen Hübner