* backend/canon_dr.[ch], backend/canon_dr-cmd.h, doc/sane-canon_dr.man,

backend/canon_dr.conf.in, doc/descriptions/canon_dr.desc:
- New Canon DR-series backend v3
- support all modes and resolutions of DR-9080C
- advanced options (MF detection, compression) not yet supported
- other larger models believed similar, smaller ones unknown
* doc/descriptions/unsupported.desc: remove Canon DR-series machines
merge-requests/1/head
m. allan noah 2008-11-10 03:36:11 +00:00
rodzic f4ccd1c46b
commit 03c5a9ee44
14 zmienionych plików z 4919 dodań i 56 usunięć

Wyświetl plik

@ -20,6 +20,7 @@ Backends:
canon: Helmut Koeberle, Manuel Panea, and Markus Mertinat
Mitsuru Okaniwa, Ulrich Deiters (*)
canon630u: Nathan Rutman (*)
canon_dr: m. allan noah (*)
canon_pp: Matthew Duggan (*), Simon Krix
coolscan: Didier Carlier, Andreas Rick
cardscan: m. allan noah (*)
@ -114,7 +115,7 @@ Sanei internal code:
Adrian Perez Jorge, Andreas Beck, Andreas Czechanowski, Christian Bucher,
David Mosberger-Tang, Frank Zago (*), Henning Geinitz (*),
Jeff Freedman, Jochen Eisinger (*), Marcio Teixeira, Yuri Dario,
Gerhard Jaeger (*)
Gerhard Jaeger (*), m. allan noah (*)
Miscellaneous coding:

Wyświetl plik

@ -1,3 +1,12 @@
2008-11-09 m. allan noah <kitno455 a t gmail d o t com>
* backend/canon_dr.[ch], backend/canon_dr-cmd.h, doc/sane-canon_dr.man,
backend/canon_dr.conf.in, doc/descriptions/canon_dr.desc:
- New Canon DR-series backend v3
- support all modes and resolutions of DR-9080C
- advanced options (MF detection, compression) not yet supported
- other larger models believed similar, smaller ones unknown
* doc/descriptions/unsupported.desc: remove Canon DR-series machines
2008-11-07 m. allan noah <kitno455 a t gmail d o t com>
* backend/fujitsu.c: backend v84
- round lines down to even number to get even # of total bytes

Wyświetl plik

@ -98,6 +98,7 @@ DISTFILES = Makefile.in saned.conf.in sane_strstatus.c stubs.c \
bh.c bh.conf.in bh.h \
canon.c canon.conf.in canon.h canon-sane.c canon-scsi.c \
canon630u.c canon630u-common.c canon630u.conf.in \
canon_dr.c canon_dr.conf.in canon_dr.h canon_dr-cmd.h \
canon_pp.conf.in canon_pp.h canon_pp.c canon_pp-dev.c \
canon_pp-dev.h canon_pp-io.c canon_pp-io.h \
cardscan.c cardscan.conf.in cardscan.h \
@ -390,6 +391,10 @@ libsane-canon.la: ../sanei/sanei_constrain_value.lo
libsane-canon.la: ../sanei/sanei_scsi.lo
libsane-canon630u.la: ../sanei/sanei_constrain_value.lo
libsane-canon630u.la: ../sanei/sanei_usb.lo
libsane-canon_dr.la: ../sanei/sanei_config2.lo
libsane-canon_dr.la: ../sanei/sanei_constrain_value.lo
libsane-canon_dr.la: ../sanei/sanei_scsi.lo
libsane-canon_dr.la: ../sanei/sanei_usb.lo
libsane-canon_pp.la: $(addsuffix .lo,$(EXTRA_canon_pp))
libsane-cardscan.la: ../sanei/sanei_constrain_value.lo
libsane-cardscan.la: ../sanei/sanei_usb.lo

Wyświetl plik

