# AGFA SnapScan 1236 (patch 2)

Petter Reinholdtsen (pere@hungry.com)
Sat, 13 Mar 1999 14:51:22 +0100

- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Svend Daugaard Pedersen: "SnapScan backend"
- Previous message: Petter Reinholdtsen: "saned documentation patch"

Here is the second take of the SnapScan 1236 driver patch. This is a
small cleanup. 600dpi is tested, so the SnapScap 600 debug message no
longer apply, and I found a small and simple bug in sane_read().

This backend still fails 'scanimage -T', but I've yet do find the
solution.

The patch is also available from
<URL:http://www.student.uit.no/~pere/linux/>.

diff -ru /store/store/joseph/sane/src-pre1.01r3/ChangeLog src-pre1.01r3-allarchs/ChangeLog
--- /store/store/joseph/sane/src-pre1.01r3/ChangeLog Fri Mar 5 07:20:00 1999
+++ src-pre1.01r3-allarchs/ChangeLog Sat Mar 13 15:37:48 1999
@@ -1,3 +1,14 @@
+1999-03-10 Petter Reinholdtsen <pere@td.org.uit.no>
+
+ * backend/snapscan.c (add_device init_options inquiry
+ sane_snapscan_get_parameters sane_snapscan_start
+ sane_snapscan_set_io_mode sane_snapscan_read) backend/snapscan.h
+ backend/snapscan.desc: Rewrote scanner detection code to loop over
+ array of supported SCSI names. Added AGFA SnapScan 1236 support.
+ It seems to be compatible with SnapScan 600.
+ Make sure to not add the same device more then once to the device
+ list. Bugfix in sane_snapscan_read() triggered on EOF.
+
1999-03-04 David Mosberger-Tang <David.Mosberger@acm.org>
* backend/canon.c (adjust_hilo_points): Print values of type
diff -ru /store/store/joseph/sane/src-pre1.01r3/backend/snapscan.c src-pre1.01r3-allarchs/backend/snapscan.c
--- /store/store/joseph/sane/src-pre1.01r3/backend/snapscan.c Sun Feb 28 21:34:05 1999
+++ src-pre1.01r3-allarchs/backend/snapscan.c Fri Mar 12 20:17:16 1999
@@ -111,6 +111,8 @@
/*----- internal scanner operations -----*/
+#define DEFAULT_DEVICE "/dev/scanner" /* Check this if config is missing */
+
/* hardware configuration byte masks */
#define HCFG_ADC 0x80 /* AD converter 1 ==> 10bit, 0 ==> 8bit */
@@ -161,7 +163,6 @@
#define DEFAULT_BRX (x_range.max)
#define DEFAULT_BRY (y_range.max)
-
#ifdef INOPERATIVE
static const SANE_Range percent_range =
{
@@ -339,6 +340,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
po[OPT_MODE].constraint.string_list = names_310;
break;
@@ -370,6 +372,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
po[OPT_PREVIEW_MODE].constraint.string_list = names_310;
break;
@@ -995,6 +998,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
rgb_buf_set_diff (pss,
pss->buf[INQUIRY_G2R_DIFF],
@@ -1530,6 +1534,15 @@
static SnapScan_Device *first_device = NULL; /* device list head */
static int n_devices = 0; /* the device count */
+static SANE_Bool
+device_already_in_list(SnapScan_Device *current, SANE_String_Const name)
+{
+ for ( ;NULL != current; current = current->pnext )
+ if (0 == strcmp(name, current->dev.name))
+ return SANE_TRUE;
+ return SANE_FALSE;
+}
+
static SANE_Status
add_device (SANE_String_Const name)
{
@@ -1537,10 +1550,16 @@
static const char me[] = "add_device";
SANE_Status status;
SnapScan_Device *pd;
- SnapScan_Model model_num;
+ SnapScan_Model model_num = UNKNOWN;
char vendor[8], model[17];
+ int i, vendor_ok = 0;
- DBG (DL_CALL_TRACE, "%s\n", me);
+ DBG (DL_CALL_TRACE, "%s(%s)\n", me, name);
+
+ /* Avoid adding the same device more then once */
+ if (device_already_in_list(first_device, name)) {
+ return SANE_STATUS_GOOD;
+ }
vendor[0] = model[0] = '\0';
@@ -1561,38 +1580,38 @@
return status;
}
- if ((strncasecmp (vendor, SNAPSCAN_VENDOR, strlen (SNAPSCAN_VENDOR)) == 0)
- ||
- (strncasecmp (vendor, VUEGO_VENDOR, strlen (VUEGO_VENDOR)) == 0)) /* WG changed */
- {
- /* original SnapScan */
- if (strncasecmp (model, SNAPSCAN_MODEL310,
- strlen (SNAPSCAN_MODEL310)) == 0)
- model_num = SNAPSCAN310;
- else if (strncasecmp (model, SNAPSCAN_MODEL600,
- strlen (SNAPSCAN_MODEL600)) == 0)
- model_num = SNAPSCAN600;
- else if (strncasecmp (model, SNAPSCAN_MODEL300,
- strlen (SNAPSCAN_MODEL300)) == 0)
- model_num = SNAPSCAN300;
- else if (strncasecmp (model, VUEGO_MODEL310S, /* WG changed */
- strlen (VUEGO_MODEL310S)) == 0)
- model_num = VUEGO310S;
- else
+ /* check if this is one of our supported vendors */
+ for (i = 0; i < known_vendors; i++)
+ if (0 == strncasecmp (vendor, vendors[i], strlen(vendors[i])))
+ {
+ vendor_ok = 1;
+ break;
+ }
+ if (!vendor_ok)
+ {
+ DBG (DL_MINOR_ERROR, "%s: \"%s %s\" is not an %s\n",
+ me, vendor, model,
+ "AGFA SnapScan model 300, 310, 600 and 1236"
+ " or VUEGO model 310S"); /* WG changed */
+ sanei_scsi_close (fd);
+ return SANE_STATUS_INVAL;
+ }
+
+ /* Known vendor. Check if it is one of our supported models */
+ for (i = 0; i < known_scanners; i++)
+ {
+ if (0 == strncasecmp (model, scanners[i].scsi_name,
+ strlen(scanners[i].scsi_name)))
{
- DBG (DL_INFO, "%s: sorry, model %s is not supported.\n"
- "Currently supported models are the SnapScan 300 and 310.\n",
- me, model);
- sanei_scsi_close (fd);
- return SANE_STATUS_INVAL;
+ model_num = scanners[i].id;
+ break;
}
}
- else
+ if (UNKNOWN == model_num)
{
- DBG (DL_MINOR_ERROR, "%s: \"%s %s\" is not an %s %s\n",
- me, vendor, model,
- SNAPSCAN_VENDOR,
- "AGFA SnapScan model 300, 310, and 600 or VUEGO model 310S"); /* WG changed */
+ DBG (DL_INFO, "%s: sorry, model %s is not supported.\n"
+ "Currently supported models are the SnapScan 300 and 310.\n",
+ me, model);
sanei_scsi_close (fd);
return SANE_STATUS_INVAL;
}
@@ -1706,10 +1725,10 @@
if (!fp)
{
DBG (DL_INFO,
- "%s: configuration file not found, defaulting to /dev/scanner.\n",
- me);
+ "%s: configuration file not found, defaulting to %s.\n",
+ me, DEFAULT_DEVICE);
/* default to /dev/scanner instead of insisting on config file */
- status = add_device ("/dev/scanner");
+ status = add_device (DEFAULT_DEVICE);
if (status != SANE_STATUS_GOOD)
{
DBG (DL_MINOR_ERROR, "%s: failed to add device \"%s\"\n",
@@ -2673,6 +2692,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
if (!pss->preview)
{
@@ -2699,6 +2719,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
pss->lines += line_offset;
p->lines -= line_offset;
@@ -3114,6 +3135,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
if (SANE_STATUS_GOOD != rgb_buf_init (pss))
return SANE_STATUS_NO_MEM;
@@ -3134,6 +3156,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
rgb_buf_clean (pss);
break;
@@ -3153,6 +3176,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
transfer_data_diff (other_buf, pss);
break;
@@ -3186,6 +3210,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
rgb_buf_clean (pss);
break;
@@ -3231,13 +3256,14 @@
pss->bytes_per_line / pss->ms_per_line);
/* allocate and initialize rgb ring buffer if the device is
- a snapscan 310 or 600 model, in colour mode */
+ a snapscan 310, 600 or 1236 model, in colour mode */
if (colour)
{
switch (pss->pdev->model)
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
rgb_buf_init (pss);
break;
@@ -3279,6 +3305,8 @@
DBG (DL_CALL_TRACE, "%s (%p, %p, %ld, %p)\n",
me, (void *) h, (void *) buf, (long) maxlen, (void *) plen);
+ *plen = 0;
+
if (!pss->expected_data_len)
{
if (pss->child > 0)
@@ -3292,8 +3320,6 @@
return SANE_STATUS_EOF;
}
- *plen = 0;
-
if (pss->preview)
mode = pss->preview_mode;
@@ -3413,6 +3444,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
transferred_bytes = transfer_data_diff (buf, pss);
break;
@@ -3486,6 +3518,7 @@
{
case SNAPSCAN310:
case SNAPSCAN600:
+ case SNAPSCAN1236:
case VUEGO310S: /* WG changed */
rgb_buf_clean (pss);
break;
diff -ru /store/store/joseph/sane/src-pre1.01r3/backend/snapscan.desc src-pre1.01r3-allarchs/backend/snapscan.desc
--- /store/store/joseph/sane/src-pre1.01r3/backend/snapscan.desc Mon Sep 7 09:28:57 1998
+++ src-pre1.01r3-allarchs/backend/snapscan.desc Wed Mar 10 21:14:10 1999
@@ -28,6 +28,8 @@
:comment "Ditto"
:model "SnapScan 600"
:comment "Ditto"
+:model "SnapScan 1236"
+:comment "Ditto"
:mfg "Vuego"
:model "310S"
:comment "Close SnapScan 310 compatible."
diff -ru /store/store/joseph/sane/src-pre1.01r3/backend/snapscan.h src-pre1.01r3-allarchs/backend/snapscan.h
--- /store/store/joseph/sane/src-pre1.01r3/backend/snapscan.h Sun Feb 28 00:59:10 1999
+++ src-pre1.01r3-allarchs/backend/snapscan.h Wed Mar 10 22:19:16 1999
@@ -54,22 +54,41 @@
/* snapscan device field values */
#define SNAPSCAN_NAME "/dev/sga"
-#define SNAPSCAN_VENDOR "AGFA"
-#define VUEGO_VENDOR "COLOR"
-#define SNAPSCAN_MODEL300 "SnapScan"
-#define SNAPSCAN_MODEL310 "SNAPSCAN 310"
-#define VUEGO_MODEL310S "FlatbedScanner_4"
-#define SNAPSCAN_MODEL600 "SNAPSCAN 600"
#define SNAPSCAN_TYPE "flatbed scanner"
/*#define INOPERATIVE*/
typedef enum
{
+ UNKNOWN,
SNAPSCAN300, /* the original SnapScan or SnapScan 300 */
SNAPSCAN310, /* the SnapScan 310 */
SNAPSCAN600, /* the SnapScan 600 */
+ SNAPSCAN1236, /* the SnapScan 1236 */
VUEGO310S /* Vuego-Version of SnapScan 310 WG changed */
} SnapScan_Model;
+
+struct SnapScan_Model_desc
+{
+ char *scsi_name;
+ SnapScan_Model id;
+};
+
+static struct SnapScan_Model_desc scanners[] =
+{
+ { "FlatbedScanner_4", VUEGO310S },
+ { "SNAPSCAN 1236", SNAPSCAN1236 },
+ { "SNAPSCAN 310", SNAPSCAN310 },
+ { "SNAPSCAN 600", SNAPSCAN600 },
+ { "SnapScan", SNAPSCAN300 },
+};
+#define known_scanners (sizeof(scanners)/sizeof(struct SnapScan_Model_desc))
+
+static char *vendors[] =
+{
+ "AGFA",
+ "COLOR",
+};
+#define known_vendors (sizeof(vendors)/sizeof(char*))
typedef enum
{

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com

- Next message: Svend Daugaard Pedersen: "SnapScan backend"
- Previous message: Petter Reinholdtsen: "saned documentation patch"