[sane-devel] Re: SANE & LS50ED
Major A
andras@users.sourceforge.net
Wed, 5 Jan 2005 12:19:08 +0000
> Oh. Weird, ok. I'll keep looking. Do you have access to the technical=20
> specs of the 50/5k?
Yes, and I can't see anything obviously wrong. But then I don't have
time to go through it in detail anyway.
> Could you send me said patch? I don't have the device (yet) but would=20
> like to look over it.
The patch is at the end of this email. Please give it a go.
Andras
--- coolscan2.c 2004-10-18 17:19:15.000000000 +0100
+++ /tmp/coolscan2.c 2005-01-05 12:15:39.000000000 +0000
@@ -43,7 +43,7 @@
=20
This file implements a SANE backend for Nikon Coolscan film scanners.
=20
- Written by Andr=E1s G. Major (andras@users.sourceforge.net), 2001-200=
4.
+ Written by Andr=E1s Major (andras@users.sourceforge.net), 2001-2002.
=20
The developers wish to express their thanks to Nikon Corporation
for providing technical information and thus making this backend
@@ -56,7 +56,6 @@
/*
Revision log:
=20
- XXXXXXXXXXXXX
0.1.8, 27/09/2002, andras: added subframe and load options
0.1.7, 22/08/2002, andras: added exposure correction option
and hack for LS-40 IR readout
@@ -80,6 +79,10 @@
#include <ctype.h>
#include <unistd.h>
#include <time.h>
+/*
+#include <limits.h>
+#include <sys/types.h>
+*/
=20
#include "../include/sane/sane.h"
#include "../include/sane/sanei.h"
@@ -231,7 +234,6 @@
/* device characteristics */
char vendor_string[9], product_string[17], revision_string[5];
cs2_type_t type;
- int boundary_type;
int maxbits;
unsigned int resx_optical, resx_min, resx_max, *resx_list, resx_n_list=
;
unsigned int resy_optical, resy_min, resy_max, *resy_list, resy_n_list=
;
@@ -1795,24 +1797,6 @@
return SANE_STATUS_UNSUPPORTED;
}
=20
- switch (s->type)
- {
- case CS2_TYPE_LS30:
- case CS2_TYPE_LS2000:
- case CS2_TYPE_LS8000:
- s->boundary_type =3D 1;
- break;
- case CS2_TYPE_LS40:
- case CS2_TYPE_LS50:
- case CS2_TYPE_LS4000:
- case CS2_TYPE_LS5000:
- case CS2_TYPE_LS9000:
- s->boundary_type =3D 2;
- break;
- case CS2_TYPE_UNKOWN:
- break;
- }
-
if (sp)
*sp =3D s;
else
@@ -2072,6 +2056,7 @@
size_t n_data, n_status;
static SANE_Byte status_buf[8];
int status_only =3D 0;
+ long nn; /* LLLLLLLLLL */
=20
DBG (20, "cs2_issue_cmd(): opcode =3D 0x%02x, n_send =3D %lu, n_recv =3D=
%lu.\n",
s->send_buf[0], (unsigned long) s->n_send, (unsigned long) s->n_r=
ecv);
@@ -2146,6 +2131,10 @@
status =3D SANE_STATUS_GOOD;
break;
case CS2_INTERFACE_USB:
+ /* LLLLLLLLLLLL */
+ for (nn =3D 0; nn < s->n_cmd; nn ++)
+ fprintf (stderr, "%02x ", s->send_buf[nn]);
+ fprintf (stderr, "\n");
status =3D sanei_usb_write_bulk (s->fd, s->send_buf, &s->n_cmd);
switch (cs2_phase_check (s))
{
@@ -2155,6 +2144,10 @@
DBG (4, "Error: cs2_issue_cmd(): Unexpected data out phase.\n");
return SANE_STATUS_IO_ERROR;
}
+ /* LLLLLLLLLLLL */
+ for (nn =3D 0; nn < n_data; nn ++)
+ fprintf (stderr, "%02x ", s->send_buf[s->n_cmd+nn]);
+ fprintf (stderr, "\n");
status =3D
sanei_usb_write_bulk (s->fd, s->send_buf + s->n_cmd, &n_data);
break;
@@ -2676,86 +2669,45 @@
int i_boundary;
unsigned long lvalue;
=20
+ return SANE_STATUS_GOOD; /* LLLLLLLLLLLL*/
+
cs2_scanner_ready (s, CS2_STATUS_READY);
cs2_init_buffer (s);
+ cs2_parse_cmd (s, "2a 00 88 00 00 03");
+ cs2_pack_byte (s, ((4 + s->n_frames * 16) >> 16) & 0xff);
+ cs2_pack_byte (s, ((4 + s->n_frames * 16) >> 8) & 0xff);
+ cs2_pack_byte (s, (4 + s->n_frames * 16) & 0xff);
+ cs2_parse_cmd (s, "00");
=20
- if (s->boundary_type =3D=3D 1)
- {
- cs2_parse_cmd (s, "2a 00 88 00 00 03");
- cs2_pack_byte (s, ((4 + s->n_frames * 16) >> 16) & 0xff);
- cs2_pack_byte (s, ((4 + s->n_frames * 16) >> 8) & 0xff);
- cs2_pack_byte (s, (4 + s->n_frames * 16) & 0xff);
- cs2_parse_cmd (s, "00");
-
- cs2_pack_byte (s, ((4 + s->n_frames * 16) >> 8) & 0xff);
- cs2_pack_byte (s, (4 + s->n_frames * 16) & 0xff);
- cs2_pack_byte (s, s->n_frames);
- cs2_parse_cmd (s, "00");
- for (i_boundary =3D 0; i_boundary < s->n_frames; i_boundary++)
- {
- lvalue =3D s->frame_offset * i_boundary + s->subframe / s->unit_mm;
- cs2_pack_byte (s, (lvalue >> 24) & 0xff);
- cs2_pack_byte (s, (lvalue >> 16) & 0xff);
- cs2_pack_byte (s, (lvalue >> 8) & 0xff);
- cs2_pack_byte (s, lvalue & 0xff);
-
- lvalue =3D 0;
- cs2_pack_byte (s, (lvalue >> 24) & 0xff);
- cs2_pack_byte (s, (lvalue >> 16) & 0xff);
- cs2_pack_byte (s, (lvalue >> 8) & 0xff);
- cs2_pack_byte (s, lvalue & 0xff);
-
- lvalue =3D s->frame_offset * i_boundary + s->subframe / s->unit_mm + =
s->frame_offset - 1;
- cs2_pack_byte (s, (lvalue >> 24) & 0xff);
- cs2_pack_byte (s, (lvalue >> 16) & 0xff);
- cs2_pack_byte (s, (lvalue >> 8) & 0xff);
- cs2_pack_byte (s, lvalue & 0xff);
-
- lvalue =3D s->boundaryx - 1;
- cs2_pack_byte (s, (lvalue >> 24) & 0xff);
- cs2_pack_byte (s, (lvalue >> 16) & 0xff);
- cs2_pack_byte (s, (lvalue >> 8) & 0xff);
- cs2_pack_byte (s, lvalue & 0xff);
- }
- }
- else if (s->boundary_type =3D=3D 2)
- {
- cs2_parse_cmd (s, "2a 00 8f 00 00 03");
- cs2_pack_byte (s, ((4 + s->n_frames * 8) >> 16) & 0xff);
- cs2_pack_byte (s, ((4 + s->n_frames * 8) >> 8) & 0xff);
- cs2_pack_byte (s, (4 + s->n_frames * 8) & 0xff);
- cs2_parse_cmd (s, "00");
-
- cs2_pack_byte (s, ((2 + s->n_frames * 8) >> 8) & 0xff);
- cs2_pack_byte (s, (2 + s->n_frames * 8) & 0xff);
- cs2_pack_byte (s, s->n_frames);
- cs2_parse_cmd (s, "00");
- for (i_boundary =3D 0; i_boundary < s->n_frames; i_boundary++)
- {
- lvalue =3D s->frame_offset * i_boundary;
- cs2_pack_byte (s, (lvalue >> 24) & 0xff);
- cs2_pack_byte (s, (lvalue >> 16) & 0xff);
- cs2_pack_byte (s, (lvalue >> 8) & 0xff);
- cs2_pack_byte (s, lvalue & 0xff);
-
- cs2_pack_byte (s, 0);
- cs2_pack_byte (s, 4);
- cs2_pack_byte (s, 0);
- cs2_pack_byte (s, 0);
-
-/* XXXXXXXXXX
- lvalue =3D 0;
- cs2_pack_byte (s, (lvalue >> 24) & 0xff);
- cs2_pack_byte (s, (lvalue >> 16) & 0xff);
- cs2_pack_byte (s, (lvalue >> 8) & 0xff);
- cs2_pack_byte (s, lvalue & 0xff);
-*/
- }
- }
- else
- {
- DBG (1, "BUG: cs2_set_boundary(): Unknown boundary type.\n");
- return SANE_STATUS_INVAL;
+ cs2_pack_byte (s, ((4 + s->n_frames * 16) >> 8) & 0xff);
+ cs2_pack_byte (s, (4 + s->n_frames * 16) & 0xff);
+ cs2_pack_byte (s, s->n_frames);
+ cs2_pack_byte (s, s->n_frames);
+ for (i_boundary =3D 0; i_boundary < s->n_frames; i_boundary++)
+ {
+ lvalue =3D s->frame_offset * i_boundary + s->subframe / s->unit_mm=
;
+ cs2_pack_byte (s, (lvalue >> 24) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 16) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 8) & 0xff);
+ cs2_pack_byte (s, lvalue & 0xff);
+
+ lvalue =3D 0;
+ cs2_pack_byte (s, (lvalue >> 24) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 16) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 8) & 0xff);
+ cs2_pack_byte (s, lvalue & 0xff);
+
+ lvalue =3D s->frame_offset * i_boundary + s->subframe / s->unit_mm=
+ s->frame_offset - 1;
+ cs2_pack_byte (s, (lvalue >> 24) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 16) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 8) & 0xff);
+ cs2_pack_byte (s, lvalue & 0xff);
+
+ lvalue =3D s->boundaryx - 1;
+ cs2_pack_byte (s, (lvalue >> 24) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 16) & 0xff);
+ cs2_pack_byte (s, (lvalue >> 8) & 0xff);
+ cs2_pack_byte (s, lvalue & 0xff);
}
status =3D cs2_issue_cmd (s);
if (status)
@@ -2782,7 +2734,7 @@
=20
cs2_scanner_ready (s, CS2_STATUS_READY);
cs2_init_buffer (s);
- cs2_parse_cmd (s, "15 10 00 00 0c 00 0b 00 00 00 03 06 00 00");
+ cs2_parse_cmd (s, "15 10 00 00 14 00 00 00 00 08 00 00 00 00 00 00 00 =
01 03 06 00 00");
cs2_pack_byte (s, (s->unit_dpi >> 8) & 0xff);
cs2_pack_byte (s, s->unit_dpi & 0xff);
cs2_parse_cmd (s, "00 00");
@@ -2842,9 +2794,11 @@
cs2_pack_byte (s, lut[pixel] & 0xff);
}
=20
+ /* LLLLLLLLLLLL
status =3D cs2_issue_cmd (s);
if (status)
return status;
+ */
}
=20
break;
@@ -2858,7 +2812,7 @@
cs2_scanner_ready (s, CS2_STATUS_READY);
=20
cs2_init_buffer (s);
- if ((s->type =3D=3D CS2_TYPE_LS40) || (s->type =3D=3D CS2_TYPE_LS4=
000))
+ if ((s->type =3D=3D CS2_TYPE_LS40) || (s->type =3D=3D CS2_TYPE_LS5=
0) || (s->type =3D=3D CS2_TYPE_LS4000))
cs2_parse_cmd (s, "24 00 00 00 00 00 00 00 3a 80");
else
cs2_parse_cmd (s, "24 00 00 00 00 00 00 00 3a 00");
@@ -2900,7 +2854,7 @@
cs2_pack_byte (s, s->real_depth); /* pixel composition */
cs2_parse_cmd (s, "00 00 00 00 00 00 00 00 00 00 00 00 00");
cs2_pack_byte (s, 0x00); /* multiread, ordering */
- cs2_pack_byte (s, 0x80 + (s->negative ? 0 : 1)); /* averaging, pos=
/neg */
+ cs2_pack_byte (s, 0x00 + (s->negative ? 0 : 1)); /* averaging, pos=
/neg */
switch (type)
{ /* scanning kind */
case CS2_SCAN_NORMAL:
@@ -2943,8 +2897,10 @@
return status;
}
=20
+ /* LLLLLLLLLLLLL
cs2_scanner_ready (s, CS2_STATUS_READY);
cs2_focus (s);
+ */
=20
cs2_scanner_ready (s, CS2_STATUS_READY);
cs2_init_buffer (s);