@ -0,0 +1,422 @@
#ifndef CANON_DR_CMD_H
#define CANON_DR_CMD_H
/*
* Part of SANE - Scanner Access Now Easy.
*
* Please see to opening comments in canon_dr.c
*/
/****************************************************/
#define USB_HEADER_LEN 12
#define USB_COMMAND_LEN 12
#define USB_STATUS_LEN 4
#define USB_STATUS_OFFSET 0
#define USB_COMMAND_TIME 30000
#define USB_DATA_TIME 30000
#define USB_STATUS_TIME 30000
/*static inline void */
static void
setbitfield (unsigned char *pageaddr, int mask, int shift, int val)
{
*pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift);
}
/* ------------------------------------------------------------------------- */
/*static inline int */
static int
getbitfield (unsigned char *pageaddr, int mask, int shift)
{
return ((*pageaddr >> shift) & mask);
}
/* ------------------------------------------------------------------------- */
static int
getnbyte (unsigned char *pnt, int nbytes)
{
unsigned int result = 0;
int i;
#ifdef DEBUG
assert (nbytes < 5);
#endif
for (i = 0; i < nbytes; i++)
result = (result << 8) | (pnt[i] & 0xff);
return result;
}
/* ------------------------------------------------------------------------- */
/*static inline void */
static void
putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes)
{
int i;
#ifdef DEBUG
assert (nbytes < 5);
#endif
for (i = nbytes - 1; i >= 0; i--)
{
pnt[i] = value & 0xff;
value = value >> 8;
}
}
/* ==================================================================== */
/* SCSI commands */
#define set_SCSI_opcode(out, val) out[0]=val
#define set_SCSI_lun(out, val) setbitfield(out + 1, 7, 5, val)
/* ==================================================================== */
/* TEST_UNIT_READY */
#define TEST_UNIT_READY_code 0x00
#define TEST_UNIT_READY_len 6
/* ==================================================================== */
/* REQUEST_SENSE */
#define REQUEST_SENSE_code 0x03
#define REQUEST_SENSE_len 6
#define RS_return_size 0x0e
#define set_RS_return_size(icb,val) icb[0x04]=val
/* defines for request sense return block */
#define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7)
#define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0)
#define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7)
#define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6)
#define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5)
#define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0)
#define get_RS_information(b) getnbyte(b+0x03, 4) /* normally 0 */
#define get_RS_additional_length(b) b[0x07] /* always 10 */
#define get_RS_ASC(b) b[0x0c]
#define get_RS_ASCQ(b) b[0x0d]
#define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid=0 */
#define get_RS_SKSB(b) getnbyte(b+0x0f, 3)
/* when RS is 0x05/0x26 bad bytes listed in sksb */
/* #define get_RS_offending_byte(b) getnbyte(b+0x10, 2) */
/* ==================================================================== */
/* INQUIRY */
#define INQUIRY_code 0x12
#define INQUIRY_len 6
#define INQUIRY_std_len 0x30
#define INQUIRY_vpd_len 0x28
#define set_IN_evpd(icb, val) setbitfield(icb + 1, 1, 0, val)
#define set_IN_page_code(icb, val) icb[0x02]=val
#define set_IN_return_size(icb,val) icb[0x04]=val
#define set_IN_length(out,n) out[0x04]=n-5
#define get_IN_periph_qual(in) getbitfield(in, 0x07, 5)
#define IN_periph_qual_lun 0x00
#define IN_periph_qual_nolun 0x03
#define get_IN_periph_devtype(in) getbitfield(in, 0x1f, 0)
#define IN_periph_devtype_scanner 0x06
#define IN_periph_devtype_unknown 0x1f
#define get_IN_response_format(in) getbitfield(in + 0x03, 0x07, 0)
#define IN_recognized 0x02
#define get_IN_vendor(in, buf) strncpy(buf, (char *)in + 0x08, 0x08)
#define get_IN_product(in, buf) strncpy(buf, (char *)in + 0x10, 0x010)
#define get_IN_version(in, buf) strncpy(buf, (char *)in + 0x20, 0x04)
/* the VPD response */
#define get_IN_page_length(in) in[0x04]
#define get_IN_basic_x_res(in) getnbyte(in + 0x05, 2)
#define get_IN_basic_y_res(in) getnbyte(in + 0x07, 2)
#define get_IN_step_x_res(in) getbitfield(in+0x09, 1, 0)
#define get_IN_step_y_res(in) getbitfield(in+0x09, 1, 4)
#define get_IN_max_x_res(in) getnbyte(in + 0x0a, 2)
#define get_IN_max_y_res(in) getnbyte(in + 0x0c, 2)
#define get_IN_min_x_res(in) getnbyte(in + 0x0e, 2)
#define get_IN_min_y_res(in) getnbyte(in + 0x10, 2)
#define get_IN_std_res_60(in) getbitfield(in+ 0x12, 1, 7)
#define get_IN_std_res_75(in) getbitfield(in+ 0x12, 1, 6)
#define get_IN_std_res_100(in) getbitfield(in+ 0x12, 1, 5)
#define get_IN_std_res_120(in) getbitfield(in+ 0x12, 1, 4)
#define get_IN_std_res_150(in) getbitfield(in+ 0x12, 1, 3)
#define get_IN_std_res_160(in) getbitfield(in+ 0x12, 1, 2)
#define get_IN_std_res_180(in) getbitfield(in+ 0x12, 1, 1)
#define get_IN_std_res_200(in) getbitfield(in+ 0x12, 1, 0)
#define get_IN_std_res_240(in) getbitfield(in+ 0x13, 1, 7)
#define get_IN_std_res_300(in) getbitfield(in+ 0x13, 1, 6)
#define get_IN_std_res_320(in) getbitfield(in+ 0x13, 1, 5)
#define get_IN_std_res_400(in) getbitfield(in+ 0x13, 1, 4)
#define get_IN_std_res_480(in) getbitfield(in+ 0x13, 1, 3)
#define get_IN_std_res_600(in) getbitfield(in+ 0x13, 1, 2)
#define get_IN_std_res_800(in) getbitfield(in+ 0x13, 1, 1)
#define get_IN_std_res_1200(in) getbitfield(in+ 0x13, 1, 0)
#define get_IN_window_width(in) getnbyte(in + 0x14, 4)
#define get_IN_window_length(in) getnbyte(in + 0x18, 4)
#define get_IN_unknown7(in) getbitfield(in+0x1c, 1, 7)
#define get_IN_unknown6(in) getbitfield(in+0x1c, 1, 6)
#define get_IN_unknown5(in) getbitfield(in+0x1c, 1, 5)
#define get_IN_unknown4(in) getbitfield(in+0x1c, 1, 4)
#define get_IN_multilevel(in) getbitfield(in+0x1c, 1, 3)
#define get_IN_half_tone(in) getbitfield(in+0x1c, 1, 2)
#define get_IN_monochrome(in) getbitfield(in+0x1c, 1, 1)
#define get_IN_overflow(in) getbitfield(in+0x1c, 1, 0)
/* some scanners need evpd inquiry data manipulated */
#define set_IN_page_length(in,val) in[0x04]=val
/* ==================================================================== */
/* RESERVE_UNIT */
#define RESERVE_UNIT_code 0x16
#define RESERVE_UNIT_len 6
/* ==================================================================== */
/* RELEASE_UNIT */
#define RELEASE_UNIT_code 0x17
#define RELEASE_UNIT_len 6
/* ==================================================================== */
/* SCAN */
#define SCAN_code 0x1b
#define SCAN_len 6
#define set_SC_xfer_length(sb, val) sb[0x04] = (unsigned char)val
/* ==================================================================== */
/* SET_WINDOW */
#define SET_WINDOW_code 0x24
#define SET_WINDOW_len 10
#define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3)
#define SW_header_len 8
#define SW_desc_len 0x2c
/* ==================================================================== */
/* GET_WINDOW */
#define GET_WINDOW_code 0x25
#define GET_WINDOW_len 0
/* ==================================================================== */
/* READ */
#define READ_code 0x28
#define READ_len 10
#define set_R_datatype_code(sb, val) sb[0x02] = val
#define R_datatype_imagedata 0x00
#define R_datatype_pixelsize 0x80
#define R_datatype_counter 0x84
#define set_R_window_id(sb, val) sb[0x05] = val
#define set_R_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3)
/*pixelsize*/
#define R_PSIZE_len 0x18
#define get_PSIZE_num_x(in) getnbyte(in + 0x00, 4)
#define get_PSIZE_num_y(in) getnbyte(in + 0x04, 4)
#define get_PSIZE_paper_w(in) getnbyte(in + 0x08, 4)
#define get_PSIZE_paper_l(in) getnbyte(in + 0x0C, 4)
/*counter*/
#define R_COUNTER_len 0x08
#define get_R_COUNTER_count(in) getnbyte(in + 0x04, 4)
/* ==================================================================== */
/* SEND */
#define SEND_code 0x2a
#define SEND_len 10
#define set_S_xfer_datatype(sb, val) sb[0x02] = (unsigned char)val
/*#define S_datatype_imagedatai 0x00
#define S_datatype_halftone_mask 0x02
#define S_datatype_gamma_function 0x03*/
#define S_datatype_lut_data 0x83
#define S_datatype_counter 0x84
/*#define S_datatype_jpg_q_table 0x88*/
#define S_datatype_endorser_data 0x90
/*#define S_EX_datatype_lut 0x01
#define S_EX_datatype_shading_data 0xa0
#define S_user_reg_gamma 0xc0
#define S_device_internal_info 0x03
#define set_S_datatype_qual_upper(sb, val) sb[0x04] = (unsigned char)val
#define S_DQ_none 0x00
#define S_DQ_Rcomp 0x06
#define S_DQ_Gcomp 0x07
#define S_DQ_Bcomp 0x08
#define S_DQ_Reg1 0x01
#define S_DQ_Reg2 0x02
#define S_DQ_Reg3 0x03*/
#define set_S_xfer_id(sb, val) putnbyte(sb + 4, val, 2)
#define set_S_xfer_length(sb, val) putnbyte(sb + 6, val, 3)
/*lut*/
#define S_lut_header_len 0x0a
#define set_S_lut_order(sb, val) putnbyte(sb + 2, val, 1)
#define S_lut_order_single 0x10
#define set_S_lut_ssize(sb, val) putnbyte(sb + 4, val, 2)
#define set_S_lut_dsize(sb, val) putnbyte(sb + 6, val, 2)
#define S_lut_data_min_len 256
#define S_lut_data_max_len 1024
/*counter*/
#define S_COUNTER_len 0x08
#define set_S_COUNTER_count(sb,val) putnbyte(sb + 0x04, val, 4)
/* ==================================================================== */
/* OBJECT_POSITION */
#define OBJECT_POSITION_code 0x31
#define OBJECT_POSITION_len 10
#define set_OP_autofeed(b,val) setbitfield(b+0x01, 0x07, 0, val)
#define OP_Discharge 0x00
#define OP_Feed 0x01
/* ==================================================================== */
/* Page codes used by GET/SET SCAN MODE */
#define SM_pc_adf 0x01
#define SM_pc_tpu 0x02
#define SM_pc_scan_ctl 0x20
#define SM_pc_unknown30 0x30
#define SM_pc_unknown32 0x32
#define SM_pc_unknown34 0x34
#define SM_pc_all_pc 0x3F
/* ==================================================================== */
/* GET SCAN MODE */
#define GET_SCAN_MODE_code 0xd5
#define GET_SCAN_MODE_len 6
#define set_GSM_unkown(sb, val) sb[0x01] = val
#define set_GSM_page_code(sb, val) sb[0x02] = val
#define set_GSM_len(sb, val) sb[0x04] = val
#define GSM_PSIZE_len 0x5a
/* ==================================================================== */
/* SET SCAN MODE */
#define SET_SCAN_MODE_code 0xd6
#define SET_SCAN_MODE_len 6
#define set_SSM_unkown(sb, val) sb[0x01] = val
#define set_SSM_page_code(sb, val) sb[0x02] = val
#define set_SSM_len(sb, val) sb[0x04] = val
#define SSM_PSIZE_len 0x14
/* ==================================================================== */
/* window descriptor macros for SET_WINDOW and GET_WINDOW */
#define set_WPDB_wdblen(sb, len) putnbyte(sb + 0x06, len, 2)
/* ==================================================================== */
/* 0x00 - Window Identifier */
#define set_WD_wid(sb, val) sb[0] = val
#define WD_wid_front 0x00
#define WD_wid_back 0x01
/* 0x01 - Reserved (bits 7-1), AUTO (bit 0) */
#define set_WD_auto(sb, val) setbitfield(sb + 0x01, 1, 0, val)
#define get_WD_auto(sb) getbitfield(sb + 0x01, 1, 0)
/* 0x02,0x03 - X resolution in dpi */
#define set_WD_Xres(sb, val) putnbyte(sb + 0x02, val, 2)
#define get_WD_Xres(sb) getnbyte(sb + 0x02, 2)
/* 0x04,0x05 - X resolution in dpi */
#define set_WD_Yres(sb, val) putnbyte(sb + 0x04, val, 2)
#define get_WD_Yres(sb) getnbyte(sb + 0x04, 2)
/* 0x06-0x09 - Upper Left X in 1/1200 inch */
#define set_WD_ULX(sb, val) putnbyte(sb + 0x06, val, 4)
#define get_WD_ULX(sb) getnbyte(sb + 0x06, 4)
/* 0x0a-0x0d - Upper Left Y in 1/1200 inch */
#define set_WD_ULY(sb, val) putnbyte(sb + 0x0a, val, 4)
#define get_WD_ULY(sb) getnbyte(sb + 0x0a, 4)
/* 0x0e-0x11 - Width in 1/1200 inch */
#define set_WD_width(sb, val) putnbyte(sb + 0x0e, val, 4)
#define get_WD_width(sb) getnbyte(sb + 0x0e, 4)
/* 0x12-0x15 - Height in 1/1200 inch */
#define set_WD_length(sb, val) putnbyte(sb + 0x12, val, 4)
#define get_WD_length(sb) getnbyte(sb + 0x12, 4)
/* 0x16 - Brightness */
#define set_WD_brightness(sb, val) sb[0x16] = val
#define get_WD_brightness(sb) sb[0x16]
/* 0x17 - Threshold */
#define set_WD_threshold(sb, val) sb[0x17] = val
#define get_WD_threshold(sb) sb[0x17]
/* 0x18 - Contrast */
#define set_WD_contrast(sb, val) sb[0x18] = val
#define get_WD_contrast(sb) sb[0x18]
/* 0x19 - Image Composition (color mode) */
#define set_WD_composition(sb, val) sb[0x19] = val
#define get_WD_composition(sb) sb[0x19]
#define WD_comp_LA 0
#define WD_comp_HT 1
#define WD_comp_GS 2
#define WD_comp_CL 3
#define WD_comp_CH 4
#define WD_comp_CG 5
/* 0x1a - Depth */
#define set_WD_bitsperpixel(sb, val) sb[0x1a] = val
#define get_WD_bitsperpixel(sb) sb[0x1a]
/* 0x1b,0x1c - Halftone Pattern */
#define set_WD_ht_type(sb, val) sb[0x1b] = val
#define get_WD_ht_type(sb) sb[0x1b]
#define WD_ht_type_DEFAULT 0
#define WD_ht_type_DITHER 1
#define WD_ht_type_DIFFUSION 2
#define set_WD_ht_pattern(sb, val) sb[0x1c] = val
#define get_WD_ht_pattern(sb) sb[0x1c]
/* 0x1d - Reverse image, reserved area, padding type */
#define set_WD_rif(sb, val) setbitfield(sb + 0x1d, 1, 7, val)
#define get_WD_rif(sb) getbitfield(sb + 0x1d, 1, 7)
#define set_WD_reserved(sb, val) setbitfield(sb + 0x1d, 1, 5, val)
#define get_WD_reserved(sb) getbitfield(sb + 0x1d, 1, 5)
/* 0x1e,0x1f - Bit ordering */
#define set_WD_bitorder(sb, val) putnbyte(sb + 0x1e, val, 2)
#define get_WD_bitorder(sb) getnbyte(sb + 0x1e, 2)
/* 0x20 - compression type */
#define set_WD_compress_type(sb, val) sb[0x20] = val
#define get_WD_compress_type(sb) sb[0x20]
#define WD_cmp_NONE 0
#define WD_cmp_MH 1
#define WD_cmp_MR 2
#define WD_cmp_MMR 3
#define WD_cmp_JBIG 0x80
#define WD_cmp_JPG1 0x81
#define WD_cmp_JPG2 0x82
#define WD_cmp_JPG3 0x83
/* 0x21 - compression argument
* specify "k" parameter with MR compress,
* or with JPEG- Q param, 0-7
*/
#define set_WD_compress_arg(sb, val) sb[0x21] = val
#define get_WD_compress_arg(sb) sb[0x21]
/* 0x22-0x27 - reserved */
/* 0x28-0x2c - vendor unique */
/* FIXME: more params here? */
/* ==================================================================== */
#endif

