[sane-devel] Reflecta ProScan / Crystalscan 7200 PIE film scanner update

Michael Rickmann mrickma at gwdg.de
Thu Sep 13 08:55:31 UTC 2012


Hi Jan, hello Klaus,
first I tried to clone Jan's backend from Klaus repository at github but 
failed to reconfigure it. I really tried hard something in the autofiles 
was always missing. In the end I had to copy some files. Then I applied 
Jan's files to a recent sane-git with the exception of reflecta.conf and 
made the necessary changes for a new backend in SANE's build system. 
After an autoreconf I configured with
configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu 
--sysconfdir=/etc --localstatedir=/var --with-snmp=no --disable-locking 
--enable-static . Finally I got it made, still about 130 lines of 
warnings. I have not yet compiled the custom scanimage yet. I also 
refrained from changing anything in SANE except for the new backend 
(renamed the stiff stuff to reflecta_stiff, put the infrared related 
defines into the reflecta files).

After making and installing the reflecta and genesys libs, Jan's 
reflecta.conf and ... I ran the usual tests under Ubuntu 12.04 64-bit 
having the Reflecta and a Canon LiDE scanner plugged in.

mrickma at velvet:~/build/proscan/git$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer
Bus 004 Device 002: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
Bus 003 Device 002: ID 0471:0311 Philips (or NXP) PCVC740K ToUcam Pro [pwc]
Bus 003 Device 003: ID 045e:00f9 Microsoft Corp. Wireless Desktop 
Receiver 3.1
Bus 001 Device 005: ID 05e3:0145 Genesys Logic, Inc.
Bus 002 Device 003: ID 04a9:190a Canon, Inc. CanoScan LiDE 210

mrickma at velvet:~/build/proscan/git$ sane-find-scanner

   # sane-find-scanner will now attempt to detect your scanner. If the
   # result is different from what you expected, first make sure your
   # scanner is powered up and properly connected to your computer.

   # No SCSI scanners found. If you expected something different, make 
sure that
   # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x0471, product=0x0311) at libusb:003:002
found USB scanner (vendor=0x04a9 [Canon], product=0x190a [CanoScan], 
chip=GL124) at libusb:002:003
found USB scanner (vendor=0x05e3, product=0x0145, chip=GL842?) at 
libusb:001:005
   # Your USB scanner was (probably) detected. It may or may not be 
supported by
   # SANE. Try scanimage -L and read the backend's manpage.
......

mrickma at velvet:~/build/proscan/git$ scanimage -L
[sanei_debug] Setting debug level of reflecta to 255.
[reflecta] sane_init() build 1
[reflecta] sane_init() trying usb 0x05e3 0x0145 0x30
[reflecta] sane_init() trying usb 0x05e3 0x0145 0x36
[reflecta] sane_init() looking for Reflecta scanner 05e3 0145 model 30
[reflecta] find_device_callback: libusb:001:005
[reflecta] find_device_callback: sanei_usb_open failed
[reflecta] sane_init() looking for Reflecta scanner 05e3 0145 model 36
[reflecta] find_device_callback: libusb:001:005
[reflecta] find_device_callback: sanei_usb_open failed
[reflecta] sane_get_devices
[sanei_debug] Setting debug level of genesys to 255.
[genesys] SANE Genesys backend version 1.0 build 2302 from sane-backends 
1.0.24git
[genesys] SANE Genesys backend built with libusb
[genesys] sane_init: authorize != null
[genesys] sane_init: little endian machine
[genesys] probe_genesys_devices start
[genesys] attach: start: devp != NULL, may_wait = 0
[genesys] attach: trying to open device `libusb:002:003'
[genesys] attach: device `libusb:002:003' successfully opened
[genesys] attach: found Canon flatbed scanner LiDE 210 at libusb:002:003
[genesys] attach completed
[genesys] probe_genesys_devices completed
[genesys] sane_genesys_init completed
[genesys] sane_get_devices: start: local_only = false
[genesys] probe_genesys_devices start
[genesys] attach: start: devp != NULL, may_wait = 0
[genesys] attach: device `libusb:002:003' was already in device list
[genesys] probe_genesys_devices completed
[genesys] check_present: libusb:002:003 detected.
[genesys] sane_genesys_get_devices completed
device `genesys:libusb:002:003' is a Canon LiDE 210 flatbed scanner
[reflecta] sane_exit()
[genesys] sane_genesys_exit start
[genesys] sane_genesys_exit completed

The result is the same for root and a normal user. Permissions in 
/dev/bus/usb/xxx/yyy are allright. The genesys backend from SANE git 
works, the reflecta one not. Then I tried different USB ports and once I 
got:

mrickma at velvet:~/build/proscan/git$ scanimage -L
[sanei_debug] Setting debug level of reflecta to 255.
[reflecta] sane_init() build 1
[reflecta] sane_init() trying usb 0x05e3 0x0145 0x30
[reflecta] sane_init() trying usb 0x05e3 0x0145 0x36
[reflecta] sane_init() looking for Reflecta scanner 05e3 0145 model 30
[reflecta] find_device_callback: libusb:002:004
[reflecta] cmdGetScannerProperties()
[reflecta] commandScannerRepeat(): enter, repeat=5
[reflecta] commandScannerRepeat(): ready, tries=1
[reflecta] cmdGetScannerProperties()
[reflecta] commandScannerRepeat(): enter, repeat=5
[reflecta] commandScannerRepeat(): ready, tries=1
[reflecta] find_device_callback: wrong model number 54
[reflecta] sane_init() looking for Reflecta scanner 05e3 0145 model 36
[reflecta] find_device_callback: libusb:002:004
[reflecta] find_device_callback: sanei_usb_open failed
[reflecta] sane_get_devices