3744
backend/canon_dr.c 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,51 @@
# NOTE: any 'option' lines only apply to
# scanners discovered later in this file
# to set data buffer size, in bytes
# the value ranges from 4096 - infinity
# but you may have scanning problems with
# a value larger than 65536 (the default)
option buffer-size 65536
# To search for all CANON scsi devices, who's name starts with 'DR'
scsi CANON DR
# To use a specific scsi device
#scsi /dev/sg1
# For Canon scanners connected via USB on a known device (kernel driver):
#usb /dev/usb/scanner0
# For Canon scanners connected via USB using vendor and device ids (libusb):
#usb VENDORID PRODUCTID
# NOTE: if you have to add your device here- please send the id and model
# to the author via email, so it can be included in next version. kitno455 at
# gmail dot com - with Fujitsu in the subject line
# DR-9080C
usb 0x04a9 0x1603
# DR-7080C
usb 0x04a9 0x1604
# DR-5010C
usb 0x04a9 0x1606
# DR-6080C
usb 0x04a9 0x1607
# DR-2580C
usb 0x04a9 0x1608
# DR-3080CII
usb 0x04a9 0x1609
# DR-7580
usb 0x04a9 0x160b
# DR-4010C
usb 0x04a9 0x1614
# DR-X10C
usb 0x04a9 0x1618

424
backend/canon_dr.h 100644
Wyświetl plik

@ -0,0 +1,424 @@
#ifndef CANON_DR_H
#define CANON_DR_H
#if V_MINOR == 0
#define SANE_NAME_STANDARD "standard"
#define SANE_TITLE_STANDARD SANE_I18N("Standard")
#define SANE_DESC_STANDARD SANE_I18N("Source, mode and resolution options")
#define SANE_NAME_GEOMETRY "geometry"
#define SANE_TITLE_GEOMETRY SANE_I18N("Geometry")
#define SANE_DESC_GEOMETRY SANE_I18N("Scan area and media size options")
#define SANE_NAME_PAGE_WIDTH "page-width"
#define SANE_TITLE_PAGE_WIDTH SANE_I18N("Page width")
#define SANE_DESC_PAGE_WIDTH \
SANE_I18N("Specifies the width of the media. Required for automatic " \
"centering of sheet-fed scans.")
#define SANE_NAME_PAGE_HEIGHT "page-height"
#define SANE_TITLE_PAGE_HEIGHT SANE_I18N("Page height")
#define SANE_DESC_PAGE_HEIGHT \
SANE_I18N("Specifies the height of the media.")
#define SANE_NAME_ENHANCEMENT "enhancement"
#define SANE_TITLE_ENHANCEMENT SANE_I18N("Enhancement")
#define SANE_DESC_ENHANCEMENT SANE_I18N("Image modification options")
#endif
/*
* Part of SANE - Scanner Access Now Easy.
* Please see opening comment in canon_dr.c
*/
/* -------------------------------------------------------------------------
* This option list has to contain all options for all scanners supported by
* this driver. If a certain scanner cannot handle a certain option, there's
* still the possibility to say so, later.
*/
enum scanner_Option
{
OPT_NUM_OPTS = 0,
OPT_STANDARD_GROUP,
OPT_SOURCE, /*fb/adf/front/back/duplex*/
OPT_MODE, /*mono/gray/color*/
OPT_X_RES, /*a range or a list*/
OPT_Y_RES, /*a range or a list*/
OPT_GEOMETRY_GROUP,
OPT_TL_X,
OPT_TL_Y,
OPT_BR_X,
OPT_BR_Y,
OPT_PAGE_WIDTH,
OPT_PAGE_HEIGHT,
OPT_ENHANCEMENT_GROUP,
OPT_BRIGHTNESS,
OPT_CONTRAST,
OPT_THRESHOLD,
OPT_RIF,
OPT_COUNTER,
/* must come last: */
NUM_OPTIONS
};
struct scanner
{
/* --------------------------------------------------------------------- */
/* immutable values which are set during init of scanner. */
struct scanner *next;
char device_name[1024]; /* The name of the device from sanei */
int missing; /* used to mark unplugged scanners */
/* --------------------------------------------------------------------- */
/* immutable values which are set during reading of config file. */
int buffer_size;
int connection; /* hardware interface type */
/* --------------------------------------------------------------------- */
/* immutable values which are set during inquiry probing of the scanner. */
/* members in order found in scsi data... */
char vendor_name[9]; /* raw data as returned by SCSI inquiry. */
char model_name[17]; /* raw data as returned by SCSI inquiry. */
char version_name[5]; /* raw data as returned by SCSI inquiry. */
/* --------------------------------------------------------------------- */
/* immutable values which are set during std VPD probing of the scanner. */
/* members in order found in scsi data... */
int basic_x_res;
int basic_y_res;
int step_x_res;
int step_y_res;
int max_x_res;
int max_y_res;
int min_x_res;
int min_y_res;
int std_res_200;
int std_res_180;
int std_res_160;
int std_res_150;
int std_res_120;
int std_res_100;
int std_res_75;
int std_res_60;
int std_res_1200;
int std_res_800;
int std_res_600;
int std_res_480;
int std_res_400;
int std_res_320;
int std_res_300;
int std_res_240;
/* max scan size in pixels comes from scanner in basic res units */
int max_x_basic;
int max_y_basic;
int can_grayscale;
int can_halftone;
int can_monochrome;
int can_overflow;
/* --------------------------------------------------------------------- */
/* immutable values which are hard coded because they are not in vpd */
int brightness_steps;
int threshold_steps;
int contrast_steps;
/* the scan size in 1/1200th inches, NOT basic_units or sane units */
int max_x;
int max_y;
int min_x;
int min_y;
int max_x_fb;
int max_y_fb;
int can_color; /* actually might be in vpd, but which bit? */
int has_counter;
int has_rif;
int has_adf;
int has_flatbed;
int has_duplex;
int has_back; /* not all duplex scanners can do adf back side only */
int color_interlace; /* different models interlace colors differently */
int duplex_interlace; /* different models interlace sides differently */
int reverse_by_mode[6]; /* mode specific */
/* --------------------------------------------------------------------- */
/* immutable values which are set during serial number probing scanner */
char serial_name[28]; /* 16 char model, ':', 10 byte serial, null */
/* --------------------------------------------------------------------- */
/* struct with pointers to device/vendor/model names, and a type value */
/* used to inform sane frontend about the device */
SANE_Device sane;
/* --------------------------------------------------------------------- */
/* changeable SANE_Option structs provide our interface to frontend. */
/* some options require lists of strings or numbers, we keep them here */
/* instead of in global vars so that they can differ for each scanner */
/* long array of option structs */
SANE_Option_Descriptor opt[NUM_OPTIONS];
/*mode group*/
SANE_String_Const mode_list[7];
SANE_String_Const source_list[5];
SANE_Int x_res_list[17];
SANE_Int y_res_list[17];
SANE_Range x_res_range;
SANE_Range y_res_range;
/*geometry group*/
SANE_Range tl_x_range;
SANE_Range tl_y_range;
SANE_Range br_x_range;
SANE_Range br_y_range;
SANE_Range paper_x_range;
SANE_Range paper_y_range;
/*enhancement group*/
SANE_Range brightness_range;
SANE_Range contrast_range;
SANE_Range threshold_range;
SANE_Range counter_range;
/* --------------------------------------------------------------------- */
/* changeable vars to hold user input. modified by SANE_Options above */
/*mode group*/
int mode; /*color,lineart,etc*/
int source; /*fb,adf front,adf duplex,etc*/
int resolution_x; /* X resolution in dpi */
int resolution_y; /* Y resolution in dpi */
/*geometry group*/
/* The desired size of the scan, all in 1/1200 inch */
int tl_x;
int tl_y;
int br_x;
int br_y;
int page_width;
int page_height;
/*enhancement group*/
int brightness;
int contrast;
int threshold;
int rif;
/* --------------------------------------------------------------------- */
/* values which are derived from setting the options above */
/* the user never directly modifies these */
/* this is defined in sane spec as a struct containing:
SANE_Frame format;
SANE_Bool last_frame;
SANE_Int lines;
SANE_Int depth; ( binary=1, gray=8, color=8 (!24) )
SANE_Int pixels_per_line;
SANE_Int bytes_per_line;
*/
SANE_Parameters params;
/* --------------------------------------------------------------------- */
/* values which are set by scanning functions to keep track of pages, etc */
int started;
int reading;
int cancelled;
int side;
/* total to read/write */
int bytes_tot[2];
/* how far we have read */
int bytes_rx[2];
int lines_rx[2]; /*only used by 3091*/
/* how far we have written */
int bytes_tx[2];
unsigned char * buffers[2];
int fds[2];
/* --------------------------------------------------------------------- */
/* values which used by the command and data sending functions (scsi/usb)*/
int fd; /* The scanner device file descriptor. */
size_t rs_info;
};
#define CONNECTION_SCSI 0 /* SCSI interface */
#define CONNECTION_USB 1 /* USB interface */
#define SIDE_FRONT 0
#define SIDE_BACK 1
#define SOURCE_FLATBED 0
#define SOURCE_ADF_FRONT 1
#define SOURCE_ADF_BACK 2
#define SOURCE_ADF_DUPLEX 3
/* these are same as scsi data to make code easier */
#define MODE_LINEART WD_comp_LA
#define MODE_HALFTONE WD_comp_HT
#define MODE_GRAYSCALE WD_comp_GS
#define MODE_COLOR_LINEART WD_comp_CL
#define MODE_COLOR_HALFTONE WD_comp_CH
#define MODE_COLOR WD_comp_CG
/* these are same as dropout scsi data to make code easier */
#define COLOR_DEFAULT 0
#define COLOR_GREEN 8
#define COLOR_RED 9
#define COLOR_BLUE 11
#define COLOR_WHITE 1
#define COLOR_BLACK 2
#define COLOR_INTERLACE_UNK 0
#define COLOR_INTERLACE_RGB 1
#define COLOR_INTERLACE_BGR 2
#define COLOR_INTERLACE_RRGGBB 3
#define COLOR_INTERLACE_3091 4
#define DUPLEX_INTERLACE_ALT 0
#define DUPLEX_INTERLACE_NONE 1
#define DUPLEX_INTERLACE_3091 2
#define CROP_RELATIVE 0
#define CROP_ABSOLUTE 1
/* ------------------------------------------------------------------------- */
#define MM_PER_INCH 25.4
#define MM_PER_UNIT_UNFIX SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0))
#define MM_PER_UNIT_FIX SANE_FIX(SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0)))
#define SCANNER_UNIT_TO_FIXED_MM(number) SANE_FIX((number) * MM_PER_UNIT_UNFIX)
#define FIXED_MM_TO_SCANNER_UNIT(number) SANE_UNFIX(number) / MM_PER_UNIT_UNFIX
#define CANON_DR_CONFIG_FILE "canon_dr.conf"
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif
#ifndef PATH_SEP
#ifdef HAVE_OS2_H
# define PATH_SEP '\\'
#else
# define PATH_SEP '/'
#endif
#endif
/* ------------------------------------------------------------------------- */
SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize);
SANE_Status sane_get_devices (const SANE_Device *** device_list,
SANE_Bool local_only);
SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle);
SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking);
SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fdp);
const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle,
SANE_Int option);
SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option,
SANE_Action action, void *val,
SANE_Int * info);
SANE_Status sane_start (SANE_Handle handle);
SANE_Status sane_get_parameters (SANE_Handle handle,
SANE_Parameters * params);
SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len,
SANE_Int * len);
void sane_cancel (SANE_Handle h);
void sane_close (SANE_Handle h);
void sane_exit (void);
/* ------------------------------------------------------------------------- */
static SANE_Status attach_one_scsi (const char *name);
static SANE_Status attach_one_usb (const char *name);
static SANE_Status attach_one (const char *devicename, int connType);
static SANE_Status connect_fd (struct scanner *s);
static SANE_Status disconnect_fd (struct scanner *s);
static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg);
static SANE_Status init_inquire (struct scanner *s);
static SANE_Status init_vpd (struct scanner *s);
static SANE_Status init_model (struct scanner *s);
static SANE_Status init_user (struct scanner *s);
static SANE_Status init_options (struct scanner *s);
static SANE_Status
do_cmd(struct scanner *s, int runRS, int shortTime,
unsigned char * cmdBuff, size_t cmdLen,
unsigned char * outBuff, size_t outLen,
unsigned char * inBuff, size_t * inLen
);
static SANE_Status
do_scsi_cmd(struct scanner *s, int runRS, int shortTime,
unsigned char * cmdBuff, size_t cmdLen,
unsigned char * outBuff, size_t outLen,
unsigned char * inBuff, size_t * inLen
);
static SANE_Status
do_usb_cmd(struct scanner *s, int runRS, int shortTime,
unsigned char * cmdBuff, size_t cmdLen,
unsigned char * outBuff, size_t outLen,
unsigned char * inBuff, size_t * inLen
);
static SANE_Status do_usb_reset(struct scanner *s, int runRS);
static SANE_Status wait_scanner (struct scanner *s);
static SANE_Status object_position (struct scanner *s, int i_load);
int get_page_width (struct scanner *s);
int get_page_height (struct scanner *s);
static SANE_Status set_window (struct scanner *s);
static SANE_Status get_pixelsize(struct scanner *s);
static SANE_Status read_counter(struct scanner *s, SANE_Word *);
static SANE_Status send_counter(struct scanner *s, SANE_Word);
static SANE_Status start_scan (struct scanner *s);
static SANE_Status check_for_cancel(struct scanner *s);
static SANE_Status read_from_scanner(struct scanner *s, int side);
static SANE_Status copy_buffer(struct scanner *s, unsigned char * buf, int len, int side);
static SANE_Status read_from_buffer(struct scanner *s, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len, int side);
static SANE_Status setup_buffers (struct scanner *s);
static void hexdump (int level, char *comment, unsigned char *p, int l);
static size_t maxStringSize (const SANE_String_Const strings[]);
#endif /* CANON_DR_H */