I really think that we should not invent a custom format for 
reflecta.conf but adhere to SANE's standard which is really safe. We 
know which scanners we want to support. So there is no need to build 
this list dynamically.
static Reflecta_Model crystalscan_7200_model = {
   "PIE/Reflecta",        /* Device vendor string */
   "CrystalScan 7200",        /* Device model name */
   0x05e3,            /* Vendor ID */
   0x0145,            /* Product ID */
   0x30,                /* Model ID */
......
}
.....
static Reflecta_Model *reflecta_supported_model_list[] = {
   &crystalscan_7200_model,    /* Reflecta CrystalScan 7200, id 0x30 */
   &proscan_7200_model,        /* Reflecta ProScan 7200, id 0x36 */
   ...,
   NULL
};
Something like that, the compiler will do it for us. Then we should not 
read the reflecta.conf ourselves but use SANE's configuration framework. 
First we check whether USB vendor- and product-ids matches any devices 
in above list. If yes, it it is safe to issue one INQUIRY, loop through 
our list and check the Reflecta model-id. I have attached a completely 
untested file (a mixture between your, mine and genesys backend code) 
which is just a study to show the interplay between sane_init, 
sane_get_devices and sane_open using SANE's configuration framework. 
What the initial device query is concerned I would like to derive the 
number, width and bit depth of the calibration lines and the halftone 
names from the inquiry.

Yours
Michael


Am 06.09.2012 23:41, schrieb Vleeshouwers, J.M.:
> Hi Michael & Klaus,
>
> A working separate Reflecta/PIE-USB demo backend in the attachment. At least it works for a Crystalscan 7200. I'm curious about your devices.
>
> The backend consists of:
> * reflecta.c: the SANE interface implementation
> * reflecta_specific.c: several auxiliary functions
> * reflecta_scancmd.c: scanner command functions
> * reflecta_usb.c: usb level functions
> * reflecta_buffer.c: reader buffer (queue)
> and corresponding header files.
>
> I added a modified scanimage frontend, to allow 4-channel TIFF generation. The frontend is hardcoded for reflecta only, and consists of:
> * scanimage00.c: modified, see below
> * stiff.c: added a 4-channel TIFF header function
> * sanei_usb.c: the file from the regular distribution
> * sane.h: disabled the definitions of sane_xxx (they move to reflecta.h); enabled SANE_STATUS_WARMING_UP and SANE_FRAME_RGBI
> The modifications to scanimage are:
> * all functions sane_xxx changed to sane_reflecta_xxx
> * gain and offset are set using array syntax; scanimage already has the capability to do that, but it is not documented (so I added a couple of lines to the help text as well)
> * added reading RGBI data from the scanner (and save it as 4-channel TIFF)
>
> Build the modified reflecta-frontend+backend:
> * include directories: sane-backends-git20120722/backend sane-backends-git20120722/include /usr/include/libusb-1.0
> * libraries: libsane & libusb-1.0
>
> I did only shallow testing:
> ./scanimage -L
> ./scanimage -A
> ./scanimage --test
> ./scanimage --format=pnm >test00.pnm
> ./scanimage --format=tiff test01.tiff
> ./scanimage --mode=Color+Infrared --format=tiff >test02.tiff
>
> The list of current options:
>    Scan Mode:
>      --mode Lineart|Halftone|Gray|Color|Color+Infrared [Color]
>          Selects the scan mode (e.g., lineart, monochrome, or color).
>      --depth 1|8|12|16 [8]
>          Number of bits per sample, typical values are 1 for "line-art" and 8
>          for multibit scans.
>      --resolution 25..7200dpi (in steps of 1) [300]
>          Sets the resolution of the scanned image.
>    Geometry:
>      -l 0..37.6767mm [0]
>          Top-left x position of scan area.
>      -t 0..24.2993mm [0]
>          Top-left y position of scan area.
>      -x 0..37.6767mm [37.6767]
>          Width of scan-area.
>      -y 0..24.2993mm [24.2993]
>          Height of scan-area.
>    Enhancement:
>      --halftone-pattern 53lpi 45d ROUND|70lpi 45d ROUND|75lpi Hori. Line|4X4 BAYER|
>        4X4 SCROLL|5x5 26 Levels|4x4 SQUARE|5x5 TILE [inactive]
>          Defines the halftoning (dithering) pattern for scanning halftoned
>          images.
>      --threshold 0..100% [inactive]
>          Select minimum-brightness to get a white point
>      --sharpen[=(yes|no)] [yes]
>          Sharpen scan by taking more time to discharge the CCD.
>      --skip-calibration[=(yes|no)] [no]
>          Skip auto-calibration before scanning image. Option may be overridden
>          by scanner.
>      --fast-infrared[=(yes|no)] [no]
>          Do not reposition scan head before scanning infrared line. Results in
>          an infrared offset which may deteriorate IR dust and scratch removal.
>    Advanced:
>      --preview[=(yes|no)] [no]
>          Request a preview-quality scan.
>      --save-shading-data[=(yes|no)] [no]
>          Save shading data in 'reflecta.shading'
>      --save-ccdmask[=(yes|no)] [no]
>          Save CCD mask 'reflecta.ccd'
>      --exposure-time 100..5000us (in steps of 1) [2937, 2937, 2937, 2937]
>          The time the 4 different color filters of the CCD are exposed
>          (R,G,B,I)
>      --gain 0..63 [19, 19, 19, 19]
>          The gain of the signal processor for the 4 CCD color filters (R,G,B,I)
>      --offset 0..255 [0, 0, 0, 0]
>          The offset of the signal processor for the 4 CCD color filters
>          (R,G,B,I)
>
> Yours,
>
> Jan=




More information about the sane-devel mailing list