Wyświetl plik

@ -10,6 +10,7 @@ as6e
bh
canon
canon630u
canon_dr
#canon_pp
cardscan
coolscan

4
configure vendored
Wyświetl plik

@ -27267,8 +27267,8 @@ else
echo "$as_me: Manually selected backends: ${BACKENDS}" >&6;}
else
BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e avision bh \
canon canon630u cardscan coolscan coolscan2 coolscan3 dc25 dmc \
epjitsu epson epson2 fujitsu genesys gt68xx \
canon canon630u canon_dr cardscan coolscan coolscan2 coolscan3 \
dc25 dmc epjitsu epson epson2 fujitsu genesys gt68xx \
hp hp3500 hp3900 hp4200 hp5400 hp5590 hpljm1005 hs2p \
ibm leo lexmark \
ma1509 matsushita microtek microtek2 mustek mustek_usb \

Wyświetl plik

@ -375,8 +375,8 @@ else
AC_MSG_NOTICE([Manually selected backends: ${BACKENDS}])
else
BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e avision bh \
canon canon630u cardscan coolscan coolscan2 coolscan3 dc25 dmc \
epjitsu epson epson2 fujitsu genesys gt68xx \
canon canon630u canon_dr cardscan coolscan coolscan2 coolscan3 \
dc25 dmc epjitsu epson epson2 fujitsu genesys gt68xx \
hp hp3500 hp3900 hp4200 hp5400 hp5590 hpljm1005 hs2p \
ibm leo lexmark \
ma1509 matsushita microtek microtek2 mustek mustek_usb \

Wyświetl plik

@ -56,7 +56,7 @@ SECT5 = sane-abaton.5 sane-agfafocus.5 sane-apple.5 sane-as6e.5 sane-dll.5 \
sane-niash.5 sane-sm3840.5 sane-genesys.5 sane-hp4200.5 \
sane-mustek_usb2.5 sane-hp3500.5 sane-pixma.5 sane-stv680.5 \
sane-hp5590.5 sane-hpljm1005.5 sane-cardscan.5 sane-hp3900.5 \
sane-epjitsu.5 sane-hs2p.5
sane-epjitsu.5 sane-hs2p.5 sane-canon_dr.5
SECT7 = sane.7
SECT8 = saned.8
MANPAGES = $(SECT1) $(SECT5) $(SECT7) $(SECT8)
@ -115,7 +115,7 @@ DISTFILES = Makefile.in backend-writing.txt descriptions.txt \
sane-u12.man sane-niash.man sane-sm3840.man sane-genesys.man sane-hp4200.man \
sane-mustek_usb2.man sane-hp3500.man sane-pixma.man sane-stv680.man \
sane-hp5590.man sane-hpljm1005.man sane-cardscan.man sane-hp3900.man \
sane-epjitsu.man sane-hs2p.man
sane-epjitsu.man sane-hs2p.man sane-canon_dr.man
.PHONY: all clean depend dist distclean html html-man install \
sane-html uninstall

Wyświetl plik

@ -0,0 +1,98 @@
;
; SANE Backend specification file
;
; It's basically emacs-lisp --- so ";" indicates comment to end of line.
; All syntactic elements are keyword tokens, followed by a string or
; keyword argument, as specified.
;
; ":backend" *must* be specified.
; All other information is optional (but what good is the file without it?).
;
:backend "canon_dr" ; name of backend
:url "http://www.thebility.com/canon/"
:version "3" ; version of backend
:manpage "sane-canon_dr" ; name of manpage (if it exists)
:comment "New backend as of SANE release 1.1.0, testers needed, see manpage"
:devicetype :scanner ; start of a list of devices....
; other types: :stillcam, :vidcam,
; :meta, :api
:mfg "Canon" ; name a manufacturer
:url "http://www.canon.com/"
;==================================================
:model "DR-2080C"
:interface "USB SCSI"
:usbid "0x04a9" "0x1601"
:status :untested
:comment "Please test!"
:model "DR-2580C"
:interface "USB SCSI"
:usbid "0x04a9" "0x1608"
:status :untested
:comment "Please test!"
:model "DR-3020C"
:interface "SCSI"
:status :untested
:comment "Please test!"
:model "DR-3060"
:interface "SCSI"
:status :untested
:comment "Please test!"
:model "DR-3080C"
:interface "SCSI"
:status :untested
:comment "Please test!"
:model "DR-3080CII"
:interface "USB SCSI"
:usbid "0x04a9" "0x1609"
:status :untested
:comment "Please test!"
:model "DR-4010C"
:interface "USB"
:usbid "0x1083" "0x1614"
:status :untested
:comment "Please test!"
:model "DR-5010C"
:interface "USB"
:usbid "0x1083" "0x1606"
:status :untested
:comment "Please test!"
:model "DR-6080"
:interface "USB SCSI"
:usbid "0x04a9" "0x1607"
:status :untested
:comment "Please test!"
:model "DR-7080C"
:interface "USB SCSI"
:usbid "0x04a9" "0x1604"
:status :untested
:comment "Please test!"
:model "DR-7580"
:interface "USB SCSI"
:usbid "0x04a9" "0x160b"
:status :untested
:comment "Please test!"
:model "DR-9080C"
:interface "USB SCSI"
:usbid "0x04a9" "0x1603"
:status :good
:comment "No support for advanced options like compression, multifeed detection, etc."
:model "DR-X10C"
:interface "USB SCSI"
:usbid "0x04a9" "0x1618"
:status :untested
:comment "Please test!"

Wyświetl plik

@ -1,4 +1,4 @@
; SANE Backend specification file
;
; It's basically emacs-lisp --- so ";" indicates comment to end of line.
; All syntactic elements are keyword tokens, followed by a string or
@ -462,54 +462,6 @@
:status :unsupported
:comment "Probably not supported. "
:model "DR-2080C"
:url "/unsupported/canon-dr2080c.html"
:interface "USB SCSI"
:usbid "0x04a9" "0x1601"
:status :unsupported
:comment "Probably not supported. Pass-trough (ADF) scanner."
:model "DR-3020C"
:interface "SCSI"
:status :unsupported
:comment "Not supported. High-speed pass-trough (ADF) scanner."
:model "DR-3060"
:interface "SCSI"
:status :unsupported
:comment "Probably not supported. High-speed pass-trough (ADF) scanner."
:model "DR-3080C"
:interface "SCSI"
:status :unsupported
:comment "Probably not supported. High-speed pass-trough (ADF) color scanner."
:model "DR-4010C"
:url "/unsupported/canon-dr4010.html"
:interface "USB"
:usbid "0x1083" "0x1614"
:status :unsupported
:comment "Not supported. See link for details."
:model "DR-6080"
:url "/unsupported/canon-dr6080.html"
:interface "USB SCSI"
:usbid "0x04a9" "0x1607"
:status :unsupported
:comment "Probably not supported. High-speed pass-trough (ADF) scanner."
:model "DR-7580"
:url "/unsupported/canon-dr7580.html"
:interface "USB SCSI"
:usbid "0x04a9" "0x160b"
:status :unsupported
:comment "Not supported. See link for details."
:model "DR-9080C"
:interface "SCSI"
:status :unsupported
:comment "Probably not supported. High-speed pass-trough (ADF) color scanner. Similar to DR-6080C, but can scan in color."
:model "FS4000"
:url "/unsupported/canon-fs4000.html"
:interface "USB SCSI"

Wyświetl plik

@ -0,0 +1,156 @@
.TH sane\-canon_dr 5 "09 Oct 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.IX sane\-canon_dr
.SH NAME
sane\-canon_dr \- SANE backend for Canon DR-series scanners
.SH DESCRIPTION
The
.B sane\-canon_dr
library implements a SANE (Scanner Access Now Easy) backend which
provides access to some Canon DR-series scanners.
This document describes backend version 3, slated to ship with SANE 1.1.0.
.SH SUPPORTED HARDWARE
This version has only been tested with the DR\-9080C and DR\-7580C. Please see
http://www.sane\-project.org/sane\-supported\-devices.html for a more recent
list.
This backend may support other Canon scanners. The best
way to determine level of support is to test the scanner directly,
or to collect a trace of the windows driver in action.
Please contact the author for help or with test results.
.SH OPTIONS
Effort has been made to expose most hardware options, including:
.PP
source s
.RS
Selects the source for the scan. Options
may include "Flatbed", "ADF Front", "ADF Back", "ADF Duplex".
.RE
.PP
mode m
.RS
Selects the mode for the scan. Options
may include "Lineart", "Halftone", "Gray", and "Color".
.RE
.PP
resolution, y\-resolution
.RS
Controls scan resolution. Setting \-\-resolution also sets \-\-y\-resolution,
though this behavior is overridden by some frontends.
.RE
.PP
tl\-x, tl\-y, br\-x, br\-y
.RS
Sets scan area upper left and lower right coordinates. These are renamed
t, l, x, y by some frontends.
.RE
.PP
page\-width, page\-height
.RS
Sets paper size. Used by scanner to determine centering of scan
coordinates when using ADF and to detect double feed errors.
.RE
.PP
Other options will be available based on the capabilities of the scanner:
machines with IPC or DTC will have additional enhancement options, those
with CMP will have compression options, those with a printer will have a
group of endorser options.
Use 'scanimage \-\-help' to get a list, but be aware that some options may
be settable only when another option has been set, and that advanced options
may be hidden by some frontend programs.
.PP
.SH CONFIGURATION FILE
The configuration file "canon_dr.conf" is used to tell the backend how to look
for scanners, and provide options controlling the operation of the backend.
This file is read each time the frontend asks the backend for a list
of scanners, generally only when the frontend starts. If the configuration
file is missing, the backend will use a set of compiled defaults, which
are identical to the default configuration file shipped with SANE.
.PP
Scanners can be specified in the configuration file in 4 ways:
.PP
"scsi CANON DR"
.RS
Requests backend to search all scsi busses in the system for a device
which reports itself to be a scanner made by 'CANON', with a model name
starting with 'DR'.
.RE
.PP
"scsi /dev/sg0" (or other scsi device file)
.RS
Requests backend to open the named scsi device. Only useful if you have
multiple compatible scanners connected to your system, and need to
specify one. Probably should not be used with the other "scsi" line above.
.RE
.PP
"usb 0x04a9 0x1603" (or other vendor/product ids)
.RS
Requests backend to search all usb busses in the system for a device
which uses that vendor and product id. The device will then be queried
to determine if it is a Canon scanner.
.RE
.PP
"usb /dev/usb/scanner0" (or other device file)
.RS
Some systems use a kernel driver to access usb scanners. This method is untested.
.RE
.PP
The only configuration option supported is "buffer\-size=xxx", allowing you
to set the number of bytes in the data buffer to something other than the
compiled\-in default, 65536 (64K). Some users report that their scanner will
"hang" mid\-page, or fail to transmit the image if the buffer is not large
enough.
.PP
Note: This option may appear multiple times in the configuration file. It only
applies to scanners discovered by 'scsi/usb' lines that follow this option.
.PP
Note: The backend does not place an upper bound on this value, as some users
required it to be quite large. Values above the default are not recommended,
and may crash your OS or lockup your scsi card driver. You have been
warned.
.PP
.SH ENVIRONMENT
The backend uses a single environment variable, SANE_DEBUG_CANON_DR, which
enables debugging output to stderr. Valid values are:
.PP
.RS
5 Errors
.br
10 Function trace
.br
15 Function detail
.br
20 Option commands
.br
25 SCSI/USB trace
.br
30 SCSI/USB detail
.br
35 Useless noise
.RE
.SH KNOWN ISSUES
This backend was entirely reverse engineered from usb traces of the proprietary
driver. Various advanced features of the machines may not be enabled. No small
machines or flatbed models have been tested. Their protocol is unknown.
.SH CREDITS
The various authors of the sane\-fujitsu backend provided useful code
Corcaribe Tecnología C.A. www.cc.com.ve provided significant funding
EvriChart, Inc. www.evrichart.com provided funding and equipment
.SH "SEE ALSO"
sane(7),
sane\-scsi(5),
sane\-usb(5),
.SH AUTHOR
m. allan noah: <kitno455 a t gmail d o t com>